Page.cc (xpdf-4.03) | : | Page.cc (xpdf-4.04) | ||
---|---|---|---|---|
skipping to change at line 67 | skipping to change at line 67 | |||
y2 = rect->y1; | y2 = rect->y1; | |||
} else if (y2 > rect->y2) { | } else if (y2 > rect->y2) { | |||
y2 = rect->y2; | y2 = rect->y2; | |||
} | } | |||
} | } | |||
//------------------------------------------------------------------------ | //------------------------------------------------------------------------ | |||
// PageAttrs | // PageAttrs | |||
//------------------------------------------------------------------------ | //------------------------------------------------------------------------ | |||
PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) { | PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict, XRef *xref) { | |||
Object obj1; | Object obj1; | |||
// get old/default values | // get old/default values | |||
if (attrs) { | if (attrs) { | |||
mediaBox = attrs->mediaBox; | mediaBox = attrs->mediaBox; | |||
cropBox = attrs->cropBox; | cropBox = attrs->cropBox; | |||
haveCropBox = attrs->haveCropBox; | haveCropBox = attrs->haveCropBox; | |||
rotate = attrs->rotate; | rotate = attrs->rotate; | |||
attrs->resources.copy(&resources); | ||||
} else { | } else { | |||
// set default MediaBox to 8.5" x 11" -- this shouldn't be necessary | // set default MediaBox to 8.5" x 11" -- this shouldn't be necessary | |||
// but some (non-compliant) PDF files don't specify a MediaBox | // but some (non-compliant) PDF files don't specify a MediaBox | |||
mediaBox.x1 = 0; | mediaBox.x1 = 0; | |||
mediaBox.y1 = 0; | mediaBox.y1 = 0; | |||
mediaBox.x2 = 612; | mediaBox.x2 = 612; | |||
mediaBox.y2 = 792; | mediaBox.y2 = 792; | |||
cropBox.x1 = cropBox.y1 = cropBox.x2 = cropBox.y2 = 0; | cropBox.x1 = cropBox.y1 = cropBox.x2 = cropBox.y2 = 0; | |||
haveCropBox = gFalse; | haveCropBox = gFalse; | |||
rotate = 0; | rotate = 0; | |||
resources.initNull(); | ||||
} | } | |||
// media box | // media box | |||
readBox(dict, "MediaBox", &mediaBox); | readBox(dict, "MediaBox", &mediaBox); | |||
// crop box | // crop box | |||
if (readBox(dict, "CropBox", &cropBox)) { | if (readBox(dict, "CropBox", &cropBox)) { | |||
haveCropBox = gTrue; | haveCropBox = gTrue; | |||
} | } | |||
if (!haveCropBox) { | if (!haveCropBox) { | |||
skipping to change at line 140 | skipping to change at line 138 | |||
userUnit = obj1.getNum(); | userUnit = obj1.getNum(); | |||
if (userUnit < 1) { | if (userUnit < 1) { | |||
userUnit = 1; | userUnit = 1; | |||
} | } | |||
} else { | } else { | |||
userUnit = 1; | userUnit = 1; | |||
} | } | |||
obj1.free(); | obj1.free(); | |||
// resource dictionary | // resource dictionary | |||
dict->lookup("Resources", &obj1); | Object childResDictObj; | |||
if (obj1.isDict()) { | dict->lookup("Resources", &childResDictObj); | |||
resources.free(); | if (attrs && attrs->resources.isDict() && childResDictObj.isDict()) { | |||
obj1.copy(&resources); | // 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() { | PageAttrs::PageAttrs() { | |||
mediaBox.x1 = mediaBox.y1 = 0; | mediaBox.x1 = mediaBox.y1 = 0; | |||
mediaBox.x2 = mediaBox.y2 = 50; | mediaBox.x2 = mediaBox.y2 = 50; | |||
cropBox = mediaBox; | cropBox = mediaBox; | |||
haveCropBox = gFalse; | haveCropBox = gFalse; | |||
bleedBox = cropBox; | bleedBox = cropBox; | |||
trimBox = cropBox; | trimBox = cropBox; | |||
artBox = cropBox; | artBox = cropBox; | |||
rotate = 0; | rotate = 0; | |||
lastModified.initNull(); | lastModified.initNull(); | |||
boxColorInfo.initNull(); | boxColorInfo.initNull(); | |||
group.initNull(); | group.initNull(); | |||
metadata.initNull(); | metadata.initNull(); | |||
pieceInfo.initNull(); | pieceInfo.initNull(); | |||
separationInfo.initNull(); | separationInfo.initNull(); | |||
userUnit = 1; | ||||
resources.initNull(); | resources.initNull(); | |||
} | } | |||
PageAttrs::~PageAttrs() { | PageAttrs::~PageAttrs() { | |||
lastModified.free(); | lastModified.free(); | |||
boxColorInfo.free(); | boxColorInfo.free(); | |||
group.free(); | group.free(); | |||
metadata.free(); | metadata.free(); | |||
pieceInfo.free(); | pieceInfo.free(); | |||
separationInfo.free(); | separationInfo.free(); | |||
End of changes. 6 change blocks. | ||||
8 lines changed or deleted | 54 lines changed or added |