1 //========================================================================
5 // Copyright 2002-2003 Glyph & Cog, LLC
7 //========================================================================
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
19 #include "PDFDocEncoding.h"
22 //------------------------------------------------------------------------
24 Outline::Outline(Object *outlineObj, XRef *xref) {
28 if (!outlineObj->isDict()) {
31 items = OutlineItem::readItemList(outlineObj->dictLookupNF("First", &first),
32 outlineObj->dictLookupNF("Last", &last),
40 deleteGList(items, OutlineItem);
44 //------------------------------------------------------------------------
46 OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
56 if (dict->lookup("Title", &obj1)->isString()) {
58 if ((s->getChar(0) & 0xff) == 0xfe &&
59 (s->getChar(1) & 0xff) == 0xff) {
60 titleLen = (s->getLength() - 2) / 2;
61 title = (Unicode *)gmallocn(titleLen, sizeof(Unicode));
62 for (i = 0; i < titleLen; ++i) {
63 title[i] = ((s->getChar(2 + 2*i) & 0xff) << 8) |
64 (s->getChar(3 + 2*i) & 0xff);
67 titleLen = s->getLength();
68 title = (Unicode *)gmallocn(titleLen, sizeof(Unicode));
69 for (i = 0; i < titleLen; ++i) {
70 title[i] = pdfDocEncoding[s->getChar(i) & 0xff];
78 if (!dict->lookup("Dest", &obj1)->isNull()) {
79 action = LinkAction::parseDest(&obj1);
82 if (!dict->lookup("A", &obj1)->isNull()) {
83 action = LinkAction::parseAction(&obj1);
88 dict->lookupNF("First", &firstRef);
89 dict->lookupNF("Last", &lastRef);
90 dict->lookupNF("Next", &nextRef);
93 if (dict->lookup("Count", &obj1)->isInt()) {
94 if (obj1.getInt() > 0) {
101 OutlineItem::~OutlineItem() {
114 GList *OutlineItem::readItemList(Object *firstItemRef, Object *lastItemRef,
124 if (!p->fetch(xrefA, &obj)->isDict()) {
128 item = new OutlineItem(obj.getDict(), xrefA);
131 if (p->getRef().num == lastItemRef->getRef().num &&
132 p->getRef().gen == lastItemRef->getRef().gen) {
140 void OutlineItem::open() {
142 kids = readItemList(&firstRef, &lastRef, xref);
146 void OutlineItem::close() {
148 deleteGList(kids, OutlineItem);