poppler/Catalog.cc | 24 +++++++++--------------- poppler/Catalog.h | 3 ++- poppler/ViewerPreferences.cc | 6 +----- 3 files changed, 12 insertions(+), 21 deletions(-)
New commits: commit 1dd88d0b6b7cbfda76e81902a351c89457a061a8 Author: Pino Toscano <[email protected]> Date: Tue Mar 29 09:58:10 2011 +0200 read the ViewerPreferences dict once, and construct ViewerPreferences on demand this way it is possible to know whether the ViewerPreferences dictionary is present in the Catalog diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc index 68bb8fc..cb41e92 100644 --- a/poppler/Catalog.cc +++ b/poppler/Catalog.cc @@ -76,7 +76,7 @@ Catalog::Catalog(XRef *xrefA) { destNameTree = NULL; embeddedFileNameTree = NULL; jsNameTree = NULL; - viewerPreferences = NULL; + viewerPrefs = NULL; pagesList = NULL; pagesRefList = NULL; @@ -111,6 +111,9 @@ Catalog::Catalog(XRef *xrefA) { } optContentProps.free(); + // get the ViewerPreferences dictionary + catDict.dictLookup("ViewerPreferences", &viewerPreferences); + // perform form-related loading after all widgets have been loaded if (getForm()) getForm()->postWidgetsLoad(this); @@ -162,7 +165,7 @@ Catalog::~Catalog() { delete pageLabelInfo; delete form; delete optContent; - delete viewerPreferences; + delete viewerPrefs; metadata.free(); structTreeRoot.free(); outline.free(); @@ -966,22 +969,13 @@ Form *Catalog::getForm() ViewerPreferences *Catalog::getViewerPreferences() { - if (!viewerPreferences) { - Object catDict; - Dict *d = NULL; - - xref->getCatalog(&catDict); - if (catDict.isDict()) { - d = catDict.getDict(); - } else { - error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName()); + if (!viewerPrefs) { + if (viewerPreferences.isDict()) { + viewerPrefs = new ViewerPreferences(viewerPreferences.getDict()); } - viewerPreferences = new ViewerPreferences(d); - - catDict.free(); } - return viewerPreferences; + return viewerPrefs; } Object *Catalog::getNames() diff --git a/poppler/Catalog.h b/poppler/Catalog.h index fb12850..94c6bdd 100644 --- a/poppler/Catalog.h +++ b/poppler/Catalog.h @@ -243,7 +243,7 @@ private: std::vector<PageAttrs *> *attrsList; std::vector<int> *kidsIdxList; Form *form; - ViewerPreferences *viewerPreferences; + ViewerPreferences *viewerPrefs; int numPages; // number of pages int pagesSize; // size of pages array Object dests; // named destination dictionary @@ -256,6 +256,7 @@ private: Object structTreeRoot; // structure tree root dictionary Object outline; // outline dictionary Object acroForm; // AcroForm dictionary + Object viewerPreferences; // ViewerPreference dictionary OCGs *optContent; // Optional Content groups GBool ok; // true if catalog is valid PageLabelInfo *pageLabelInfo; // info about page labels commit f10b0b8c88a7df83ada09f32b6cb6fd930fcb748 Author: Pino Toscano <[email protected]> Date: Tue Mar 29 09:57:46 2011 +0200 assume the prefDict is not null diff --git a/poppler/ViewerPreferences.cc b/poppler/ViewerPreferences.cc index 33e65b2..bf78db8 100644 --- a/poppler/ViewerPreferences.cc +++ b/poppler/ViewerPreferences.cc @@ -19,10 +19,6 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict) { init(); - if (!prefDict) { - return; - } - Object obj; if (prefDict->lookup("HideToolbar", &obj)->isBool()) { commit d4a5ea45057cad531a8979cf9861ac05cdd56613 Author: Pino Toscano <[email protected]> Date: Tue Mar 29 09:54:22 2011 +0200 fix variable name for DisplayDocTitle diff --git a/poppler/ViewerPreferences.cc b/poppler/ViewerPreferences.cc index 1c38582..33e65b2 100644 --- a/poppler/ViewerPreferences.cc +++ b/poppler/ViewerPreferences.cc @@ -51,7 +51,7 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict) obj.free(); if (prefDict->lookup("DisplayDocTitle", &obj)->isBool()) { - centerWindow = obj.getBool(); + displayDocTitle = obj.getBool(); } obj.free(); _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
