Bruno Friedmann
54fac41f93
- Add upstream patches to fix build with the latest poppler in Tumbleweed: * Poppler-revision-version-management.patch * add-support-for-poppler-0.72.0-and-0.73.0.patch OBS-URL: https://build.opensuse.org/request/show/670314 OBS-URL: https://build.opensuse.org/package/show/Application:Geo/gdal?expand=0&rev=82
1145 lines
44 KiB
Diff
1145 lines
44 KiB
Diff
From d9ff536713c1bcaff00657f5fb9a94f36b92c0d8 Mon Sep 17 00:00:00 2001
|
|
From: Even Rouault <even.rouault@spatialys.com>
|
|
Date: Thu, 17 Jan 2019 22:36:09 +0100
|
|
Subject: [PATCH] Poppler: revision version management. Drop support for
|
|
ancient versions older than 0.23.0 (preparation for support of newer version:
|
|
refs #1207, #1208)
|
|
|
|
---
|
|
appveyor.yml | 6 +-
|
|
gdal/GDALmake.opt.in | 10 +-
|
|
gdal/configure | 374 ++++++++++++++++++----------------
|
|
gdal/configure.ac | 177 ++--------------
|
|
gdal/frmts/pdf/GNUmakefile | 26 +--
|
|
gdal/frmts/pdf/makefile.vc | 30 +--
|
|
gdal/frmts/pdf/pdfdataset.cpp | 69 +------
|
|
gdal/frmts/pdf/pdfio.cpp | 20 +-
|
|
gdal/frmts/pdf/pdfio.h | 22 +-
|
|
gdal/frmts/pdf/pdfobject.cpp | 8 +-
|
|
gdal/nmake.opt | 15 +-
|
|
11 files changed, 257 insertions(+), 500 deletions(-)
|
|
|
|
diff --git a/gdal/GDALmake.opt.in b/gdal/GDALmake.opt.in
|
|
index ea54dc2ff3c..770ad859799 100644
|
|
--- a/gdal/GDALmake.opt.in
|
|
+++ b/gdal/GDALmake.opt.in
|
|
@@ -483,13 +483,9 @@ PDF_PLUGIN = @PDF_PLUGIN@
|
|
#
|
|
|
|
HAVE_POPPLER = @HAVE_POPPLER@
|
|
-POPPLER_HAS_OPTCONTENT = @POPPLER_HAS_OPTCONTENT@
|
|
-POPPLER_BASE_STREAM_HAS_TWO_ARGS = @POPPLER_BASE_STREAM_HAS_TWO_ARGS@
|
|
-POPPLER_0_20_OR_LATER = @POPPLER_0_20_OR_LATER@
|
|
-POPPLER_0_23_OR_LATER = @POPPLER_0_23_OR_LATER@
|
|
-POPPLER_0_58_OR_LATER = @POPPLER_0_58_OR_LATER@
|
|
-POPPLER_0_69_OR_LATER = @POPPLER_0_69_OR_LATER@
|
|
-POPPLER_INC = @POPPLER_INC@
|
|
+POPPLER_MAJOR_VERSION = @POPPLER_MAJOR_VERSION@
|
|
+POPPLER_MINOR_VERSION = @POPPLER_MINOR_VERSION@
|
|
+POPPLER_INC = @POPPLER_CFLAGS@
|
|
POPPLER_PLUGIN_LIB = @POPPLER_PLUGIN_LIB@
|
|
|
|
#
|
|
diff --git a/gdal/configure b/gdal/configure
|
|
index 6f7f76b48f2..c0fe46c8f68 100755
|
|
--- a/gdal/configure
|
|
+++ b/gdal/configure
|
|
@@ -668,14 +668,11 @@ PODOFO_PLUGIN_LIB
|
|
PODOFO_INC
|
|
HAVE_PODOFO
|
|
POPPLER_PLUGIN_LIB
|
|
-POPPLER_INC
|
|
-POPPLER_0_69_OR_LATER
|
|
-POPPLER_0_58_OR_LATER
|
|
-POPPLER_0_23_OR_LATER
|
|
-POPPLER_0_20_OR_LATER
|
|
-POPPLER_BASE_STREAM_HAS_TWO_ARGS
|
|
-POPPLER_HAS_OPTCONTENT
|
|
+POPPLER_MINOR_VERSION
|
|
+POPPLER_MAJOR_VERSION
|
|
HAVE_POPPLER
|
|
+POPPLER_LIBS
|
|
+POPPLER_CFLAGS
|
|
PDF_PLUGIN
|
|
PAM_SETTING
|
|
JSON_INCLUDE
|
|
@@ -1117,7 +1114,9 @@ HDF5_LIBS
|
|
OPENJPEG_CFLAGS
|
|
OPENJPEG_LIBS
|
|
LIBKML_CFLAGS
|
|
-LIBKML_LIBS'
|
|
+LIBKML_LIBS
|
|
+POPPLER_CFLAGS
|
|
+POPPLER_LIBS'
|
|
|
|
|
|
# Initialize some variables set by options.
|
|
@@ -1927,6 +1926,10 @@ Some influential environment variables:
|
|
LIBKML_CFLAGS
|
|
C compiler flags for LIBKML, overriding pkg-config
|
|
LIBKML_LIBS linker flags for LIBKML, overriding pkg-config
|
|
+ POPPLER_CFLAGS
|
|
+ C compiler flags for POPPLER, overriding pkg-config
|
|
+ POPPLER_LIBS
|
|
+ linker flags for POPPLER, overriding pkg-config
|
|
|
|
Use these variables to override the choices made by `configure' or to help
|
|
it to find libraries and programs with nonstandard names/locations.
|
|
@@ -35065,208 +35068,225 @@ fi
|
|
|
|
|
|
HAVE_POPPLER=no
|
|
-POPPLER_HAS_OPTCONTENT=no
|
|
-POPPLER_BASE_STREAM_HAS_TWO_ARGS=no
|
|
-POPPLER_0_20_OR_LATER=no
|
|
-POPPLER_0_23_OR_LATER=no
|
|
-POPPLER_0_58_OR_LATER=no
|
|
-POPPLER_0_69_OR_LATER=no
|
|
+POPPLER_MAJOR_VERSION=
|
|
+POPPLER_MINOR_VERSION=
|
|
|
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for poppler" >&5
|
|
$as_echo_n "checking for poppler... " >&6; }
|
|
|
|
if test "$with_poppler" != "no" -a "$with_poppler" != ""; then
|
|
|
|
- if test "$with_poppler" = "yes" ; then
|
|
- TEST_POPPLER_INC="-I/usr/include -I/usr/include/poppler"
|
|
- TEST_POPPLER_LIB="-lpoppler"
|
|
- else
|
|
- TEST_POPPLER_INC="-I$with_poppler/include -I$with_poppler/include/poppler"
|
|
- TEST_POPPLER_LIB="-L$with_poppler/lib -lpoppler"
|
|
- fi
|
|
|
|
- # Check that we can accept Page::pageObj private member
|
|
- rm -f testpoppler.*
|
|
- echo '#define private public' > testpoppler.cpp
|
|
- echo '#include <poppler/Page.h>' >> testpoppler.cpp
|
|
- echo '#include <poppler/splash/SplashBitmap.h>' >> testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { return &(((Page*)0x8000)->pageObj) == 0; } ' >> testpoppler.cpp
|
|
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -o testpoppler ${TEST_POPPLER_INC} ${TEST_POPPLER_LIB} 2>&1`" ; then
|
|
- HAVE_POPPLER=yes
|
|
- else
|
|
- # poppler 0.23.0 needs to be linked against pthread
|
|
- TEST_POPPLER_LIB="${TEST_POPPLER_LIB} -lpthread"
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -o testpoppler ${TEST_POPPLER_INC} ${TEST_POPPLER_LIB} 2>&1`" ; then
|
|
- HAVE_POPPLER=yes
|
|
- fi
|
|
- fi
|
|
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
|
|
+ if test -n "$ac_tool_prefix"; then
|
|
+ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
|
|
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
|
|
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
|
+$as_echo_n "checking for $ac_word... " >&6; }
|
|
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
|
|
+ $as_echo_n "(cached) " >&6
|
|
+else
|
|
+ case $PKG_CONFIG in
|
|
+ [\\/]* | ?:[\\/]*)
|
|
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
|
|
+ ;;
|
|
+ *)
|
|
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
|
+for as_dir in $PATH
|
|
+do
|
|
+ IFS=$as_save_IFS
|
|
+ test -z "$as_dir" && as_dir=.
|
|
+ for ac_exec_ext in '' $ac_executable_extensions; do
|
|
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
|
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
|
|
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
|
+ break 2
|
|
+ fi
|
|
+done
|
|
+ done
|
|
+IFS=$as_save_IFS
|
|
|
|
- if test "$HAVE_POPPLER" = "yes"; then
|
|
- if test "$PDF_PLUGIN" = "no"; then
|
|
- LIBS="${TEST_POPPLER_LIB} ${LIBS}"
|
|
- fi
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
-$as_echo "yes" >&6; }
|
|
- POPPLER_INC=$TEST_POPPLER_INC
|
|
- POPPLER_PLUGIN_LIB="${TEST_POPPLER_LIB}"
|
|
-
|
|
- CHECK_OTHER_POPPLER_VERSION=yes
|
|
-
|
|
- if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if OptionalContent has API >= 0.69.0" >&5
|
|
-$as_echo_n "checking if OptionalContent has API >= 0.69.0... " >&6; }
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/OptionalContent.h>' > testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) {' >> testpoppler.cpp
|
|
- echo 'OCGs ocg(nullptr, nullptr);' >> testpoppler.cpp
|
|
- echo 'ocg.getOCGs().size();' >> testpoppler.cpp
|
|
- echo 'return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_0_69_OR_LATER=yes
|
|
- POPPLER_0_58_OR_LATER=yes
|
|
- POPPLER_0_23_OR_LATER=yes
|
|
- POPPLER_0_20_OR_LATER=yes
|
|
- POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
|
|
- POPPLER_HAS_OPTCONTENT=yes
|
|
- CHECK_OTHER_POPPLER_VERSION=no
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
-$as_echo "yes" >&6; }
|
|
- else
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
+ ;;
|
|
+esac
|
|
+fi
|
|
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
|
|
+if test -n "$PKG_CONFIG"; then
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
|
|
+$as_echo "$PKG_CONFIG" >&6; }
|
|
+else
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
$as_echo "no" >&6; }
|
|
- fi
|
|
- fi
|
|
+fi
|
|
|
|
- if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
|
|
- # And now we check if we have Poppler >= 0.58.0
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Object does have new API (>= 0.58.0)" >&5
|
|
-$as_echo_n "checking if Object does have new API (>= 0.58.0)... " >&6; }
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/Object.h>' > testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { Object o(objNull); return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_0_58_OR_LATER=yes
|
|
- POPPLER_0_23_OR_LATER=yes
|
|
- POPPLER_0_20_OR_LATER=yes
|
|
- POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
|
|
- POPPLER_HAS_OPTCONTENT=yes
|
|
- CHECK_OTHER_POPPLER_VERSION=no
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
-$as_echo "yes" >&6; }
|
|
- else
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
+
|
|
+fi
|
|
+if test -z "$ac_cv_path_PKG_CONFIG"; then
|
|
+ ac_pt_PKG_CONFIG=$PKG_CONFIG
|
|
+ # Extract the first word of "pkg-config", so it can be a program name with args.
|
|
+set dummy pkg-config; ac_word=$2
|
|
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
|
+$as_echo_n "checking for $ac_word... " >&6; }
|
|
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
|
|
+ $as_echo_n "(cached) " >&6
|
|
+else
|
|
+ case $ac_pt_PKG_CONFIG in
|
|
+ [\\/]* | ?:[\\/]*)
|
|
+ ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
|
|
+ ;;
|
|
+ *)
|
|
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
|
+for as_dir in $PATH
|
|
+do
|
|
+ IFS=$as_save_IFS
|
|
+ test -z "$as_dir" && as_dir=.
|
|
+ for ac_exec_ext in '' $ac_executable_extensions; do
|
|
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
|
+ ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
|
|
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
|
+ break 2
|
|
+ fi
|
|
+done
|
|
+ done
|
|
+IFS=$as_save_IFS
|
|
+
|
|
+ ;;
|
|
+esac
|
|
+fi
|
|
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
|
|
+if test -n "$ac_pt_PKG_CONFIG"; then
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
|
|
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
|
|
+else
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
$as_echo "no" >&6; }
|
|
- fi
|
|
- fi
|
|
+fi
|
|
|
|
- if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
|
|
-
|
|
- # And now try another dirty thing, but this one is
|
|
- # optional.
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Catalog::optContent exists" >&5
|
|
-$as_echo_n "checking if Catalog::optContent exists... " >&6; }
|
|
- rm -f testpoppler.*
|
|
- echo '#define private public' > testpoppler.cpp
|
|
- echo '#include <poppler/Object.h>' >> testpoppler.cpp
|
|
- echo '#include <poppler/Catalog.h>' >> testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { return &(((Catalog*)0x8000)->optContent) == 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_HAS_OPTCONTENT=yes
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
+ if test "x$ac_pt_PKG_CONFIG" = x; then
|
|
+ PKG_CONFIG=""
|
|
+ else
|
|
+ case $cross_compiling:$ac_tool_warned in
|
|
+yes:)
|
|
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
|
|
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
|
|
+ac_tool_warned=yes ;;
|
|
+esac
|
|
+ PKG_CONFIG=$ac_pt_PKG_CONFIG
|
|
+ fi
|
|
+else
|
|
+ PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
|
|
+fi
|
|
+
|
|
+fi
|
|
+if test -n "$PKG_CONFIG"; then
|
|
+ _pkg_min_version=0.21
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
|
|
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
|
|
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
$as_echo "yes" >&6; }
|
|
- else
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
+ else
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
$as_echo "no" >&6; }
|
|
- fi
|
|
+ PKG_CONFIG=""
|
|
+ fi
|
|
|
|
- # And now we check if we have Poppler >= 0.16.0
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if BaseStream constructor needs 2 arguments" >&5
|
|
-$as_echo_n "checking if BaseStream constructor needs 2 arguments... " >&6; }
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/Object.h>' > testpoppler.cpp
|
|
- echo '#include <poppler/Stream.h>' >> testpoppler.cpp
|
|
- echo 'class TestStream: public BaseStream {' >> testpoppler.cpp
|
|
- echo 'public:' >> testpoppler.cpp
|
|
- echo ' TestStream() : BaseStream(0,0) {}' >> testpoppler.cpp
|
|
- echo '};' >> testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
-$as_echo "yes" >&6; }
|
|
+fi
|
|
|
|
- # And now we check if we have Poppler >= 0.20.0
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have Poppler >= 0.20.0" >&5
|
|
-$as_echo_n "checking if we have Poppler >= 0.20.0... " >&6; }
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/Error.h>' > testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { setErrorCallback(0,0); return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_0_20_OR_LATER=yes
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
-$as_echo "yes" >&6; }
|
|
+pkg_failed=no
|
|
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for POPPLER" >&5
|
|
+$as_echo_n "checking for POPPLER... " >&6; }
|
|
|
|
- # And now we check if we have Poppler >= 0.23.0
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have Poppler >= 0.23.0" >&5
|
|
-$as_echo_n "checking if we have Poppler >= 0.23.0... " >&6; }
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/Object.h>' > testpoppler.cpp
|
|
- echo '#include <poppler/Stream.h>' >> testpoppler.cpp
|
|
- echo 'class TestStream: public BaseStream {' >> testpoppler.cpp
|
|
- echo 'public:' >> testpoppler.cpp
|
|
- echo ' TestStream() : BaseStream(0,0) {}' >> testpoppler.cpp
|
|
- echo ' ~TestStream() {}' >> testpoppler.cpp
|
|
- echo ' virtual BaseStream *copy() { return BaseStream::copy(); }' >> testpoppler.cpp
|
|
- echo '};' >> testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_0_23_OR_LATER=yes
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
-$as_echo "yes" >&6; }
|
|
- else
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
-$as_echo "no" >&6; }
|
|
- fi
|
|
+if test -n "$PKG_CONFIG"; then
|
|
+ if test -n "$POPPLER_CFLAGS"; then
|
|
+ pkg_cv_POPPLER_CFLAGS="$POPPLER_CFLAGS"
|
|
+ else
|
|
+ if test -n "$PKG_CONFIG" && \
|
|
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"poppler >= 0.23.0\""; } >&5
|
|
+ ($PKG_CONFIG --exists --print-errors "poppler >= 0.23.0") 2>&5
|
|
+ ac_status=$?
|
|
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
+ test $ac_status = 0; }; then
|
|
+ pkg_cv_POPPLER_CFLAGS=`$PKG_CONFIG --cflags "poppler >= 0.23.0" 2>/dev/null`
|
|
+else
|
|
+ pkg_failed=yes
|
|
+fi
|
|
+ fi
|
|
+else
|
|
+ pkg_failed=untried
|
|
+fi
|
|
+if test -n "$PKG_CONFIG"; then
|
|
+ if test -n "$POPPLER_LIBS"; then
|
|
+ pkg_cv_POPPLER_LIBS="$POPPLER_LIBS"
|
|
+ else
|
|
+ if test -n "$PKG_CONFIG" && \
|
|
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"poppler >= 0.23.0\""; } >&5
|
|
+ ($PKG_CONFIG --exists --print-errors "poppler >= 0.23.0") 2>&5
|
|
+ ac_status=$?
|
|
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
+ test $ac_status = 0; }; then
|
|
+ pkg_cv_POPPLER_LIBS=`$PKG_CONFIG --libs "poppler >= 0.23.0" 2>/dev/null`
|
|
+else
|
|
+ pkg_failed=yes
|
|
+fi
|
|
+ fi
|
|
+else
|
|
+ pkg_failed=untried
|
|
+fi
|
|
|
|
- else
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
-$as_echo "no" >&6; }
|
|
- fi
|
|
|
|
- else
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
-$as_echo "no" >&6; }
|
|
- fi
|
|
+
|
|
+if test $pkg_failed = yes; then
|
|
+
|
|
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
|
+ _pkg_short_errors_supported=yes
|
|
+else
|
|
+ _pkg_short_errors_supported=no
|
|
+fi
|
|
+ if test $_pkg_short_errors_supported = yes; then
|
|
+ POPPLER_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "poppler >= 0.23.0"`
|
|
+ else
|
|
+ POPPLER_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "poppler >= 0.23.0"`
|
|
fi
|
|
- else
|
|
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
+ # Put the nasty error message in config.log where it belongs
|
|
+ echo "$POPPLER_PKG_ERRORS" >&5
|
|
+
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
$as_echo "no" >&6; }
|
|
+ POPPLER_VERSION=
|
|
+elif test $pkg_failed = untried; then
|
|
+ POPPLER_VERSION=
|
|
+else
|
|
+ POPPLER_CFLAGS=$pkg_cv_POPPLER_CFLAGS
|
|
+ POPPLER_LIBS=$pkg_cv_POPPLER_LIBS
|
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
+$as_echo "yes" >&6; }
|
|
+ POPPLER_VERSION=`$PKG_CONFIG --modversion poppler`
|
|
+fi
|
|
+ if test "$POPPLER_VERSION" != ""; then
|
|
+ HAVE_POPPLER=yes
|
|
+ POPPLER_MAJOR_VERSION=`expr $POPPLER_VERSION : '\([0-9]*\)'`
|
|
+ POPPLER_MINOR_VERSION=`expr $POPPLER_VERSION : '[0-9]*\.\([0-9]*\)'`
|
|
+ POPPLER_CFLAGS=`echo $POPPLER_CFLAGS $POPPLER_CFLAGS | sed "s/include\/poppler/include/"`
|
|
fi
|
|
- rm -f testpoppler.*
|
|
- rm -f testpoppler
|
|
else
|
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
|
|
$as_echo "disabled" >&6; }
|
|
fi
|
|
|
|
-HAVE_POPPLER=$HAVE_POPPLER
|
|
-
|
|
-POPPLER_HAS_OPTCONTENT=$POPPLER_HAS_OPTCONTENT
|
|
-
|
|
-POPPLER_BASE_STREAM_HAS_TWO_ARGS=$POPPLER_BASE_STREAM_HAS_TWO_ARGS
|
|
-
|
|
-POPPLER_0_20_OR_LATER=$POPPLER_0_20_OR_LATER
|
|
+if test "$HAVE_POPPLER" = "yes" -a "$PDF_PLUGIN" = "no"; then
|
|
+ LIBS="${POPPLER_LIBS} ${LIBS}"
|
|
+fi
|
|
|
|
-POPPLER_0_23_OR_LATER=$POPPLER_0_23_OR_LATER
|
|
+HAVE_POPPLER=$HAVE_POPPLER
|
|
|
|
-POPPLER_0_58_OR_LATER=$POPPLER_0_58_OR_LATER
|
|
+POPPLER_MAJOR_VERSION=$POPPLER_MAJOR_VERSION
|
|
|
|
-POPPLER_0_69_OR_LATER=$POPPLER_0_69_OR_LATER
|
|
+POPPLER_MINOR_VERSION=$POPPLER_MINOR_VERSION
|
|
|
|
-POPPLER_INC=$POPPLER_INC
|
|
+POPPLER_CFLAGS=$POPPLER_CFLAGS
|
|
|
|
-POPPLER_PLUGIN_LIB=$POPPLER_PLUGIN_LIB
|
|
+POPPLER_PLUGIN_LIB=$POPPLER_LIBS
|
|
|
|
|
|
|
|
diff --git a/gdal/configure.ac b/gdal/configure.ac
|
|
index 56500f9ccfd..7f106be74cb 100644
|
|
--- a/gdal/configure.ac
|
|
+++ b/gdal/configure.ac
|
|
@@ -4539,178 +4539,35 @@ dnl ---------------------------------------------------------------------------
|
|
AC_ARG_WITH(poppler,[ --with-poppler[=ARG] Include poppler(for PDF) support (ARG=no(default), yes or poppler install path)],,)
|
|
|
|
HAVE_POPPLER=no
|
|
-POPPLER_HAS_OPTCONTENT=no
|
|
-POPPLER_BASE_STREAM_HAS_TWO_ARGS=no
|
|
-POPPLER_0_20_OR_LATER=no
|
|
-POPPLER_0_23_OR_LATER=no
|
|
-POPPLER_0_58_OR_LATER=no
|
|
-POPPLER_0_69_OR_LATER=no
|
|
+POPPLER_MAJOR_VERSION=
|
|
+POPPLER_MINOR_VERSION=
|
|
|
|
AC_MSG_CHECKING([for poppler])
|
|
|
|
if test "$with_poppler" != "no" -a "$with_poppler" != ""; then
|
|
|
|
- if test "$with_poppler" = "yes" ; then
|
|
- TEST_POPPLER_INC="-I/usr/include -I/usr/include/poppler"
|
|
- TEST_POPPLER_LIB="-lpoppler"
|
|
- else
|
|
- TEST_POPPLER_INC="-I$with_poppler/include -I$with_poppler/include/poppler"
|
|
- TEST_POPPLER_LIB="-L$with_poppler/lib -lpoppler"
|
|
- fi
|
|
-
|
|
- # Check that we can accept Page::pageObj private member
|
|
- rm -f testpoppler.*
|
|
- echo '#define private public' > testpoppler.cpp
|
|
- echo '#include <poppler/Page.h>' >> testpoppler.cpp
|
|
- echo '#include <poppler/splash/SplashBitmap.h>' >> testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { return &(((Page*)0x8000)->pageObj) == 0; } ' >> testpoppler.cpp
|
|
-
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -o testpoppler ${TEST_POPPLER_INC} ${TEST_POPPLER_LIB} 2>&1`" ; then
|
|
+ PKG_PROG_PKG_CONFIG([0.21])
|
|
+ PKG_CHECK_MODULES([POPPLER], [poppler >= 0.23.0],
|
|
+ [POPPLER_VERSION=`$PKG_CONFIG --modversion poppler`], [POPPLER_VERSION=])
|
|
+ if test "$POPPLER_VERSION" != ""; then
|
|
HAVE_POPPLER=yes
|
|
- else
|
|
- # poppler 0.23.0 needs to be linked against pthread
|
|
- TEST_POPPLER_LIB="${TEST_POPPLER_LIB} -lpthread"
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -o testpoppler ${TEST_POPPLER_INC} ${TEST_POPPLER_LIB} 2>&1`" ; then
|
|
- HAVE_POPPLER=yes
|
|
- fi
|
|
+ POPPLER_MAJOR_VERSION=`expr $POPPLER_VERSION : '\([[0-9]]*\)'`
|
|
+ POPPLER_MINOR_VERSION=`expr $POPPLER_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
|
|
+ POPPLER_CFLAGS=`echo $POPPLER_CFLAGS $POPPLER_CFLAGS | sed "s/include\/poppler/include/"`
|
|
fi
|
|
-
|
|
- if test "$HAVE_POPPLER" = "yes"; then
|
|
- if test "$PDF_PLUGIN" = "no"; then
|
|
- LIBS="${TEST_POPPLER_LIB} ${LIBS}"
|
|
- fi
|
|
- AC_MSG_RESULT([yes])
|
|
- POPPLER_INC=$TEST_POPPLER_INC
|
|
- POPPLER_PLUGIN_LIB="${TEST_POPPLER_LIB}"
|
|
-
|
|
- CHECK_OTHER_POPPLER_VERSION=yes
|
|
-
|
|
- if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
|
|
- AC_MSG_CHECKING([if OptionalContent has API >= 0.69.0])
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/OptionalContent.h>' > testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) {' >> testpoppler.cpp
|
|
- echo 'OCGs ocg(nullptr, nullptr);' >> testpoppler.cpp
|
|
- echo 'ocg.getOCGs().size();' >> testpoppler.cpp
|
|
- echo 'return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_0_69_OR_LATER=yes
|
|
- POPPLER_0_58_OR_LATER=yes
|
|
- POPPLER_0_23_OR_LATER=yes
|
|
- POPPLER_0_20_OR_LATER=yes
|
|
- POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
|
|
- POPPLER_HAS_OPTCONTENT=yes
|
|
- CHECK_OTHER_POPPLER_VERSION=no
|
|
- AC_MSG_RESULT([yes])
|
|
- else
|
|
- AC_MSG_RESULT([no])
|
|
- fi
|
|
- fi
|
|
-
|
|
- if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
|
|
- # And now we check if we have Poppler >= 0.58.0
|
|
- AC_MSG_CHECKING([if Object does have new API (>= 0.58.0)])
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/Object.h>' > testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { Object o(objNull); return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_0_58_OR_LATER=yes
|
|
- POPPLER_0_23_OR_LATER=yes
|
|
- POPPLER_0_20_OR_LATER=yes
|
|
- POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
|
|
- POPPLER_HAS_OPTCONTENT=yes
|
|
- CHECK_OTHER_POPPLER_VERSION=no
|
|
- AC_MSG_RESULT([yes])
|
|
- else
|
|
- AC_MSG_RESULT([no])
|
|
- fi
|
|
- fi
|
|
-
|
|
- if test "$CHECK_OTHER_POPPLER_VERSION" = "yes"; then
|
|
-
|
|
- # And now try another dirty thing, but this one is
|
|
- # optional.
|
|
- AC_MSG_CHECKING([if Catalog::optContent exists])
|
|
- rm -f testpoppler.*
|
|
- echo '#define private public' > testpoppler.cpp
|
|
- echo '#include <poppler/Object.h>' >> testpoppler.cpp
|
|
- echo '#include <poppler/Catalog.h>' >> testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { return &(((Catalog*)0x8000)->optContent) == 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_HAS_OPTCONTENT=yes
|
|
- AC_MSG_RESULT([yes])
|
|
- else
|
|
- AC_MSG_RESULT([no])
|
|
- fi
|
|
-
|
|
- # And now we check if we have Poppler >= 0.16.0
|
|
- AC_MSG_CHECKING([if BaseStream constructor needs 2 arguments])
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/Object.h>' > testpoppler.cpp
|
|
- echo '#include <poppler/Stream.h>' >> testpoppler.cpp
|
|
- echo 'class TestStream: public BaseStream {' >> testpoppler.cpp
|
|
- echo 'public:' >> testpoppler.cpp
|
|
- echo ' TestStream() : BaseStream(0,0) {}' >> testpoppler.cpp
|
|
- echo '};' >> testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes
|
|
- AC_MSG_RESULT([yes])
|
|
-
|
|
- # And now we check if we have Poppler >= 0.20.0
|
|
- AC_MSG_CHECKING([if we have Poppler >= 0.20.0])
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/Error.h>' > testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { setErrorCallback(0,0); return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_0_20_OR_LATER=yes
|
|
- AC_MSG_RESULT([yes])
|
|
-
|
|
- # And now we check if we have Poppler >= 0.23.0
|
|
- AC_MSG_CHECKING([if we have Poppler >= 0.23.0])
|
|
- rm -f testpoppler.*
|
|
- echo '#include <poppler/Object.h>' > testpoppler.cpp
|
|
- echo '#include <poppler/Stream.h>' >> testpoppler.cpp
|
|
- echo 'class TestStream: public BaseStream {' >> testpoppler.cpp
|
|
- echo 'public:' >> testpoppler.cpp
|
|
- echo ' TestStream() : BaseStream(0,0) {}' >> testpoppler.cpp
|
|
- echo ' ~TestStream() {}' >> testpoppler.cpp
|
|
- echo ' virtual BaseStream *copy() { return BaseStream::copy(); }' >> testpoppler.cpp
|
|
- echo '};' >> testpoppler.cpp
|
|
- echo 'int main(int argc, char** argv) { return 0; }' >> testpoppler.cpp
|
|
- if test -z "`${CXX} ${CXXFLAGS} ${CPPFLAGS} testpoppler.cpp -c ${POPPLER_INC} 2>&1`" ; then
|
|
- POPPLER_0_23_OR_LATER=yes
|
|
- AC_MSG_RESULT([yes])
|
|
- else
|
|
- AC_MSG_RESULT([no])
|
|
- fi
|
|
-
|
|
- else
|
|
- AC_MSG_RESULT([no])
|
|
- fi
|
|
-
|
|
- else
|
|
- AC_MSG_RESULT([no])
|
|
- fi
|
|
- fi
|
|
- else
|
|
- AC_MSG_RESULT([no])
|
|
- fi
|
|
- rm -f testpoppler.*
|
|
- rm -f testpoppler
|
|
else
|
|
AC_MSG_RESULT([disabled])
|
|
fi
|
|
|
|
+if test "$HAVE_POPPLER" = "yes" -a "$PDF_PLUGIN" = "no"; then
|
|
+ LIBS="${POPPLER_LIBS} ${LIBS}"
|
|
+fi
|
|
+
|
|
AC_SUBST(HAVE_POPPLER, $HAVE_POPPLER)
|
|
-AC_SUBST(POPPLER_HAS_OPTCONTENT, $POPPLER_HAS_OPTCONTENT)
|
|
-AC_SUBST(POPPLER_BASE_STREAM_HAS_TWO_ARGS, $POPPLER_BASE_STREAM_HAS_TWO_ARGS)
|
|
-AC_SUBST(POPPLER_0_20_OR_LATER, $POPPLER_0_20_OR_LATER)
|
|
-AC_SUBST(POPPLER_0_23_OR_LATER, $POPPLER_0_23_OR_LATER)
|
|
-AC_SUBST(POPPLER_0_58_OR_LATER, $POPPLER_0_58_OR_LATER)
|
|
-AC_SUBST(POPPLER_0_69_OR_LATER, $POPPLER_0_69_OR_LATER)
|
|
-AC_SUBST(POPPLER_INC, $POPPLER_INC)
|
|
-AC_SUBST(POPPLER_PLUGIN_LIB, $POPPLER_PLUGIN_LIB)
|
|
+AC_SUBST(POPPLER_MAJOR_VERSION, $POPPLER_MAJOR_VERSION)
|
|
+AC_SUBST(POPPLER_MINOR_VERSION, $POPPLER_MINOR_VERSION)
|
|
+AC_SUBST(POPPLER_CFLAGS, $POPPLER_CFLAGS)
|
|
+AC_SUBST(POPPLER_PLUGIN_LIB, $POPPLER_LIBS)
|
|
|
|
dnl ---------------------------------------------------------------------------
|
|
dnl Check if libpodofo is available
|
|
diff --git a/gdal/frmts/pdf/GNUmakefile b/gdal/frmts/pdf/GNUmakefile
|
|
index 6a267f529b2..1ce563a5144 100644
|
|
--- a/gdal/frmts/pdf/GNUmakefile
|
|
+++ b/gdal/frmts/pdf/GNUmakefile
|
|
@@ -11,31 +11,7 @@ LD_SHARED = $(LD) -bundle
|
|
endif
|
|
|
|
ifeq ($(HAVE_POPPLER),yes)
|
|
-CPPFLAGS += -DHAVE_POPPLER
|
|
-endif
|
|
-
|
|
-ifeq ($(POPPLER_HAS_OPTCONTENT),yes)
|
|
-CPPFLAGS += -DPOPPLER_HAS_OPTCONTENT
|
|
-endif
|
|
-
|
|
-ifeq ($(POPPLER_BASE_STREAM_HAS_TWO_ARGS),yes)
|
|
-CPPFLAGS += -DPOPPLER_BASE_STREAM_HAS_TWO_ARGS
|
|
-endif
|
|
-
|
|
-ifeq ($(POPPLER_0_20_OR_LATER),yes)
|
|
-CPPFLAGS += -DPOPPLER_0_20_OR_LATER
|
|
-endif
|
|
-
|
|
-ifeq ($(POPPLER_0_23_OR_LATER),yes)
|
|
-CPPFLAGS += -DPOPPLER_0_23_OR_LATER
|
|
-endif
|
|
-
|
|
-ifeq ($(POPPLER_0_58_OR_LATER),yes)
|
|
-CPPFLAGS += -DPOPPLER_0_58_OR_LATER
|
|
-endif
|
|
-
|
|
-ifeq ($(POPPLER_0_69_OR_LATER),yes)
|
|
-CPPFLAGS += -DPOPPLER_0_69_OR_LATER
|
|
+CPPFLAGS += -DHAVE_POPPLER -DPOPPLER_MAJOR_VERSION=$(POPPLER_MAJOR_VERSION) -DPOPPLER_MINOR_VERSION=$(POPPLER_MINOR_VERSION)
|
|
endif
|
|
|
|
ifeq ($(HAVE_PODOFO),yes)
|
|
diff --git a/gdal/frmts/pdf/pdfdataset.cpp b/gdal/frmts/pdf/pdfdataset.cpp
|
|
index 6e8223e4708..27c9b552431 100644
|
|
--- a/gdal/frmts/pdf/pdfdataset.cpp
|
|
+++ b/gdal/frmts/pdf/pdfdataset.cpp
|
|
@@ -130,7 +130,7 @@ class ObjectAutoFree : public Object
|
|
public:
|
|
ObjectAutoFree() {}
|
|
~ObjectAutoFree() {
|
|
-#ifndef POPPLER_0_58_OR_LATER
|
|
+#if !(POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58)
|
|
obj.free();
|
|
#endif
|
|
}
|
|
@@ -176,17 +176,10 @@ class GDALPDFOutputDev : public SplashOutputDev
|
|
void SetEnableText(int bFlag) { bEnableText = bFlag; }
|
|
void SetEnableBitmap(int bFlag) { bEnableBitmap = bFlag; }
|
|
|
|
- virtual void startPage(int pageNum, GfxState *state
|
|
-#ifdef POPPLER_0_23_OR_LATER
|
|
- ,XRef* xrefIn
|
|
-#endif
|
|
+ virtual void startPage(int pageNum, GfxState *state,XRef* xrefIn
|
|
) override
|
|
{
|
|
- SplashOutputDev::startPage(pageNum, state
|
|
-#ifdef POPPLER_0_23_OR_LATER
|
|
- ,xrefIn
|
|
-#endif
|
|
- );
|
|
+ SplashOutputDev::startPage(pageNum, state,xrefIn);
|
|
SplashBitmap* poBitmap = getBitmap();
|
|
memset(poBitmap->getDataPtr(), 255, poBitmap->getRowSize() * poBitmap->getHeight());
|
|
}
|
|
@@ -226,15 +219,6 @@ class GDALPDFOutputDev : public SplashOutputDev
|
|
SplashOutputDev::beginTextObject(state);
|
|
}
|
|
|
|
-#ifndef POPPLER_0_23_OR_LATER
|
|
- virtual GBool deviceHasTextClip(GfxState *state) override
|
|
- {
|
|
- if (bEnableText)
|
|
- return SplashOutputDev::deviceHasTextClip(state);
|
|
- return gFalse;
|
|
- }
|
|
-#endif
|
|
-
|
|
virtual void endTextObject(GfxState *state) override
|
|
{
|
|
if (bEnableText)
|
|
@@ -260,7 +244,6 @@ class GDALPDFOutputDev : public SplashOutputDev
|
|
}
|
|
}
|
|
|
|
-#ifdef POPPLER_0_20_OR_LATER
|
|
virtual void setSoftMaskFromImageMask(GfxState *state,
|
|
Object *ref, Stream *str,
|
|
int width, int height, GBool invert,
|
|
@@ -279,7 +262,6 @@ class GDALPDFOutputDev : public SplashOutputDev
|
|
if (bEnableBitmap)
|
|
SplashOutputDev::unsetSoftMaskFromImageMask(state, baseMatrix);
|
|
}
|
|
-#endif
|
|
|
|
virtual void drawImage(GfxState *state, Object *ref, Stream *str,
|
|
int width, int height, GfxImageColorMap *colorMap,
|
|
@@ -1758,11 +1740,7 @@ CPLErr PDFDataset::ReadPixels( int nReqXOff, int nReqYOff,
|
|
}
|
|
|
|
PDFDoc* poDoc = poDocPoppler;
|
|
-#ifdef POPPLER_0_20_OR_LATER
|
|
poSplashOut->startDoc(poDoc);
|
|
-#else
|
|
- poSplashOut->startDoc(poDoc->getXRef());
|
|
-#endif
|
|
|
|
/* EVIL: we modify a private member... */
|
|
/* poppler (at least 0.12 and 0.14 versions) don't render correctly */
|
|
@@ -1770,12 +1748,10 @@ CPLErr PDFDataset::ReadPixels( int nReqXOff, int nReqYOff,
|
|
/* in those cases. This processing of optional content is an addition of */
|
|
/* poppler in comparison to original xpdf, which hasn't the issue. All in */
|
|
/* all, nullifying optContent removes the error message and improves the rendering */
|
|
-#ifdef POPPLER_HAS_OPTCONTENT
|
|
Catalog* poCatalog = poDoc->getCatalog();
|
|
OCGs* poOldOCGs = poCatalog->optContent;
|
|
if (!bUseOCG)
|
|
poCatalog->optContent = nullptr;
|
|
-#endif
|
|
poDoc->displayPageSlice(poSplashOut,
|
|
iPage,
|
|
dfDPI, dfDPI,
|
|
@@ -1785,9 +1761,7 @@ CPLErr PDFDataset::ReadPixels( int nReqXOff, int nReqYOff,
|
|
nReqXSize, nReqYSize);
|
|
|
|
/* Restore back */
|
|
-#ifdef POPPLER_HAS_OPTCONTENT
|
|
poCatalog->optContent = poOldOCGs;
|
|
-#endif
|
|
|
|
SplashBitmap* poBitmap = poSplashOut->getBitmap();
|
|
if (poBitmap->getWidth() != nReqXSize || poBitmap->getHeight() != nReqYSize)
|
|
@@ -2294,7 +2268,7 @@ GDALPDFObject* PDFDataset::GetCatalog()
|
|
if (bUseLib.test(PDFLIB_POPPLER))
|
|
{
|
|
poCatalogObjectPoppler = new ObjectAutoFree;
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
*poCatalogObjectPoppler->getObj() = poDocPoppler->getXRef()->getCatalog();
|
|
#else
|
|
poDocPoppler->getXRef()->getCatalog(poCatalogObjectPoppler->getObj());
|
|
@@ -2592,16 +2566,10 @@ static void PDFDatasetErrorFunctionCommon(const CPLString& osError)
|
|
CPLError(CE_Failure, CPLE_AppDefined, "%s", osError.c_str());
|
|
}
|
|
|
|
-#ifdef POPPLER_0_20_OR_LATER
|
|
-
|
|
static void PDFDatasetErrorFunction(void* /* userData*/,
|
|
ErrorCategory /* eErrCategory */,
|
|
-#ifdef POPPLER_0_23_OR_LATER
|
|
Goffset nPos,
|
|
-#else
|
|
- int nPos,
|
|
-#endif
|
|
-#ifdef POPPLER_0_71_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 71
|
|
const char *pszMsg
|
|
#else
|
|
char *pszMsg
|
|
@@ -2615,17 +2583,6 @@ static void PDFDatasetErrorFunction(void* /* userData*/,
|
|
osError += pszMsg;
|
|
PDFDatasetErrorFunctionCommon(osError);
|
|
}
|
|
-#else
|
|
-static void PDFDatasetErrorFunction(int nPos, char *pszMsg, va_list args)
|
|
-{
|
|
- CPLString osError;
|
|
-
|
|
- if (nPos >= 0)
|
|
- osError.Printf("Pos = %d, ", nPos);
|
|
- osError += CPLString().vPrintf(pszMsg, args);
|
|
- PDFDatasetErrorFunctionCommon(osError);
|
|
-}
|
|
-#endif
|
|
#endif
|
|
|
|
/************************************************************************/
|
|
@@ -3447,7 +3404,7 @@ void PDFDataset::FindLayersPoppler()
|
|
}
|
|
else
|
|
{
|
|
-#ifdef POPPLER_0_69_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 69
|
|
for( const auto& refOCGPair: optContentConfig->getOCGs() )
|
|
{
|
|
auto ocg = refOCGPair.second.get();
|
|
@@ -3485,7 +3442,7 @@ void PDFDataset::TurnLayersOnOffPoppler()
|
|
{
|
|
int i;
|
|
int bAll = EQUAL(pszLayers, "ALL");
|
|
-#ifdef POPPLER_0_69_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 69
|
|
for( const auto& refOCGPair: optContentConfig->getOCGs() )
|
|
{
|
|
auto ocg = refOCGPair.second.get();
|
|
@@ -4058,7 +4015,7 @@ GDALDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo )
|
|
GDALPDFObject* poPageObj = nullptr;
|
|
#ifdef HAVE_POPPLER
|
|
PDFDoc* poDocPoppler = nullptr;
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
Object oObj;
|
|
#else
|
|
ObjectAutoFree oObj;
|
|
@@ -4082,11 +4039,7 @@ GDALDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo )
|
|
GooString* poUserPwd = nullptr;
|
|
|
|
/* Set custom error handler for poppler errors */
|
|
-#ifdef POPPLER_0_20_OR_LATER
|
|
setErrorCallback(PDFDatasetErrorFunction, nullptr);
|
|
-#else
|
|
- setErrorFunction(PDFDatasetErrorFunction);
|
|
-#endif
|
|
|
|
{
|
|
CPLMutexHolderD(&hGlobalParamsMutex);
|
|
@@ -4109,7 +4062,7 @@ GDALDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo )
|
|
if (pszUserPwd)
|
|
poUserPwd = new GooString(pszUserPwd);
|
|
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
poDocPoppler = new PDFDoc(new VSIPDFFileStream(fp, pszFilename, std::move(oObj)), nullptr, poUserPwd);
|
|
#else
|
|
oObj.getObj()->initNull();
|
|
@@ -4803,14 +4756,14 @@ GDALDataset *PDFDataset::Open( GDALOpenInfo * poOpenInfo )
|
|
if( poDocPoppler->getXRef()->isOk() )
|
|
{
|
|
Object oInfo;
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
oInfo = poDocPoppler->getDocInfo();
|
|
#else
|
|
poDocPoppler->getDocInfo(&oInfo);
|
|
#endif
|
|
GDALPDFObjectPoppler oInfoObjPoppler(&oInfo, FALSE);
|
|
poDS->ParseInfo(&oInfoObjPoppler);
|
|
-#ifndef POPPLER_0_58_OR_LATER
|
|
+#if !(POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58)
|
|
oInfo.free();
|
|
#endif
|
|
}
|
|
diff --git a/gdal/frmts/pdf/pdfio.cpp b/gdal/frmts/pdf/pdfio.cpp
|
|
index 582d0632b41..7850e0d292a 100644
|
|
--- a/gdal/frmts/pdf/pdfio.cpp
|
|
+++ b/gdal/frmts/pdf/pdfio.cpp
|
|
@@ -36,7 +36,6 @@
|
|
|
|
CPL_CVSID("$Id: pdfio.cpp 7e07230bbff24eb333608de4dbd460b7312839d0 2017-12-11 19:08:47Z Even Rouault $")
|
|
|
|
-#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS
|
|
/* Poppler 0.31.0 is the first one that needs to know the file size */
|
|
static vsi_l_offset VSIPDFFileStreamGetSize(VSILFILE* f)
|
|
{
|
|
@@ -45,7 +44,6 @@ static vsi_l_offset VSIPDFFileStreamGetSize(VSILFILE* f)
|
|
VSIFSeekL(f, 0, SEEK_SET);
|
|
return nSize;
|
|
}
|
|
-#endif
|
|
|
|
/************************************************************************/
|
|
/* VSIPDFFileStream() */
|
|
@@ -55,12 +53,10 @@ VSIPDFFileStream::VSIPDFFileStream(
|
|
VSILFILE* fIn, const char* pszFilename,
|
|
makeSubStream_object_type dictA
|
|
) :
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
BaseStream(std::move(dictA), (Goffset)VSIPDFFileStreamGetSize(fIn)),
|
|
-#elif defined(POPPLER_BASE_STREAM_HAS_TWO_ARGS)
|
|
- BaseStream(dictA, (setPos_offset_type)VSIPDFFileStreamGetSize(fIn)),
|
|
#else
|
|
- BaseStream(dictA),
|
|
+ BaseStream(dictA, (setPos_offset_type)VSIPDFFileStreamGetSize(fIn)),
|
|
#endif
|
|
poParent(nullptr),
|
|
poFilename(new GooString(pszFilename)),
|
|
@@ -83,12 +79,10 @@ VSIPDFFileStream::VSIPDFFileStream( VSIPDFFileStream* poParentIn,
|
|
vsi_l_offset startA, GBool limitedA,
|
|
vsi_l_offset lengthA,
|
|
makeSubStream_object_type dictA) :
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
BaseStream(std::move(dictA), (Goffset)lengthA),
|
|
-#elif defined(POPPLER_BASE_STREAM_HAS_TWO_ARGS)
|
|
- BaseStream(dictA, (makeSubStream_offset_type)lengthA),
|
|
#else
|
|
- BaseStream(dictA),
|
|
+ BaseStream(dictA, (makeSubStream_offset_type)lengthA),
|
|
#endif
|
|
poParent(poParentIn),
|
|
poFilename(poParentIn->poFilename),
|
|
@@ -122,13 +116,13 @@ VSIPDFFileStream::~VSIPDFFileStream()
|
|
/* copy() */
|
|
/************************************************************************/
|
|
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
BaseStream* VSIPDFFileStream::copy()
|
|
{
|
|
return new VSIPDFFileStream(poParent, nStart, bLimited,
|
|
nLength, dict.copy());
|
|
}
|
|
-#elif defined(POPPLER_0_23_OR_LATER)
|
|
+#else
|
|
BaseStream* VSIPDFFileStream::copy()
|
|
{
|
|
return new VSIPDFFileStream(poParent, nStart, bLimited,
|
|
@@ -142,7 +136,7 @@ BaseStream* VSIPDFFileStream::copy()
|
|
Stream *VSIPDFFileStream::makeSubStream(makeSubStream_offset_type startA, GBool limitedA,
|
|
makeSubStream_offset_type lengthA, makeSubStream_object_type dictA)
|
|
{
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
return new VSIPDFFileStream(this,
|
|
startA, limitedA,
|
|
lengthA, std::move(dictA));
|
|
diff --git a/gdal/frmts/pdf/pdfio.h b/gdal/frmts/pdf/pdfio.h
|
|
index 2d58059e801..7ae15c88aa3 100644
|
|
--- a/gdal/frmts/pdf/pdfio.h
|
|
+++ b/gdal/frmts/pdf/pdfio.h
|
|
@@ -38,34 +38,27 @@
|
|
|
|
#define BUFFER_SIZE 1024
|
|
|
|
-#ifdef POPPLER_0_23_OR_LATER
|
|
#define getPos_ret_type Goffset
|
|
#define getStart_ret_type Goffset
|
|
#define makeSubStream_offset_type Goffset
|
|
#define setPos_offset_type Goffset
|
|
#define moveStart_delta_type Goffset
|
|
-#else
|
|
-#define getPos_ret_type int
|
|
-#define getStart_ret_type Guint
|
|
-#define makeSubStream_offset_type Guint
|
|
-#define setPos_offset_type Guint
|
|
-#define moveStart_delta_type int
|
|
-#endif
|
|
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
#define makeSubStream_object_type Object&&
|
|
#else
|
|
#define makeSubStream_object_type Object*
|
|
#endif
|
|
|
|
// Detect Poppler 0.71 that no longer defines GBool
|
|
-#ifdef POPPLER_0_69_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 69
|
|
#ifndef initObj
|
|
-#define POPPLER_0_71_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 71
|
|
#define GBool bool
|
|
#define gFalse false
|
|
#endif
|
|
#endif
|
|
+#endif
|
|
|
|
class VSIPDFFileStream final: public BaseStream
|
|
{
|
|
@@ -78,9 +71,7 @@ class VSIPDFFileStream final: public BaseStream
|
|
makeSubStream_object_type dictA);
|
|
virtual ~VSIPDFFileStream();
|
|
|
|
-#ifdef POPPLER_0_23_OR_LATER
|
|
virtual BaseStream* copy() override;
|
|
-#endif
|
|
|
|
virtual Stream * makeSubStream(makeSubStream_offset_type startA, GBool limitedA,
|
|
makeSubStream_offset_type lengthA, makeSubStream_object_type dictA) override;
|
|
@@ -102,7 +93,6 @@ class VSIPDFFileStream final: public BaseStream
|
|
virtual void close() override;
|
|
|
|
private:
|
|
-#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS
|
|
/* getChars/hasGetChars added in poppler 0.15.0
|
|
* POPPLER_BASE_STREAM_HAS_TWO_ARGS true from poppler 0.16,
|
|
* This test will be wrong for poppler 0.15 or 0.16,
|
|
@@ -110,10 +100,6 @@ class VSIPDFFileStream final: public BaseStream
|
|
*/
|
|
virtual GBool hasGetChars() override;
|
|
virtual int getChars(int nChars, Guchar *buffer) override;
|
|
-#else
|
|
- virtual GBool hasGetChars() ;
|
|
- virtual int getChars(int nChars, Guchar *buffer) ;
|
|
-#endif
|
|
|
|
VSIPDFFileStream *poParent;
|
|
GooString *poFilename;
|
|
diff --git a/gdal/frmts/pdf/pdfobject.cpp b/gdal/frmts/pdf/pdfobject.cpp
|
|
index e8929aa1810..cc87a8ec258 100644
|
|
--- a/gdal/frmts/pdf/pdfobject.cpp
|
|
+++ b/gdal/frmts/pdf/pdfobject.cpp
|
|
@@ -971,7 +971,7 @@ class GDALPDFStreamPoppler : public GDALPDFStream
|
|
|
|
GDALPDFObjectPoppler::~GDALPDFObjectPoppler()
|
|
{
|
|
-#ifndef POPPLER_0_58_OR_LATER
|
|
+#if !(POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58)
|
|
m_po->free();
|
|
#endif
|
|
if (m_bDestroy)
|
|
@@ -1055,7 +1055,7 @@ const CPLString& GDALPDFObjectPoppler::GetString()
|
|
{
|
|
if (GetType() == PDFObjectType_String)
|
|
{
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
// At least available since poppler 0.41
|
|
const GooString* gooString = m_po->getString();
|
|
#else
|
|
@@ -1189,7 +1189,7 @@ GDALPDFObject* GDALPDFDictionaryPoppler::Get(const char* pszKey)
|
|
if (oIter != m_map.end())
|
|
return oIter->second;
|
|
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
Object o = m_poDict->lookupNF(((char*)pszKey));
|
|
if (!o.isNull())
|
|
{
|
|
@@ -1323,7 +1323,7 @@ GDALPDFObject* GDALPDFArrayPoppler::Get(int nIndex)
|
|
if (m_v[nIndex] != nullptr)
|
|
return m_v[nIndex];
|
|
|
|
-#ifdef POPPLER_0_58_OR_LATER
|
|
+#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58
|
|
Object o = m_poArray->getNF(nIndex);
|
|
if( !o.isNull() )
|
|
{
|
|
diff --git a/gdal/nmake.opt b/gdal/nmake.opt
|
|
index 318f9ed784c..96f52297f25 100644
|
|
--- a/gdal/nmake.opt
|
|
+++ b/gdal/nmake.opt
|
|
@@ -640,20 +640,11 @@ OCI_INCLUDE = -I$(ORACLE_HOME)\oci\include
|
|
#ZLIB_INC = -IC:\projects\zlib
|
|
#ZLIB_LIB = C:\projects\lib\Release\zlib.lib
|
|
|
|
-# Uncomment for PDF support
|
|
-# Uncomment POPPLER_BASE_STREAM_HAS_TWO_ARGS = YES for Poppler >= 0.16.0
|
|
-# Uncomment POPPLER_0_20_OR_LATER = YES for Poppler >= 0.20.0
|
|
-# Uncomment POPPLER_0_23_OR_LATER = YES for Poppler >= 0.23.0
|
|
-# Uncomment POPPLER_0_58_OR_LATER = YES for Poppler >= 0.58.0
|
|
-# Uncomment POPPLER_0_69_OR_LATER = YES for Poppler >= 0.69.0
|
|
+# Uncomment for PDF support, and update version numbers (poppler 0.23 or later required)
|
|
#POPPLER_ENABLED = YES
|
|
#POPPLER_CFLAGS = -Ie:/kde/include -Ie:/kde/include/poppler
|
|
-#POPPLER_HAS_OPTCONTENT = YES
|
|
-#POPPLER_BASE_STREAM_HAS_TWO_ARGS = YES
|
|
-#POPPLER_0_20_OR_LATER = YES
|
|
-#POPPLER_0_23_OR_LATER = YES
|
|
-#POPPLER_0_58_OR_LATER = YES
|
|
-#POPPLER_0_69_OR_LATER = YES
|
|
+#POPPLER_MAJOR_VERSION = 0
|
|
+#POPPLER_MINOR_VERSION = 69
|
|
#POPPLER_LIBS = e:/kde/lib/poppler.lib e:/kde/lib/freetype.lib e:/kde/lib/liblcms-1.lib advapi32.lib gdi32.lib
|
|
|
|
# Uncomment for PDF support
|