Code

Fix build with poppler >= 0.12.2
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Sun, 21 Mar 2010 01:53:59 +0000 (02:53 +0100)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Sun, 21 Mar 2010 01:53:59 +0000 (02:53 +0100)
configure.ac
src/extension/internal/pdfinput/pdf-parser.cpp

index 330e40d7dd32ffb091ef91eae4331644d61de24f..d7c38a7c9d233177db54159b419597644d913a01 100644 (file)
@@ -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 ******************************
index 118896fd30318d74881f4d97a1a273ee592bc1ed..b37cbb7779ecb237c05e3a23576af3179cb77a3e 100644 (file)
@@ -809,7 +809,11 @@ void PdfParser::opSetExtGState(Object args[], int numArgs) {
          blendingColorSpace = NULL;
          isolated = knockout = gFalse;
          if (!obj4.dictLookup(const_cast<char*>("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<char*>("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<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
+       blendingColorSpace = GfxColorSpace::parse(&obj3, NULL);
+#else
        blendingColorSpace = GfxColorSpace::parse(&obj3);
+#endif
       }
       obj3.free();
       if (obj1.dictLookup(const_cast<char*>("I"), &obj3)->isBool()) {