[poppler] 10 commits - poppler/Catalog.cc poppler/Catalog.h poppler/PDFDoc.cc poppler/PDFDoc.h
Albert Astals Cid
aacid at kemper.freedesktop.org
Wed Apr 7 12:25:44 PDT 2010
poppler/Catalog.cc | 384 +++++++++++++++++++++++++++++++++++++++--------------
poppler/Catalog.h | 43 +++--
poppler/PDFDoc.cc | 17 +-
poppler/PDFDoc.h | 2
4 files changed, 327 insertions(+), 119 deletions(-)
New commits:
commit d46581c574b3088a82555cbc3b76e95e2571b9c0
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Apr 7 20:25:23 2010 +0100
Fix destructor
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index a0d33cf..74af00e 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
-// Copyright (C) 2005-2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2005-2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2005 Jeff Muizelaar <jrmuizel at nit.ca>
// Copyright (C) 2005 Jonathan Blandford <jrb at redhat.com>
// Copyright (C) 2005 Marco Pesenti Gritti <mpg at redhat.com>
@@ -500,7 +500,12 @@ NameTree::NameTree()
NameTree::~NameTree()
{
- this->free();
+ int i;
+
+ for (i = 0; i < length; i++)
+ delete entries[i];
+
+ gfree(entries);
}
NameTree::Entry::Entry(Array *array, int index) {
@@ -612,16 +617,6 @@ GooString *NameTree::getName(int index)
}
}
-void NameTree::free()
-{
- int i;
-
- for (i = 0; i < length; i++)
- delete entries[i];
-
- gfree(entries);
-}
-
GBool Catalog::labelToIndex(GooString *label, int *index)
{
char *end;
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index fd1c32e..2cab80a 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
-// Copyright (C) 2005, 2007, 2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2005, 2007, 2009, 2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2005 Jonathan Blandford <jrb at redhat.com>
// Copyright (C) 2005, 2006, 2008 Brad Hards <bradh at frogmouth.net>
// Copyright (C) 2007 Julien Rebetez <julienr at svn.gnome.org>
@@ -54,7 +54,6 @@ public:
void init(XRef *xref, Object *tree);
void parse(Object *tree);
GBool lookup(GooString *name, Object *obj);
- void free();
int numEntries() { return length; };
// iterator accessor
Object getValue(int i);
commit ab14433f8b3d7c67f279cece65dfdd40c6675ac0
Author: Hib Eris <hib at hiberis.nl>
Date: Thu Mar 25 15:33:33 2010 +0100
Parse Form on demand
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 4135d79..a0d33cf 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -86,12 +86,6 @@ Catalog::Catalog(XRef *xrefA) {
// get the AcroForm dictionary
catDict.dictLookup("AcroForm", &acroForm);
- // load Forms
- if (acroForm.isDict()) {
- form = new Form(xref,&acroForm);
- }
-
-
// read page tree
catDict.dictLookup("Pages", &pagesDict);
// This should really be isDict("Pages"), but I've seen at least one
@@ -153,8 +147,8 @@ Catalog::Catalog(XRef *xrefA) {
optContentProps.free();
// perform form-related loading after all widgets have been loaded
- if (form)
- form->postWidgetsLoad();
+ if (getForm())
+ getForm()->postWidgetsLoad();
catDict.free();
return;
@@ -848,6 +842,17 @@ Object *Catalog::getDests()
return &dests;
}
+Form *Catalog::getForm()
+{
+ if (!form) {
+ if (acroForm.isDict()) {
+ form = new Form(xref,&acroForm);
+ }
+ }
+
+ return form;
+}
+
Object *Catalog::getNames()
{
if (names.isNone())
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index 6021eed..fd1c32e 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -199,7 +199,7 @@ public:
OCGs *getOptContentConfig() { return optContent; }
- Form* getForm() { return form; }
+ Form* getForm();
enum PageMode {
pageModeNone,
commit c72a2c7f70b13a7b7b531b3c983d9a9bc104bac7
Author: Hib Eris <hib at hiberis.nl>
Date: Thu Mar 25 17:33:11 2010 +0100
Parse Names on demand
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 07b1e20..4135d79 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -74,6 +74,9 @@ Catalog::Catalog(XRef *xrefA) {
optContent = NULL;
pageMode = pageModeNull;
pageLayout = pageLayoutNull;
+ destNameTree = NULL;
+ embeddedFileNameTree = NULL;
+ jsNameTree = NULL;
xref->getCatalog(&catDict);
if (!catDict.isDict()) {
@@ -130,20 +133,6 @@ Catalog::Catalog(XRef *xrefA) {
}
pagesDict.free();
- // read root of named destination tree - PDF1.6 table 3.28
- if (catDict.dictLookup("Names", &obj)->isDict()) {
- obj.dictLookup("Dests", &obj2);
- destNameTree.init(xref, &obj2);
- obj2.free();
- obj.dictLookup("EmbeddedFiles", &obj2);
- embeddedFileNameTree.init(xref, &obj2);
- obj2.free();
- obj.dictLookup("JavaScript", &obj2);
- jsNameTree.init(xref, &obj2);
- obj2.free();
- }
- obj.free();
-
// read base URI
if (catDict.dictLookup("URI", &obj)->isDict()) {
if (obj.dictLookup("Base", &obj2)->isString()) {
@@ -190,9 +179,9 @@ Catalog::~Catalog() {
gfree(pageRefs);
}
dests.free();
- destNameTree.free();
- embeddedFileNameTree.free();
- jsNameTree.free();
+ delete destNameTree;
+ delete embeddedFileNameTree;
+ delete jsNameTree;
if (baseURI) {
delete baseURI;
}
@@ -346,7 +335,7 @@ LinkDest *Catalog::findDest(GooString *name) {
obj1.free();
}
if (!found) {
- if (destNameTree.lookup(name, &obj1))
+ if (getDestNameTree()->lookup(name, &obj1))
found = gTrue;
else
obj1.free();
@@ -380,10 +369,10 @@ EmbFile *Catalog::embeddedFile(int i)
{
Object efDict;
Object obj;
- obj = embeddedFileNameTree.getValue(i);
+ obj = getEmbeddedFileNameTree()->getValue(i);
EmbFile *embeddedFile = 0;
if (obj.isRef()) {
- GooString desc(embeddedFileNameTree.getName(i));
+ GooString desc(getEmbeddedFileNameTree()->getName(i));
embeddedFile = new EmbFile(obj.fetch(xref, &efDict), &desc);
efDict.free();
} else {
@@ -395,7 +384,7 @@ EmbFile *Catalog::embeddedFile(int i)
GooString *Catalog::getJS(int i)
{
- Object obj = jsNameTree.getValue(i);
+ Object obj = getJSNameTree()->getValue(i);
if (obj.isRef()) {
Ref r = obj.getRef();
obj.free();
@@ -515,6 +504,11 @@ NameTree::NameTree()
entries = NULL;
}
+NameTree::~NameTree()
+{
+ this->free();
+}
+
NameTree::Entry::Entry(Array *array, int index) {
if (!array->getString(index, &name) || !array->getNF(index + 1, &value)) {
Object aux;
@@ -854,3 +848,79 @@ Object *Catalog::getDests()
return &dests;
}
+Object *Catalog::getNames()
+{
+ if (names.isNone())
+ {
+ Object catDict;
+
+ xref->getCatalog(&catDict);
+ if (catDict.isDict()) {
+ catDict.dictLookup("Names", &names);
+ } else {
+ error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+ names.initNull();
+ }
+ catDict.free();
+ }
+
+ return &names;
+}
+
+NameTree *Catalog::getDestNameTree()
+{
+ if (!destNameTree) {
+
+ destNameTree = new NameTree();
+
+ if (getNames()->isDict()) {
+ Object obj;
+
+ getNames()->dictLookup("Dests", &obj);
+ destNameTree->init(xref, &obj);
+ obj.free();
+ }
+
+ }
+
+ return destNameTree;
+}
+
+NameTree *Catalog::getEmbeddedFileNameTree()
+{
+ if (!embeddedFileNameTree) {
+
+ embeddedFileNameTree = new NameTree();
+
+ if (getNames()->isDict()) {
+ Object obj;
+
+ getNames()->dictLookup("EmbeddedFiles", &obj);
+ embeddedFileNameTree->init(xref, &obj);
+ obj.free();
+ }
+
+ }
+
+ return embeddedFileNameTree;
+}
+
+NameTree *Catalog::getJSNameTree()
+{
+ if (!jsNameTree) {
+
+ jsNameTree = new NameTree();
+
+ if (getNames()->isDict()) {
+ Object obj;
+
+ getNames()->dictLookup("JavaScript", &obj);
+ jsNameTree->init(xref, &obj);
+ obj.free();
+ }
+
+ }
+
+ return jsNameTree;
+}
+
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index 134f1db..6021eed 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -50,6 +50,7 @@ class OCGs;
class NameTree {
public:
NameTree();
+ ~NameTree();
void init(XRef *xref, Object *tree);
void parse(Object *tree);
GBool lookup(GooString *name, Object *obj);
@@ -177,13 +178,13 @@ public:
Object *getDests();
// Get the number of embedded files
- int numEmbeddedFiles() { return embeddedFileNameTree.numEntries(); }
+ int numEmbeddedFiles() { return getEmbeddedFileNameTree()->numEntries(); }
// Get the i'th file embedded (at the Document level) in the document
EmbFile *embeddedFile(int i);
// Get the number of javascript scripts
- int numJS() { return jsNameTree.numEntries(); }
+ int numJS() { return getJSNameTree()->numEntries(); }
// Get the i'th JavaScript script (at the Document level) in the document
GooString *getJS(int i);
@@ -236,9 +237,10 @@ private:
int numPages; // number of pages
int pagesSize; // size of pages array
Object dests; // named destination dictionary
- NameTree destNameTree; // named destination name-tree
- NameTree embeddedFileNameTree; // embedded file name-tree
- NameTree jsNameTree; // Java Script name-tree
+ Object names; // named names dictionary
+ NameTree *destNameTree; // named destination name-tree
+ NameTree *embeddedFileNameTree; // embedded file name-tree
+ NameTree *jsNameTree; // Java Script name-tree
GooString *baseURI; // base URI for URI-type links
Object metadata; // metadata stream
Object structTreeRoot; // structure tree root dictionary
@@ -253,6 +255,12 @@ private:
int readPageTree(Dict *pages, PageAttrs *attrs, int start,
char *alreadyRead);
Object *findDestInTree(Object *tree, GooString *name, Object *obj);
+
+ Object *getNames();
+ NameTree *getDestNameTree();
+ NameTree *getEmbeddedFileNameTree();
+ NameTree *getJSNameTree();
+
};
#endif
commit 32053360c93607cf9bdc092257cefad5d4df9ec5
Author: Hib Eris <hib at hiberis.nl>
Date: Thu Mar 25 16:32:22 2010 +0100
Parse Dests on demand
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index f6a8bef..07b1e20 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -130,9 +130,6 @@ Catalog::Catalog(XRef *xrefA) {
}
pagesDict.free();
- // read named destination dictionary
- catDict.dictLookup("Dests", &dests);
-
// read root of named destination tree - PDF1.6 table 3.28
if (catDict.dictLookup("Names", &obj)->isDict()) {
obj.dictLookup("Dests", &obj2);
@@ -177,7 +174,6 @@ Catalog::Catalog(XRef *xrefA) {
pagesDict.free();
err1:
catDict.free();
- dests.initNull();
ok = gFalse;
}
@@ -343,8 +339,8 @@ LinkDest *Catalog::findDest(GooString *name) {
// try named destination dictionary then name tree
found = gFalse;
- if (dests.isDict()) {
- if (!dests.dictLookup(name->getCString(), &obj1)->isNull())
+ if (getDests()->isDict()) {
+ if (!getDests()->dictLookup(name->getCString(), &obj1)->isNull())
found = gTrue;
else
obj1.free();
@@ -839,3 +835,22 @@ Object *Catalog::getOutline()
return &outline;
}
+Object *Catalog::getDests()
+{
+ if (dests.isNone())
+ {
+ Object catDict;
+
+ xref->getCatalog(&catDict);
+ if (catDict.isDict()) {
+ catDict.dictLookup("Dests", &dests);
+ } else {
+ error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+ dests.initNull();
+ }
+ catDict.free();
+ }
+
+ return &dests;
+}
+
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index cfae726..134f1db 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -174,7 +174,7 @@ public:
// NULL if <name> is not a destination.
LinkDest *findDest(GooString *name);
- Object *getDests() { return &dests; }
+ Object *getDests();
// Get the number of embedded files
int numEmbeddedFiles() { return embeddedFileNameTree.numEntries(); }
commit da0f8e69eecb944e128474f62829f729eeabd189
Author: Hib Eris <hib at hiberis.nl>
Date: Thu Mar 25 16:48:07 2010 +0100
Parse Outline on demand in PDFDoc
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 9505639..2d1477d 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -226,11 +226,6 @@ GBool PDFDoc::setup(GooString *ownerPassword, GooString *userPassword) {
return gFalse;
}
-#ifndef DISABLE_OUTLINE
- // read outline
- outline = new Outline(catalog->getOutline(), xref);
-#endif
-
// done
return gTrue;
}
@@ -907,6 +902,18 @@ void PDFDoc::writeTrailer (Guint uxrefOffset, int uxrefSize, OutStream* outStr,
delete trailerDict;
}
+#ifndef DISABLE_OUTLINE
+Outline *PDFDoc::getOutline()
+{
+ if (!outline) {
+ // read outline
+ outline = new Outline(catalog->getOutline(), xref);
+ }
+
+ return outline;
+}
+#endif
+
PDFDoc *PDFDoc::ErrorPDFDoc(int errorCode, GooString *fileNameA)
{
PDFDoc *doc = new PDFDoc();
diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h
index 79f6d6d..6d7dea2 100644
--- a/poppler/PDFDoc.h
+++ b/poppler/PDFDoc.h
@@ -170,7 +170,7 @@ public:
#ifndef DISABLE_OUTLINE
// Return the outline object.
- Outline *getOutline() { return outline; }
+ Outline *getOutline();
#endif
// Is the file encrypted?
commit d7a69c8cad112cb6616d0192d8a4028fdaee2f73
Author: Hib Eris <hib at hiberis.nl>
Date: Thu Mar 25 16:05:02 2010 +0100
Parse Outline on demand
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index bcae737..f6a8bef 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -156,9 +156,6 @@ Catalog::Catalog(XRef *xrefA) {
}
obj.free();
- // get the outline dictionary
- catDict.dictLookup("Outlines", &outline);
-
// get the Optional Content dictionary
if (catDict.dictLookup("OCProperties", &optContentProps)->isDict()) {
optContent = new OCGs(&optContentProps, xref);
@@ -822,3 +819,23 @@ Object *Catalog::getStructTreeRoot()
return &structTreeRoot;
}
+
+Object *Catalog::getOutline()
+{
+ if (outline.isNone())
+ {
+ Object catDict;
+
+ xref->getCatalog(&catDict);
+ if (catDict.isDict()) {
+ catDict.dictLookup("Outlines", &outline);
+ } else {
+ error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+ outline.initNull();
+ }
+ catDict.free();
+ }
+
+ return &outline;
+}
+
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index a55d449..cfae726 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -192,7 +192,7 @@ public:
GBool labelToIndex(GooString *label, int *index);
GBool indexToLabel(int index, GooString *label);
- Object *getOutline() { return &outline; }
+ Object *getOutline();
Object *getAcroForm() { return &acroForm; }
commit c149e027fa76824221a78fe6d3bf9bfe953491d4
Author: Hib Eris <hib at hiberis.nl>
Date: Thu Mar 25 15:51:51 2010 +0100
Parse StructTreeRoot on demand
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index d27b6f1..bcae737 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -156,9 +156,6 @@ Catalog::Catalog(XRef *xrefA) {
}
obj.free();
- // get the structure tree root
- catDict.dictLookup("StructTreeRoot", &structTreeRoot);
-
// get the outline dictionary
catDict.dictLookup("Outlines", &outline);
@@ -806,3 +803,22 @@ PageLabelInfo *Catalog::getPageLabelInfo()
return pageLabelInfo;
}
+
+Object *Catalog::getStructTreeRoot()
+{
+ if (structTreeRoot.isNone())
+ {
+ Object catDict;
+
+ xref->getCatalog(&catDict);
+ if (catDict.isDict()) {
+ catDict.dictLookup("StructTreeRoot", &structTreeRoot);
+ } else {
+ error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+ structTreeRoot.initNull();
+ }
+ catDict.free();
+ }
+
+ return &structTreeRoot;
+}
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index 2f7c616..a55d449 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -164,7 +164,7 @@ public:
GooString *readMetadata();
// Return the structure tree root object.
- Object *getStructTreeRoot() { return &structTreeRoot; }
+ Object *getStructTreeRoot();
// Find a page, given its object ID. Returns page number, or 0 if
// not found.
commit 3c6effe44d6d97f175c2ee7f3913d8c4ba34d612
Author: Hib Eris <hib at hiberis.nl>
Date: Thu Mar 25 14:55:22 2010 +0100
Parse Metadata on demand
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index aa21b45..d27b6f1 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -156,9 +156,6 @@ Catalog::Catalog(XRef *xrefA) {
}
obj.free();
- // get the metadata stream
- catDict.dictLookup("Metadata", &metadata);
-
// get the structure tree root
catDict.dictLookup("StructTreeRoot", &structTreeRoot);
@@ -224,6 +221,19 @@ GooString *Catalog::readMetadata() {
Object obj;
int c;
+ if (metadata.isNone()) {
+ Object catDict;
+
+ xref->getCatalog(&catDict);
+ if (catDict.isDict()) {
+ catDict.dictLookup("Metadata", &metadata);
+ } else {
+ error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+ metadata.initNull();
+ }
+ catDict.free();
+ }
+
if (!metadata.isStream()) {
return NULL;
}
commit 749d67ea2346a3453ef41dc37ba59d419ad900b0
Author: Hib Eris <hib at hiberis.nl>
Date: Thu Mar 25 15:09:58 2010 +0100
Parse PageLabelInfo on demand
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 94ccff2..aa21b45 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -147,10 +147,6 @@ Catalog::Catalog(XRef *xrefA) {
}
obj.free();
- if (catDict.dictLookup("PageLabels", &obj)->isDict())
- pageLabelInfo = new PageLabelInfo(&obj, numPages);
- obj.free();
-
// read base URI
if (catDict.dictLookup("URI", &obj)->isDict()) {
if (obj.dictLookup("Base", &obj2)->isString()) {
@@ -642,8 +638,9 @@ GBool Catalog::labelToIndex(GooString *label, int *index)
{
char *end;
- if (pageLabelInfo != NULL) {
- if (!pageLabelInfo->labelToIndex(label, index))
+ PageLabelInfo *pli = getPageLabelInfo();
+ if (pli != NULL) {
+ if (!pli->labelToIndex(label, index))
return gFalse;
} else {
*index = strtol(label->getCString(), &end, 10) - 1;
@@ -664,8 +661,9 @@ GBool Catalog::indexToLabel(int index, GooString *label)
if (index < 0 || index >= numPages)
return gFalse;
- if (pageLabelInfo != NULL) {
- return pageLabelInfo->indexToLabel(index, label);
+ PageLabelInfo *pli = getPageLabelInfo();
+ if (pli != NULL) {
+ return pli->indexToLabel(index, label);
} else {
snprintf(buffer, sizeof (buffer), "%d", index + 1);
label->append(buffer);
@@ -775,3 +773,26 @@ EmbFile::EmbFile(Object *efDict, GooString *description)
if (!m_mimetype)
m_mimetype = new GooString();
}
+
+PageLabelInfo *Catalog::getPageLabelInfo()
+{
+ if (!pageLabelInfo) {
+ Object catDict;
+ Object obj;
+
+ xref->getCatalog(&catDict);
+ if (!catDict.isDict()) {
+ error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+ catDict.free();
+ return NULL;
+ }
+
+ if (catDict.dictLookup("PageLabels", &obj)->isDict()) {
+ pageLabelInfo = new PageLabelInfo(&obj, getNumPages());
+ }
+ obj.free();
+ catDict.free();
+ }
+
+ return pageLabelInfo;
+}
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index 5e84679..2f7c616 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -226,6 +226,9 @@ public:
private:
+ // Get page label info.
+ PageLabelInfo *getPageLabelInfo();
+
XRef *xref; // the xref table for this PDF file
Page **pages; // array of pages
Ref *pageRefs; // object ID for each page
commit 78f7d106714fa489a66c39410163a6902ba24856
Author: Hib Eris <hib at hiberis.nl>
Date: Sat Mar 27 14:43:57 2010 +0100
Parse PageMode and PageLayout on demand
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index b659180..94ccff2 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -23,6 +23,7 @@
// Copyright (C) 2007 Julien Rebetez <julienr at svn.gnome.org>
// Copyright (C) 2008 Pino Toscano <pino at kde.org>
// Copyright (C) 2009 Ilya Gorenbein <igorenbein at finjan.com>
+// Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -71,6 +72,8 @@ Catalog::Catalog(XRef *xrefA) {
pageLabelInfo = NULL;
form = NULL;
optContent = NULL;
+ pageMode = pageModeNull;
+ pageLayout = pageLayoutNull;
xref->getCatalog(&catDict);
if (!catDict.isDict()) {
@@ -148,41 +151,6 @@ Catalog::Catalog(XRef *xrefA) {
pageLabelInfo = new PageLabelInfo(&obj, numPages);
obj.free();
- // read page mode
- pageMode = pageModeNone;
- if (catDict.dictLookup("PageMode", &obj)->isName()) {
- if (obj.isName("UseNone"))
- pageMode = pageModeNone;
- else if (obj.isName("UseOutlines"))
- pageMode = pageModeOutlines;
- else if (obj.isName("UseThumbs"))
- pageMode = pageModeThumbs;
- else if (obj.isName("FullScreen"))
- pageMode = pageModeFullScreen;
- else if (obj.isName("UseOC"))
- pageMode = pageModeOC;
- else if (obj.isName("UseAttachments"))
- pageMode = pageModeAttach;
- }
- obj.free();
-
- pageLayout = pageLayoutNone;
- if (catDict.dictLookup("PageLayout", &obj)->isName()) {
- if (obj.isName("SinglePage"))
- pageLayout = pageLayoutSinglePage;
- if (obj.isName("OneColumn"))
- pageLayout = pageLayoutOneColumn;
- if (obj.isName("TwoColumnLeft"))
- pageLayout = pageLayoutTwoColumnLeft;
- if (obj.isName("TwoColumnRight"))
- pageLayout = pageLayoutTwoColumnRight;
- if (obj.isName("TwoPageLeft"))
- pageLayout = pageLayoutTwoPageLeft;
- if (obj.isName("TwoPageRight"))
- pageLayout = pageLayoutTwoPageRight;
- }
- obj.free();
-
// read base URI
if (catDict.dictLookup("URI", &obj)->isDict()) {
if (obj.dictLookup("Base", &obj2)->isString()) {
@@ -473,6 +441,77 @@ GooString *Catalog::getJS(int i)
return js;
}
+Catalog::PageMode Catalog::getPageMode() {
+
+ if (pageMode == pageModeNull) {
+
+ Object catDict, obj;
+
+ pageMode = pageModeNone;
+
+ xref->getCatalog(&catDict);
+ if (!catDict.isDict()) {
+ error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+ catDict.free();
+ return pageMode;
+ }
+
+ if (catDict.dictLookup("PageMode", &obj)->isName()) {
+ if (obj.isName("UseNone"))
+ pageMode = pageModeNone;
+ else if (obj.isName("UseOutlines"))
+ pageMode = pageModeOutlines;
+ else if (obj.isName("UseThumbs"))
+ pageMode = pageModeThumbs;
+ else if (obj.isName("FullScreen"))
+ pageMode = pageModeFullScreen;
+ else if (obj.isName("UseOC"))
+ pageMode = pageModeOC;
+ else if (obj.isName("UseAttachments"))
+ pageMode = pageModeAttach;
+ }
+ obj.free();
+ catDict.free();
+ }
+ return pageMode;
+}
+
+Catalog::PageLayout Catalog::getPageLayout() {
+
+ if (pageLayout == pageLayoutNull) {
+
+ Object catDict, obj;
+
+ pageLayout = pageLayoutNone;
+
+ xref->getCatalog(&catDict);
+ if (!catDict.isDict()) {
+ error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+ catDict.free();
+ return pageLayout;
+ }
+
+ pageLayout = pageLayoutNone;
+ if (catDict.dictLookup("PageLayout", &obj)->isName()) {
+ if (obj.isName("SinglePage"))
+ pageLayout = pageLayoutSinglePage;
+ if (obj.isName("OneColumn"))
+ pageLayout = pageLayoutOneColumn;
+ if (obj.isName("TwoColumnLeft"))
+ pageLayout = pageLayoutTwoColumnLeft;
+ if (obj.isName("TwoColumnRight"))
+ pageLayout = pageLayoutTwoColumnRight;
+ if (obj.isName("TwoPageLeft"))
+ pageLayout = pageLayoutTwoPageLeft;
+ if (obj.isName("TwoPageRight"))
+ pageLayout = pageLayoutTwoPageRight;
+ }
+ obj.free();
+ catDict.free();
+ }
+ return pageLayout;
+}
+
NameTree::NameTree()
{
size = 0;
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index f5b389f..5e84679 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -19,6 +19,7 @@
// Copyright (C) 2005, 2006, 2008 Brad Hards <bradh at frogmouth.net>
// Copyright (C) 2007 Julien Rebetez <julienr at svn.gnome.org>
// Copyright (C) 2008 Pino Toscano <pino at kde.org>
+// Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -205,7 +206,8 @@ public:
pageModeThumbs,
pageModeFullScreen,
pageModeOC,
- pageModeAttach
+ pageModeAttach,
+ pageModeNull
};
enum PageLayout {
pageLayoutNone,
@@ -214,12 +216,13 @@ public:
pageLayoutTwoColumnLeft,
pageLayoutTwoColumnRight,
pageLayoutTwoPageLeft,
- pageLayoutTwoPageRight
+ pageLayoutTwoPageRight,
+ pageLayoutNull
};
// Returns the page mode.
- PageMode getPageMode() { return pageMode; }
- PageLayout getPageLayout() { return pageLayout; }
+ PageMode getPageMode();
+ PageLayout getPageLayout();
private:
More information about the poppler
mailing list