~naesten/tex-live/trunk

« back to all changes in this revision

Viewing changes to libs/poppler/poppler-src/poppler/Outline.cc

  • Committer: karl
  • Date: 2018-01-09 18:53:05 UTC
  • Revision ID: svn-v4:c570f23f-e606-0410-a88d-b1316a301751:trunk/Build/source:46257
poppler 0.62.0, requiring C++11; luatex not updated yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
// under GPL version 2 or later
15
15
//
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>
20
21
//
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
//------------------------------------------------------------------------
42
43
 
43
44
Outline::Outline(Object *outlineObj, XRef *xref) {
44
 
  Object first, last;
45
 
 
46
 
  items = NULL;
 
45
  items = nullptr;
47
46
  if (!outlineObj->isDict()) {
48
47
    return;
49
48
  }
50
 
  items = OutlineItem::readItemList(outlineObj->dictLookupNF("First", &first), xref);
51
 
  first.free();
52
 
  last.free();
 
49
  Object first = outlineObj->dictLookupNF("First");
 
50
  items = OutlineItem::readItemList(&first, xref);
53
51
}
54
52
 
55
53
Outline::~Outline() {
62
60
 
63
61
OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
64
62
  Object obj1;
65
 
  GooString *s;
66
63
 
67
64
  xref = xrefA;
68
65
  title = NULL;
69
66
  action = NULL;
70
67
  kids = NULL;
71
68
 
72
 
  if (dict->lookup("Title", &obj1)->isString()) {
73
 
    s = obj1.getString();
 
69
 
 
70
  obj1 = dict->lookup("Title");
 
71
  if (obj1.isString()) {
 
72
    GooString *s = obj1.getString();
74
73
    titleLen = TextStringToUCS4(s, &title);
75
74
  } else {
76
75
    titleLen = 0;
77
76
  }
78
 
  obj1.free();
79
77
 
80
 
  if (!dict->lookup("Dest", &obj1)->isNull()) {
 
78
  obj1 = dict->lookup("Dest");
 
79
  if (!obj1.isNull()) {
81
80
    action = LinkAction::parseDest(&obj1);
82
81
  } else {
83
 
      obj1.free();
84
 
    if (!dict->lookup("A", &obj1)->isNull()) {
85
 
        action = LinkAction::parseAction(&obj1);
86
 
  }
87
 
  }
88
 
  obj1.free();
 
82
    obj1 = dict->lookup("A");
 
83
    if (!obj1.isNull()) {
 
84
      action = LinkAction::parseAction(&obj1);
 
85
    }
 
86
  }
89
87
 
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");
93
91
 
94
92
  startsOpen = gFalse;
95
 
  if (dict->lookup("Count", &obj1)->isInt()) {
 
93
  obj1 = dict->lookup("Count");
 
94
  if (obj1.isInt()) {
96
95
    if (obj1.getInt() > 0) {
97
96
      startsOpen = gTrue;
98
97
    }
99
98
  }
100
 
  obj1.free();
101
99
}
102
100
 
103
101
OutlineItem::~OutlineItem() {
108
106
  if (action) {
109
107
    delete action;
110
108
  }
111
 
  firstRef.free();
112
 
  lastRef.free();
113
 
  nextRef.free();
114
109
}
115
110
 
116
111
GooList *OutlineItem::readItemList(Object *firstItemRef, XRef *xrefA) {
117
112
  GooList *items;
118
113
  char* alreadyRead;
119
114
  OutlineItem *item;
120
 
  Object obj;
121
115
  Object *p;
122
116
 
123
117
  items = new GooList();
130
124
         (p->getRefNum() >= 0) && 
131
125
         (p->getRefNum() < xrefA->getNumObjects()) && 
132
126
         !alreadyRead[p->getRefNum()]) {
133
 
    if (!p->fetch(xrefA, &obj)->isDict()) {
134
 
      obj.free();
 
127
    Object obj = p->fetch(xrefA);
 
128
    if (!obj.isDict()) {
135
129
      break;
136
130
    }
137
131
    alreadyRead[p->getRefNum()] = 1;
138
132
    item = new OutlineItem(obj.getDict(), xrefA);
139
 
    obj.free();
140
133
    items->append(item);
141
134
    p = &item->nextRef;
142
135
  }