[poppler] poppler/OptionalContent.cc poppler/OptionalContent.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Dec 27 22:22:31 UTC 2019
poppler/OptionalContent.cc | 120 ---------------------------------------------
poppler/OptionalContent.h | 35 -------------
2 files changed, 155 deletions(-)
New commits:
commit fabc00e32b8dd90d6cfe3b03613cb335b6760fd4
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Dec 19 00:29:54 2019 +0100
Kill OCDisplayNode
diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index 178119a8..a63df16a 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -126,17 +126,6 @@ OptionalContentGroup* OCGs::findOcgByRef( const Ref ref )
return ocg != optionalContentGroups.end() ? ocg->second.get() : nullptr;
}
-OCDisplayNode *OCGs::getDisplayRoot()
-{
- if (display)
- return display.get();
-
- if (order.isArray())
- display.reset(OCDisplayNode::parse(&order, this, m_xref));
-
- return display.get();
-}
-
bool OCGs::optContentIsVisible( const Object *dictRef )
{
Dict *dict;
@@ -364,112 +353,3 @@ OptionalContentGroup::~OptionalContentGroup()
{
delete m_name;
}
-
-//------------------------------------------------------------------------
-
-OCDisplayNode *OCDisplayNode::parse(const Object *obj, OCGs *oc,
- XRef *xref, int recursion) {
- OptionalContentGroup *ocgA;
- OCDisplayNode *node, *child;
- int i;
-
- if (recursion > displayNodeRecursionLimit) {
- error(errSyntaxError, -1, "Loop detected in optional content order");
- return nullptr;
- }
- if (obj->isRef()) {
- if ((ocgA = oc->findOcgByRef(obj->getRef()))) {
- return new OCDisplayNode(ocgA);
- }
- }
- Object obj2 = obj->fetch(xref);
- if (!obj2.isArray()) {
- return nullptr;
- }
- i = 0;
- if (obj2.arrayGetLength() >= 1) {
- Object obj3 = obj2.arrayGet(0);
- if (obj3.isString()) {
- node = new OCDisplayNode(obj3.getString());
- i = 1;
- } else {
- node = new OCDisplayNode();
- }
- } else {
- node = new OCDisplayNode();
- }
- for (; i < obj2.arrayGetLength(); ++i) {
- const Object &obj3 = obj2.arrayGetNF(i);
- if ((child = OCDisplayNode::parse(&obj3, oc, xref, recursion + 1))) {
- if (!child->ocg && !child->name && node->getNumChildren() > 0) {
- node->getChild(node->getNumChildren() - 1)->addChildren(child->takeChildren());
- delete child;
- } else {
- node->addChild(child);
- }
- }
- }
- return node;
-}
-
-OCDisplayNode::OCDisplayNode() {
- name = nullptr;
- ocg = nullptr;
- children = nullptr;
-}
-
-OCDisplayNode::OCDisplayNode(const GooString *nameA) {
- name = new GooString(nameA);
- ocg = nullptr;
- children = nullptr;
-}
-
-OCDisplayNode::OCDisplayNode(OptionalContentGroup *ocgA) {
- name = (ocgA->getName()) ? ocgA->getName()->copy() : nullptr;
- ocg = ocgA;
- children = nullptr;
-}
-
-void OCDisplayNode::addChild(OCDisplayNode *child) {
- if (!children) {
- children = new std::vector<OCDisplayNode*>();
- }
- children->push_back(child);
-}
-
-void OCDisplayNode::addChildren(std::vector<OCDisplayNode*> *childrenA) {
- if (!children) {
- children = new std::vector<OCDisplayNode*>();
- }
- children->reserve(children->size() + childrenA->size());
- children->insert(children->end(), childrenA->begin(), childrenA->end());
- delete childrenA;
-}
-
-std::vector<OCDisplayNode*> *OCDisplayNode::takeChildren() {
- std::vector<OCDisplayNode*> *childrenA = children;
-
- children = nullptr;
- return childrenA;
-}
-
-OCDisplayNode::~OCDisplayNode() {
- delete name;
- if (children) {
- for (auto entry : *children) {
- delete entry;
- }
- delete children;
- }
-}
-
-int OCDisplayNode::getNumChildren() const {
- if (!children) {
- return 0;
- }
- return children->size();
-}
-
-OCDisplayNode *OCDisplayNode::getChild(int idx) const {
- return (*children)[idx];
-}
diff --git a/poppler/OptionalContent.h b/poppler/OptionalContent.h
index 02619533..fe91c6de 100644
--- a/poppler/OptionalContent.h
+++ b/poppler/OptionalContent.h
@@ -24,7 +24,6 @@ class GooString;
class XRef;
class OptionalContentGroup;
-class OCDisplayNode;
//------------------------------------------------------------------------
@@ -44,10 +43,6 @@ public:
OptionalContentGroup* findOcgByRef( const Ref ref);
- // Get the root node of the optional content group display tree
- // (which does not necessarily include all of the OCGs).
- OCDisplayNode *getDisplayRoot();
-
Array* getOrderArray()
{ return (order.isArray() && order.arrayGetLength() > 0) ? order.getArray() : nullptr; }
Array* getRBGroupsArray()
@@ -69,7 +64,6 @@ private:
Object order;
Object rbgroups;
XRef *m_xref;
- std::unique_ptr< OCDisplayNode > display; // root node of display tree
};
//------------------------------------------------------------------------
@@ -115,33 +109,4 @@ private:
//------------------------------------------------------------------------
-class OCDisplayNode {
-public:
-
- static OCDisplayNode *parse(const Object *obj, OCGs *oc, XRef *xref, int recursion = 0);
- OCDisplayNode();
- ~OCDisplayNode();
-
- OCDisplayNode(const OCDisplayNode &) = delete;
- OCDisplayNode& operator=(const OCDisplayNode &) = delete;
-
- const GooString *getName() const { return name; }
- const OptionalContentGroup *getOCG() const { return ocg; }
- int getNumChildren() const;
- OCDisplayNode *getChild(int idx) const;
-
-private:
-
- OCDisplayNode(const GooString *nameA);
- OCDisplayNode(OptionalContentGroup *ocgA);
- void addChild(OCDisplayNode *child);
- void addChildren(std::vector<OCDisplayNode*> *childrenA);
- std::vector<OCDisplayNode*> *takeChildren();
-
- GooString *name; // display name (may be nullptr)
- OptionalContentGroup *ocg; // nullptr for display labels
- std::vector<OCDisplayNode*> *children; // nullptr if there are no children
- // [OCDisplayNode]
-};
-
#endif
More information about the poppler
mailing list