git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed $(A) file creation
[swftools.git]
/
pdf2swf
/
xpdf
/
Catalog.cc
diff --git
a/pdf2swf/xpdf/Catalog.cc
b/pdf2swf/xpdf/Catalog.cc
index
1212e2e
..
fd235d6
100644
(file)
--- a/
pdf2swf/xpdf/Catalog.cc
+++ b/
pdf2swf/xpdf/Catalog.cc
@@
-2,15
+2,16
@@
//
// Catalog.cc
//
//
// Catalog.cc
//
-// Copyright 1996-2002 Glyph & Cog, LLC
+// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
//
//========================================================================
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#pragma implementation
#endif
-#include <aconf.h>
#include <stddef.h>
#include "gmem.h"
#include "Object.h"
#include <stddef.h>
#include "gmem.h"
#include "Object.h"
@@
-26,7
+27,7
@@
// Catalog
//------------------------------------------------------------------------
// Catalog
//------------------------------------------------------------------------
-Catalog::Catalog(XRef *xrefA, GBool printCommands) {
+Catalog::Catalog(XRef *xrefA) {
Object catDict, pagesDict;
Object obj, obj2;
int numPages0;
Object catDict, pagesDict;
Object obj, obj2;
int numPages0;
@@
-55,21
+56,22
@@
Catalog::Catalog(XRef *xrefA, GBool printCommands) {
goto err2;
}
pagesDict.dictLookup("Count", &obj);
goto err2;
}
pagesDict.dictLookup("Count", &obj);
- if (!obj.isInt()) {
+ // some PDF files actually use real numbers here ("/Count 9.0")
+ if (!obj.isNum()) {
error(-1, "Page count in top-level pages object is wrong type (%s)",
obj.getTypeName());
goto err3;
}
error(-1, "Page count in top-level pages object is wrong type (%s)",
obj.getTypeName());
goto err3;
}
- pagesSize = numPages0 = obj.getInt();
+ pagesSize = numPages0 = (int)obj.getNum();
obj.free();
obj.free();
- pages = (Page **)gmalloc(pagesSize * sizeof(Page *));
- pageRefs = (Ref *)gmalloc(pagesSize * sizeof(Ref));
+ pages = (Page **)gmallocn(pagesSize, sizeof(Page *));
+ pageRefs = (Ref *)gmallocn(pagesSize, sizeof(Ref));
for (i = 0; i < pagesSize; ++i) {
pages[i] = NULL;
pageRefs[i].num = -1;
pageRefs[i].gen = -1;
}
for (i = 0; i < pagesSize; ++i) {
pages[i] = NULL;
pageRefs[i].num = -1;
pageRefs[i].gen = -1;
}
- numPages = readPageTree(pagesDict.getDict(), NULL, 0, printCommands);
+ numPages = readPageTree(pagesDict.getDict(), NULL, 0);
if (numPages != numPages0) {
error(-1, "Page count in top-level pages object is incorrect");
}
if (numPages != numPages0) {
error(-1, "Page count in top-level pages object is incorrect");
}
@@
-100,6
+102,12
@@
Catalog::Catalog(XRef *xrefA, GBool printCommands) {
// get the structure tree root
catDict.dictLookup("StructTreeRoot", &structTreeRoot);
// get the structure tree root
catDict.dictLookup("StructTreeRoot", &structTreeRoot);
+ // get the outline dictionary
+ catDict.dictLookup("Outlines", &outline);
+
+ // get the AcroForm dictionary
+ catDict.dictLookup("AcroForm", &acroForm);
+
catDict.free();
return;
catDict.free();
return;
@@
-133,6
+141,8
@@
Catalog::~Catalog() {
}
metadata.free();
structTreeRoot.free();
}
metadata.free();
structTreeRoot.free();
+ outline.free();
+ acroForm.free();
}
GString *Catalog::readMetadata() {
}
GString *Catalog::readMetadata() {
@@
-159,8
+169,7
@@
GString *Catalog::readMetadata() {
return s;
}
return s;
}
-int Catalog::readPageTree(Dict *pagesDict, PageAttrs *attrs, int start,
- GBool printCommands) {
+int Catalog::readPageTree(Dict *pagesDict, PageAttrs *attrs, int start) {
Object kids;
Object kid;
Object kidRef;
Object kids;
Object kid;
Object kidRef;
@@
-179,15
+188,15
@@
int Catalog::readPageTree(Dict *pagesDict, PageAttrs *attrs, int start,
kids.arrayGet(i, &kid);
if (kid.isDict("Page")) {
attrs2 = new PageAttrs(attrs1, kid.getDict());
kids.arrayGet(i, &kid);
if (kid.isDict("Page")) {
attrs2 = new PageAttrs(attrs1, kid.getDict());
- page = new Page(xref, start+1, kid.getDict(), attrs2, printCommands);
+ page = new Page(xref, start+1, kid.getDict(), attrs2);
if (!page->isOk()) {
++start;
goto err3;
}
if (start >= pagesSize) {
pagesSize += 32;
if (!page->isOk()) {
++start;
goto err3;
}
if (start >= pagesSize) {
pagesSize += 32;
- pages = (Page **)grealloc(pages, pagesSize * sizeof(Page *));
- pageRefs = (Ref *)grealloc(pageRefs, pagesSize * sizeof(Ref));
+ pages = (Page **)greallocn(pages, pagesSize, sizeof(Page *));
+ pageRefs = (Ref *)greallocn(pageRefs, pagesSize, sizeof(Ref));
for (j = pagesSize - 32; j < pagesSize; ++j) {
pages[j] = NULL;
pageRefs[j].num = -1;
for (j = pagesSize - 32; j < pagesSize; ++j) {
pages[j] = NULL;
pageRefs[j].num = -1;
@@
-205,13
+214,12
@@
int Catalog::readPageTree(Dict *pagesDict, PageAttrs *attrs, int start,
// This should really be isDict("Pages"), but I've seen at least one
// PDF file where the /Type entry is missing.
} else if (kid.isDict()) {
// This should really be isDict("Pages"), but I've seen at least one
// PDF file where the /Type entry is missing.
} else if (kid.isDict()) {
- if ((start = readPageTree(kid.getDict(), attrs1, start, printCommands))
+ if ((start = readPageTree(kid.getDict(), attrs1, start))
< 0)
goto err2;
} else {
error(-1, "Kid object (page %d) is wrong type (%s)",
start+1, kid.getTypeName());
< 0)
goto err2;
} else {
error(-1, "Kid object (page %d) is wrong type (%s)",
start+1, kid.getTypeName());
- goto err2;
}
kid.free();
}
}
kid.free();
}
@@
-276,6
+284,10
@@
LinkDest *Catalog::findDest(GString *name) {
error(-1, "Bad named destination value");
}
obj1.free();
error(-1, "Bad named destination value");
}
obj1.free();
+ if (dest && !dest->isOk()) {
+ delete dest;
+ dest = NULL;
+ }
return dest;
}
return dest;
}
@@
-299,8
+311,8
@@
Object *Catalog::findDestInTree(Object *tree, GString *name, Object *obj) {
} else if (cmp < 0) {
done = gTrue;
}
} else if (cmp < 0) {
done = gTrue;
}
- name1.free();
}
}
+ name1.free();
}
names.free();
if (!found)
}
names.free();
if (!found)