summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/pdfinput/pdf-parser.cpp
diff options
context:
space:
mode:
authorLuca Bruno <lucab@debian.org>2012-06-30 19:43:45 +0000
committerLuca Bruno <lucab@debian.org>2012-06-30 19:43:45 +0000
commit8ccb359f4d190740e7c56cc5a145b5a8f67d14b3 (patch)
treefe7daf717d89fe762f58583b36af0e00a8287ece /src/extension/internal/pdfinput/pdf-parser.cpp
parentAllow cairomm 1.9.8. Should be good enough (diff)
downloadinkscape-8ccb359f4d190740e7c56cc5a145b5a8f67d14b3.tar.gz
inkscape-8ccb359f4d190740e7c56cc5a145b5a8f67d14b3.zip
Fix building with Poppler 0.20 (LP: #1005565)
Poppler >= 0.20 has a new internal API for errors and other miscellanea. As we are abusing these internal functionalities, they broke from time to time. Fixing it for now with a new conditional build flag. This fixes https://bugs.launchpad.net/inkscape/+bug/1005565 (bzr r11518)
Diffstat (limited to 'src/extension/internal/pdfinput/pdf-parser.cpp')
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp221
1 files changed, 208 insertions, 13 deletions
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index 7ecd8fb3c..e57161e5a 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -368,15 +368,23 @@ void PdfParser::parse(Object *obj, GBool topLevel) {
for (int i = 0; i < obj->arrayGetLength(); ++i) {
obj->arrayGet(i, &obj2);
if (!obj2.isStream()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errInternal, -1, "Weird page contents");
+#else
error(-1, const_cast<char*>("Weird page contents"));
+#endif
obj2.free();
return;
}
obj2.free();
}
} else if (!obj->isStream()) {
- error(-1, const_cast<char*>("Weird page contents"));
- return;
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errInternal, -1, "Weird page contents");
+#else
+ error(-1, const_cast<char*>("Weird page contents"));
+#endif
+ return;
}
parser = new Parser(xref, new Lexer(xref, obj), gFalse);
go(topLevel);
@@ -420,7 +428,11 @@ void PdfParser::go(GBool /*topLevel*/)
// too many arguments - something is wrong
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Too many args in content stream");
+#else
error(getPos(), const_cast<char*>("Too many args in content stream"));
+#endif
if (printCommands) {
printf("throwing away arg: ");
obj.print(stdout);
@@ -437,7 +449,11 @@ void PdfParser::go(GBool /*topLevel*/)
// args at end with no command
if (numArgs > 0) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Leftover args in content stream");
+#else
error(getPos(), const_cast<char*>("Leftover args in content stream"));
+#endif
if (printCommands) {
printf("%d leftovers:", numArgs);
for (int i = 0; i < numArgs; ++i) {
@@ -503,7 +519,11 @@ void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
name = cmd->getCmd();
if (!(op = findOp(name))) {
if (ignoreUndef == 0)
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Unknown operator '{0:s}'", name);
+#else
error(getPos(), const_cast<char*>("Unknown operator '%s'"), name);
+#endif
return;
}
@@ -511,26 +531,42 @@ void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
argPtr = args;
if (op->numArgs >= 0) {
if (numArgs < op->numArgs) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Too few ({0:d}) args to '{1:d}' operator", numArgs, name);
+#else
error(getPos(), const_cast<char*>("Too few (%d) args to '%s' operator"), numArgs, name);
+#endif
return;
}
if (numArgs > op->numArgs) {
#if 0
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Too many ({0:d}) args to '{1:s}' operator", numArgs, name);
+#else
error(getPos(), "Too many (%d) args to '%s' operator", numArgs, name);
#endif
+#endif
argPtr += numArgs - op->numArgs;
numArgs = op->numArgs;
}
} else {
if (numArgs > -op->numArgs) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Too many ({0:d}) args to '{1:s}' operator",
+#else
error(getPos(), const_cast<char*>("Too many (%d) args to '%s' operator"),
+#endif
numArgs, name);
return;
}
}
for (i = 0; i < numArgs; ++i) {
if (!checkArg(&argPtr[i], op->tchk[i])) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Arg #{0:d} to '{1:s}' operator is wrong type ({2:s})",
+#else
error(getPos(), const_cast<char*>("Arg #%d to '%s' operator is wrong type (%s)"),
+#endif
i, name, argPtr[i].getTypeName());
return;
}
@@ -703,7 +739,11 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
return;
}
if (!obj1.isDict()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "ExtGState '{0:s}' is wrong type"), args[0].getName();
+#else
error(getPos(), const_cast<char*>("ExtGState '%s' is wrong type"), args[0].getName());
+#endif
obj1.free();
return;
}
@@ -719,7 +759,11 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
if (state->parseBlendMode(&obj2, &mode)) {
state->setBlendMode(mode);
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Invalid blend mode in ExtGState");
+#else
error(getPos(), const_cast<char*>("Invalid blend mode in ExtGState"));
+#endif
}
}
obj2.free();
@@ -781,7 +825,11 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
state->setTransfer(funcs);
}
} else if (!obj2.isNull()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Invalid transfer function in ExtGState");
+#else
error(getPos(), const_cast<char*>("Invalid transfer function in ExtGState"));
+#endif
}
obj2.free();
@@ -801,8 +849,11 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
funcs[0] = Function::parse(&obj3);
if (funcs[0]->getInputSize() != 1 ||
funcs[0]->getOutputSize() != 1) {
- error(getPos(),
- const_cast<char*>("Invalid transfer function in soft mask in ExtGState"));
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Invalid transfer function in soft mask in ExtGState");
+#else
+ error(getPos(), const_cast<char*>("Invalid transfer function in soft mask in ExtGState"));
+#endif
delete funcs[0];
funcs[0] = NULL;
}
@@ -827,7 +878,7 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
GBool isolated = gFalse;
GBool knockout = gFalse;
if (!obj4.dictLookup(const_cast<char*>("CS"), &obj5)->isNull()) {
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
blendingColorSpace = GfxColorSpace::parse(&obj5, NULL);
#else
blendingColorSpace = GfxColorSpace::parse(&obj5);
@@ -858,15 +909,27 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
delete funcs[0];
}
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group");
+#else
error(getPos(), const_cast<char*>("Invalid soft mask in ExtGState - missing group"));
+#endif
}
obj4.free();
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group");
+#else
error(getPos(), const_cast<char*>("Invalid soft mask in ExtGState - missing group"));
+#endif
}
obj3.free();
} else if (!obj2.isNull()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState");
+#else
error(getPos(), const_cast<char*>("Invalid soft mask in ExtGState"));
+#endif
}
}
obj2.free();
@@ -894,7 +957,11 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
// check form type
dict->lookup(const_cast<char*>("FormType"), &obj1);
if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Unknown form type");
+#else
error(getPos(), const_cast<char*>("Unknown form type"));
+#endif
}
obj1.free();
@@ -902,7 +969,11 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
dict->lookup(const_cast<char*>("BBox"), &obj1);
if (!obj1.isArray()) {
obj1.free();
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Bad form bounding box");
+#else
error(getPos(), const_cast<char*>("Bad form bounding box"));
+#endif
return;
}
for (i = 0; i < 4; ++i) {
@@ -1041,7 +1112,7 @@ void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)
res->lookupColorSpace(args[0].getName(), &obj);
GfxColorSpace *colorSpace = 0;
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (obj.isNull()) {
colorSpace = GfxColorSpace::parse(&args[0], NULL);
} else {
@@ -1062,7 +1133,11 @@ void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)
state->setFillColor(&color);
builder->updateStyle(state);
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Bad color space (fill)");
+#else
error(getPos(), const_cast<char*>("Bad color space (fill)"));
+#endif
}
}
@@ -1074,7 +1149,7 @@ void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)
state->setStrokePattern(NULL);
res->lookupColorSpace(args[0].getName(), &obj);
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (obj.isNull()) {
colorSpace = GfxColorSpace::parse(&args[0], NULL);
} else {
@@ -1095,7 +1170,11 @@ void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)
state->setStrokeColor(&color);
builder->updateStyle(state);
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Bad color space (stroke)");
+#else
error(getPos(), const_cast<char*>("Bad color space (stroke)"));
+#endif
}
}
@@ -1104,7 +1183,11 @@ void PdfParser::opSetFillColor(Object args[], int numArgs) {
int i;
if (numArgs != state->getFillColorSpace()->getNComps()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Incorrect number of arguments in 'sc' command");
+#else
error(getPos(), const_cast<char*>("Incorrect number of arguments in 'sc' command"));
+#endif
return;
}
state->setFillPattern(NULL);
@@ -1120,7 +1203,11 @@ void PdfParser::opSetStrokeColor(Object args[], int numArgs) {
int i;
if (numArgs != state->getStrokeColorSpace()->getNComps()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Incorrect number of arguments in 'SC' command");
+#else
error(getPos(), const_cast<char*>("Incorrect number of arguments in 'SC' command"));
+#endif
return;
}
state->setStrokePattern(NULL);
@@ -1141,7 +1228,11 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
if (!((GfxPatternColorSpace *)state->getFillColorSpace())->getUnder() ||
numArgs - 1 != ((GfxPatternColorSpace *)state->getFillColorSpace())
->getUnder()->getNComps()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Incorrect number of arguments in 'scn' command");
+#else
error(getPos(), const_cast<char*>("Incorrect number of arguments in 'scn' command"));
+#endif
return;
}
for (i = 0; i < numArgs - 1 && i < gfxColorMaxComps; ++i) {
@@ -1152,7 +1243,7 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
state->setFillColor(&color);
builder->updateStyle(state);
}
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (args[numArgs-1].isName() &&
(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
state->setFillPattern(pattern);
@@ -1168,7 +1259,11 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
} else {
if (numArgs != state->getFillColorSpace()->getNComps()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Incorrect number of arguments in 'scn' command");
+#else
error(getPos(), const_cast<char*>("Incorrect number of arguments in 'scn' command"));
+#endif
return;
}
state->setFillPattern(NULL);
@@ -1193,7 +1288,11 @@ void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
->getUnder() ||
numArgs - 1 != ((GfxPatternColorSpace *)state->getStrokeColorSpace())
->getUnder()->getNComps()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Incorrect number of arguments in 'SCN' command");
+#else
error(getPos(), const_cast<char*>("Incorrect number of arguments in 'SCN' command"));
+#endif
return;
}
for (i = 0; i < numArgs - 1 && i < gfxColorMaxComps; ++i) {
@@ -1204,7 +1303,7 @@ void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
state->setStrokeColor(&color);
builder->updateStyle(state);
}
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (args[numArgs-1].isName() &&
(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
state->setStrokePattern(pattern);
@@ -1220,7 +1319,11 @@ void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
} else {
if (numArgs != state->getStrokeColorSpace()->getNComps()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Incorrect number of arguments in 'SCN' command");
+#else
error(getPos(), const_cast<char*>("Incorrect number of arguments in 'SCN' command"));
+#endif
return;
}
state->setStrokePattern(NULL);
@@ -1248,7 +1351,11 @@ void PdfParser::opMoveTo(Object args[], int /*numArgs*/)
void PdfParser::opLineTo(Object args[], int /*numArgs*/)
{
if (!state->isCurPt()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No current point in lineto");
+#else
error(getPos(), const_cast<char*>("No current point in lineto"));
+#endif
return;
}
state->lineTo(args[0].getNum(), args[1].getNum());
@@ -1258,7 +1365,11 @@ void PdfParser::opLineTo(Object args[], int /*numArgs*/)
void PdfParser::opCurveTo(Object args[], int /*numArgs*/)
{
if (!state->isCurPt()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No current point in curveto");
+#else
error(getPos(), const_cast<char*>("No current point in curveto"));
+#endif
return;
}
double x1 = args[0].getNum();
@@ -1274,7 +1385,11 @@ void PdfParser::opCurveTo(Object args[], int /*numArgs*/)
void PdfParser::opCurveTo1(Object args[], int /*numArgs*/)
{
if (!state->isCurPt()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No current point in curveto1");
+#else
error(getPos(), const_cast<char*>("No current point in curveto1"));
+#endif
return;
}
double x1 = state->getCurX();
@@ -1290,7 +1405,11 @@ void PdfParser::opCurveTo1(Object args[], int /*numArgs*/)
void PdfParser::opCurveTo2(Object args[], int /*numArgs*/)
{
if (!state->isCurPt()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No current point in curveto2");
+#else
error(getPos(), const_cast<char*>("No current point in curveto2"));
+#endif
return;
}
double x1 = args[0].getNum();
@@ -1319,7 +1438,11 @@ void PdfParser::opRectangle(Object args[], int /*numArgs*/)
void PdfParser::opClosePath(Object /*args*/[], int /*numArgs*/)
{
if (!state->isCurPt()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No current point in closepath");
+#else
error(getPos(), const_cast<char*>("No current point in closepath"));
+#endif
return;
}
state->closePath();
@@ -1485,7 +1608,11 @@ void PdfParser::doPatternFillFallback(GBool eoFill) {
doShadingPatternFillFallback(static_cast<GfxShadingPattern *>(pattern), gFalse, eoFill);
break;
default:
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errUnimplemented, getPos(), "Unimplemented pattern type (%d) in fill",
+#else
error(getPos(), const_cast<char*>("Unimplemented pattern type (%d) in fill"),
+#endif
pattern->getType());
break;
}
@@ -1504,7 +1631,11 @@ void PdfParser::doPatternStrokeFallback() {
doShadingPatternFillFallback(static_cast<GfxShadingPattern *>(pattern), gTrue, gFalse);
break;
default:
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errUnimplemented, getPos(), "Unimplemented pattern type ({0:d}) in stroke",
+#else
error(getPos(), const_cast<char*>("Unimplemented pattern type (%d) in stroke"),
+#endif
pattern->getType());
break;
}
@@ -1627,7 +1758,7 @@ void PdfParser::opShFill(Object args[], int /*numArgs*/)
double *matrix = NULL;
GBool savedState = gFalse;
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (!(shading = res->lookupShading(args[0].getName(), NULL))) {
return;
}
@@ -2247,7 +2378,11 @@ void PdfParser::opTextNextLine(Object /*args*/[], int /*numArgs*/)
void PdfParser::opShowText(Object args[], int /*numArgs*/)
{
if (!state->getFont()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No font in show");
+#else
error(getPos(), const_cast<char*>("No font in show"));
+#endif
return;
}
if (fontChanged) {
@@ -2264,7 +2399,11 @@ void PdfParser::opMoveShowText(Object args[], int /*numArgs*/)
double ty = 0;
if (!state->getFont()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No font in move/show");
+#else
error(getPos(), const_cast<char*>("No font in move/show"));
+#endif
return;
}
if (fontChanged) {
@@ -2285,7 +2424,11 @@ void PdfParser::opMoveSetShowText(Object args[], int /*numArgs*/)
double ty = 0;
if (!state->getFont()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No font in move/set/show");
+#else
error(getPos(), const_cast<char*>("No font in move/set/show"));
+#endif
return;
}
if (fontChanged) {
@@ -2309,7 +2452,11 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
int wMode = 0;
if (!state->getFont()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "No font in show/space");
+#else
error(getPos(), const_cast<char*>("No font in show/space"));
+#endif
return;
}
if (fontChanged) {
@@ -2334,7 +2481,11 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
} else if (obj.isString()) {
doShowText(obj.getString());
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Element of show/space array must be number or string");
+#else
error(getPos(), const_cast<char*>("Element of show/space array must be number or string"));
+#endif
}
obj.free();
}
@@ -2432,7 +2583,11 @@ void PdfParser::doShowText(GooString *s) {
if (charProc.isStream()) {
//parse(&charProc, gFalse); // TODO: parse into SVG font
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Missing or bad Type3 CharProc entry");
+#else
error(getPos(), const_cast<char*>("Missing or bad Type3 CharProc entry"));
+#endif
}
//out->endType3Char(state);
if (resDict) {
@@ -2509,7 +2664,11 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
return;
}
if (!obj1.isStream()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "XObject '{0:s}' is wrong type", name);
+#else
error(getPos(), const_cast<char*>("XObject '%s' is wrong type"), name);
+#endif
obj1.free();
return;
}
@@ -2525,9 +2684,17 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
/* out->psXObject(obj1.getStream(),
obj3.isStream() ? obj3.getStream() : (Stream *)NULL);*/
} else if (obj2.isName()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Unknown XObject subtype '{0:s}'", obj2.getName());
+#else
error(getPos(), const_cast<char*>("Unknown XObject subtype '%s'"), obj2.getName());
+#endif
} else {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "XObject subtype is missing or wrong type");
+#else
error(getPos(), const_cast<char*>("XObject subtype is missing or wrong type"));
+#endif
}
obj2.free();
obj1.free();
@@ -2659,7 +2826,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
}
}
if (!obj1.isNull()) {
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
colorSpace = GfxColorSpace::parse(&obj1, NULL);
#else
colorSpace = GfxColorSpace::parse(&obj1);
@@ -2748,7 +2915,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
obj2.free();
}
}
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
#else
maskColorSpace = GfxColorSpace::parse(&obj1);
@@ -2858,7 +3025,11 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
err2:
obj1.free();
err1:
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Bad image parameters");
+#else
error(getPos(), const_cast<char*>("Bad image parameters"));
+#endif
}
void PdfParser::doForm(Object *str) {
@@ -2883,7 +3054,11 @@ void PdfParser::doForm(Object *str) {
// check form type
dict->lookup(const_cast<char*>("FormType"), &obj1);
if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Unknown form type");
+#else
error(getPos(), const_cast<char*>("Unknown form type"));
+#endif
}
obj1.free();
@@ -2891,7 +3066,11 @@ void PdfParser::doForm(Object *str) {
dict->lookup(const_cast<char*>("BBox"), &bboxObj);
if (!bboxObj.isArray()) {
bboxObj.free();
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Bad form bounding box");
+#else
error(getPos(), const_cast<char*>("Bad form bounding box"));
+#endif
return;
}
for (i = 0; i < 4; ++i) {
@@ -2927,7 +3106,7 @@ void PdfParser::doForm(Object *str) {
if (obj1.dictLookup(const_cast<char*>("S"), &obj2)->isName(const_cast<char*>("Transparency"))) {
transpGroup = gTrue;
if (!obj1.dictLookup(const_cast<char*>("CS"), &obj3)->isNull()) {
-#ifdef POPPLER_NEW_COLOR_SPACE_API
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
blendingColorSpace = GfxColorSpace::parse(&obj3, NULL);
#else
blendingColorSpace = GfxColorSpace::parse(&obj3);
@@ -3088,7 +3267,11 @@ Stream *PdfParser::buildImageStream() {
parser->getObj(&obj);
while (!obj.isCmd(const_cast<char*>("ID")) && !obj.isEOF()) {
if (!obj.isName()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "Inline image dictionary key must be a name object");
+#else
error(getPos(), const_cast<char*>("Inline image dictionary key must be a name object"));
+#endif
obj.free();
} else {
key = copyString(obj.getName());
@@ -3103,7 +3286,11 @@ Stream *PdfParser::buildImageStream() {
parser->getObj(&obj);
}
if (obj.isEOF()) {
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errSyntaxError, getPos(), "End of file in inline image");
+#else
error(getPos(), const_cast<char*>("End of file in inline image"));
+#endif
obj.free();
dict.free();
return NULL;
@@ -3119,12 +3306,20 @@ Stream *PdfParser::buildImageStream() {
void PdfParser::opImageData(Object /*args*/[], int /*numArgs*/)
{
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errInternal, getPos(), "Internal: got 'ID' operator");
+#else
error(getPos(), const_cast<char*>("Internal: got 'ID' operator"));
+#endif
}
void PdfParser::opEndImage(Object /*args*/[], int /*numArgs*/)
{
+#ifdef POPPLER_NEW_ERRORAPI
+ error(errInternal, getPos(), "Internal: got 'EI' operator");
+#else
error(getPos(), const_cast<char*>("Internal: got 'EI' operator"));
+#endif
}
//------------------------------------------------------------------------