[poppler] poppler/Annot.cc poppler/Catalog.cc poppler/Dict.cc poppler/Dict.h poppler/FileSpec.cc poppler/FontInfo.cc poppler/Form.cc poppler/Gfx.cc poppler/GfxFont.cc poppler/Link.cc poppler/Movie.cc poppler/Object.h poppler/OptionalContent.cc poppler/Outline.cc poppler/Page.cc poppler/PDFDoc.cc poppler/PSOutputDev.cc poppler/Stream.cc poppler/StructElement.cc poppler/StructTreeRoot.cc poppler/XRef.cc qt5/src utils/pdfunite.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 27 17:16:57 UTC 2019
poppler/Annot.cc | 46 ++++++++++++++++++------------------
poppler/Catalog.cc | 6 ++--
poppler/Dict.cc | 9 +++----
poppler/Dict.h | 2 -
poppler/FileSpec.cc | 4 +--
poppler/FontInfo.cc | 2 -
poppler/Form.cc | 4 +--
poppler/Gfx.cc | 17 ++++++-------
poppler/GfxFont.cc | 8 +++---
poppler/Link.cc | 6 ++--
poppler/Movie.cc | 4 +--
poppler/Object.h | 4 +--
poppler/OptionalContent.cc | 2 -
poppler/Outline.cc | 10 +++----
poppler/PDFDoc.cc | 10 +++----
poppler/PSOutputDev.cc | 2 -
poppler/Page.cc | 24 +++++++++---------
poppler/Stream.cc | 4 +--
poppler/StructElement.cc | 12 ++++-----
poppler/StructTreeRoot.cc | 2 -
poppler/XRef.cc | 21 +++++++---------
qt5/src/poppler-annotation-helper.h | 4 +--
utils/pdfunite.cc | 8 +++---
23 files changed, 105 insertions(+), 106 deletions(-)
New commits:
commit 49ecbd5933e5b182ffc211d281cdfdc499d0357e
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Feb 27 15:44:01 2019 +0100
Change Dict::lookupNF return a const &
Saves some copy()
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 467836d1..80e3a99b 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -891,22 +891,22 @@ Object AnnotAppearance::getAppearanceStream(AnnotAppearanceType type, const char
// Obtain dictionary or stream associated to appearance type
switch (type) {
case appearRollover:
- apData = appearDict.dictLookupNF("R");
+ apData = appearDict.dictLookupNF("R").copy();
if (apData.isNull())
- apData = appearDict.dictLookupNF("N");
+ apData = appearDict.dictLookupNF("N").copy();
break;
case appearDown:
- apData = appearDict.dictLookupNF("D");
+ apData = appearDict.dictLookupNF("D").copy();
if (apData.isNull())
- apData = appearDict.dictLookupNF("N");
+ apData = appearDict.dictLookupNF("N").copy();
break;
case appearNormal:
- apData = appearDict.dictLookupNF("N");
+ apData = appearDict.dictLookupNF("N").copy();
break;
}
if (apData.isDict() && state)
- return apData.dictLookupNF(state);
+ return apData.dictLookupNF(state).copy();
else if (apData.isRef())
return apData;
@@ -914,7 +914,7 @@ Object AnnotAppearance::getAppearanceStream(AnnotAppearanceType type, const char
}
std::unique_ptr<GooString> AnnotAppearance::getStateKey(int i) {
- Object obj1 = appearDict.dictLookupNF("N");
+ const Object &obj1 = appearDict.dictLookupNF("N");
if (obj1.isDict())
return std::make_unique<GooString>(obj1.dictGetKey(i));
return nullptr;
@@ -922,7 +922,7 @@ std::unique_ptr<GooString> AnnotAppearance::getStateKey(int i) {
int AnnotAppearance::getNumStates() {
int res = 0;
- Object obj1 = appearDict.dictLookupNF("N");
+ const Object &obj1 = appearDict.dictLookupNF("N");
if (obj1.isDict())
res = obj1.dictGetLength();
return res;
@@ -956,17 +956,17 @@ bool AnnotAppearance::referencesStream(Ref refToStream) {
bool found;
// Scan each state's ref/subdictionary
- obj1 = appearDict.dictLookupNF("N");
+ obj1 = appearDict.dictLookupNF("N").copy();
found = referencesStream(&obj1, refToStream);
if (found)
return true;
- obj1 = appearDict.dictLookupNF("R");
+ obj1 = appearDict.dictLookupNF("R").copy();
found = referencesStream(&obj1, refToStream);
if (found)
return true;
- obj1 = appearDict.dictLookupNF("D");
+ obj1 = appearDict.dictLookupNF("D").copy();
found = referencesStream(&obj1, refToStream);
return found;
}
@@ -1011,11 +1011,11 @@ void AnnotAppearance::removeStateStreams(Object *obj1) {
void AnnotAppearance::removeAllStreams() {
Object obj1;
- obj1 = appearDict.dictLookupNF("N");
+ obj1 = appearDict.dictLookupNF("N").copy();
removeStateStreams(&obj1);
- obj1 = appearDict.dictLookupNF("R");
+ obj1 = appearDict.dictLookupNF("R").copy();
removeStateStreams(&obj1);
- obj1 = appearDict.dictLookupNF("D");
+ obj1 = appearDict.dictLookupNF("D").copy();
removeStateStreams(&obj1);
}
@@ -1226,7 +1226,7 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) {
}
// Note: This value is overwritten by Annots ctor
- obj1 = dict->lookupNF("P");
+ obj1 = dict->lookupNF("P").copy();
if (obj1.isRef()) {
Ref ref = obj1.getRef();
@@ -1303,7 +1303,7 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) {
treeKey = 0;
}
- oc = dict->lookupNF("OC");
+ oc = dict->lookupNF("OC").copy();
}
void Annot::getRect(double *x1, double *y1, double *x2, double *y2) const {
@@ -1866,7 +1866,7 @@ AnnotPopup::~AnnotPopup() {
}
void AnnotPopup::initialize(PDFDoc *docA, Dict *dict) {
- parent = dict->lookupNF("Parent");
+ parent = dict->lookupNF("Parent").copy();
if (!parent.isRef()) {
parent.setToNull();
}
@@ -1905,7 +1905,7 @@ AnnotMarkup::AnnotMarkup(PDFDoc *docA, Object &&dictObject, const Object *obj) :
AnnotMarkup::~AnnotMarkup() = default;
void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict) {
- Object obj1, obj2;
+ Object obj1;
obj1 = dict->lookup("T");
if (obj1.isString()) {
@@ -1913,7 +1913,7 @@ void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict) {
}
Object popupObj = dict->lookup("Popup");
- obj2 = dict->lookupNF("Popup");
+ const Object &obj2 = dict->lookupNF("Popup");
if (popupObj.isDict() && obj2.isRef()) {
popup = std::make_unique<AnnotPopup>(docA, std::move(popupObj), &obj2);
}
@@ -1930,7 +1930,7 @@ void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict) {
date.reset(obj1.getString()->copy());
}
- obj1 = dict->lookupNF("IRT");
+ obj1 = dict->lookupNF("IRT").copy();
if (obj1.isRef()) {
inReplyTo = obj1.getRef();
} else {
@@ -2825,7 +2825,7 @@ void AnnotFreeText::generateFreeTextAppearance()
error(errSyntaxWarning, -1, "Font subdictionary is not a dictionary");
} else {
// Get the font dictionary for the actual requested font
- Object fontDictionary = fontResources.getDict()->lookupNF(da.getFontName().getName());
+ Object fontDictionary = fontResources.getDict()->lookupNF(da.getFontName().getName()).copy();
// Resolve reference, if necessary
Ref fontReference = {-1, -1};
@@ -3760,7 +3760,7 @@ void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) {
action.reset(LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()));
}
- additionalActions = dict->lookupNF("AA");
+ additionalActions = dict->lookupNF("AA").copy();
obj1 = dict->lookup("Parent");
if (obj1.isDict()) {
@@ -5132,7 +5132,7 @@ void AnnotScreen::initialize(PDFDoc *docA, Dict* dict) {
}
}
- additionalActions = dict->lookupNF("AA");
+ additionalActions = dict->lookupNF("AA").copy();
obj1 = dict->lookup("MK");
if (obj1.isDict()) {
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index ed11145d..e958ad12 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -120,7 +120,7 @@ Catalog::Catalog(PDFDoc *docA) {
}
// actions
- additionalActions = catDict.dictLookupNF("AA");
+ additionalActions = catDict.dictLookupNF("AA").copy();
// get the ViewerPreferences dictionary
viewerPreferences = catDict.dictLookup("ViewerPreferences");
@@ -213,7 +213,7 @@ bool Catalog::cachePageTree(int page)
Object catDict = xref->getCatalog();
if (catDict.isDict()) {
- Object pagesDictRef = catDict.dictLookupNF("Pages");
+ const Object &pagesDictRef = catDict.dictLookupNF("Pages");
if (pagesDictRef.isRef() &&
pagesDictRef.getRefNum() >= 0 &&
pagesDictRef.getRefNum() < xref->getNumObjects()) {
@@ -732,7 +732,7 @@ int Catalog::getNumPages()
// some PDF files actually use real numbers here ("/Count 9.0")
if (!obj.isNum()) {
if (pagesDict.dictIs("Page")) {
- Object pageRootRef = catDict.dictLookupNF("Pages");
+ const Object &pageRootRef = catDict.dictLookupNF("Pages");
error(errSyntaxError, -1, "Pages top-level is a single Page. The document is malformed, trying to recover...");
diff --git a/poppler/Dict.cc b/poppler/Dict.cc
index 768d70b1..383f7fd4 100644
--- a/poppler/Dict.cc
+++ b/poppler/Dict.cc
@@ -16,7 +16,7 @@
// Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk at gmail.com>
// Copyright (C) 2007-2008 Julien Rebetez <julienr at svn.gnome.org>
-// Copyright (C) 2008, 2010, 2013, 2014, 2017 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2008, 2010, 2013, 2014, 2017, 2019 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2010 Paweł Wiejacha <pawel.wiejacha at gmail.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
@@ -168,11 +168,12 @@ Object Dict::lookup(const char *key, int recursion) const {
return Object(objNull);
}
-Object Dict::lookupNF(const char *key) const {
+const Object &Dict::lookupNF(const char *key) const {
if (const auto *entry = find(key)) {
- return entry->second.copy();
+ return entry->second;
}
- return Object(objNull);
+ static Object nullObj(objNull);
+ return nullObj;
}
bool Dict::lookupInt(const char *key, const char *alt_key, int *value) const
diff --git a/poppler/Dict.h b/poppler/Dict.h
index 0747d40e..db381310 100644
--- a/poppler/Dict.h
+++ b/poppler/Dict.h
@@ -76,7 +76,7 @@ public:
// Look up an entry and return the value. Returns a null object
// if <key> is not in the dictionary.
Object lookup(const char *key, int recursion = 0) const;
- Object lookupNF(const char *key) const;
+ const Object &lookupNF(const char *key) const;
bool lookupInt(const char *key, const char *alt_key, int *value) const;
// Iterative accessors.
diff --git a/poppler/FileSpec.cc b/poppler/FileSpec.cc
index 2087fe2c..463e5514 100644
--- a/poppler/FileSpec.cc
+++ b/poppler/FileSpec.cc
@@ -7,7 +7,7 @@
//
// Copyright (C) 2008-2009 Carlos Garcia Campos <carlosgc at gnome.org>
// Copyright (C) 2009 Kovid Goyal <kovid at kovidgoyal.net>
-// Copyright (C) 2012, 2017, 2018 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2012, 2017-2019 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2012 Hib Eris <hib at hiberis.nl>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
// Copyright (C) 2018 Adam Reichold <adam.reichold at t-online.de>
@@ -127,7 +127,7 @@ FileSpec::FileSpec(const Object *fileSpecA)
if (fileSpec.isDict()) {
obj1 = fileSpec.dictLookup("EF");
if (obj1.isDict()) {
- fileStream = obj1.dictLookupNF("F");
+ fileStream = obj1.dictLookupNF("F").copy();
if (!fileStream.isRef()) {
ok = false;
fileStream.setToNull();
diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc
index 8467d650..161e5978 100644
--- a/poppler/FontInfo.cc
+++ b/poppler/FontInfo.cc
@@ -99,7 +99,7 @@ void FontInfoScanner::scanFonts(XRef *xrefA, Dict *resDict, GooList *fontsList)
// scan the fonts in this resource dictionary
gfxFontDict = nullptr;
- Object fontObj = resDict->lookupNF("Font");
+ const Object &fontObj = resDict->lookupNF("Font");
if (fontObj.isRef()) {
Object obj2 = fontObj.fetch(xrefA);
if (obj2.isDict()) {
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 204bf4df..905e5c3e 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -648,7 +648,7 @@ FormField::FormField(PDFDoc *docA, Object &&aobj, const Ref aref, FormField *par
const Ref ref = childRef.getRef();
if (usedParents->find(ref.num) == usedParents->end()) {
// Field child: it could be a form field or a widget or composed dict
- Object obj2 = childObj.dictLookupNF("Parent");
+ Object obj2 = childObj.dictLookupNF("Parent").copy();
Object obj3 = childObj.dictLookup("Parent");
if (obj2.isRef() || obj3.isDict()) {
// Child is a form field or composed dict
@@ -1875,7 +1875,7 @@ static Object fieldLookup(Dict *field, const char *key, std::set<int> *usedParen
if (!obj.isNull()) {
return obj;
}
- Object parent = dict->lookupNF("Parent");
+ const Object &parent = dict->lookupNF("Parent");
if (parent.isRef()) {
const Ref ref = parent.getRef();
if (usedParents->find(ref.num) == usedParents->end()) {
diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index c80786e7..4da19c14 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -317,7 +317,6 @@ static inline bool isSameGfxColor(const GfxColor &colorA, const GfxColor &colorB
GfxResources::GfxResources(XRef *xrefA, Dict *resDictA, GfxResources *nextA) :
gStateCache(2), xref(xrefA) {
- Object obj1, obj2;
Ref r;
if (resDictA) {
@@ -325,9 +324,9 @@ GfxResources::GfxResources(XRef *xrefA, Dict *resDictA, GfxResources *nextA) :
// build font dictionary
Dict *resDict = resDictA->copy(xref);
fonts = nullptr;
- obj1 = resDict->lookupNF("Font");
+ const Object &obj1 = resDict->lookupNF("Font");
if (obj1.isRef()) {
- obj2 = obj1.fetch(xref);
+ Object obj2 = obj1.fetch(xref);
if (obj2.isDict()) {
r = obj1.getRef();
fonts = new GfxFontDict(xref, &r, obj2.getDict());
@@ -414,7 +413,7 @@ Object GfxResources::lookupXObjectNF(const char *name) {
for (resPtr = this; resPtr; resPtr = resPtr->next) {
if (resPtr->xObjDict.isDict()) {
- Object obj = resPtr->xObjDict.dictLookupNF(name);
+ Object obj = resPtr->xObjDict.dictLookupNF(name).copy();
if (!obj.isNull())
return obj;
}
@@ -428,7 +427,7 @@ Object GfxResources::lookupMarkedContentNF(const char *name) {
for (resPtr = this; resPtr; resPtr = resPtr->next) {
if (resPtr->propertiesDict.isDict()) {
- Object obj = resPtr->propertiesDict.dictLookupNF(name);
+ Object obj = resPtr->propertiesDict.dictLookupNF(name).copy();
if (!obj.isNull())
return obj;
}
@@ -457,7 +456,7 @@ GfxPattern *GfxResources::lookupPattern(const char *name, OutputDev *out, GfxSta
for (resPtr = this; resPtr; resPtr = resPtr->next) {
if (resPtr->patternDict.isDict()) {
- Object obj = resPtr->patternDict.dictLookupNF(name);
+ Object obj = resPtr->patternDict.dictLookupNF(name).copy();
if (!obj.isNull()) {
Ref patternRef = { -1, -1 };
if (obj.isRef()) {
@@ -515,7 +514,7 @@ Object GfxResources::lookupGStateNF(const char *name) {
for (resPtr = this; resPtr; resPtr = resPtr->next) {
if (resPtr->gStateDict.isDict()) {
- Object obj = resPtr->gStateDict.dictLookupNF(name);
+ Object obj = resPtr->gStateDict.dictLookupNF(name).copy();
if (!obj.isNull()) {
return obj;
}
@@ -4228,7 +4227,7 @@ void Gfx::doImage(Object *ref, Stream *str, bool inlineImg) {
// check for optional content key
if (ref) {
- obj1 = dict->lookupNF("OC");
+ obj1 = dict->lookupNF("OC").copy();
if (catalog->getOptContentConfig() && !catalog->getOptContentConfig()->optContentIsVisible(&obj1)) {
return;
}
@@ -4692,7 +4691,7 @@ void Gfx::doForm(Object *str) {
// check for optional content key
ocSaved = ocState;
- obj1 = dict->lookupNF("OC");
+ obj1 = dict->lookupNF("OC").copy();
if (catalog->getOptContentConfig() && !catalog->getOptContentConfig()->optContentIsVisible(&obj1)) {
if (out->needCharCount()) {
ocState = false;
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 172d8375..44282d94 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -341,14 +341,14 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) {
Object fontDesc = fontDict2->lookup("FontDescriptor");
if (fontDesc.isDict()) {
- Object obj3 = fontDesc.dictLookupNF("FontFile");
+ Object obj3 = fontDesc.dictLookupNF("FontFile").copy();
if (obj3.isRef()) {
*embID = obj3.getRef();
if (expectedType != fontType1) {
err = true;
}
}
- if (embID->num == -1 && (obj3 = fontDesc.dictLookupNF("FontFile2"), obj3.isRef())) {
+ if (embID->num == -1 && (obj3 = fontDesc.dictLookupNF("FontFile2").copy(), obj3.isRef())) {
*embID = obj3.getRef();
if (isType0) {
expectedType = fontCIDType2;
@@ -356,7 +356,7 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) {
err = true;
}
}
- if (embID->num == -1 && (obj3 = fontDesc.dictLookupNF("FontFile3"), obj3.isRef())) {
+ if (embID->num == -1 && (obj3 = fontDesc.dictLookupNF("FontFile3").copy(), obj3.isRef())) {
*embID = obj3.getRef();
Object obj4 = obj3.fetch(xref);
if (obj4.isStream()) {
@@ -1684,7 +1684,7 @@ Object Gfx8BitFont::getCharProc(int code) {
Object Gfx8BitFont::getCharProcNF(int code) {
if (enc[code] && charProcs.isDict()) {
- return charProcs.dictLookupNF(enc[code]);
+ return charProcs.dictLookupNF(enc[code]).copy();
} else {
return Object(objNull);
}
diff --git a/poppler/Link.cc b/poppler/Link.cc
index 32fc41cd..428e8b6f 100644
--- a/poppler/Link.cc
+++ b/poppler/Link.cc
@@ -163,7 +163,7 @@ LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI,
// Prevent circles in the tree by checking the ref against used refs in
// our current tree branch.
- const Object nextRefObj = obj->dictLookupNF("Next");
+ const Object &nextRefObj = obj->dictLookupNF("Next");
if (nextRefObj.isRef()) {
const Ref ref = nextRefObj.getRef();
if (!seenNextActions->insert(ref.num).second) {
@@ -637,7 +637,7 @@ LinkMovie::LinkMovie(const Object *obj) {
annotRef.num = -1;
annotTitle = nullptr;
- Object tmp = obj->dictLookupNF("Annotation");
+ Object tmp = obj->dictLookupNF("Annotation").copy();
if (tmp.isRef()) {
annotRef = tmp.getRef();
}
@@ -758,7 +758,7 @@ LinkRendition::LinkRendition(const Object *obj) {
renditionObj.setToNull();
}
- screenRef = obj->dictLookupNF("AN");
+ screenRef = obj->dictLookupNF("AN").copy();
if (!screenRef.isRef() && operation >= 0 && operation <= 4) {
error(errSyntaxWarning, -1, "Invalid Rendition Action: no AN field with op = {0:d}", operationCode);
screenRef.setToNull();
diff --git a/poppler/Movie.cc b/poppler/Movie.cc
index f4dfdf91..1a540237 100644
--- a/poppler/Movie.cc
+++ b/poppler/Movie.cc
@@ -6,7 +6,7 @@
// Hugo Mercier <hmercier31[at]gmail.com> (c) 2008
// Pino Toscano <pino at kde.org> (c) 2008
// Carlos Garcia Campos <carlosgc at gnome.org> (c) 2010
-// Albert Astals Cid <aacid at kde.org> (c) 2010, 2017, 2018
+// Albert Astals Cid <aacid at kde.org> (c) 2010, 2017-2019
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -213,7 +213,7 @@ void Movie::parseMovie (const Object *movieDict) {
//
// movie poster
//
- poster = movieDict->dictLookupNF("Poster");
+ poster = movieDict->dictLookupNF("Poster").copy();
if (!poster.isNull()) {
if (poster.isRef() || poster.isStream()) {
showPoster = true;
diff --git a/poppler/Object.h b/poppler/Object.h
index 4f07efa7..77a40cda 100644
--- a/poppler/Object.h
+++ b/poppler/Object.h
@@ -280,7 +280,7 @@ public:
void dictRemove(const char *key);
bool dictIs(const char *dictType) const;
Object dictLookup(const char *key, int recursion = 0) const;
- Object dictLookupNF(const char *key) const;
+ const Object &dictLookupNF(const char *key) const;
const char *dictGetKey(int i) const;
Object dictGetVal(int i) const;
const Object &dictGetValNF(int i) const;
@@ -368,7 +368,7 @@ inline bool Object::isDict(const char *dictType) const
inline Object Object::dictLookup(const char *key, int recursion) const
{ OBJECT_TYPE_CHECK(objDict); return dict->lookup(key, recursion); }
-inline Object Object::dictLookupNF(const char *key) const
+inline const Object &Object::dictLookupNF(const char *key) const
{ OBJECT_TYPE_CHECK(objDict); return dict->lookupNF(key); }
inline const char *Object::dictGetKey(int i) const
diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index f4906bf9..23acd019 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -163,7 +163,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
if (ve.isArray()) {
result = evalOCVisibilityExpr(&ve, 0);
} else {
- Object ocg = dict->lookupNF("OCGs");
+ const Object &ocg = dict->lookupNF("OCGs");
if (ocg.isArray()) {
Object policy = dict->lookup("P");
if (policy.isName("AllOn")) {
diff --git a/poppler/Outline.cc b/poppler/Outline.cc
index b17ffdf9..1b7fb8d1 100644
--- a/poppler/Outline.cc
+++ b/poppler/Outline.cc
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Marco Pesenti Gritti <mpg at redhat.com>
-// Copyright (C) 2008, 2016-2018 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2008, 2016-2019 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2009 Nick Jones <nick.jones at network-box.com>
// Copyright (C) 2016 Jason Crain <jason at aquaticape.us>
// Copyright (C) 2017 Adrian Johnson <ajohnson at redneon.com>
@@ -44,7 +44,7 @@ Outline::Outline(const Object *outlineObj, XRef *xref) {
if (!outlineObj->isDict()) {
return;
}
- Object first = outlineObj->dictLookupNF("First");
+ const Object &first = outlineObj->dictLookupNF("First");
items = OutlineItem::readItemList(nullptr, &first, xref);
}
@@ -85,9 +85,9 @@ OutlineItem::OutlineItem(const Dict *dict, int refNumA, OutlineItem *parentA, XR
}
}
- firstRef = dict->lookupNF("First");
- lastRef = dict->lookupNF("Last");
- nextRef = dict->lookupNF("Next");
+ firstRef = dict->lookupNF("First").copy();
+ lastRef = dict->lookupNF("Last").copy();
+ nextRef = dict->lookupNF("Next").copy();
startsOpen = false;
obj1 = dict->lookup("Count");
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 65267116..75f169e8 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -925,7 +925,7 @@ int PDFDoc::savePageAs(const GooString *name, int pageNo)
markPageObjects(infoDict, yRef, countRef, 0, refPage->num, rootNum + 2);
if (trailerObj->isDict()) {
Dict *trailerDict = trailerObj->getDict();
- Object ref = trailerDict->lookupNF("Info");
+ const Object &ref = trailerDict->lookupNF("Info");
if (ref.isRef()) {
yRef->add(ref.getRef().num, ref.getRef().gen, 0, true);
if (getXRef()->getEntry(ref.getRef().num)->type == xrefEntryCompressed) {
@@ -939,7 +939,7 @@ int PDFDoc::savePageAs(const GooString *name, int pageNo)
Object catObj = getXRef()->getCatalog();
Dict *catDict = catObj.getDict();
Object pagesObj = catDict->lookup("Pages");
- Object afObj = catDict->lookupNF("AcroForm");
+ Object afObj = catDict->lookupNF("AcroForm").copy();
if (!afObj.isNull()) {
markAcroForm(&afObj, yRef, countRef, 0, refPage->num, rootNum + 2);
}
@@ -958,7 +958,7 @@ int PDFDoc::savePageAs(const GooString *name, int pageNo)
}
}
markPageObjects(pageDict, yRef, countRef, 0, refPage->num, rootNum + 2);
- Object annotsObj = pageDict->lookupNF("Annots");
+ Object annotsObj = pageDict->lookupNF("Annots").copy();
if (!annotsObj.isNull()) {
markAnnotations(&annotsObj, yRef, countRef, 0, refPage->num, rootNum + 2);
}
@@ -1550,7 +1550,7 @@ Object PDFDoc::createTrailerDict(int uxrefSize, bool incrUpdate, Goffset startxR
bool hasEncrypt = false;
if (!xRef->getTrailerDict()->isNone()) {
- Object obj2 = xRef->getTrailerDict()->dictLookupNF("Encrypt");
+ Object obj2 = xRef->getTrailerDict()->dictLookupNF("Encrypt").copy();
if (!obj2.isNull()) {
trailerDict->set("Encrypt", std::move(obj2));
hasEncrypt = true;
@@ -1807,7 +1807,7 @@ bool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, unsi
Dict *dict = obj1.getDict();
Object type = dict->lookup("Type");
if (type.isName() && strcmp(type.getName(), "Annot") == 0) {
- Object obj2 = dict->lookupNF("P");
+ const Object &obj2 = dict->lookupNF("P");
if (obj2.isRef()) {
if (obj2.getRef().num == oldPageNum) {
const Object &obj3 = array->getNF(i);
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 32f11fce..ee07a6f6 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1854,7 +1854,7 @@ void PSOutputDev::setupFonts(Dict *resDict) {
int i;
gfxFontDict = nullptr;
- Object obj1 = resDict->lookupNF("Font");
+ const Object &obj1 = resDict->lookupNF("Font");
if (obj1.isRef()) {
Object obj2 = obj1.fetch(xref);
if (obj2.isDict()) {
diff --git a/poppler/Page.cc b/poppler/Page.cc
index 33c624f0..2cb75146 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -258,7 +258,7 @@ Page::Page(PDFDoc *docA, int numA, Object &&pageDict, Ref pageRefA, PageAttrs *a
attrs->clipBoxes();
// transtion
- trans = pageObj.dictLookupNF("Trans");
+ trans = pageObj.dictLookupNF("Trans").copy();
if (!(trans.isRef() || trans.isDict() || trans.isNull())) {
error(errSyntaxError, -1, "Page transition object (page {0:d}) is wrong type ({1:s})",
num, trans.getTypeName());
@@ -266,7 +266,7 @@ Page::Page(PDFDoc *docA, int numA, Object &&pageDict, Ref pageRefA, PageAttrs *a
}
// duration
- Object tmp = pageObj.dictLookupNF("Dur");
+ const Object &tmp = pageObj.dictLookupNF("Dur");
if (!(tmp.isNum() || tmp.isNull())) {
error(errSyntaxError, -1, "Page duration object (page {0:d}) is wrong type ({1:s})",
num, tmp.getTypeName());
@@ -275,7 +275,7 @@ Page::Page(PDFDoc *docA, int numA, Object &&pageDict, Ref pageRefA, PageAttrs *a
}
// annotations
- annotsObj = pageObj.dictLookupNF("Annots");
+ annotsObj = pageObj.dictLookupNF("Annots").copy();
if (!(annotsObj.isRef() || annotsObj.isArray() || annotsObj.isNull())) {
error(errSyntaxError, -1, "Page annotations object (page {0:d}) is wrong type ({1:s})",
num, annotsObj.getTypeName());
@@ -283,7 +283,7 @@ Page::Page(PDFDoc *docA, int numA, Object &&pageDict, Ref pageRefA, PageAttrs *a
}
// contents
- contents = pageObj.dictLookupNF("Contents");
+ contents = pageObj.dictLookupNF("Contents").copy();
if (!(contents.isRef() || contents.isArray() ||
contents.isNull())) {
error(errSyntaxError, -1, "Page contents object (page {0:d}) is wrong type ({1:s})",
@@ -292,7 +292,7 @@ Page::Page(PDFDoc *docA, int numA, Object &&pageDict, Ref pageRefA, PageAttrs *a
}
// thumb
- thumb = pageObj.dictLookupNF("Thumb");
+ thumb = pageObj.dictLookupNF("Thumb").copy();
if (!(thumb.isStream() || thumb.isNull() || thumb.isRef())) {
error(errSyntaxError, -1, "Page thumb object (page {0:d}) is wrong type ({1:s})",
num, thumb.getTypeName());
@@ -300,7 +300,7 @@ Page::Page(PDFDoc *docA, int numA, Object &&pageDict, Ref pageRefA, PageAttrs *a
}
// actions
- actions = pageObj.dictLookupNF("AA");
+ actions = pageObj.dictLookupNF("AA").copy();
if (!(actions.isDict() || actions.isNull())) {
error(errSyntaxError, -1, "Page additional action object (page {0:d}) is wrong type ({1:s})",
num, actions.getTypeName());
@@ -340,15 +340,15 @@ void Page::replaceXRef(XRef *xrefA) {
Object obj1;
Dict *pageDict = pageObj.getDict()->copy(xrefA);
xref = xrefA;
- trans = pageDict->lookupNF("Trans");
- annotsObj = pageDict->lookupNF("Annots");
- contents = pageDict->lookupNF("Contents");
+ trans = pageDict->lookupNF("Trans").copy();
+ annotsObj = pageDict->lookupNF("Annots").copy();
+ contents = pageDict->lookupNF("Contents").copy();
if (contents.isArray()) {
- obj1 = pageDict->lookupNF("Contents");
+ obj1 = pageDict->lookupNF("Contents").copy();
contents = obj1.getArray()->copy(xrefA);
}
- thumb = pageDict->lookupNF("Thumb");
- actions = pageDict->lookupNF("AA");
+ thumb = pageDict->lookupNF("Thumb").copy();
+ actions = pageDict->lookupNF("AA").copy();
obj1 = pageDict->lookup("Resources");
if (obj1.isDict()) {
attrs->replaceResource(std::move(obj1));
diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index 6a6b46a2..33537b0e 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff at infidigm.net>
-// Copyright (C) 2006-2010, 2012-2014, 2016, 2017, 2018 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2010, 2012-2014, 2016-2019 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk at gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien at fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
@@ -322,7 +322,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re
Object globals;
if (params->isDict()) {
XRef *xref = params->getDict()->getXRef();
- obj = params->dictLookupNF("JBIG2Globals");
+ obj = params->dictLookupNF("JBIG2Globals").copy();
globals = obj.fetch(xref, recursion);
}
str = new JBIG2Stream(str, std::move(globals), &obj);
diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
index 3cde8c91..41491161 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -1045,7 +1045,7 @@ void StructElement::parse(Dict *element)
}
// Parent object reference (required).
- s->parentRef = element->lookupNF("P");
+ s->parentRef = element->lookupNF("P").copy();
if (!s->parentRef.isRef()) {
error(errSyntaxError, -1, "P object is wrong type ({0:s})", obj.getTypeName());
return;
@@ -1085,7 +1085,7 @@ void StructElement::parse(Dict *element)
// is to be rendered in. Note: each element stores only the /Pg value
// contained by it, and StructElement::getPageRef() may look in parent
// elements to find the page where an element belongs.
- pageRef = element->lookupNF("Pg");
+ pageRef = element->lookupNF("Pg").copy();
// Revision number (optional).
obj = element->lookup("R");
@@ -1201,17 +1201,17 @@ StructElement *StructElement::parseChild(const Object *ref,
child = new StructElement(mcidObj.getInt(), treeRoot, this);
- Object pageRefObj = childObj->dictLookupNF("Pg");
+ Object pageRefObj = childObj->dictLookupNF("Pg").copy();
if (pageRefObj.isRef()) {
child->pageRef = std::move(pageRefObj);
}
} else if (childObj->isDict("OBJR")) {
- Object refObj = childObj->dictLookupNF("Obj");
+ const Object &refObj = childObj->dictLookupNF("Obj");
if (refObj.isRef()) {
child = new StructElement(refObj.getRef(), treeRoot, this);
- Object pageRefObj = childObj->dictLookupNF("Pg");
+ Object pageRefObj = childObj->dictLookupNF("Pg").copy();
if (pageRefObj.isRef()) {
child->pageRef = std::move(pageRefObj);
}
@@ -1259,7 +1259,7 @@ void StructElement::parseChildren(Dict *element, std::set<int> &seen)
parseChild(&ref, &obj, seen);
}
} else if (kids.isDict() || kids.isInt()) {
- Object ref = element->lookupNF("K");
+ const Object &ref = element->lookupNF("K");
parseChild(&ref, &kids, seen);
}
}
diff --git a/poppler/StructTreeRoot.cc b/poppler/StructTreeRoot.cc
index 99359b76..dc9eb56a 100644
--- a/poppler/StructTreeRoot.cc
+++ b/poppler/StructTreeRoot.cc
@@ -95,7 +95,7 @@ void StructTreeRoot::parse(Dict *root)
StructElement *child = new StructElement(kids.getDict(), this, nullptr, seenElements);
if (child->isOk()) {
appendChild(child);
- Object ref = root->lookupNF("K");
+ const Object &ref = root->lookupNF("K");
if (ref.isRef())
parentTreeAdd(ref.getRef(), child);
} else {
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 4679da96..d9b7a33b 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -291,7 +291,7 @@ XRef::XRef(BaseStream *strA, Goffset pos, Goffset mainXRefEntriesOffsetA, bool *
}
// set size to (at least) the size specified in trailer dict
- obj = trailerDict.dictLookupNF("Size");
+ obj = trailerDict.dictLookupNF("Size").copy();
if (!obj.isInt()) {
error(errSyntaxWarning, -1, "No valid XRef size in trailer");
} else {
@@ -306,7 +306,7 @@ XRef::XRef(BaseStream *strA, Goffset pos, Goffset mainXRefEntriesOffsetA, bool *
}
// get the root dictionary (catalog) object
- obj = trailerDict.dictLookupNF("Root");
+ obj = trailerDict.dictLookupNF("Root").copy();
if (obj.isRef()) {
rootNum = obj.getRefNum();
rootGen = obj.getRefGen();
@@ -588,7 +588,7 @@ bool XRef::readXRefTable(Parser *parser, Goffset *pos, std::vector<Goffset> *fol
}
// get the 'Prev' pointer
- obj2 = obj.getDict()->lookupNF("Prev");
+ obj2 = obj.getDict()->lookupNF("Prev").copy();
if (obj2.isInt() || obj2.isInt64()) {
if (obj2.isInt())
pos2 = obj2.getInt();
@@ -657,7 +657,7 @@ bool XRef::readXRefStream(Stream *xrefStr, Goffset *pos) {
ok = false;
Dict *dict = xrefStr->getDict();
- obj = dict->lookupNF("Size");
+ obj = dict->lookupNF("Size").copy();
if (!obj.isInt()) {
return false;
}
@@ -672,7 +672,7 @@ bool XRef::readXRefStream(Stream *xrefStr, Goffset *pos) {
}
}
- obj = dict->lookupNF("W");
+ obj = dict->lookupNF("W").copy();
if (!obj.isArray() || obj.arrayGetLength() < 3) {
return false;
}
@@ -691,7 +691,7 @@ bool XRef::readXRefStream(Stream *xrefStr, Goffset *pos) {
}
xrefStr->reset();
- Object idx = dict->lookupNF("Index");
+ const Object &idx = dict->lookupNF("Index");
if (idx.isArray()) {
for (int i = 0; i+1 < idx.arrayGetLength(); i += 2) {
obj = idx.arrayGet(i);
@@ -715,7 +715,7 @@ bool XRef::readXRefStream(Stream *xrefStr, Goffset *pos) {
}
}
- obj = dict->lookupNF("Prev");
+ obj = dict->lookupNF("Prev").copy();
if (obj.isInt() && obj.getInt() >= 0) {
*pos = obj.getInt();
more = true;
@@ -816,7 +816,6 @@ bool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) {
// Existing data in XRef::entries may get corrupted if applied anyway.
bool XRef::constructXRef(bool *wasReconstructed, bool needCatalogDict) {
Parser *parser;
- Object obj;
char buf[256];
Goffset pos;
int num, gen;
@@ -872,7 +871,7 @@ bool XRef::constructXRef(bool *wasReconstructed, bool needCatalogDict) {
false);
Object newTrailerDict = parser->getObj();
if (newTrailerDict.isDict()) {
- obj = newTrailerDict.dictLookupNF("Root");
+ const Object &obj = newTrailerDict.dictLookupNF("Root");
if (obj.isRef() && (!gotRoot || !needCatalogDict) && rootNum != obj.getRefNum()) {
rootNum = obj.getRefNum();
rootGen = obj.getRefGen();
@@ -1196,7 +1195,7 @@ Object XRef::getDocInfo() {
// Added for the pdftex project.
Object XRef::getDocInfoNF() {
- return trailerDict.dictLookupNF("Info");
+ return trailerDict.dictLookupNF("Info").copy();
}
Object XRef::createDocInfoIfNoneExists() {
@@ -1695,7 +1694,7 @@ void XRef::scanSpecialFlags() {
void XRef::markUnencrypted() {
// Mark objects referred from the Encrypt dict as Unencrypted
- Object obj = trailerDict.dictLookupNF("Encrypt");
+ const Object &obj = trailerDict.dictLookupNF("Encrypt");
if (obj.isRef()) {
XRefEntry *e = getEntry(obj.getRefNum());
e->setFlag(XRefEntry::Unencrypted, true);
diff --git a/qt5/src/poppler-annotation-helper.h b/qt5/src/poppler-annotation-helper.h
index f7d2dece..d8193c65 100644
--- a/qt5/src/poppler-annotation-helper.h
+++ b/qt5/src/poppler-annotation-helper.h
@@ -1,5 +1,5 @@
/* poppler-annotation-helper.h: qt interface to poppler
- * Copyright (C) 2006, 2008, 2017, 2018, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2006, 2008, 2017-2019, Albert Astals Cid <aacid at kde.org>
* Copyright (C) 2008, Pino Toscano <pino at kde.org>
* Copyright (C) 2012, Fabio D'Urso <fabiodurso at hotmail.it>
* Copyright (C) 2018, Dileep Sankhla <sankhla.dileep96 at gmail.com>
@@ -139,7 +139,7 @@ void XPDFReader::lookupColor( Dict * dict, char * type, QColor & dest )
void XPDFReader::lookupIntRef( Dict * dict, char * type, int & dest )
{
- Object refObj = dict->lookupNF( type );
+ const Object &refObj = dict->lookupNF( type );
if ( refObj.isNull() )
return;
if ( refObj.isRef() )
diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc
index 4505f875..b0142116 100644
--- a/utils/pdfunite.cc
+++ b/utils/pdfunite.cc
@@ -204,12 +204,12 @@ int main (int argc, char *argv[])
Object catObj = docs[0]->getXRef()->getCatalog();
Dict *catDict = catObj.getDict();
intents = catDict->lookup("OutputIntents");
- afObj = catDict->lookupNF("AcroForm");
+ afObj = catDict->lookupNF("AcroForm").copy();
Ref *refPage = docs[0]->getCatalog()->getPageRef(1);
if (!afObj.isNull() && refPage) {
docs[0]->markAcroForm(&afObj, yRef, countRef, 0, refPage->num, refPage->num);
}
- ocObj = catDict->lookupNF("OCProperties");
+ ocObj = catDict->lookupNF("OCProperties").copy();
if (!ocObj.isNull() && ocObj.isDict() && refPage) {
docs[0]->markPageObjects(ocObj.getDict(), yRef, countRef, 0, refPage->num, refPage->num);
}
@@ -296,7 +296,7 @@ int main (int argc, char *argv[])
pages.push_back(std::move(page));
offsets.push_back(numOffset);
docs[i]->markPageObjects(pageDict, yRef, countRef, numOffset, refPage->num, refPage->num);
- Object annotsObj = pageDict->lookupNF("Annots");
+ Object annotsObj = pageDict->lookupNF("Annots").copy();
if (!annotsObj.isNull()) {
docs[i]->markAnnotations(&annotsObj, yRef, countRef, numOffset, refPage->num, refPage->num);
}
@@ -313,7 +313,7 @@ int main (int argc, char *argv[])
Object pageForm = pageCatDict->lookup("AcroForm");
if (i > 0 && !pageForm.isNull() && pageForm.isDict()) {
if (afObj.isNull()) {
- afObj = pageCatDict->lookupNF("AcroForm");
+ afObj = pageCatDict->lookupNF("AcroForm").copy();
} else if (afObj.isDict()) {
doMergeFormDict(afObj.getDict(), pageForm.getDict(), numOffset);
}
More information about the poppler
mailing list