File indexing completed on 2025-12-10 10:23:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #ifndef OUTLINE_H
0027 #define OUTLINE_H
0028
0029 #include <memory>
0030 #include "Object.h"
0031 #include "CharTypes.h"
0032 #include "poppler_private_export.h"
0033
0034 class PDFDoc;
0035 class GooString;
0036 class XRef;
0037 class LinkAction;
0038 class OutlineItem;
0039
0040
0041
0042 class POPPLER_PRIVATE_EXPORT Outline
0043 {
0044 PDFDoc *doc;
0045 XRef *xref;
0046 Object *outlineObj;
0047
0048 public:
0049 Outline(Object *outlineObj, XRef *xref, PDFDoc *doc);
0050 ~Outline();
0051
0052 Outline(const Outline &) = delete;
0053 Outline &operator=(const Outline &) = delete;
0054
0055 const std::vector<OutlineItem *> *getItems() const
0056 {
0057 if (!items || items->empty()) {
0058 return nullptr;
0059 } else {
0060 return items;
0061 }
0062 }
0063
0064 struct OutlineTreeNode
0065 {
0066 std::string title;
0067 int destPageNum;
0068 std::vector<OutlineTreeNode> children;
0069 };
0070
0071
0072
0073 void setOutline(const std::vector<OutlineTreeNode> &nodeList);
0074 void insertChild(const std::string &itemTitle, int destPageNum, unsigned int pos);
0075 void removeChild(unsigned int pos);
0076
0077 private:
0078 std::vector<OutlineItem *> *items;
0079 int addOutlineTreeNodeList(const std::vector<OutlineTreeNode> &nodeList, Ref &parentRef, Ref &firstRef, Ref &lastRef);
0080 };
0081
0082
0083
0084 class POPPLER_PRIVATE_EXPORT OutlineItem
0085 {
0086 friend Outline;
0087
0088 public:
0089 OutlineItem(const Dict *dict, Ref refA, OutlineItem *parentA, XRef *xrefA, PDFDoc *docA);
0090 ~OutlineItem();
0091 OutlineItem(const OutlineItem &) = delete;
0092 OutlineItem &operator=(const OutlineItem &) = delete;
0093 static std::vector<OutlineItem *> *readItemList(OutlineItem *parent, const Object *firstItemRef, XRef *xrefA, PDFDoc *docA);
0094 const Unicode *getTitle() const { return title; }
0095 void setTitle(const std::string &titleA);
0096 int getTitleLength() const { return titleLen; }
0097 bool setPageDest(int i);
0098
0099 const LinkAction *getAction() const { return action.get(); }
0100 void setStartsOpen(bool value);
0101 bool isOpen() const { return startsOpen; }
0102 bool hasKids();
0103 void open();
0104 const std::vector<OutlineItem *> *getKids();
0105 int getRefNum() const { return ref.num; }
0106 Ref getRef() const { return ref; }
0107 void insertChild(const std::string &itemTitle, int destPageNum, unsigned int pos);
0108 void removeChild(unsigned int pos);
0109
0110 private:
0111 Ref ref;
0112 OutlineItem *parent;
0113 PDFDoc *doc;
0114 XRef *xref;
0115 Unicode *title;
0116 int titleLen;
0117 std::unique_ptr<LinkAction> action;
0118 bool startsOpen;
0119 std::vector<OutlineItem *> *kids;
0120 };
0121
0122 #endif