diff options
Diffstat (limited to 'src/extension/internal/pdfinput/pdf-parser.cpp')
| -rw-r--r-- | src/extension/internal/pdfinput/pdf-parser.cpp | 196 |
1 files changed, 0 insertions, 196 deletions
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 50d44d7a8..5ede59bf3 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -416,22 +416,14 @@ 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()) { -#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); @@ -476,11 +468,7 @@ 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); @@ -497,11 +485,7 @@ 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) { @@ -568,11 +552,7 @@ 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; } @@ -580,42 +560,26 @@ 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; } @@ -784,11 +748,7 @@ 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; } @@ -804,11 +764,7 @@ 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(); @@ -870,11 +826,7 @@ 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(); @@ -894,11 +846,7 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/) funcs[0] = Function::parse(&obj3); if (funcs[0]->getInputSize() != 1 || funcs[0]->getOutputSize() != 1) { -#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; } @@ -956,27 +904,15 @@ 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(); @@ -1004,11 +940,7 @@ 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(); @@ -1016,11 +948,7 @@ 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) { @@ -1186,11 +1114,7 @@ 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 } } @@ -1229,11 +1153,7 @@ 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 } } @@ -1242,11 +1162,7 @@ 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); @@ -1262,11 +1178,7 @@ 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); @@ -1286,11 +1198,7 @@ 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) { @@ -1318,11 +1226,7 @@ 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); @@ -1346,11 +1250,7 @@ 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) { @@ -1378,11 +1278,7 @@ 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); @@ -1410,11 +1306,7 @@ 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()); @@ -1424,11 +1316,7 @@ 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(); @@ -1444,11 +1332,7 @@ 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(); @@ -1464,11 +1348,7 @@ 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(); @@ -1497,11 +1377,7 @@ 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(); @@ -1667,11 +1543,7 @@ 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; } @@ -1690,11 +1562,7 @@ 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; } @@ -2435,11 +2303,7 @@ 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) { @@ -2456,11 +2320,7 @@ 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) { @@ -2481,11 +2341,7 @@ 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) { @@ -2509,11 +2365,7 @@ 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) { @@ -2538,11 +2390,7 @@ 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(); } @@ -2624,11 +2472,7 @@ 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) { @@ -2701,11 +2545,7 @@ 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; } @@ -2721,17 +2561,9 @@ 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(); @@ -3106,11 +2938,7 @@ 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) { @@ -3135,11 +2963,7 @@ 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(); @@ -3147,11 +2971,7 @@ 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) { @@ -3350,11 +3170,7 @@ 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()); @@ -3369,11 +3185,7 @@ 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; @@ -3389,20 +3201,12 @@ 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 } //------------------------------------------------------------------------ |
