poppler/PDFDoc.cc | 10 +++++----- poppler/XRef.cc | 12 +----------- poppler/XRef.h | 6 ++---- 3 files changed, 8 insertions(+), 20 deletions(-)
New commits: commit 33aded82fbd98832eaab7cb7487fe6a1c7ef15f5 Author: Albert Astals Cid <[email protected]> Date: Sat Feb 18 17:21:10 2012 +0100 Rework XRef getNumObjects and getSize Kill XRef::last since we do not maintain it correctly, now getNumObjects returns size as it did Kill getSize as it just returns the same as getNumObjects diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 6e124fd..ecc5980 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005, 2006, 2008 Brad Hards <[email protected]> -// Copyright (C) 2005, 2007-2009, 2011 Albert Astals Cid <[email protected]> +// Copyright (C) 2005, 2007-2009, 2011, 2012 Albert Astals Cid <[email protected]> // Copyright (C) 2008 Julien Rebetez <[email protected]> // Copyright (C) 2008, 2010 Pino Toscano <[email protected]> // Copyright (C) 2008, 2010, 2011 Carlos Garcia Campos <[email protected]> @@ -608,7 +608,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) FILE *f; OutStream *outStr; XRef *yRef, *countRef; - int rootNum = getXRef()->getSize() + 1; + int rootNum = getXRef()->getNumObjects() + 1; if (pageNo < 1 || pageNo > getNumPages()) { error(errInternal, -1, "Illegal pageNo: {0:d}({1:d})", pageNo, getNumPages() ); @@ -851,7 +851,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) obj1.free(); } } - if (uxref->getSize() == 0) { //we have nothing to update + if (uxref->getNumObjects() == 0) { //we have nothing to update delete uxref; return; } @@ -859,7 +859,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) Guint uxrefOffset = outStr->getPos(); uxref->writeToFile(outStr, gFalse /* do not write unnecessary entries */); - writeTrailer(uxrefOffset, xref->getSize(), outStr, gTrue); + writeTrailer(uxrefOffset, xref->getNumObjects(), outStr, gTrue); delete uxref; } @@ -899,7 +899,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr) Guint uxrefOffset = outStr->getPos(); uxref->writeToFile(outStr, gTrue /* write all entries */); - writeTrailer(uxrefOffset, uxref->getSize(), outStr, gFalse); + writeTrailer(uxrefOffset, uxref->getNumObjects(), outStr, gFalse); delete uxref; diff --git a/poppler/XRef.cc b/poppler/XRef.cc index 5f44d80..699eb6b 100644 --- a/poppler/XRef.cc +++ b/poppler/XRef.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Dan Sheridan <[email protected]> // Copyright (C) 2005 Brad Hards <[email protected]> -// Copyright (C) 2006, 2008, 2010 Albert Astals Cid <[email protected]> +// Copyright (C) 2006, 2008, 2010, 2012 Albert Astals Cid <[email protected]> // Copyright (C) 2007-2008 Julien Rebetez <[email protected]> // Copyright (C) 2007 Carlos Garcia Campos <[email protected]> // Copyright (C) 2009, 2010 Ilya Gorenbein <[email protected]> @@ -261,7 +261,6 @@ void XRef::init() { entries = NULL; capacity = 0; size = 0; - last = -1; streamEnds = NULL; streamEndsLen = 0; objStrs = new PopplerCache(5); @@ -545,9 +544,6 @@ GBool XRef::readXRefTable(Parser *parser, Guint *pos, std::vector<Guint> *follow entries[0] = entries[1]; entries[1].offset = 0xffffffff; } - if (i > last) { - last = i; - } } } } @@ -766,9 +762,6 @@ GBool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) { default: return gFalse; } - if (i > last) { - last = i; - } } } @@ -887,9 +880,6 @@ GBool XRef::constructXRef(GBool *wasReconstructed) { entries[num].offset = pos - start; entries[num].gen = gen; entries[num].type = xrefEntryUncompressed; - if (num > last) { - last = num; - } } } } diff --git a/poppler/XRef.h b/poppler/XRef.h index cc8f64d..c7b20bd 100644 --- a/poppler/XRef.h +++ b/poppler/XRef.h @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Brad Hards <[email protected]> -// Copyright (C) 2006, 2008, 2010, 2011 Albert Astals Cid <[email protected]> +// Copyright (C) 2006, 2008, 2010-2012 Albert Astals Cid <[email protected]> // Copyright (C) 2007-2008 Julien Rebetez <[email protected]> // Copyright (C) 2007 Carlos Garcia Campos <[email protected]> // Copyright (C) 2010 Ilya Gorenbein <[email protected]> @@ -112,7 +112,7 @@ public: Object *getDocInfoNF(Object *obj); // Return the number of objects in the xref table. - int getNumObjects() { return last + 1; } + int getNumObjects() { return size; } // Return the catalog object reference. int getRootNum() { return rootNum; } @@ -126,7 +126,6 @@ public: int getNumEntry(Guint offset); // Direct access. - int getSize() { return size; } XRefEntry *getEntry(int i); Object *getTrailerDict() { return &trailerDict; } @@ -144,7 +143,6 @@ private: XRefEntry *entries; // xref entries int capacity; // size of <entries> array int size; // number of entries - int last; // last used index in <entries> int rootNum, rootGen; // catalog dict GBool ok; // true if xref table is valid int errCode; // error code (if <ok> is false) _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
