make 'gb.pdf' compile with poppler 24.02.0
authorAmin Bandali <bandali@canonical.com>
Wed, 14 Feb 2024 14:56:10 +0000 (09:56 -0500)
committerBastian Germann <bage@debian.org>
Fri, 16 Feb 2024 19:44:32 +0000 (19:44 +0000)
Forwarded: https://gitlab.com/gambas/gambas/-/merge_requests/330

Gbp-Pq: Name make-gb.pdf-compile-with-poppler-24.02.0.patch

gb.pdf/configure.ac
gb.pdf/src/CPdfDocument.cpp

index 6931e2c4887c3b34054819313af915a930820272..6e612e40a9cc1acd8ea1aad10f0b97a85d2fd140 100644 (file)
@@ -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([\
index 8f4aac7fba4b4d2670fa3be6ee759c31e66c8493..5dfbfefc11b93c9d0074cda0c243412376c6ba31 100644 (file)
@@ -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