summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-src/xpdf/Page.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/xpdf/Page.cc')
-rw-r--r--Build/source/libs/xpdf/xpdf-src/xpdf/Page.cc62
1 files changed, 54 insertions, 8 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/xpdf/Page.cc b/Build/source/libs/xpdf/xpdf-src/xpdf/Page.cc
index ace0b33d85c..368bc68dd8a 100644
--- a/Build/source/libs/xpdf/xpdf-src/xpdf/Page.cc
+++ b/Build/source/libs/xpdf/xpdf-src/xpdf/Page.cc
@@ -64,7 +64,7 @@ void PDFRectangle::clipTo(PDFRectangle *rect) {
// PageAttrs
//------------------------------------------------------------------------
-PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) {
+PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict, XRef *xref) {
Object obj1;
// get old/default values
@@ -73,7 +73,6 @@ PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) {
cropBox = attrs->cropBox;
haveCropBox = attrs->haveCropBox;
rotate = attrs->rotate;
- attrs->resources.copy(&resources);
} else {
// set default MediaBox to 8.5" x 11" -- this shouldn't be necessary
// but some (non-compliant) PDF files don't specify a MediaBox
@@ -84,7 +83,6 @@ PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) {
cropBox.x1 = cropBox.y1 = cropBox.x2 = cropBox.y2 = 0;
haveCropBox = gFalse;
rotate = 0;
- resources.initNull();
}
// media box
@@ -137,12 +135,59 @@ PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) {
obj1.free();
// resource dictionary
- dict->lookup("Resources", &obj1);
- if (obj1.isDict()) {
- resources.free();
- obj1.copy(&resources);
+ Object childResDictObj;
+ dict->lookup("Resources", &childResDictObj);
+ if (attrs && attrs->resources.isDict() && childResDictObj.isDict()) {
+ // merge this node's resources into the parent's resources
+ // (some PDF files violate the PDF spec and expect this merging)
+ resources.initDict(xref);
+ Dict *resDict = resources.getDict();
+ Dict *parentResDict = attrs->resources.getDict();
+ for (int i = 0; i < parentResDict->getLength(); ++i) {
+ char *resType = parentResDict->getKey(i);
+ Object subdictObj1;
+ if (parentResDict->getVal(i, &subdictObj1)->isDict()) {
+ Dict *subdict1 = subdictObj1.getDict();
+ Object subdictObj2;
+ subdictObj2.initDict(xref);
+ Dict *subdict2 = subdictObj2.getDict();
+ for (int j = 0; j < subdict1->getLength(); ++j) {
+ subdict1->getValNF(j, &obj1);
+ subdict2->add(copyString(subdict1->getKey(j)), &obj1);
+ }
+ resDict->add(copyString(resType), &subdictObj2);
+ }
+ subdictObj1.free();
+ }
+ Dict *childResDict = childResDictObj.getDict();
+ for (int i = 0; i < childResDict->getLength(); ++i) {
+ char *resType = childResDict->getKey(i);
+ Object subdictObj1;
+ if (childResDict->getVal(i, &subdictObj1)->isDict()) {
+ Object subdictObj2;
+ if (resDict->lookup(resType, &subdictObj2)->isDict()) {
+ Dict *subdict1 = subdictObj1.getDict();
+ Dict *subdict2 = subdictObj2.getDict();
+ for (int j = 0; j < subdict1->getLength(); ++j) {
+ subdict1->getValNF(j, &obj1);
+ subdict2->add(copyString(subdict1->getKey(j)), &obj1);
+ }
+ subdictObj2.free();
+ } else {
+ subdictObj2.free();
+ resDict->add(copyString(resType), subdictObj1.copy(&subdictObj2));
+ }
+ }
+ subdictObj1.free();
+ }
+ } else if (attrs && attrs->resources.isDict()) {
+ attrs->resources.copy(&resources);
+ } else if (childResDictObj.isDict()) {
+ childResDictObj.copy(&resources);
+ } else {
+ resources.initNull();
}
- obj1.free();
+ childResDictObj.free();
}
PageAttrs::PageAttrs() {
@@ -160,6 +205,7 @@ PageAttrs::PageAttrs() {
metadata.initNull();
pieceInfo.initNull();
separationInfo.initNull();
+ userUnit = 1;
resources.initNull();
}