summaryrefslogtreecommitdiff
path: root/Build/source/libs/poppler/poppler-src/poppler/Link.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/poppler/poppler-src/poppler/Link.cc')
-rw-r--r--Build/source/libs/poppler/poppler-src/poppler/Link.cc211
1 files changed, 76 insertions, 135 deletions
diff --git a/Build/source/libs/poppler/poppler-src/poppler/Link.cc b/Build/source/libs/poppler/poppler-src/poppler/Link.cc
index d4680dbc54d..a927c214f9a 100644
--- a/Build/source/libs/poppler/poppler-src/poppler/Link.cc
+++ b/Build/source/libs/poppler/poppler-src/poppler/Link.cc
@@ -16,7 +16,7 @@
// Copyright (C) 2006, 2008 Pino Toscano <pino@kde.org>
// Copyright (C) 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
-// Copyright (C) 2008-2010, 2012-2014, 2016 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2008-2010, 2012-2014, 2016, 2017 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
// Copyright (C) 2009 Ilya Gorenbein <igorenbein@finjan.com>
// Copyright (C) 2012 Tobias Koening <tobias.koenig@kdab.com>
@@ -64,7 +64,6 @@ LinkAction *LinkAction::parseDest(Object *obj) {
LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) {
LinkAction *action;
- Object obj2, obj3, obj4;
if (!obj->isDict()) {
error(errSyntaxWarning, -1, "parseAction: Bad annotation action for URI '{0:s}'",
@@ -72,21 +71,18 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) {
return NULL;
}
- obj->dictLookup("S", &obj2);
+ Object obj2 = obj->dictLookup("S");
// GoTo action
if (obj2.isName("GoTo")) {
- obj->dictLookup("D", &obj3);
+ Object obj3 = obj->dictLookup("D");
action = new LinkGoTo(&obj3);
- obj3.free();
// GoToR action
} else if (obj2.isName("GoToR")) {
- obj->dictLookup("F", &obj3);
- obj->dictLookup("D", &obj4);
+ Object obj3 = obj->dictLookup("F");
+ Object obj4 = obj->dictLookup("D");
action = new LinkGoToR(&obj3, &obj4);
- obj3.free();
- obj4.free();
// Launch action
} else if (obj2.isName("Launch")) {
@@ -94,15 +90,13 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) {
// URI action
} else if (obj2.isName("URI")) {
- obj->dictLookup("URI", &obj3);
+ Object obj3 = obj->dictLookup("URI");
action = new LinkURI(&obj3, baseURI);
- obj3.free();
// Named action
} else if (obj2.isName("Named")) {
- obj->dictLookup("N", &obj3);
+ Object obj3 = obj->dictLookup("N");
action = new LinkNamed(&obj3);
- obj3.free();
// Movie action
} else if (obj2.isName("Movie")) {
@@ -118,9 +112,8 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) {
// JavaScript action
} else if (obj2.isName("JavaScript")) {
- obj->dictLookup("JS", &obj3);
+ Object obj3 = obj->dictLookup("JS");
action = new LinkJavaScript(&obj3);
- obj3.free();
// Set-OCG-State action
} else if (obj2.isName("SetOCGState")) {
@@ -137,8 +130,6 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) {
action = NULL;
}
- obj2.free();
-
if (action && !action->isOk()) {
delete action;
return NULL;
@@ -151,8 +142,6 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) {
//------------------------------------------------------------------------
LinkDest::LinkDest(Array *a) {
- Object obj1, obj2;
-
// initialize fields
left = bottom = right = top = zoom = 0;
changeLeft = changeTop = changeZoom = gFalse;
@@ -163,7 +152,7 @@ LinkDest::LinkDest(Array *a) {
error(errSyntaxWarning, -1, "Annotation destination array is too short");
return;
}
- a->getNF(0, &obj1);
+ Object obj1 = a->getNF(0);
if (obj1.isInt()) {
pageNum = obj1.getInt() + 1;
pageIsRef = gFalse;
@@ -173,12 +162,11 @@ LinkDest::LinkDest(Array *a) {
pageIsRef = gTrue;
} else {
error(errSyntaxWarning, -1, "Bad annotation destination");
- goto err2;
+ return;
}
- obj1.free();
// get destination type
- a->get(1, &obj1);
+ obj1 = a->get(1);
// XYZ link
if (obj1.isName("XYZ")) {
@@ -186,7 +174,7 @@ LinkDest::LinkDest(Array *a) {
if (a->getLength() < 3) {
changeLeft = gFalse;
} else {
- a->get(2, &obj2);
+ Object obj2 = a->get(2);
if (obj2.isNull()) {
changeLeft = gFalse;
} else if (obj2.isNum()) {
@@ -194,14 +182,13 @@ LinkDest::LinkDest(Array *a) {
left = obj2.getNum();
} else {
error(errSyntaxWarning, -1, "Bad annotation destination position");
- goto err1;
+ return;
}
- obj2.free();
}
if (a->getLength() < 4) {
changeTop = gFalse;
} else {
- a->get(3, &obj2);
+ Object obj2 = a->get(3);
if (obj2.isNull()) {
changeTop = gFalse;
} else if (obj2.isNum()) {
@@ -209,14 +196,13 @@ LinkDest::LinkDest(Array *a) {
top = obj2.getNum();
} else {
error(errSyntaxWarning, -1, "Bad annotation destination position");
- goto err1;
+ return;
}
- obj2.free();
}
if (a->getLength() < 5) {
changeZoom = gFalse;
} else {
- a->get(4, &obj2);
+ Object obj2 = a->get(4);
if (obj2.isNull()) {
changeZoom = gFalse;
} else if (obj2.isNum()) {
@@ -224,9 +210,8 @@ LinkDest::LinkDest(Array *a) {
changeZoom = (zoom == 0) ? gFalse : gTrue;
} else {
error(errSyntaxWarning, -1, "Bad annotation destination position");
- goto err1;
+ return;
}
- obj2.free();
}
// Fit link
@@ -239,7 +224,7 @@ LinkDest::LinkDest(Array *a) {
if (a->getLength() < 3) {
changeTop = gFalse;
} else {
- a->get(2, &obj2);
+ Object obj2 = a->get(2);
if (obj2.isNull()) {
changeTop = gFalse;
} else if (obj2.isNum()) {
@@ -249,17 +234,16 @@ LinkDest::LinkDest(Array *a) {
error(errSyntaxWarning, -1, "Bad annotation destination position");
kind = destFit;
}
- obj2.free();
}
// FitV link
} else if (obj1.isName("FitV")) {
if (a->getLength() < 3) {
error(errSyntaxWarning, -1, "Annotation destination array is too short");
- goto err2;
+ return;
}
kind = destFitV;
- a->get(2, &obj2);
+ Object obj2 = a->get(2);
if (obj2.isNull()) {
changeLeft = gFalse;
} else if (obj2.isNum()) {
@@ -269,43 +253,42 @@ LinkDest::LinkDest(Array *a) {
error(errSyntaxWarning, -1, "Bad annotation destination position");
kind = destFit;
}
- obj2.free();
// FitR link
} else if (obj1.isName("FitR")) {
if (a->getLength() < 6) {
error(errSyntaxWarning, -1, "Annotation destination array is too short");
- goto err2;
+ return;
}
kind = destFitR;
- if (a->get(2, &obj2)->isNum()) {
+ Object obj2 = a->get(2);
+ if (obj2.isNum()) {
left = obj2.getNum();
} else {
error(errSyntaxWarning, -1, "Bad annotation destination position");
kind = destFit;
}
- obj2.free();
- if (a->get(3, &obj2)->isNum()) {
+ obj2 = a->get(3);
+ if (obj2.isNum()) {
bottom = obj2.getNum();
} else {
error(errSyntaxWarning, -1, "Bad annotation destination position");
kind = destFit;
}
- obj2.free();
- if (a->get(4, &obj2)->isNum()) {
+ obj2 = a->get(4);
+ if (obj2.isNum()) {
right = obj2.getNum();
} else {
error(errSyntaxWarning, -1, "Bad annotation destination position");
kind = destFit;
}
- obj2.free();
- if (a->get(5, &obj2)->isNum()) {
+ obj2 = a->get(5);
+ if (obj2.isNum()) {
top = obj2.getNum();
} else {
error(errSyntaxWarning, -1, "Bad annotation destination position");
kind = destFit;
}
- obj2.free();
// FitB link
} else if (obj1.isName("FitB")) {
@@ -315,10 +298,10 @@ LinkDest::LinkDest(Array *a) {
} else if (obj1.isName("FitBH")) {
if (a->getLength() < 3) {
error(errSyntaxWarning, -1, "Annotation destination array is too short");
- goto err2;
+ return;
}
kind = destFitBH;
- a->get(2, &obj2);
+ Object obj2 = a->get(2);
if (obj2.isNull()) {
changeTop = gFalse;
} else if (obj2.isNum()) {
@@ -328,16 +311,15 @@ LinkDest::LinkDest(Array *a) {
error(errSyntaxWarning, -1, "Bad annotation destination position");
kind = destFit;
}
- obj2.free();
// FitBV link
} else if (obj1.isName("FitBV")) {
if (a->getLength() < 3) {
error(errSyntaxWarning, -1, "Annotation destination array is too short");
- goto err2;
+ return;
}
kind = destFitBV;
- a->get(2, &obj2);
+ Object obj2 = a->get(2);
if (obj2.isNull()) {
changeLeft = gFalse;
} else if (obj2.isNum()) {
@@ -347,22 +329,14 @@ LinkDest::LinkDest(Array *a) {
error(errSyntaxWarning, -1, "Bad annotation destination position");
kind = destFit;
}
- obj2.free();
// unknown link kind
} else {
error(errSyntaxWarning, -1, "Unknown annotation destination type");
- goto err2;
}
- obj1.free();
ok = gTrue;
return;
-
- err1:
- obj2.free();
- err2:
- obj1.free();
}
LinkDest::LinkDest(LinkDest *dest) {
@@ -428,10 +402,9 @@ LinkGoToR::LinkGoToR(Object *fileSpecObj, Object *destObj) {
namedDest = NULL;
// get file name
- Object obj1;
- if (getFileSpecNameForPlatform (fileSpecObj, &obj1)) {
+ Object obj1 = getFileSpecNameForPlatform (fileSpecObj);
+ if (obj1.isString()) {
fileName = obj1.getString()->copy();
- obj1.free();
}
// named destination
@@ -469,54 +442,39 @@ LinkGoToR::~LinkGoToR() {
//------------------------------------------------------------------------
LinkLaunch::LinkLaunch(Object *actionObj) {
- Object obj1, obj2, obj3;
fileName = NULL;
params = NULL;
if (actionObj->isDict()) {
- if (!actionObj->dictLookup("F", &obj1)->isNull()) {
- if (getFileSpecNameForPlatform (&obj1, &obj3)) {
+ Object obj1 = actionObj->dictLookup("F");
+ if (!obj1.isNull()) {
+ Object obj3 = getFileSpecNameForPlatform (&obj1);
+ if (obj3.isString()) {
fileName = obj3.getString()->copy();
- obj3.free();
}
} else {
- obj1.free();
#ifdef _WIN32
- if (actionObj->dictLookup("Win", &obj1)->isDict()) {
- obj1.dictLookup("F", &obj2);
- if (getFileSpecNameForPlatform (&obj2, &obj3)) {
- fileName = obj3.getString()->copy();
- obj3.free();
- }
- obj2.free();
- if (obj1.dictLookup("P", &obj2)->isString()) {
- params = obj2.getString()->copy();
- }
- obj2.free();
- } else {
- error(errSyntaxWarning, -1, "Bad launch-type link action");
- }
+ obj1 = actionObj->dictLookup("Win");
#else
//~ This hasn't been defined by Adobe yet, so assume it looks
//~ just like the Win dictionary until they say otherwise.
- if (actionObj->dictLookup("Unix", &obj1)->isDict()) {
- obj1.dictLookup("F", &obj2);
- if (getFileSpecNameForPlatform (&obj2, &obj3)) {
+ obj1 = actionObj->dictLookup("Unix");
+#endif
+ if (obj1.isDict()) {
+ Object obj2 = obj1.dictLookup("F");
+ Object obj3 = getFileSpecNameForPlatform (&obj2);
+ if (obj3.isString()) {
fileName = obj3.getString()->copy();
- obj3.free();
}
- obj2.free();
- if (obj1.dictLookup("P", &obj2)->isString()) {
+ obj2 = obj1.dictLookup("P");
+ if (obj2.isString()) {
params = obj2.getString()->copy();
}
- obj2.free();
} else {
error(errSyntaxWarning, -1, "Bad launch-type link action");
}
-#endif
}
- obj1.free();
}
}
@@ -601,23 +559,23 @@ LinkMovie::LinkMovie(Object *obj) {
annotRef.num = -1;
annotTitle = NULL;
- Object tmp;
- if (obj->dictLookupNF("Annotation", &tmp)->isRef()) {
+ Object tmp = obj->dictLookupNF("Annotation");
+ if (tmp.isRef()) {
annotRef = tmp.getRef();
}
- tmp.free();
- if (obj->dictLookup("T", &tmp)->isString()) {
+ tmp = obj->dictLookup("T");
+ if (tmp.isString()) {
annotTitle = tmp.getString()->copy();
}
- tmp.free();
if ((annotTitle == NULL) && (annotRef.num == -1)) {
error(errSyntaxError, -1,
"Movie action is missing both the Annot and T keys");
}
- if (obj->dictLookup("Operation", &tmp)->isName()) {
+ tmp = obj->dictLookup("Operation");
+ if (tmp.isName()) {
char *name = tmp.getName();
if (!strcmp(name, "Play")) {
@@ -633,7 +591,6 @@ LinkMovie::LinkMovie(Object *obj) {
operation = operationTypeResume;
}
}
- tmp.free();
}
LinkMovie::~LinkMovie() {
@@ -654,35 +611,29 @@ LinkSound::LinkSound(Object *soundObj) {
sound = NULL;
if (soundObj->isDict())
{
- Object tmp;
// volume
- soundObj->dictLookup("Volume", &tmp);
+ Object tmp = soundObj->dictLookup("Volume");
if (tmp.isNum()) {
volume = tmp.getNum();
}
- tmp.free();
// sync
- soundObj->dictLookup("Synchronous", &tmp);
+ tmp = soundObj->dictLookup("Synchronous");
if (tmp.isBool()) {
sync = tmp.getBool();
}
- tmp.free();
// repeat
- soundObj->dictLookup("Repeat", &tmp);
+ tmp = soundObj->dictLookup("Repeat");
if (tmp.isBool()) {
repeat = tmp.getBool();
}
- tmp.free();
// mix
- soundObj->dictLookup("Mix", &tmp);
+ tmp = soundObj->dictLookup("Mix");
if (tmp.isBool()) {
mix = tmp.getBool();
}
- tmp.free();
// 'Sound' object
- soundObj->dictLookup("Sound", &tmp);
+ tmp = soundObj->dictLookup("Sound");
sound = Sound::parseSound(&tmp);
- tmp.free();
}
}
@@ -701,9 +652,8 @@ LinkRendition::LinkRendition(Object *obj) {
int operationCode = -1;
if (obj->isDict()) {
- Object tmp;
-
- if (!obj->dictLookup("JS", &tmp)->isNull()) {
+ Object tmp = obj->dictLookup("JS");
+ if (!tmp.isNull()) {
if (tmp.isString()) {
js = new GooString(tmp.getString());
} else if (tmp.isStream()) {
@@ -714,9 +664,9 @@ LinkRendition::LinkRendition(Object *obj) {
error(errSyntaxWarning, -1, "Invalid Rendition Action: JS not string or stream");
}
}
- tmp.free();
- if (obj->dictLookup("OP", &tmp)->isInt()) {
+ tmp = obj->dictLookup("OP");
+ if (tmp.isInt()) {
operationCode = tmp.getInt();
if (!js && (operationCode < 0 || operationCode > 4)) {
error(errSyntaxWarning, -1, "Invalid Rendition Action: unrecognized operation valued: {0:d}", operationCode);
@@ -724,16 +674,18 @@ LinkRendition::LinkRendition(Object *obj) {
Object obj1;
// retrieve rendition object
- if (obj->dictLookup("R", &renditionObj)->isDict()) {
+ renditionObj = obj->dictLookup("R");
+ if (renditionObj.isDict()) {
media = new MediaRendition(&renditionObj);
} else if (operationCode == 0 || operationCode == 4) {
error(errSyntaxWarning, -1, "Invalid Rendition Action: no R field with op = {0:d}", operationCode);
- renditionObj.free();
+ renditionObj.setToNull();
}
- if (!obj->dictLookupNF("AN", &screenRef)->isRef() && operation >= 0 && operation <= 4) {
+ screenRef = obj->dictLookupNF("AN");
+ if (!screenRef.isRef() && operation >= 0 && operation <= 4) {
error(errSyntaxWarning, -1, "Invalid Rendition Action: no AN field with op = {0:d}", operationCode);
- screenRef.free();
+ screenRef.setToNull();
}
}
@@ -757,18 +709,12 @@ LinkRendition::LinkRendition(Object *obj) {
} else if (!js) {
error(errSyntaxWarning, -1, "Invalid Rendition action: no OP or JS field defined");
}
- tmp.free();
}
}
LinkRendition::~LinkRendition() {
- renditionObj.free();
- screenRef.free();
-
- if (js)
- delete js;
- if (media)
- delete media;
+ delete js;
+ delete media;
}
@@ -799,18 +745,15 @@ LinkJavaScript::~LinkJavaScript() {
// LinkOCGState
//------------------------------------------------------------------------
LinkOCGState::LinkOCGState(Object *obj) {
- Object obj1;
-
stateList = new GooList();
preserveRB = gTrue;
- if (obj->dictLookup("State", &obj1)->isArray()) {
+ Object obj1 = obj->dictLookup("State");
+ if (obj1.isArray()) {
StateList *stList = NULL;
for (int i = 0; i < obj1.arrayGetLength(); ++i) {
- Object obj2;
-
- obj1.arrayGetNF(i, &obj2);
+ Object obj2 = obj1.arrayGetNF(i);
if (obj2.isName()) {
if (stList)
stateList->append(stList);
@@ -842,7 +785,6 @@ LinkOCGState::LinkOCGState(Object *obj) {
} else {
error(errSyntaxWarning, -1, "Invalid item in OCG Action State array");
}
- obj2.free();
}
// Add the last group
if (stList)
@@ -852,12 +794,11 @@ LinkOCGState::LinkOCGState(Object *obj) {
delete stateList;
stateList = NULL;
}
- obj1.free();
- if (obj->dictLookup("PreserveRB", &obj1)->isBool()) {
+ obj1 = obj->dictLookup("PreserveRB");
+ if (obj1.isBool()) {
preserveRB = obj1.getBool();
}
- obj1.free();
}
LinkOCGState::~LinkOCGState() {