From dfc28332a81d8c008ff16f09559b338da98cef4e Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Sat, 20 Aug 2016 19:35:27 +0900 Subject: [PATCH v2 1/3] Divide Catalog::findDest() In order to use constructing LinkDest from other functions, this commit divides Catalog::findDest(). --- poppler/Catalog.cc | 24 +++++++++++++++++------- poppler/Catalog.h | 2 ++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc index a8c96ac..7754e47 100644 --- a/poppler/Catalog.cc +++ b/poppler/Catalog.cc @@ -32,6 +32,7 @@ // Copyright (C) 2013 José Aliste // Copyright (C) 2014 Ed Porras // Copyright (C) 2015 Even Rouault +// Copyright (C) 2016 Masamichi Hosoda // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -451,7 +452,7 @@ int Catalog::findPage(int num, int gen) { LinkDest *Catalog::findDest(GooString *name) { LinkDest *dest; - Object obj1, obj2; + Object obj1; GBool found; // try named destination dictionary then name tree @@ -472,12 +473,22 @@ LinkDest *Catalog::findDest(GooString *name) { if (!found) return NULL; - // construct LinkDest + dest = createLinkDest(&obj1); + obj1.free(); + + return dest; +} + +LinkDest *Catalog::createLinkDest(Object *obj) +{ + LinkDest *dest; + Object obj2; + dest = NULL; - if (obj1.isArray()) { - dest = new LinkDest(obj1.getArray()); - } else if (obj1.isDict()) { - if (obj1.dictLookup("D", &obj2)->isArray()) + if (obj->isArray()) { + dest = new LinkDest(obj->getArray()); + } else if (obj->isDict()) { + if (obj->dictLookup("D", &obj2)->isArray()) dest = new LinkDest(obj2.getArray()); else error(errSyntaxWarning, -1, "Bad named destination value"); @@ -485,7 +496,6 @@ LinkDest *Catalog::findDest(GooString *name) { } else { error(errSyntaxWarning, -1, "Bad named destination value"); } - obj1.free(); if (dest && !dest->isOk()) { delete dest; dest = NULL; diff --git a/poppler/Catalog.h b/poppler/Catalog.h index bc9ce20..c7cce92 100644 --- a/poppler/Catalog.h +++ b/poppler/Catalog.h @@ -25,6 +25,7 @@ // Copyright (C) 2013 Adrian Perez de Castro // Copyright (C) 2013 Adrian Johnson // Copyright (C) 2013 José Aliste +// Copyright (C) 2016 Masamichi Hosoda // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -263,6 +264,7 @@ private: NameTree *getDestNameTree(); NameTree *getEmbeddedFileNameTree(); NameTree *getJSNameTree(); + LinkDest *createLinkDest(Object *obj); #if MULTITHREADED GooMutex mutex; #endif -- 2.8.3