From 5b9caf5bd51412f82a3aedcfa2ab387c2b3d1cdb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Krzysztof=20Kosi=C5=84ski?= Date: Sun, 21 Mar 2010 02:53:59 +0100 Subject: [PATCH] Fix build with poppler >= 0.12.2 --- configure.ac | 13 +++-- .../internal/pdfinput/pdf-parser.cpp | 54 +++++++++++++++++++ 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 330e40d7d..d7c38a7c9 100644 --- a/configure.ac +++ b/configure.ac @@ -570,7 +570,6 @@ PKG_CHECK_MODULES(POPPLER, poppler >= 0.5.9, poppler=yes, poppler=no) if test "x$poppler" = "xyes"; then dnl Working libpoppler - POPPLER_LIBS="-lpoppler " dnl Have to test libpoppler-glib presence PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib >= 0.5.9, poppler_glib=yes, poppler_glib=no) if test "x$poppler_glib" = "xyes"; then @@ -578,7 +577,7 @@ if test "x$poppler" = "xyes"; then dnl Check whether the Cairo SVG backend is available PKG_CHECK_MODULES(CAIRO_SVG, cairo-svg, cairo_svg=yes, cairo_svg=no) if test "x$cairo_svg" = "xyes"; then - POPPLER_LIBS="$POPPLER_LIBS -lpoppler-glib " + POPPLER_LIBS="$POPPLER_LIBS $POPPLER_GLIB_LIBS " fi fi if test "x$enable_poppler_cairo" = "xyes"; then @@ -588,7 +587,7 @@ if test "x$poppler" = "xyes"; then if test "x$poppler_glib" = "xyes" -a "x$poppler_cairo" = "xyes" -a \ "x$cairo_svg" = "xno" then - POPPLER_LIBS="$POPPLER_LIBS -lpoppler-glib " + POPPLER_LIBS="$POPPLER_LIBS $POPPLER_CAIRO_LIBS " fi fi fi @@ -606,9 +605,13 @@ fi AC_SUBST(POPPLER_CFLAGS) AC_SUBST(POPPLER_LIBS) -PKG_CHECK_MODULES(POPPLERNEW, poppler >= 0.8.3, popplernew=yes, popplernew=no) +PKG_CHECK_MODULES(POPPLER_GFXFONT, poppler >= 0.8.3, popplernew=yes, popplernew=no) if test "x$popplernew" = "xyes"; then - AC_DEFINE(POPPLER_NEW_GFXFONT, 1, [Poppler version of GfxFont to use (0.8.3 or higher versions of Poppler)]) + AC_DEFINE(POPPLER_NEW_GFXFONT, 1, [Use GfxFont from Poppler >= 0.8.3]) +fi +PKG_CHECK_MODULES(POPPLER_COLORSPACE, poppler >= 0.12.2, popplercolor=yes, popplercolor=no) +if test "x$popplercolor" = "xyes"; then + AC_DEFINE(POPPLER_NEW_COLOR_SPACE_API, 1, [Use color space API from Poppler >= 0.12.2]) fi dnl ****************************** diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 118896fd3..b37cbb777 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -809,7 +809,11 @@ void PdfParser::opSetExtGState(Object args[], int numArgs) { blendingColorSpace = NULL; isolated = knockout = gFalse; if (!obj4.dictLookup(const_cast("CS"), &obj5)->isNull()) { +#ifdef POPPLER_NEW_COLOR_SPACE_API + blendingColorSpace = GfxColorSpace::parse(&obj5, NULL); +#else blendingColorSpace = GfxColorSpace::parse(&obj5); +#endif } obj5.free(); if (obj4.dictLookup(const_cast("I"), &obj5)->isBool()) { @@ -1008,11 +1012,19 @@ void PdfParser::opSetFillColorSpace(Object args[], int numArgs) { state->setFillPattern(NULL); res->lookupColorSpace(args[0].getName(), &obj); +#ifdef POPPLER_NEW_COLOR_SPACE_API + if (obj.isNull()) { + colorSpace = GfxColorSpace::parse(&args[0], NULL); + } else { + colorSpace = GfxColorSpace::parse(&obj, NULL); + } +#else if (obj.isNull()) { colorSpace = GfxColorSpace::parse(&args[0]); } else { colorSpace = GfxColorSpace::parse(&obj); } +#endif obj.free(); if (colorSpace) { state->setFillColorSpace(colorSpace); @@ -1031,11 +1043,19 @@ void PdfParser::opSetStrokeColorSpace(Object args[], int numArgs) { state->setStrokePattern(NULL); res->lookupColorSpace(args[0].getName(), &obj); +#ifdef POPPLER_NEW_COLOR_SPACE_API + if (obj.isNull()) { + colorSpace = GfxColorSpace::parse(&args[0], NULL); + } else { + colorSpace = GfxColorSpace::parse(&obj, NULL); + } +#else if (obj.isNull()) { colorSpace = GfxColorSpace::parse(&args[0]); } else { colorSpace = GfxColorSpace::parse(&obj); } +#endif obj.free(); if (colorSpace) { state->setStrokeColorSpace(colorSpace); @@ -1100,11 +1120,19 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) { state->setFillColor(&color); builder->updateStyle(state); } +#ifdef POPPLER_NEW_COLOR_SPACE_API + if (args[numArgs-1].isName() && + (pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) { + state->setFillPattern(pattern); + builder->updateStyle(state); + } +#else if (args[numArgs-1].isName() && (pattern = res->lookupPattern(args[numArgs-1].getName()))) { state->setFillPattern(pattern); builder->updateStyle(state); } +#endif } else { if (numArgs != state->getFillColorSpace()->getNComps()) { @@ -1144,11 +1172,19 @@ void PdfParser::opSetStrokeColorN(Object args[], int numArgs) { state->setStrokeColor(&color); builder->updateStyle(state); } +#ifdef POPPLER_NEW_COLOR_SPACE_API + if (args[numArgs-1].isName() && + (pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) { + state->setStrokePattern(pattern); + builder->updateStyle(state); + } +#else if (args[numArgs-1].isName() && (pattern = res->lookupPattern(args[numArgs-1].getName()))) { state->setStrokePattern(pattern); builder->updateStyle(state); } +#endif } else { if (numArgs != state->getStrokeColorSpace()->getNComps()) { @@ -1543,9 +1579,15 @@ void PdfParser::opShFill(Object args[], int numArgs) { double *matrix = NULL; GBool savedState = gFalse; +#ifdef POPPLER_NEW_COLOR_SPACE_API + if (!(shading = res->lookupShading(args[0].getName(), NULL))) { + return; + } +#else if (!(shading = res->lookupShading(args[0].getName()))) { return; } +#endif // save current graphics state if (shading->getType() != 2 && shading->getType() != 3) { @@ -2507,7 +2549,11 @@ void PdfParser::doImage(Object *ref, Stream *str, GBool inlineImg) { } } if (!obj1.isNull()) { +#ifdef POPPLER_NEW_COLOR_SPACE_API + colorSpace = GfxColorSpace::parse(&obj1, NULL); +#else colorSpace = GfxColorSpace::parse(&obj1); +#endif } else if (csMode == streamCSDeviceGray) { colorSpace = new GfxDeviceGrayColorSpace(); } else if (csMode == streamCSDeviceRGB) { @@ -2592,7 +2638,11 @@ void PdfParser::doImage(Object *ref, Stream *str, GBool inlineImg) { obj2.free(); } } +#ifdef POPPLER_NEW_COLOR_SPACE_API + maskColorSpace = GfxColorSpace::parse(&obj1, NULL); +#else maskColorSpace = GfxColorSpace::parse(&obj1); +#endif obj1.free(); if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) { goto err1; @@ -2767,7 +2817,11 @@ void PdfParser::doForm(Object *str) { 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 + blendingColorSpace = GfxColorSpace::parse(&obj3, NULL); +#else blendingColorSpace = GfxColorSpace::parse(&obj3); +#endif } obj3.free(); if (obj1.dictLookup(const_cast("I"), &obj3)->isBool()) { -- 2.30.2