71 lines
2.2 KiB
Diff
71 lines
2.2 KiB
Diff
|
From: Amin Bandali <bandali@canonical.com>
|
||
|
Date: Wed, 14 Feb 2024 09:56:10 -0500
|
||
|
Subject: make 'gb.pdf' compile with poppler 24.02.0
|
||
|
Forwarded: https://gitlab.com/gambas/gambas/-/merge_requests/330
|
||
|
|
||
|
---
|
||
|
gb.pdf/configure.ac | 2 ++
|
||
|
gb.pdf/src/CPdfDocument.cpp | 21 +++++++++++++++++++++
|
||
|
2 files changed, 23 insertions(+)
|
||
|
|
||
|
diff --git a/gb.pdf/configure.ac b/gb.pdf/configure.ac
|
||
|
index 6931e2c48..6e612e40a 100644
|
||
|
--- a/gb.pdf/configure.ac
|
||
|
+++ b/gb.pdf/configure.ac
|
||
|
@@ -34,6 +34,8 @@ if test "$have_poppler" = "yes"; then
|
||
|
AC_DEFINE_UNQUOTED(POPPLER_VERSION_21_06_0, $((1-$?)), Poppler version >= 21.06.0)
|
||
|
$PKG_CONFIG --atleast-version=22.06.0 poppler
|
||
|
AC_DEFINE_UNQUOTED(POPPLER_VERSION_22_06_0, $((1-$?)), Poppler version >= 22.06.0)
|
||
|
+ $PKG_CONFIG --atleast-version=24.02.0 poppler
|
||
|
+ AC_DEFINE_UNQUOTED(POPPLER_VERSION_24_02_0, $((1-$?)), Poppler version >= 24.02.0)
|
||
|
fi
|
||
|
|
||
|
AC_CONFIG_FILES([\
|
||
|
diff --git a/gb.pdf/src/CPdfDocument.cpp b/gb.pdf/src/CPdfDocument.cpp
|
||
|
index 8f4aac7fb..5dfbfefc1 100644
|
||
|
--- a/gb.pdf/src/CPdfDocument.cpp
|
||
|
+++ b/gb.pdf/src/CPdfDocument.cpp
|
||
|
@@ -102,6 +102,22 @@ END_PROPERTY
|
||
|
|
||
|
****************************************************************************/
|
||
|
|
||
|
+#if POPPLER_VERSION_24_02_0
|
||
|
+static void return_unicode_string(const std::vector<Unicode> &unicode)
|
||
|
+{
|
||
|
+ GooString gstr;
|
||
|
+ char buf[8]; /* 8 is enough for mapping an unicode char to a string */
|
||
|
+ int n;
|
||
|
+
|
||
|
+ const UnicodeMap *uMap = globalParams->getUtf8Map();
|
||
|
+ for (const auto &c : unicode) {
|
||
|
+ n = uMap->mapUnicode(c, buf, sizeof(buf));
|
||
|
+ gstr.append(buf, n);
|
||
|
+ }
|
||
|
+
|
||
|
+ GB.ReturnNewZeroString(gstr.getCString());
|
||
|
+}
|
||
|
+#else
|
||
|
static void return_unicode_string(const Unicode *unicode, int len)
|
||
|
{
|
||
|
GooString gstr;
|
||
|
@@ -128,6 +144,7 @@ static void return_unicode_string(const Unicode *unicode, int len)
|
||
|
|
||
|
GB.ReturnNewZeroString(gstr.getCString());
|
||
|
}
|
||
|
+#endif
|
||
|
|
||
|
|
||
|
static void aux_return_string_info(void *_object, const char *key)
|
||
|
@@ -776,7 +793,11 @@ END_PROPERTY
|
||
|
BEGIN_PROPERTY(PDFINDEX_title)
|
||
|
|
||
|
OutlineItem *item = CPDF_index_get(THIS->currindex);
|
||
|
+#if POPPLER_VERSION_24_02_0
|
||
|
+ return_unicode_string(item->getTitle());
|
||
|
+#else
|
||
|
return_unicode_string(item->getTitle(), item->getTitleLength());
|
||
|
+#endif
|
||
|
|
||
|
END_PROPERTY
|
||
|
|