[poppler] 2 commits - poppler/XRef.cc poppler/XRef.h

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Sep 10 09:50:28 PDT 2012


 poppler/XRef.cc |   14 ++++++++++++--
 poppler/XRef.h  |    4 ++--
 2 files changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 1b40cdd9f863cd3868db85b5ccfa77a8350c56d6
Merge: 6c40a55... b3e86db...
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Sep 10 18:49:52 2012 +0200

    Merge remote-tracking branch 'origin/poppler-0.20'

diff --cc poppler/XRef.h
index 78c1782,2add0a1..310572f
--- a/poppler/XRef.h
+++ b/poppler/XRef.h
@@@ -210,14 -175,12 +210,14 @@@ private
    void init();
    int reserve(int newSize);
    int resize(int newSize);
 -  GBool readXRef(Guint *pos, std::vector<Guint> *followedXRefStm);
 -  GBool readXRefTable(Parser *parser, Guint *pos, std::vector<Guint> *followedXRefStm);
 +  GBool readXRef(Guint *pos, std::vector<Guint> *followedXRefStm, std::vector<int> *xrefStreamObjsNum);
 +  GBool readXRefTable(Parser *parser, Guint *pos, std::vector<Guint> *followedXRefStm, std::vector<int> *xrefStreamObjsNum);
    GBool readXRefStreamSection(Stream *xrefStr, int *w, int first, int n);
    GBool readXRefStream(Stream *xrefStr, Guint *pos);
-   GBool constructXRef(GBool *wasReconstructed);
+   GBool constructXRef(GBool *wasReconstructed, GBool needCatalogDict = gFalse);
    GBool parseEntry(Guint offset, XRefEntry *entry);
 +  void readXRefUntil(int untilEntryNum, std::vector<int> *xrefStreamObjsNum = NULL);
 +  void markUnencrypted(Object *obj);
  
    class XRefWriter {
    public:
commit b3e86dbdba82956f125e37f69176072e2d0127f2
Author: Thomas Freitag <Thomas.Freitag at kabelmail.de>
Date:   Sun Sep 9 23:35:45 2012 +0200

    Try to find another rootNum if actual rootNum doesn't point to a dict
    
    Bug #14303

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 9a0c900..4d01320 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -774,7 +774,7 @@ GBool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) {
 }
 
 // Attempt to construct an xref table for a damaged file.
-GBool XRef::constructXRef(GBool *wasReconstructed) {
+GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) {
   Parser *parser;
   Object newTrailerDict, obj;
   char buf[256];
@@ -834,7 +834,7 @@ GBool XRef::constructXRef(GBool *wasReconstructed) {
         parser->getObj(&newTrailerDict);
         if (newTrailerDict.isDict()) {
 	  newTrailerDict.dictLookupNF("Root", &obj);
-	  if (obj.isRef()) {
+	  if (obj.isRef() && (!gotRoot || !needCatalogDict) && rootNum != obj.getRefNum()) {
 	    rootNum = obj.getRefNum();
 	    rootGen = obj.getRefGen();
 	    if (!trailerDict.isNone()) {
@@ -990,6 +990,16 @@ GBool XRef::okToAssemble(GBool ignoreOwnerPW) {
   return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permAssemble);
 }
 
+Object *XRef::getCatalog(Object *catalog) {
+  Object *obj = fetch(rootNum, rootGen, catalog);
+  if (obj->isDict()) {
+    return obj;
+  }
+  GBool wasReconstructed = false;
+  GBool ok = constructXRef(&wasReconstructed, gTrue);
+  return (ok) ? fetch(rootNum, rootGen, catalog) : obj;
+}
+
 Object *XRef::fetch(int num, int gen, Object *obj, int recursion) {
   XRefEntry *e;
   Parser *parser;
diff --git a/poppler/XRef.h b/poppler/XRef.h
index 76621ad..2add0a1 100644
--- a/poppler/XRef.h
+++ b/poppler/XRef.h
@@ -106,7 +106,7 @@ public:
   int getPermFlags() { return permFlags; }
 
   // Get catalog object.
-  Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); }
+  Object *getCatalog(Object *obj);
 
   // Fetch an indirect reference.
   Object *fetch(int num, int gen, Object *obj, int recursion = 0);
@@ -179,7 +179,7 @@ private:
   GBool readXRefTable(Parser *parser, Guint *pos, std::vector<Guint> *followedXRefStm);
   GBool readXRefStreamSection(Stream *xrefStr, int *w, int first, int n);
   GBool readXRefStream(Stream *xrefStr, Guint *pos);
-  GBool constructXRef(GBool *wasReconstructed);
+  GBool constructXRef(GBool *wasReconstructed, GBool needCatalogDict = gFalse);
   GBool parseEntry(Guint offset, XRefEntry *entry);
 
   class XRefWriter {


More information about the poppler mailing list