summaryrefslogtreecommitdiffstats
path: root/development/gambas3/adapt-to-poppler-0.58.patch
blob: b2819da5692e0b5aa993ab5a2e1068355cb76f46 (plain)
From 6a4adabfd7e02e6fef99049e8e2373b12b559e69 Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
Date: Wed, 6 Sep 2017 12:58:12 +0200
Subject: [PATCH] adapt to poppler 0.58

---
 gb.pdf/configure.ac         |  2 ++
 gb.pdf/src/CPdfDocument.cpp | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/gb.pdf/configure.ac b/gb.pdf/configure.ac
index 25b344a9a..be4bf9557 100644
--- a/gb.pdf/configure.ac
+++ b/gb.pdf/configure.ac
@@ -29,6 +29,8 @@ if test "$have_poppler" = "yes"; then
   AC_DEFINE_UNQUOTED(POPPLER_VERSION_0_17, $((1-$?)), Poppler version >= 0.17)
   pkg-config --atleast-version=0.20.0 poppler
   AC_DEFINE_UNQUOTED(POPPLER_VERSION_0_20, $((1-$?)), Poppler version >= 0.20)
+  pkg-config --atleast-version=0.58.0 poppler
+  AC_DEFINE_UNQUOTED(POPPLER_VERSION_0_58, $((1-$?)), Poppler version >= 0.58)
 fi
 
 AC_OUTPUT( \
diff --git a/gb.pdf/src/CPdfDocument.cpp b/gb.pdf/src/CPdfDocument.cpp
index 43802c77b..80d2d97c5 100644
--- a/gb.pdf/src/CPdfDocument.cpp
+++ b/gb.pdf/src/CPdfDocument.cpp
@@ -132,11 +132,19 @@ static void aux_return_string_info(void *_object, const char *key)
 	Dict *info_dict;
 	char *tmpstr;
 
+	#if POPPLER_VERSION_0_58
+	obj = THIS->doc->getDocInfo ();
+	#else
 	THIS->doc->getDocInfo (&obj);
+	#endif
 	if (!obj.isDict()) { GB.ReturnNewZeroString(""); return; }
 		
 	info_dict=obj.getDict();
+	#if POPPLER_VERSION_0_58
+	dst = info_dict->lookup ((char *)key);
+	#else
 	info_dict->lookup ((char *)key, &dst);
+	#endif
 	if (!dst.isString ()) { GB.ReturnNewZeroString(""); }
 	else {
 		goo_value = dst.getString();
@@ -149,8 +157,10 @@ static void aux_return_string_info(void *_object, const char *key)
 		else
 			GB.ReturnNewString(goo_value->getCString(),goo_value->getLength());		
 	}
+	#if ! POPPLER_VERSION_0_58
 	dst.free();
 	obj.free();		
+	#endif
 }
 
 static void aux_return_date_info(void *_object, const char *key)
@@ -167,11 +177,19 @@ static void aux_return_date_info(void *_object, const char *key)
 
 	GB.ReturnDate(NULL);
 	
+	#if POPPLER_VERSION_0_58
+	obj = THIS->doc->getDocInfo ();
+	#else
 	THIS->doc->getDocInfo (&obj);
+	#endif
 	if (!obj.isDict()) return;
 
 	info_dict=obj.getDict();
+	#if POPPLER_VERSION_0_58
+	dst = info_dict->lookup ((char *)key);
+	#else
 	info_dict->lookup ((char *)key, &dst);
+	#endif
 	if (dst.isString ())
 	{
 		goo = dst.getString();
@@ -197,8 +215,10 @@ static void aux_return_date_info(void *_object, const char *key)
 	}
 
 	if (tofree) GB.FreeString(&tofree);
+	#if ! POPPLER_VERSION_0_58
 	dst.free();
 	obj.free();
+	#endif
 }
 
 static LinkDest *get_dest(LinkAction *act)
@@ -426,8 +446,12 @@ int32_t open_document (void *_object, char *sfile, int32_t lfile)
 
 	if ( GB.LoadFile(sfile,lfile,&buf,&len) ) return -1;
 
+	#if POPPLER_VERSION_0_58
+	stream=new MemStream(buf,0,(Guint)len,std::move(obj));
+	#else
 	obj.initNull();
 	stream=new MemStream(buf,0,(Guint)len,&obj);
+	#endif
 	test=new PDFDoc (stream,0,0);
 
 	if (!test->isOk())
-- 
2.13.5