Source:
https://build.opensuse.org/projects/graphics/packages/inkscape/files/fix_build_with_poppler_26.07.patch

From eebf0342cbfcd23c6cba6053dd6ab7306d0de065 Mon Sep 17 00:00:00 2001
From: KrIr17 <elendil.krir17@gmail.com>
Date: Sat, 4 Jul 2026 14:07:44 +0200
Subject: [PATCH] Fix building with Poppler 26.07.0

1. `arrayGetfoo()` to `getArray()->getFoo()`  [1]
2. `streamGetFoo()` to `getStream()->getFoo()` [2]
3. indextolabel now requires an `std::string *` and not `GooString *`
   introduced _POPPLER_STRING_26_7 that changes accordingly.

Relevant poppler commits:

[1]  [Remove Object::arrayGetNF](https://gitlab.freedesktop.org/poppler/poppler/-/commit/d9ffc4c29d1975a5c81d6bac9d8a1b6dc5aa1f50): Technically only arrayGetNF was removed, but perusing the commit shows that all `arrayGetFoo` are being changed. I assume they are slated for removal in future releases.

[2]  [Remove Object::streamGetDict](gitlab.freedesktop.org/poppler/poppler/-/commit/87edb5a5c40e67e782e54a14a2251547b4acdfb5)

[3]  [Use std::string instead of GooString for label](https://gitlab.freedesktop.org/poppler/poppler/-/commit/9e34004aae04064f1b798b5e711e13d0dddacf9e)

(cherry picked from commit 9262f83aff7d8a6cadcb42446f9b943a561910cf)
---
 src/extension/internal/pdfinput/pdf-input.cpp |  5 +-
 .../internal/pdfinput/pdf-parser.cpp          | 50 +++++++++----------
 .../pdfinput/poppler-transition-api.h         |  6 +++
 .../internal/pdfinput/poppler-utils.cpp       | 29 ++++++-----
 .../internal/pdfinput/poppler-utils.h         |  1 +
 5 files changed, 52 insertions(+), 39 deletions(-)

diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 441871bb10..3507ce4173 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -855,9 +855,10 @@ PdfInput::add_builder_page(std::shared_ptr<PDFDoc>pdf_doc, SvgBuilder *builder,
 
     // Parse the annotations
     if (auto annots = page->getAnnotsObject(); annots.isArray()) {
-        auto const size = annots.arrayGetLength();
+        auto* annotsArray = annots.getArray();
+        auto const size = annotsArray->getLength();
         for (int i = 0; i < size; i++) {
-            pdf_parser.build_annots(annots.arrayGet(i), page_num);
+            pdf_parser.build_annots(annotsArray->get(i), page_num);
         }
     }
 }
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index e32fa24b32..bf8daaac1b 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -293,8 +293,8 @@ PdfParser::PdfParser(std::shared_ptr<PDFDoc> pdf_doc, Inkscape::Extension::Inter
     if (page) {
         // Increment the page building here and set page label
         Catalog *catalog = pdf_doc->getCatalog();
-        GooString *label = new GooString("");
-        catalog->indexToLabel(page->getNum() - 1, label);
+        _POPPLER_STRING_26_7 label;
+        catalog->indexToLabel(page->getNum() - 1, &label);
         builder->pushPage(getString(label), state);
     }
 
@@ -370,8 +370,8 @@ void PdfParser::parse(Object *obj, GBool topLevel) {
   Object obj2;
 
   if (obj->isArray()) {
-    for (int i = 0; i < obj->arrayGetLength(); ++i) {
-      _POPPLER_CALL_ARGS(obj2, obj->arrayGet, i);
+    for (int i = 0; i < obj->getArray()->getLength(); ++i) {
+      _POPPLER_CALL_ARGS(obj2, obj->getArray()->get, i);
       if (!obj2.isStream()) {
 	error(errInternal, -1, "Weird page contents");
 	_POPPLER_FREE(obj2);
@@ -808,8 +808,8 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
                 for (int &i : backdropColor.c) {
                     i = 0;
                 }
-                for (int i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; ++i) {
-                    _POPPLER_CALL_ARGS(obj4, obj3.arrayGet, i);
+                for (int i = 0; i < obj3.getArray()->getLength() && i < gfxColorMaxComps; ++i) {
+                    _POPPLER_CALL_ARGS(obj4, obj3.getArray()->get, i);
                     if (obj4.isNum()) {
                         backdropColor.c[i] = dblToCol(obj4.getNum());
                     }
@@ -818,7 +818,7 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
             }
             _POPPLER_FREE(obj3);
             if (_POPPLER_CALL_ARGS_DEREF(obj3, obj2.dictLookup, "G").isStream()) {
-                if (_POPPLER_CALL_ARGS_DEREF(obj4, obj3.streamGetDict()->lookup, "Group").isDict()) {
+                if (_POPPLER_CALL_ARGS_DEREF(obj4, obj3.getStream()->getDict()->lookup, "Group").isDict()) {
                     std::unique_ptr<GfxColorSpace> blendingColorSpace;
                     GBool isolated = gFalse;
                     GBool knockout = gFalse;
@@ -881,7 +881,7 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
   }
 
   // get stream dict
-  dict = str->streamGetDict();
+  dict = str->getStream()->getDict();
 
   // check form type
   _POPPLER_CALL_ARGS(obj1, dict->lookup, "FormType");
@@ -898,7 +898,7 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
     return;
   }
   for (i = 0; i < 4; ++i) {
-    _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, i);
+    _POPPLER_CALL_ARGS(obj2, obj1.getArray()->get, i);
     bbox[i] = obj2.getNum();
     _POPPLER_FREE(obj2);
   }
@@ -908,7 +908,7 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
   _POPPLER_CALL_ARGS(obj1, dict->lookup, "Matrix");
   if (obj1.isArray()) {
     for (i = 0; i < 6; ++i) {
-      _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, i);
+      _POPPLER_CALL_ARGS(obj2, obj1.getArray()->get, i);
       m[i] = obj2.getNum();
       _POPPLER_FREE(obj2);
     }
@@ -2378,7 +2378,7 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
     }
 
 //add layer at root if xObject has type OCG
-    _POPPLER_CALL_ARGS(obj2, obj1.streamGetDict()->lookup, "OC");
+    _POPPLER_CALL_ARGS(obj2, obj1.getStream()->getDict()->lookup, "OC");
     if(obj2.isDict()){
         auto type_dict = obj2.getDict();
         if (type_dict->lookup("Type").isName("OCG")) {
@@ -2396,7 +2396,7 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
         }
     }
 
-    _POPPLER_CALL_ARGS(obj2, obj1.streamGetDict()->lookup, "Subtype");
+    _POPPLER_CALL_ARGS(obj2, obj1.getStream()->getDict()->lookup, "Subtype");
     if (obj2.isName(const_cast<char*>("Image"))) {
         _POPPLER_CALL_ARGS(refObj, res->lookupXObjectNF, name);
         doImage(&refObj, obj1.getStream(), gFalse);
@@ -2404,7 +2404,7 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
     } else if (obj2.isName(const_cast<char*>("Form"))) {
         doForm(&obj1);
     } else if (obj2.isName(const_cast<char*>("PS"))) {
-        _POPPLER_CALL_ARGS(obj3, obj1.streamGetDict()->lookup, "Level1");
+        _POPPLER_CALL_ARGS(obj3, obj1.getStream()->getDict()->lookup, "Level1");
     } else if (obj2.isName()) {
         error(errSyntaxError, getPos(), "Unknown XObject subtype '{0:s}'", obj2.getName());
     } else {
@@ -2535,7 +2535,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
             _POPPLER_CALL_ARGS(obj1, dict->lookup, "D");
         }
         if (obj1.isArray()) {
-            _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, 0);
+            _POPPLER_CALL_ARGS(obj2, obj1.getArray()->get, 0);
             if (obj2.isInt() && obj2.getInt() == 1) {
                 invert = gTrue;
             }
@@ -2597,7 +2597,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
 	            goto err1;
             }
             maskStr = smaskObj.getStream();
-            maskDict = smaskObj.streamGetDict();
+            maskDict = smaskObj.getStream()->getDict();
             _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Width");
             if (obj1.isNull()) {
                     _POPPLER_FREE(obj1);
@@ -2663,8 +2663,8 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
         } else if (maskObj.isArray()) {
             // color key mask
             int i;
-            for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) {
-                _POPPLER_CALL_ARGS(obj1, maskObj.arrayGet, i);
+            for (i = 0; i < maskObj.getArray()->getLength() && i < 2*gfxColorMaxComps; ++i) {
+                _POPPLER_CALL_ARGS(obj1, maskObj.getArray()->get, i);
                 maskColors[i] = obj1.getInt();
                 _POPPLER_FREE(obj1);
             }
@@ -2675,7 +2675,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
                 goto err1;
             }
             maskStr = maskObj.getStream();
-            maskDict = maskObj.streamGetDict();
+            maskDict = maskObj.getStream()->getDict();
             _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Width");
             if (obj1.isNull()) {
                 _POPPLER_FREE(obj1);
@@ -2722,7 +2722,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
                 _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "D");
             }
             if (obj1.isArray()) {
-                _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, 0);
+                _POPPLER_CALL_ARGS(obj2, obj1.getArray()->get, 0);
                 if (obj2.isInt() && obj2.getInt() == 1) {
                     maskInvert = gTrue;
                 }
@@ -2775,7 +2775,7 @@ void PdfParser::doForm(Object *str, double *offset)
     }
 
     // get stream dict
-    dict = str->streamGetDict();
+    dict = str->getStream()->getDict();
 
     // check form type
     _POPPLER_CALL_ARGS(obj1, dict->lookup, "FormType");
@@ -2792,7 +2792,7 @@ void PdfParser::doForm(Object *str, double *offset)
         return;
     }
     for (i = 0; i < 4; ++i) {
-        _POPPLER_CALL_ARGS(obj1, bboxObj.arrayGet, i);
+        _POPPLER_CALL_ARGS(obj1, bboxObj.getArray()->get, i);
         bbox[i] = obj1.getNum();
         _POPPLER_FREE(obj1);
     }
@@ -2802,7 +2802,7 @@ void PdfParser::doForm(Object *str, double *offset)
     _POPPLER_CALL_ARGS(matrixObj, dict->lookup, "Matrix");
     if (matrixObj.isArray()) {
         for (i = 0; i < 6; ++i) {
-        _POPPLER_CALL_ARGS(obj1, matrixObj.arrayGet, i);
+        _POPPLER_CALL_ARGS(obj1, matrixObj.getArray()->get, i);
         m[i] = obj1.getNum();
         _POPPLER_FREE(obj1);
         }
@@ -3194,10 +3194,10 @@ void PdfParser::loadColorProfile()
         return;
 
     Object outputIntents = catDict.dictLookup("OutputIntents");
-    if (!outputIntents.isArray() || outputIntents.arrayGetLength() != 1)
+    if (!outputIntents.isArray() || outputIntents.getArray()->getLength() != 1)
         return;
 
-    Object firstElement = outputIntents.arrayGet(0);
+    Object firstElement = outputIntents.getArray()->get(0);
     if (!firstElement.isDict())
         return;
 
@@ -3245,7 +3245,7 @@ void PdfParser::build_annots(const Object &annot, int page_num)
             _POPPLER_CALL_ARGS(Rect_obj, annot_dict->lookup, "Rect");
             if (Rect_obj.isArray()) {
                 for (int i = 0; i < 2; i++) {
-                    _POPPLER_CALL_ARGS(xy_obj, Rect_obj.arrayGet, i);
+                    _POPPLER_CALL_ARGS(xy_obj, Rect_obj.getArray()->get, i);
                     offset[i] = xy_obj.getNum();
                 }
                 doForm(&first_state_obj, offset);
diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
index bf42f54142..058c91f379 100644
--- a/src/extension/internal/pdfinput/poppler-transition-api.h
+++ b/src/extension/internal/pdfinput/poppler-transition-api.h
@@ -15,6 +15,12 @@
 #include <glib/poppler-features.h>
 #include <poppler/UTF.h>
 
+#if POPPLER_CHECK_VERSION(26, 7, 0)
+#define _POPPLER_STRING_26_7 std::string
+#else
+#define _POPPLER_STRING_26_7 GooString
+#endif
+
 #if POPPLER_CHECK_VERSION(26, 6, 0)
 #define _POPPLER_GET_GRAY(color, gray) getGray(color, gray)
 #define _POPPLER_GET_RGB(color, rgb) getRGB(color, rgb)
diff --git a/src/extension/internal/pdfinput/poppler-utils.cpp b/src/extension/internal/pdfinput/poppler-utils.cpp
index 902736281a..d084d9218a 100644
--- a/src/extension/internal/pdfinput/poppler-utils.cpp
+++ b/src/extension/internal/pdfinput/poppler-utils.cpp
@@ -186,15 +186,16 @@ void InkFontDict::hashFontObject1(const Object *obj, FNVHash *h)
         case objNull:
             h->hash('z');
             break;
-        case objArray:
-            h->hash('a');
-            n = obj->arrayGetLength();
-            h->hash((char *)&n, sizeof(int));
-            for (i = 0; i < n; ++i) {
-                const Object &obj2 = obj->arrayGetNF(i);
-                hashFontObject1(&obj2, h);
-            }
-            break;
+        case objArray: {
+                h->hash('a');
+                Array * objArray = obj->getArray();
+                n = objArray->getLength();
+                h->hash((char *)&n, sizeof(int));
+                for (i = 0; i < n; ++i) {
+                    const Object &obj2 = objArray->getNF(i);
+                    hashFontObject1(&obj2, h);
+                }
+            } break;
         case objDict: {
                 h->hash('d');
                 auto objdict = obj->getDict();
@@ -206,8 +207,7 @@ void InkFontDict::hashFontObject1(const Object *obj, FNVHash *h)
                     const Object &obj2 = objdict->getValNF(i);
                     hashFontObject1(&obj2, h);
                 }
-            }
-            break;
+            } break;
         case objStream:
             // this should never happen - streams must be indirect refs
             break;
@@ -545,7 +545,7 @@ void _getFontsRecursive(std::shared_ptr<PDFDoc> pdf_doc, Dict *resources, const
                 continue;
 
             Ref resourcesRef;
-            const Object resObj = obj2.streamGetDict()->lookup("Resources", &resourcesRef);
+            const Object resObj = obj2.getStream()->getDict()->lookup("Resources", &resourcesRef);
             if (resourcesRef != Ref::INVALID() && !visitedObjects.insert(resourcesRef.num).second)
                 continue;
 
@@ -610,6 +610,11 @@ std::string getString(const GooString *value)
     return "";
 }
 
+std::string getString(const GooString &value)
+{
+    return getString(value.toStr());
+}
+
 /**
  * Convert PDF strings, which can be formatted as UTF8, UTF16BE or UTF16LE into
  * a predictable UTF8 string consistant with svg requirements.
diff --git a/src/extension/internal/pdfinput/poppler-utils.h b/src/extension/internal/pdfinput/poppler-utils.h
index 13123d79a9..2b1978bf0f 100644
--- a/src/extension/internal/pdfinput/poppler-utils.h
+++ b/src/extension/internal/pdfinput/poppler-utils.h
@@ -86,6 +86,7 @@ std::string getDictString(Dict *dict, const char *key);
 std::string getString(const std::string &value);
 std::string getString(const std::unique_ptr<GooString> &value);
 std::string getString(const GooString *value);
+std::string getString(const GooString &value);
 std::string validateString(std::string const &in);
 
 // Replacate poppler FontDict
-- 
2.54.0
