From 2ddb27bdc5960a982c8533a3abc7bfdd32e6abea Mon Sep 17 00:00:00 2001
From: Heiko Becker <heiko.becker@kde.org>
Date: Sat, 11 Apr 2026 10:09:58 +0200
Subject: [PATCH] Fix build with poppler >= 26.04.0

BUG: 518774
---
 filters/karbon/pdf/SvgOutputDev.cpp | 25 +++++++++++++++++++------
 filters/karbon/pdf/SvgOutputDev.h   |  4 ++++
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/filters/karbon/pdf/SvgOutputDev.cpp b/filters/karbon/pdf/SvgOutputDev.cpp
index 94a5e91087d..6aa8faabffd 100644
--- a/filters/karbon/pdf/SvgOutputDev.cpp
+++ b/filters/karbon/pdf/SvgOutputDev.cpp
@@ -386,7 +386,11 @@ QString SvgOutputDev::printStroke()
     return stroke;
 }
 
+#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(26, 4, 0)
+void SvgOutputDev::drawString(GfxState *state, const std::string &s)
+#else
 void SvgOutputDev::drawString(GfxState *state, const GooString *s)
+#endif
 {
     int render = state->getRender();
     // check for invisible text -- this is used by Acrobat Capture
@@ -395,10 +399,12 @@ void SvgOutputDev::drawString(GfxState *state, const GooString *s)
     }
 
     // ignore empty strings
-#if POPPLER_VERSION_MACRO < QT_VERSION_CHECK(25, 10, 0)
-    if (s->getLength() == 0) {
-#else
+#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(26, 4, 0)
+    if (s.size() == 0) {
+#elif POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(25, 10, 0)
     if (s->size() == 0) {
+#else
+    if (s->getLength() == 0) {
 #endif
         return;
     }
@@ -407,11 +413,18 @@ void SvgOutputDev::drawString(GfxState *state, const GooString *s)
 
     QString str;
 
-    const char *p = s->c_str();
-#if POPPLER_VERSION_MACRO < QT_VERSION_CHECK(25, 10, 0)
-    int len = s->getLength();
+#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(26, 4, 0)
+    const char *p = s.c_str();
 #else
+    const char *p = s->c_str();
+#endif
+
+#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(26, 4, 0)
+    int len = s.size();
+#elif POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(25, 10, 0)
     int len = s->size();
+#else
+    int len = s->getLength();
 #endif
     CharCode code;
     const Unicode *u = nullptr;
diff --git a/filters/karbon/pdf/SvgOutputDev.h b/filters/karbon/pdf/SvgOutputDev.h
index 721894b1de6..952ca366c17 100644
--- a/filters/karbon/pdf/SvgOutputDev.h
+++ b/filters/karbon/pdf/SvgOutputDev.h
@@ -44,7 +44,11 @@ public:
     void eoFill(GfxState *state) override;
 
     // text
+#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(26, 4, 0)
+    void drawString(GfxState *state, const std::string &s) override;
+#else
     void drawString(GfxState *state, const GooString *s) override;
+#endif
 
     // images
     void drawImage(GfxState *state,
-- 
GitLab

