]>
Commit | Line | Data |
---|---|---|
ee43bca4 JP |
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) | |
5 | ||
6 | --- | |
7 | gdal/frmts/pdf/pdfobject.cpp | 5 +++++ | |
8 | 1 file changed, 5 insertions(+) | |
9 | ||
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() | |
15 | { | |
16 | if (GetType() == PDFObjectType_String) | |
17 | { | |
18 | +#ifdef POPPLER_0_58_OR_LATER | |
19 | + // At least available since poppler 0.41 | |
20 | + const GooString* gooString = m_po->getString(); | |
21 | +#else | |
22 | GooString* gooString = m_po->getString(); | |
23 | +#endif | |
24 | return (osStr = GDALPDFGetUTF8StringFromBytes(reinterpret_cast<const GByte*>(gooString->getCString()), | |
25 | static_cast<int>(gooString->getLength()))); | |
26 | } | |
32c35647 JP |
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) | |
31 | ||
32 | --- | |
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 +++++++ | |
39 | gdal/nmake.opt | 2 ++ | |
40 | 7 files changed, 111 insertions(+), 31 deletions(-) | |
41 | ||
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@ | |
53 | ||
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 | |
62 | ||
63 | AC_MSG_CHECKING([for poppler]) | |
64 | ||
65 | @@ -4486,21 +4487,45 @@ if test "$with_poppler" != "no" -a "$with_poppler" != ""; then | |
66 | ||
67 | CHECK_OTHER_POPPLER_VERSION=yes | |
68 | ||
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)]) | |
71 | - rm -f testpoppler.* | |
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]) | |
82 | - else | |
83 | - AC_MSG_RESULT([no]) | |
84 | + if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then | |
85 | + AC_MSG_CHECKING([if OptionalContent has API >= 0.69.0]) | |
86 | + rm -f testpoppler.* | |
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]) | |
101 | + else | |
102 | + AC_MSG_RESULT([no]) | |
103 | + fi | |
104 | + fi | |
105 | + | |
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]) | |
120 | + else | |
121 | + AC_MSG_RESULT([no]) | |
122 | + fi | |
123 | fi | |
124 | ||
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) | |
133 | ||
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 | |
140 | endif | |
141 | ||
142 | +ifeq ($(POPPLER_0_69_OR_LATER),yes) | |
143 | +CPPFLAGS += -DPOPPLER_0_69_OR_LATER | |
144 | +endif | |
145 | + | |
146 | ifeq ($(HAVE_PODOFO),yes) | |
147 | CPPFLAGS += -DHAVE_PODOFO | |
148 | endif | |
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) | |
155 | ||
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 | |
159 | ||
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 | |
164 | !ENDIF | |
165 | ||
166 | +!IFDEF POPPLER_0_69_OR_LATER | |
167 | +POPPLER_0_69_OR_LATER_FLAGS = -DPOPPLER_0_69_OR_LATER | |
168 | +!ENDIF | |
169 | + | |
170 | !ENDIF | |
171 | ||
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() | |
178 | } | |
179 | else | |
180 | { | |
181 | +#ifdef POPPLER_0_69_OR_LATER | |
182 | + for( const auto& refOCGPair: optContentConfig->getOCGs() ) | |
183 | + { | |
184 | + auto ocg = refOCGPair.second.get(); | |
185 | +#else | |
186 | GooList* ocgList = optContentConfig->getOCGs(); | |
187 | for(int i=0;i<ocgList->getLength();i++) | |
188 | { | |
189 | OptionalContentGroup* ocg = (OptionalContentGroup*) ocgList->get(i); | |
190 | +#endif | |
191 | if( ocg != NULL && ocg->getName() != NULL ) | |
192 | { | |
193 | const char* pszLayerName = (const char*)ocg->getName()->getCString(); | |
194 | @@ -3472,10 +3478,16 @@ void PDFDataset::TurnLayersOnOffPoppler() | |
195 | { | |
196 | int i; | |
197 | int bAll = EQUAL(pszLayers, "ALL"); | |
198 | +#ifdef POPPLER_0_69_OR_LATER | |
199 | + for( const auto& refOCGPair: optContentConfig->getOCGs() ) | |
200 | + { | |
201 | + auto ocg = refOCGPair.second.get(); | |
202 | +#else | |
203 | GooList* ocgList = optContentConfig->getOCGs(); | |
204 | for(i=0;i<ocgList->getLength();i++) | |
205 | { | |
206 | OptionalContentGroup* ocg = (OptionalContentGroup*) ocgList->get(i); | |
207 | +#endif | |
208 | ocg->setState( (bAll) ? OptionalContentGroup::On : OptionalContentGroup::Off ); | |
209 | } | |
210 | ||
211 | diff --git a/gdal/nmake.opt b/gdal/nmake.opt | |
212 | index a3b88583425..c9ca28d3cd9 100644 | |
213 | --- a/gdal/nmake.opt | |
214 | +++ b/gdal/nmake.opt | |
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 | |
229 | ||
230 | # Uncomment for PDF support |