19#include "PDFDocEncoding.h"
24Outline::Outline(Object *outlineObj, XRef *xref) {
28 if (!outlineObj->isDict()) {
31 items = OutlineItem::readItemList(outlineObj->dictLookupNF(
"First", &first),
38 deleteGList(items, OutlineItem);
44OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
54 if (dict->lookup(
"Title", &obj1)->isString()) {
56 if ((s->getChar(0) & 0xff) == 0xfe &&
57 (s->getChar(1) & 0xff) == 0xff) {
58 titleLen = (s->getLength() - 2) / 2;
59 title = (Unicode *)gmalloc(titleLen *
sizeof(Unicode));
60 for (i = 0; i < titleLen; ++i) {
61 title[i] = ((s->getChar(2 + 2*i) & 0xff) << 8) |
62 (s->getChar(3 + 2*i) & 0xff);
65 titleLen = s->getLength();
66 title = (Unicode *)gmalloc(titleLen *
sizeof(Unicode));
67 for (i = 0; i < titleLen; ++i) {
68 title[i] = pdfDocEncoding[s->getChar(i) & 0xff];
74 if (!dict->lookup(
"Dest", &obj1)->isNull()) {
75 action = LinkAction::parseDest(&obj1);
78 if (dict->lookup(
"A", &obj1)) {
79 action = LinkAction::parseAction(&obj1);
84 dict->lookupNF(
"First", &firstRef);
85 dict->lookupNF(
"Next", &nextRef);
88 if (dict->lookup(
"Count", &obj1)->isInt()) {
89 if (obj1.getInt() > 0) {
96OutlineItem::~OutlineItem() {
108GList *OutlineItem::readItemList(Object *itemRef, XRef *xrefA) {
117 if (!p->fetch(xrefA, &obj)->isDict()) {
121 item =
new OutlineItem(obj.getDict(), xrefA);
129void OutlineItem::open() {
131 kids = readItemList(&firstRef, xref);
135void OutlineItem::close() {
137 deleteGList(kids, OutlineItem);