=== modified file 'configure.ac' --- configure.ac 2012-06-12 16:12:48 +0000 +++ configure.ac 2012-06-14 12:58:01 +0000 @@ -578,6 +578,12 @@ AC_DEFINE(POPPLER_NEW_GFXFONT, 1, [Use GfxFont from Poppler >= 0.8.3]) fi +PKG_CHECK_MODULES(POPPLER_NEWERRORAPI, poppler >= 0.20.0, popplernewerror=yes, popplernewerror=no) +if test "x$popplernewerror" = "xyes"; then + AC_DEFINE(POPPLER_NEW_ERRORAPI, 1, [Use new error API from Poppler >= 0.20.0]) +fi + + ink_svd_CPPFLAGS=$CPPFLAGS ink_svd_LIBS=$LIBS CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS" === modified file 'src/extension/internal/pdfinput/pdf-parser.cpp' --- src/extension/internal/pdfinput/pdf-parser.cpp 2012-05-15 01:22:42 +0000 +++ src/extension/internal/pdfinput/pdf-parser.cpp 2012-06-14 13:00:37 +0000 @@ -368,15 +368,23 @@ 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("Weird page contents")); +#endif obj2.free(); return; } obj2.free(); } } else if (!obj->isStream()) { - error(-1, const_cast("Weird page contents")); - return; +#ifdef POPPLER_NEW_ERRORAPI + error(errInternal, -1, "Weird page contents"); +#else + error(-1, const_cast("Weird page contents")); +#endif + return; } parser = new Parser(xref, new Lexer(xref, obj), gFalse); go(topLevel); @@ -420,7 +428,11 @@ // 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("Too many args in content stream")); +#endif if (printCommands) { printf("throwing away arg: "); obj.print(stdout); @@ -437,7 +449,11 @@ // 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("Leftover args in content stream")); +#endif if (printCommands) { printf("%d leftovers:", numArgs); for (int i = 0; i < numArgs; ++i) { @@ -503,7 +519,11 @@ 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("Unknown operator '%s'"), name); +#endif return; } @@ -511,26 +531,42 @@ 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("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("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("Arg #%d to '%s' operator is wrong type (%s)"), +#endif i, name, argPtr[i].getTypeName()); return; } @@ -703,7 +739,11 @@ 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("ExtGState '%s' is wrong type"), args[0].getName()); +#endif obj1.free(); return; } @@ -719,7 +759,11 @@ 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("Invalid blend mode in ExtGState")); +#endif } } obj2.free(); @@ -781,7 +825,11 @@ state->setTransfer(funcs); } } else if (!obj2.isNull()) { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "Invalid transfer function in ExtGState"); +#else error(getPos(), const_cast("Invalid transfer function in ExtGState")); +#endif } obj2.free(); @@ -801,8 +849,11 @@ funcs[0] = Function::parse(&obj3); if (funcs[0]->getInputSize() != 1 || funcs[0]->getOutputSize() != 1) { - error(getPos(), - const_cast("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("Invalid transfer function in soft mask in ExtGState")); +#endif delete funcs[0]; funcs[0] = NULL; } @@ -827,7 +878,7 @@ GBool isolated = gFalse; GBool knockout = gFalse; if (!obj4.dictLookup(const_cast("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 @@ delete funcs[0]; } } else { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group"); +#else error(getPos(), const_cast("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("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("Invalid soft mask in ExtGState")); +#endif } } obj2.free(); @@ -894,7 +957,11 @@ // check form type dict->lookup(const_cast("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("Unknown form type")); +#endif } obj1.free(); @@ -902,7 +969,11 @@ dict->lookup(const_cast("BBox"), &obj1); if (!obj1.isArray()) { obj1.free(); +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "Bad form bounding box"); +#else error(getPos(), const_cast("Bad form bounding box")); +#endif return; } for (i = 0; i < 4; ++i) { @@ -1041,7 +1112,7 @@ 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 @@ state->setFillColor(&color); builder->updateStyle(state); } else { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "Bad color space (fill)"); +#else error(getPos(), const_cast("Bad color space (fill)")); +#endif } } @@ -1074,7 +1149,7 @@ 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 @@ state->setStrokeColor(&color); builder->updateStyle(state); } else { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "Bad color space (stroke)"); +#else error(getPos(), const_cast("Bad color space (stroke)")); +#endif } } @@ -1104,7 +1183,11 @@ 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("Incorrect number of arguments in 'sc' command")); +#endif return; } state->setFillPattern(NULL); @@ -1120,7 +1203,11 @@ 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("Incorrect number of arguments in 'SC' command")); +#endif return; } state->setStrokePattern(NULL); @@ -1141,7 +1228,11 @@ 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("Incorrect number of arguments in 'scn' command")); +#endif return; } for (i = 0; i < numArgs - 1 && i < gfxColorMaxComps; ++i) { @@ -1152,7 +1243,7 @@ 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 @@ } 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("Incorrect number of arguments in 'scn' command")); +#endif return; } state->setFillPattern(NULL); @@ -1193,7 +1288,11 @@ ->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("Incorrect number of arguments in 'SCN' command")); +#endif return; } for (i = 0; i < numArgs - 1 && i < gfxColorMaxComps; ++i) { @@ -1204,7 +1303,7 @@ 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 @@ } 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("Incorrect number of arguments in 'SCN' command")); +#endif return; } state->setStrokePattern(NULL); @@ -1248,7 +1351,11 @@ 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("No current point in lineto")); +#endif return; } state->lineTo(args[0].getNum(), args[1].getNum()); @@ -1258,7 +1365,11 @@ 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("No current point in curveto")); +#endif return; } double x1 = args[0].getNum(); @@ -1274,7 +1385,11 @@ 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("No current point in curveto1")); +#endif return; } double x1 = state->getCurX(); @@ -1290,7 +1405,11 @@ 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("No current point in curveto2")); +#endif return; } double x1 = args[0].getNum(); @@ -1319,7 +1438,11 @@ 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("No current point in closepath")); +#endif return; } state->closePath(); @@ -1485,7 +1608,11 @@ doShadingPatternFillFallback(static_cast(pattern), gFalse, eoFill); break; default: +#ifdef POPPLER_NEW_ERRORAPI + error(errUnimplemented, getPos(), "Unimplemented pattern type (%d) in fill", +#else error(getPos(), const_cast("Unimplemented pattern type (%d) in fill"), +#endif pattern->getType()); break; } @@ -1504,7 +1631,11 @@ doShadingPatternFillFallback(static_cast(pattern), gTrue, gFalse); break; default: +#ifdef POPPLER_NEW_ERRORAPI + error(errUnimplemented, getPos(), "Unimplemented pattern type ({0:d}) in stroke", +#else error(getPos(), const_cast("Unimplemented pattern type (%d) in stroke"), +#endif pattern->getType()); break; } @@ -1627,7 +1758,7 @@ 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::opShowText(Object args[], int /*numArgs*/) { if (!state->getFont()) { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "No font in show"); +#else error(getPos(), const_cast("No font in show")); +#endif return; } if (fontChanged) { @@ -2264,7 +2399,11 @@ double ty = 0; if (!state->getFont()) { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "No font in move/show"); +#else error(getPos(), const_cast("No font in move/show")); +#endif return; } if (fontChanged) { @@ -2285,7 +2424,11 @@ double ty = 0; if (!state->getFont()) { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "No font in move/set/show"); +#else error(getPos(), const_cast("No font in move/set/show")); +#endif return; } if (fontChanged) { @@ -2309,7 +2452,11 @@ int wMode = 0; if (!state->getFont()) { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "No font in show/space"); +#else error(getPos(), const_cast("No font in show/space")); +#endif return; } if (fontChanged) { @@ -2334,7 +2481,11 @@ } 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("Element of show/space array must be number or string")); +#endif } obj.free(); } @@ -2432,7 +2583,11 @@ 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("Missing or bad Type3 CharProc entry")); +#endif } //out->endType3Char(state); if (resDict) { @@ -2509,7 +2664,11 @@ return; } if (!obj1.isStream()) { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "XObject '{0:s}' is wrong type", name); +#else error(getPos(), const_cast("XObject '%s' is wrong type"), name); +#endif obj1.free(); return; } @@ -2525,9 +2684,17 @@ /* 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("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("XObject subtype is missing or wrong type")); +#endif } obj2.free(); obj1.free(); @@ -2659,7 +2826,7 @@ } } 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 @@ 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 @@ err2: obj1.free(); err1: +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "Bad image parameters"); +#else error(getPos(), const_cast("Bad image parameters")); +#endif } void PdfParser::doForm(Object *str) { @@ -2883,7 +3054,11 @@ // check form type dict->lookup(const_cast("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("Unknown form type")); +#endif } obj1.free(); @@ -2891,7 +3066,11 @@ dict->lookup(const_cast("BBox"), &bboxObj); if (!bboxObj.isArray()) { bboxObj.free(); +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "Bad form bounding box"); +#else error(getPos(), const_cast("Bad form bounding box")); +#endif return; } for (i = 0; i < 4; ++i) { @@ -2927,7 +3106,7 @@ if (obj1.dictLookup(const_cast("S"), &obj2)->isName(const_cast("Transparency"))) { transpGroup = gTrue; if (!obj1.dictLookup(const_cast("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 @@ parser->getObj(&obj); while (!obj.isCmd(const_cast("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("Inline image dictionary key must be a name object")); +#endif obj.free(); } else { key = copyString(obj.getName()); @@ -3103,7 +3286,11 @@ parser->getObj(&obj); } if (obj.isEOF()) { +#ifdef POPPLER_NEW_ERRORAPI + error(errSyntaxError, getPos(), "End of file in inline image"); +#else error(getPos(), const_cast("End of file in inline image")); +#endif obj.free(); dict.free(); return NULL; @@ -3119,12 +3306,20 @@ void PdfParser::opImageData(Object /*args*/[], int /*numArgs*/) { +#ifdef POPPLER_NEW_ERRORAPI + error(errInternal, getPos(), "Internal: got 'ID' operator"); +#else error(getPos(), const_cast("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("Internal: got 'EI' operator")); +#endif } //------------------------------------------------------------------------ === modified file 'src/extension/internal/pdfinput/svg-builder.cpp' --- src/extension/internal/pdfinput/svg-builder.cpp 2012-05-18 07:54:13 +0000 +++ src/extension/internal/pdfinput/svg-builder.cpp 2012-06-14 10:17:04 +0000 @@ -1004,9 +1004,7 @@ _font_style = sp_repr_css_attr_new(); GfxFont *font = state->getFont(); // Store original name - if (font->getOrigName()) { - _font_specification = font->getOrigName()->getCString(); - } else if (font->getName()) { + if (font->getName()) { _font_specification = font->getName()->getCString(); } else { _font_specification = (char*) "Arial";