Commit fbc05a67 authored by Albert Astals Cid's avatar Albert Astals Cid

* poppler/Annot.cc:

* poppler/Annot.h: Add type checking to processing of "Rect". Patch by Scott Turner <scotty1024@mac.com>
parent dc6b3723
2006-12-28 Albert Astals Cid <aacid@kde.org>
* poppler/Annot.cc:
* poppler/Annot.h: Add type checking to processing of "Rect". Patch by
Scott Turner <scotty1024@mac.com>
2006-12-27 Albert Astals Cid <aacid@kde.org>
* poppler/Catalog.h:
......
......@@ -30,30 +30,27 @@ Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict) {
GBool regen, isTextField;
double t;
ok = gFalse;
ok = gTrue;
xref = xrefA;
appearBuf = NULL;
if (dict->lookup("Rect", &obj1)->isArray() &&
obj1.arrayGetLength() == 4) {
//~ should check object types here
obj1.arrayGet(0, &obj2);
xMin = obj2.getNum();
obj2.free();
obj1.arrayGet(1, &obj2);
yMin = obj2.getNum();
obj2.free();
obj1.arrayGet(2, &obj2);
xMax = obj2.getNum();
obj2.free();
obj1.arrayGet(3, &obj2);
yMax = obj2.getNum();
obj2.free();
if (xMin > xMax) {
t = xMin; xMin = xMax; xMax = t;
}
if (yMin > yMax) {
t = yMin; yMin = yMax; yMax = t;
readArrayNum(&obj1, 0, &xMin);
readArrayNum(&obj1, 1, &yMin);
readArrayNum(&obj1, 2, &xMax);
readArrayNum(&obj1, 3, &yMax);
if (ok) {
if (xMin > xMax) {
t = xMin; xMin = xMax; xMax = t;
}
if (yMin > yMax) {
t = yMin; yMin = yMax; yMax = t;
}
} else {
//~ this should return an error
xMin = yMin = 0;
xMax = yMax = 1;
}
} else {
//~ this should return an error
......@@ -112,6 +109,19 @@ Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict) {
#endif
}
void Annot::readArrayNum(Object *pdfArray, int key, double *value) {
Object valueObject;
pdfArray->arrayGet(key, &valueObject);
if (valueObject.isNum()) {
*value = valueObject.getNum();
} else {
*value = 0;
ok = gFalse;
}
valueObject.free();
}
Annot::~Annot() {
appearance.free();
if (appearBuf) {
......
......@@ -36,6 +36,7 @@ public:
private:
void generateAppearance(Dict *acroForm, Dict *dict);
void readArrayNum(Object *pdfArray, int key, double *value);
XRef *xref; // the xref table for this PDF file
Object appearance; // a reference to the Form XObject stream
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment