1 //========================================================================
5 // Copyright 2002-2003 Glyph & Cog, LLC
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com>
17 // Copyright (C) 2008, 2016 Albert Astals Cid <aacid@kde.org>
18 // Copyright (C) 2009 Nick Jones <nick.jones@network-box.com>
19 // Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
21 // To see a description of the changes please see the Changelog file that
22 // came with your tarball or type make ChangeLog if you are building from git
24 //========================================================================
28 #ifdef USE_GCC_PRAGMAS
29 #pragma implementation
33 #include "goo/GooString.h"
34 #include "goo/GooList.h"
37 #include "PDFDocEncoding.h"
41 //------------------------------------------------------------------------
43 Outline::Outline(Object
*outlineObj
, XRef
*xref
) {
47 if (!outlineObj
->isDict()) {
50 items
= OutlineItem::readItemList(outlineObj
->dictLookupNF("First", &first
), xref
);
57 deleteGooList(items
, OutlineItem
);
61 //------------------------------------------------------------------------
63 OutlineItem::OutlineItem(Dict
*dict
, XRef
*xrefA
) {
72 if (dict
->lookup("Title", &obj1
)->isString()) {
74 titleLen
= TextStringToUCS4(s
, &title
);
80 if (!dict
->lookup("Dest", &obj1
)->isNull()) {
81 action
= LinkAction::parseDest(&obj1
);
84 if (!dict
->lookup("A", &obj1
)->isNull()) {
85 action
= LinkAction::parseAction(&obj1
);
90 dict
->lookupNF("First", &firstRef
);
91 dict
->lookupNF("Last", &lastRef
);
92 dict
->lookupNF("Next", &nextRef
);
95 if (dict
->lookup("Count", &obj1
)->isInt()) {
96 if (obj1
.getInt() > 0) {
103 OutlineItem::~OutlineItem() {
116 GooList
*OutlineItem::readItemList(Object
*firstItemRef
, XRef
*xrefA
) {
123 items
= new GooList();
125 alreadyRead
= (char *)gmalloc(xrefA
->getNumObjects());
126 memset(alreadyRead
, 0, xrefA
->getNumObjects());
130 (p
->getRefNum() >= 0) &&
131 (p
->getRefNum() < xrefA
->getNumObjects()) &&
132 !alreadyRead
[p
->getRefNum()]) {
133 if (!p
->fetch(xrefA
, &obj
)->isDict()) {
137 alreadyRead
[p
->getRefNum()] = 1;
138 item
= new OutlineItem(obj
.getDict(), xrefA
);
146 if (!items
->getLength()) {
154 void OutlineItem::open() {
156 kids
= readItemList(&firstRef
, xref
);
160 void OutlineItem::close() {
162 deleteGooList(kids
, OutlineItem
);