1 From 2d789902ffb48251ec2ff632320d78ee088c2c5f Mon Sep 17 00:00:00 2001
2 From: Even Rouault <even.rouault@spatialys.com>
3 Date: Sat, 5 May 2018 22:18:37 +0200
4 Subject: [PATCH] Fix build with recent Poppler (0.64) (fix #573)
7 gdal/frmts/pdf/pdfobject.cpp | 5 +++++
8 1 file changed, 5 insertions(+)
10 diff --git a/gdal/frmts/pdf/pdfobject.cpp b/gdal/frmts/pdf/pdfobject.cpp
11 index ae734a74e4c..5eab5dd1546 100644
12 --- a/gdal/frmts/pdf/pdfobject.cpp
13 +++ b/gdal/frmts/pdf/pdfobject.cpp
14 @@ -1055,7 +1055,12 @@ const CPLString& GDALPDFObjectPoppler::GetString()
16 if (GetType() == PDFObjectType_String)
18 +#ifdef POPPLER_0_58_OR_LATER
19 + // At least available since poppler 0.41
20 + const GooString* gooString = m_po->getString();
22 GooString* gooString = m_po->getString();
24 return (osStr = GDALPDFGetUTF8StringFromBytes(reinterpret_cast<const GByte*>(gooString->getCString()),
25 static_cast<int>(gooString->getLength())));
27 From 69e07012533b8393edd8b9ec4da6d239d204858a Mon Sep 17 00:00:00 2001
28 From: Even Rouault <even.rouault@spatialys.com>
29 Date: Fri, 12 Oct 2018 19:02:40 +0200
30 Subject: [PATCH] Add support for Poppler 0.69 (fixes #1004)
33 gdal/GDALmake.opt.in | 1 +
34 gdal/configure | 61 ++++++++++++++++++++++++++---------
35 gdal/configure.ac | 56 +++++++++++++++++++++++---------
36 gdal/frmts/pdf/GNUmakefile | 4 +++
37 gdal/frmts/pdf/makefile.vc | 6 +++-
38 gdal/frmts/pdf/pdfdataset.cpp | 12 +++++++
40 7 files changed, 111 insertions(+), 31 deletions(-)
42 diff --git a/gdal/GDALmake.opt.in b/gdal/GDALmake.opt.in
43 index c3b5b34f92b..eaf005e5a14 100644
44 --- a/gdal/GDALmake.opt.in
45 +++ b/gdal/GDALmake.opt.in
46 @@ -473,6 +473,7 @@ POPPLER_BASE_STREAM_HAS_TWO_ARGS = @POPPLER_BASE_STREAM_HAS_TWO_ARGS@
47 POPPLER_0_20_OR_LATER = @POPPLER_0_20_OR_LATER@
48 POPPLER_0_23_OR_LATER = @POPPLER_0_23_OR_LATER@
49 POPPLER_0_58_OR_LATER = @POPPLER_0_58_OR_LATER@
50 +POPPLER_0_69_OR_LATER = @POPPLER_0_69_OR_LATER@
51 POPPLER_INC = @POPPLER_INC@
52 POPPLER_PLUGIN_LIB = @POPPLER_PLUGIN_LIB@
54 index 857f7fdb445..b6e59020c5b 100644
55 --- a/gdal/configure.ac
56 +++ b/gdal/configure.ac
57 @@ -4446,6 +4446,7 @@ POPPLER_BASE_STREAM_HAS_TWO_ARGS=no
58 POPPLER_0_20_OR_LATER=no
59 POPPLER_0_23_OR_LATER=no
60 POPPLER_0_58_OR_LATER=no
61 +POPPLER_0_69_OR_LATER=no
63 AC_MSG_CHECKING([for poppler])
65 @@ -4486,21 +4487,45 @@ if test "$with_poppler" != "no" -a "$with_poppler" != ""; then
67 CHECK_OTHER_POPPLER_VERSION=yes
69 - # And now we check if we have Poppler >= 0.58.0
70 - AC_MSG_CHECKING([if Object does have new API (>= 0.58.0)])
72 - echo '#include <poppler/Object.h>' > testpoppler.cpp
73 - echo 'int main(int argc, char** argv) { Object o(objNull); return 0; }' >> testpoppler.cpp
74 - if test -z "`${CXX} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
75 - POPPLER_0_58_OR_LATER=yes
76 - POPPLER_0_23_OR_LATER=yes
77 - POPPLER_0_20_OR_LATER=yes
78 - POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
79 - POPPLER_HAS_OPTCONTENT=yes
80 - CHECK_OTHER_POPPLER_VERSION=no
81 - AC_MSG_RESULT([yes])
84 + if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
85 + AC_MSG_CHECKING([if OptionalContent has API >= 0.69.0])
87 + echo '#include <poppler/OptionalContent.h>' > testpoppler.cpp
88 + echo 'int main(int argc, char** argv) {' >> testpoppler.cpp
89 + echo 'OCGs ocg(nullptr, nullptr);' >> testpoppler.cpp
90 + echo 'ocg.getOCGs().size();' >> testpoppler.cpp
91 + echo 'return 0; }' >> testpoppler.cpp
92 + if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
93 + POPPLER_0_69_OR_LATER=yes
94 + POPPLER_0_58_OR_LATER=yes
95 + POPPLER_0_23_OR_LATER=yes
96 + POPPLER_0_20_OR_LATER=yes
97 + POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
98 + POPPLER_HAS_OPTCONTENT=yes
99 + CHECK_OTHER_POPPLER_VERSION=no
100 + AC_MSG_RESULT([yes])
102 + AC_MSG_RESULT([no])
106 + if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
107 + # And now we check if we have Poppler >= 0.58.0
108 + AC_MSG_CHECKING([if Object does have new API (>= 0.58.0)])
109 + rm -f testpoppler.*
110 + echo '#include <poppler/Object.h>' > testpoppler.cpp
111 + echo 'int main(int argc, char** argv) { Object o(objNull); return 0; }' >> testpoppler.cpp
112 + if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
113 + POPPLER_0_58_OR_LATER=yes
114 + POPPLER_0_23_OR_LATER=yes
115 + POPPLER_0_20_OR_LATER=yes
116 + POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
117 + POPPLER_HAS_OPTCONTENT=yes
118 + CHECK_OTHER_POPPLER_VERSION=no
119 + AC_MSG_RESULT([yes])
121 + AC_MSG_RESULT([no])
125 if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
126 @@ -4585,6 +4610,7 @@ AC_SUBST(POPPLER_BASE_STREAM_HAS_TWO_ARGS, $POPPLER_BASE_STREAM_HAS_TWO_ARGS)
127 AC_SUBST(POPPLER_0_20_OR_LATER, $POPPLER_0_20_OR_LATER)
128 AC_SUBST(POPPLER_0_23_OR_LATER, $POPPLER_0_23_OR_LATER)
129 AC_SUBST(POPPLER_0_58_OR_LATER, $POPPLER_0_58_OR_LATER)
130 +AC_SUBST(POPPLER_0_69_OR_LATER, $POPPLER_0_69_OR_LATER)
131 AC_SUBST(POPPLER_INC, $POPPLER_INC)
132 AC_SUBST(POPPLER_PLUGIN_LIB, $POPPLER_PLUGIN_LIB)
134 diff --git a/gdal/frmts/pdf/GNUmakefile b/gdal/frmts/pdf/GNUmakefile
135 index 2014070eac7..618072f05d3 100644
136 --- a/gdal/frmts/pdf/GNUmakefile
137 +++ b/gdal/frmts/pdf/GNUmakefile
138 @@ -35,6 +35,10 @@ ifeq ($(POPPLER_0_58_OR_LATER),yes)
139 CPPFLAGS += -DPOPPLER_0_58_OR_LATER
142 +ifeq ($(POPPLER_0_69_OR_LATER),yes)
143 +CPPFLAGS += -DPOPPLER_0_69_OR_LATER
146 ifeq ($(HAVE_PODOFO),yes)
147 CPPFLAGS += -DHAVE_PODOFO
149 diff --git a/gdal/frmts/pdf/makefile.vc b/gdal/frmts/pdf/makefile.vc
150 index b4fa14d0a18..ad76d3de70c 100644
151 --- a/gdal/frmts/pdf/makefile.vc
152 +++ b/gdal/frmts/pdf/makefile.vc
153 @@ -14,7 +14,7 @@ OBJ = $(OBJ) ..\..\ogr\ogrsf_frmts\mem\ogrmemdatasource.obj ..\..\ogr\ogrsf_frmt
154 EXTRAFLAGS = -I..\vrt -I..\mem -I..\..\ogr\ogrsf_frmts\mem $(POPPLER_EXTRAFLAGS) $(PODOFO_EXTRAFLAGS) $(PDFIUM_EXTRAFLAGS)
156 !IFDEF POPPLER_ENABLED
157 -POPPLER_EXTRAFLAGS = $(POPPLER_CFLAGS) $(POPPLER_HAS_OPTCONTENT_FLAGS) $(POPPLER_BASE_STREAM_HAS_TWO_ARGS_FLAGS) $(POPPLER_0_20_OR_LATER_FLAGS) $(POPPLER_0_23_OR_LATER_FLAGS) $(POPPLER_0_58_OR_LATER_FLAGS) -DHAVE_POPPLER
158 +POPPLER_EXTRAFLAGS = $(POPPLER_CFLAGS) $(POPPLER_HAS_OPTCONTENT_FLAGS) $(POPPLER_BASE_STREAM_HAS_TWO_ARGS_FLAGS) $(POPPLER_0_20_OR_LATER_FLAGS) $(POPPLER_0_23_OR_LATER_FLAGS) $(POPPLER_0_58_OR_LATER_FLAGS) $(POPPLER_0_69_OR_LATER_FLAGS) -DHAVE_POPPLER
160 !IFDEF POPPLER_HAS_OPTCONTENT
161 POPPLER_HAS_OPTCONTENT_FLAGS = -DPOPPLER_HAS_OPTCONTENT
162 @@ -36,6 +36,10 @@ POPPLER_0_23_OR_LATER_FLAGS = -DPOPPLER_0_23_OR_LATER
163 POPPLER_0_58_OR_LATER_FLAGS = -DPOPPLER_0_58_OR_LATER
166 +!IFDEF POPPLER_0_69_OR_LATER
167 +POPPLER_0_69_OR_LATER_FLAGS = -DPOPPLER_0_69_OR_LATER
172 !IFDEF PODOFO_ENABLED
173 diff --git a/gdal/frmts/pdf/pdfdataset.cpp b/gdal/frmts/pdf/pdfdataset.cpp
174 index ee89fd07564..1a56f57ee06 100644
175 --- a/gdal/frmts/pdf/pdfdataset.cpp
176 +++ b/gdal/frmts/pdf/pdfdataset.cpp
177 @@ -3440,10 +3440,16 @@ void PDFDataset::FindLayersPoppler()
181 +#ifdef POPPLER_0_69_OR_LATER
182 + for( const auto& refOCGPair: optContentConfig->getOCGs() )
184 + auto ocg = refOCGPair.second.get();
186 GooList* ocgList = optContentConfig->getOCGs();
187 for(int i=0;i<ocgList->getLength();i++)
189 OptionalContentGroup* ocg = (OptionalContentGroup*) ocgList->get(i);
191 if( ocg != NULL && ocg->getName() != NULL )
193 const char* pszLayerName = (const char*)ocg->getName()->getCString();
194 @@ -3472,10 +3478,16 @@ void PDFDataset::TurnLayersOnOffPoppler()
197 int bAll = EQUAL(pszLayers, "ALL");
198 +#ifdef POPPLER_0_69_OR_LATER
199 + for( const auto& refOCGPair: optContentConfig->getOCGs() )
201 + auto ocg = refOCGPair.second.get();
203 GooList* ocgList = optContentConfig->getOCGs();
204 for(i=0;i<ocgList->getLength();i++)
206 OptionalContentGroup* ocg = (OptionalContentGroup*) ocgList->get(i);
208 ocg->setState( (bAll) ? OptionalContentGroup::On : OptionalContentGroup::Off );
211 diff --git a/gdal/nmake.opt b/gdal/nmake.opt
212 index a3b88583425..c9ca28d3cd9 100644
215 @@ -632,6 +632,7 @@ OCI_INCLUDE = -I$(ORACLE_HOME)\oci\include
216 # Uncomment POPPLER_0_20_OR_LATER = YES for Poppler >= 0.20.0
217 # Uncomment POPPLER_0_23_OR_LATER = YES for Poppler >= 0.23.0
218 # Uncomment POPPLER_0_58_OR_LATER = YES for Poppler >= 0.58.0
219 +# Uncomment POPPLER_0_69_OR_LATER = YES for Poppler >= 0.69.0
220 #POPPLER_ENABLED = YES
221 #POPPLER_CFLAGS = -Ie:/kde/include -Ie:/kde/include/poppler
222 #POPPLER_HAS_OPTCONTENT = YES
223 @@ -639,6 +640,7 @@ OCI_INCLUDE = -I$(ORACLE_HOME)\oci\include
224 #POPPLER_0_20_OR_LATER = YES
225 #POPPLER_0_23_OR_LATER = YES
226 #POPPLER_0_58_OR_LATER = YES
227 +#POPPLER_0_69_OR_LATER = YES
228 #POPPLER_LIBS = e:/kde/lib/poppler.lib e:/kde/lib/freetype.lib e:/kde/lib/liblcms-1.lib advapi32.lib gdi32.lib
230 # Uncomment for PDF support