4b6703
commit 6f7d0e79120a973eb4a17abbd8ac5bef6be06804
4b6703
Author: Matthias Kilian <Unknown>
4b6703
Date:   Wed Jun 4 15:01:44 2014 +0200
4b6703
4b6703
    Fix build failure with poppler 0.26 (Bug #1315142)
4b6703
4b6703
diff --git a/configure.ac b/configure.ac
4b6703
index 712aa68..f78668d 100644
4b6703
--- a/configure.ac
4b6703
+++ b/configure.ac
4b6703
@@ -491,6 +491,11 @@ else
4b6703
 	AC_MSG_RESULT(no)
4b6703
 fi
4b6703
 
4b6703
+PKG_CHECK_MODULES(POPPLER_EVEN_NEWER_COLOR_SPACE_API, poppler >= 0.26.0, popplernewercolorspaceapi=yes, popplernewercolorspaceapi=no)
4b6703
+if test "x$popplernewercolorspaceapi" = "xyes"; then
4b6703
+	AC_DEFINE(POPPLER_EVEN_NEWER_COLOR_SPACE_API, 1, [Use even newer color space API from Poppler >= 0.26.0])
4b6703
+fi
4b6703
+
4b6703
 # Poppler's b604a008 commit changes this
4b6703
 AC_MSG_CHECKING([whether Poppler's GfxPatch no longer uses GfxColor])
4b6703
 popplergfxcolor="no"
4b6703
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
4b6703
index b398486..c5f03e5 100644
4b6703
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
4b6703
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
4b6703
@@ -866,7 +866,9 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
4b6703
 	  blendingColorSpace = NULL;
4b6703
 	  isolated = knockout = gFalse;
4b6703
 	  if (!obj4.dictLookup(const_cast<char*>("CS"), &obj5)->isNull()) {
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+	    blendingColorSpace = GfxColorSpace::parse(&obj5, NULL, NULL);
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
 	    blendingColorSpace = GfxColorSpace::parse(&obj5, NULL);
4b6703
 #else
4b6703
 	    blendingColorSpace = GfxColorSpace::parse(&obj5);
4b6703
@@ -1100,7 +1102,13 @@ void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)
4b6703
 
4b6703
   state->setFillPattern(NULL);
4b6703
   res->lookupColorSpace(args[0].getName(), &obj);
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+  if (obj.isNull()) {
4b6703
+    colorSpace = GfxColorSpace::parse(&args[0], NULL, NULL);
4b6703
+  } else {
4b6703
+    colorSpace = GfxColorSpace::parse(&obj, NULL, NULL);
4b6703
+  }
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
   if (obj.isNull()) {
4b6703
     colorSpace = GfxColorSpace::parse(&args[0], NULL);
4b6703
   } else {
4b6703
@@ -1137,7 +1145,13 @@ void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)
4b6703
 
4b6703
   state->setStrokePattern(NULL);
4b6703
   res->lookupColorSpace(args[0].getName(), &obj);
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+  if (obj.isNull()) {
4b6703
+    colorSpace = GfxColorSpace::parse(&args[0], NULL, NULL);
4b6703
+  } else {
4b6703
+    colorSpace = GfxColorSpace::parse(&obj, NULL, NULL);
4b6703
+  }
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
   if (obj.isNull()) {
4b6703
     colorSpace = GfxColorSpace::parse(&args[0], NULL);
4b6703
   } else {
4b6703
@@ -1231,7 +1245,13 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
4b6703
       state->setFillColor(&color;;
4b6703
       builder->updateStyle(state);
4b6703
     }
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+    if (args[numArgs-1].isName() &&
4b6703
+	(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL, NULL))) {
4b6703
+      state->setFillPattern(pattern);
4b6703
+      builder->updateStyle(state);
4b6703
+    }
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
     if (args[numArgs-1].isName() &&
4b6703
 	(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
4b6703
       state->setFillPattern(pattern);
4b6703
@@ -1291,7 +1311,13 @@ void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
4b6703
       state->setStrokeColor(&color;;
4b6703
       builder->updateStyle(state);
4b6703
     }
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+    if (args[numArgs-1].isName() &&
4b6703
+	(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL, NULL))) {
4b6703
+      state->setStrokePattern(pattern);
4b6703
+      builder->updateStyle(state);
4b6703
+    }
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
     if (args[numArgs-1].isName() &&
4b6703
 	(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
4b6703
       state->setStrokePattern(pattern);
4b6703
@@ -1746,7 +1772,11 @@ void PdfParser::opShFill(Object args[], int /*numArgs*/)
4b6703
   double *matrix = NULL;
4b6703
   GBool savedState = gFalse;
4b6703
 
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+  if (!(shading = res->lookupShading(args[0].getName(), NULL, NULL))) {
4b6703
+    return;
4b6703
+  }
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
   if (!(shading = res->lookupShading(args[0].getName(), NULL))) {
4b6703
     return;
4b6703
   }
4b6703
@@ -2817,7 +2847,9 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
4b6703
       }
4b6703
     }
4b6703
     if (!obj1.isNull()) {
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+      colorSpace = GfxColorSpace::parse(&obj1, NULL, NULL);
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
       colorSpace = GfxColorSpace::parse(&obj1, NULL);
4b6703
 #else
4b6703
       colorSpace = GfxColorSpace::parse(&obj1);
4b6703
@@ -2909,7 +2941,9 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
4b6703
 	  obj2.free();
4b6703
 	}
4b6703
       }
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+      maskColorSpace = GfxColorSpace::parse(&obj1, NULL, NULL);
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
       maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
4b6703
 #else
4b6703
       maskColorSpace = GfxColorSpace::parse(&obj1);
4b6703
@@ -3099,7 +3133,9 @@ void PdfParser::doForm(Object *str) {
4b6703
     if (obj1.dictLookup(const_cast<char*>("S"), &obj2)->isName(const_cast<char*>("Transparency"))) {
4b6703
       transpGroup = gTrue;
4b6703
       if (!obj1.dictLookup(const_cast<char*>("CS"), &obj3)->isNull()) {
4b6703
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
4b6703
+	blendingColorSpace = GfxColorSpace::parse(&obj3, NULL, NULL);
4b6703
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
4b6703
 	blendingColorSpace = GfxColorSpace::parse(&obj3, NULL);
4b6703
 #else
4b6703
 	blendingColorSpace = GfxColorSpace::parse(&obj3);