14
14
// under GPL version 2 or later
16
16
// Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com>
17
// Copyright (C) 2008, 2016 Albert Astals Cid <aacid@kde.org>
17
// Copyright (C) 2008, 2016, 2017 Albert Astals Cid <aacid@kde.org>
18
18
// Copyright (C) 2009 Nick Jones <nick.jones@network-box.com>
19
19
// Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
20
// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
21
22
// To see a description of the changes please see the Changelog file that
22
23
// came with your tarball or type make ChangeLog if you are building from git
41
42
//------------------------------------------------------------------------
43
44
Outline::Outline(Object *outlineObj, XRef *xref) {
47
46
if (!outlineObj->isDict()) {
50
items = OutlineItem::readItemList(outlineObj->dictLookupNF("First", &first), xref);
49
Object first = outlineObj->dictLookupNF("First");
50
items = OutlineItem::readItemList(&first, xref);
55
53
Outline::~Outline() {
63
61
OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
72
if (dict->lookup("Title", &obj1)->isString()) {
70
obj1 = dict->lookup("Title");
71
if (obj1.isString()) {
72
GooString *s = obj1.getString();
74
73
titleLen = TextStringToUCS4(s, &title);
80
if (!dict->lookup("Dest", &obj1)->isNull()) {
78
obj1 = dict->lookup("Dest");
81
80
action = LinkAction::parseDest(&obj1);
84
if (!dict->lookup("A", &obj1)->isNull()) {
85
action = LinkAction::parseAction(&obj1);
82
obj1 = dict->lookup("A");
84
action = LinkAction::parseAction(&obj1);
90
dict->lookupNF("First", &firstRef);
91
dict->lookupNF("Last", &lastRef);
92
dict->lookupNF("Next", &nextRef);
88
firstRef = dict->lookupNF("First");
89
lastRef = dict->lookupNF("Last");
90
nextRef = dict->lookupNF("Next");
94
92
startsOpen = gFalse;
95
if (dict->lookup("Count", &obj1)->isInt()) {
93
obj1 = dict->lookup("Count");
96
95
if (obj1.getInt() > 0) {
97
96
startsOpen = gTrue;
103
101
OutlineItem::~OutlineItem() {
130
124
(p->getRefNum() >= 0) &&
131
125
(p->getRefNum() < xrefA->getNumObjects()) &&
132
126
!alreadyRead[p->getRefNum()]) {
133
if (!p->fetch(xrefA, &obj)->isDict()) {
127
Object obj = p->fetch(xrefA);
137
131
alreadyRead[p->getRefNum()] = 1;
138
132
item = new OutlineItem(obj.getDict(), xrefA);
140
133
items->append(item);
141
134
p = &item->nextRef;