summaryrefslogtreecommitdiff
path: root/poppler/StructTreeRoot.h
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2017-11-26 20:43:15 +1030
committerAdrian Johnson <ajohnson@redneon.com>2018-01-04 15:37:42 +1030
commit321538259a9c79a99ce846a6ea2d94dd7fa56f61 (patch)
treed7e7b275fc617e562319a1b094413220e80c149a /poppler/StructTreeRoot.h
parentc4cbb4fd5e062544bf34109140266d0b027a512b (diff)
Fix some bugs in StructTreeRoot parsing of parent tree
- Add support for parsing child nodes in the number tree - Number tree keys do not have to be consecutive numbers. Use map instead of vector for parentTree. - Due to performance impact of iterating a map instead of vector in parentTreeAdd, add a reverse mapping from Ref to parentTree. - Add mcid parameter to findParentElement() to enable finding the parent when there are multiple MCIDs on the same page. - Move RefCompare from pdfinfo.cc to Object.h so it can be used by other files. Bug #103912
Diffstat (limited to 'poppler/StructTreeRoot.h')
-rw-r--r--poppler/StructTreeRoot.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/poppler/StructTreeRoot.h b/poppler/StructTreeRoot.h
index 3b1f3c84..ca688499 100644
--- a/poppler/StructTreeRoot.h
+++ b/poppler/StructTreeRoot.h
@@ -18,6 +18,7 @@
#include "goo/gtypes.h"
#include "Object.h"
#include "StructElement.h"
+#include <map>
#include <vector>
class Dict;
@@ -43,9 +44,12 @@ public:
}
}
- const StructElement *findParentElement(unsigned index) const {
- if (index < parentTree.size() && parentTree[index].size() == 1) {
- return parentTree[index][0].element;
+ const StructElement *findParentElement(int key, unsigned mcid = 0) const {
+ auto it = parentTree.find(key);
+ if (it != parentTree.end()) {
+ if (mcid < it->second.size()) {
+ return it->second[mcid].element;
+ }
}
return NULL;
}
@@ -71,9 +75,11 @@ private:
Object roleMap;
Object classMap;
ElemPtrArray elements;
- std::vector< std::vector<Parent> > parentTree;
+ std::map<int, std::vector<Parent> > parentTree;
+ std::multimap<Ref, Parent*, RefCompare> refToParentMap;
void parse(Dict *rootDict);
+ void parseNumberTreeNode(Dict *node);
void parentTreeAdd(const Ref &objectRef, StructElement *element);
friend class StructElement;