From c3ee897b7187d0bfa88703ec5ef1a8f229ff84f5 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Thu, 19 Feb 2026 06:09:13 +0300
Subject: trinity-base/tdegraphics-tdefile-plugins: fix build with newer
 poppler

This fixes build against app-text/poppler 25.10.0 through 26.01.0
Also it fixes perditions on one of the older patches.

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 ...gins-14.1.5-add-support-for-Poppler-25.10.patch | 116 +++++++++++++++++++++
 ...ns-14.1.5-add-support-for-poppler-25.12.0.patch |  31 ++++++
 ...ns-14.1.5-add-support-for-poppler-26.01.0.patch |  70 +++++++++++++
 ...tdegraphics-tdefile-plugins-poppler-cxx20.patch |   0
 .../tdegraphics-tdefile-plugins-14.1.2.ebuild      |   5 +-
 .../tdegraphics-tdefile-plugins-14.1.4.ebuild      |   8 +-
 .../tdegraphics-tdefile-plugins-14.1.5.ebuild      |   6 ++
 7 files changed, 234 insertions(+), 2 deletions(-)
 create mode 100644 trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-Poppler-25.10.patch
 create mode 100644 trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-poppler-25.12.0.patch
 create mode 100644 trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-poppler-26.01.0.patch
 mode change 100755 => 100644 trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-poppler-cxx20.patch

diff --git a/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-Poppler-25.10.patch b/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-Poppler-25.10.patch
new file mode 100644
index 00000000..6df892c0
--- /dev/null
+++ b/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-Poppler-25.10.patch
@@ -0,0 +1,116 @@
+From 7de16ecd1e7afda4fd043128289cc9f9cd75aa22 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= <slavek.banko@axis.cz>
+Date: Mon, 3 Nov 2025 15:50:00 +0100
+Subject: [PATCH] Add support for Poppler >= 25.10. Fix confusing formatting in
+ DocumentData::addTocChildren.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
+---
+ .../poppler-tqt/poppler-document.cpp          | 14 +++++-
+ .../poppler-tqt/poppler-private.cpp           | 45 ++++++++++++-------
+ 2 files changed, 42 insertions(+), 17 deletions(-)
+
+diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cpp
+index 5ed02af6..81c6b04a 100644
+--- a/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cpp
++++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cpp
+@@ -88,7 +88,10 @@ bool Document::unlock(const TQCString &password)
+ {
+   if (data->locked) {
+     /* racier then it needs to be */
+-#   if (POPPLER_VERSION_C >= 22003000)
++#   if (POPPLER_VERSION_C >= 25010000)
++    DocumentData *doc2 = new DocumentData(data->doc.getFileName()->copy(),
++                                          GooString(password.data()));
++#   elif (POPPLER_VERSION_C >= 22003000)
+     DocumentData *doc2 = new DocumentData(std::make_unique<GooString>(data->doc.getFileName()),
+                                           GooString(password.data()));
+ #   else
+@@ -225,7 +228,14 @@ TQString Document::getInfo( const TQString & type ) const
+       isUnicode = gFalse;
+       i = 0;
+     }
+-    while ( i < obj.getString()->getLength() )
++    while
++    (
++#       if (POPPLER_VERSION_C >= 25010000)
++        i < obj.getString()->size()
++#       else
++        i < obj.getString()->getLength()
++#       endif
++    )
+     {
+       if ( isUnicode )
+       {
+diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp
+index 42ec0899..d5c028d1 100644
+--- a/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp
++++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp
+@@ -57,7 +57,14 @@ TQString UnicodeParsedString(CONST_064 GooString *s1)
+         isUnicode = gFalse;
+         i = 0;
+     }
+-    while ( i < s1->getLength() )
++    while
++    (
++#       if (POPPLER_VERSION_C >= 25010000)
++        i < s1->size()
++#       else
++        i < s1->getLength()
++#       endif
++    )
+     {
+         if ( isUnicode )
+         {
+@@ -129,23 +136,31 @@ void DocumentData::addTocChildren( TQDomDocument * docSyn, TQDomNode * parent, O
+                 // get the destination for the page now, but it's VERY time consuming,
+                 // so better storing the reference and provide the viewport on demand
+                 CONST_064 GooString *s = g->getNamedDest();
+-                TQChar *charArray = new TQChar[s->getLength()];
+-                for (int i = 0; i < s->getLength(); ++i) charArray[i] = TQChar(s->GOO_GET_CSTR()[i]);
+-                    TQString aux(charArray, s->getLength());
+-                    item.setAttribute( "DestinationName", aux );
+-                    delete[] charArray;
+-                }
+-                else if ( destination && destination->isOk() )
+-                {
+-                    LinkDestinationData ldd(destination, NULL, this);
+-                    item.setAttribute( "Destination", LinkDestination(ldd).toString() );
+-                }
+-                if ( a->getKind() == actionGoToR )
++#               if (POPPLER_VERSION_C >= 25010000)
++                int sLen = s->size();
++#               else
++                int sLen = s->getLength();
++#               endif
++                TQChar *charArray = new TQChar[sLen];
++                for (int i = 0; i < sLen; ++i)
+                 {
+-                    CONST_064 LinkGoToR * g2 = static_cast< CONST_064 LinkGoToR * >( a );
+-                    item.setAttribute( "ExternalFileName", g2->getFileName()->GOO_GET_CSTR() );
++                    charArray[i] = TQChar(s->GOO_GET_CSTR()[i]);
+                 }
++                TQString aux(charArray, sLen);
++                item.setAttribute( "DestinationName", aux );
++                delete[] charArray;
++            }
++            else if ( destination && destination->isOk() )
++            {
++                LinkDestinationData ldd(destination, NULL, this);
++                item.setAttribute( "Destination", LinkDestination(ldd).toString() );
++            }
++            if ( a->getKind() == actionGoToR )
++            {
++                CONST_064 LinkGoToR * g2 = static_cast< CONST_064 LinkGoToR * >( a );
++                item.setAttribute( "ExternalFileName", g2->getFileName()->GOO_GET_CSTR() );
+             }
++        }
+ 
+         // 3. recursively descend over children
+         outlineItem->open();
+-- 
+2.52.0
+
diff --git a/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-poppler-25.12.0.patch b/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-poppler-25.12.0.patch
new file mode 100644
index 00000000..3bbbb6e5
--- /dev/null
+++ b/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-poppler-25.12.0.patch
@@ -0,0 +1,31 @@
+From 8c9531623193493479846961e3880d2eba095ba8 Mon Sep 17 00:00:00 2001
+From: Alexander Golubev <fatzer2@gmail.com>
+Date: Sat, 7 Feb 2026 22:43:45 +0300
+Subject: [PATCH 12/13] tdefile-plugins: add support for poppler >= 25.12.0
+
+Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tdegraphics/issues/149
+Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
+---
+ tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp
+index a2463362..7a64af81 100644
+--- a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp
++++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp
+@@ -194,8 +194,12 @@ TQValueList<TextBox*> Page::textList() const
+     return output_list;
+   }
+ 
++# if (POPPLER_VERSION_C >= 25012000)
++  for (TextWord *word: word_list->getWords()) {
++# else
+   for (int i = 0; i < word_list->getLength(); i++) {
+     TextWord *word = word_list->get(i);
++# endif
+     GooString *word_str = word->getText();
+     TQString string = TQString::fromUtf8(word_str->GOO_GET_CSTR());
+     delete word_str;
+-- 
+2.52.0
+
diff --git a/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-poppler-26.01.0.patch b/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-poppler-26.01.0.patch
new file mode 100644
index 00000000..342bcfac
--- /dev/null
+++ b/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-14.1.5-add-support-for-poppler-26.01.0.patch
@@ -0,0 +1,70 @@
+From 2a26f8bf97c534e9c85ca936eb71d65fddd7fa82 Mon Sep 17 00:00:00 2001
+From: Alexander Golubev <fatzer2@gmail.com>
+Date: Sat, 7 Feb 2026 22:44:48 +0300
+Subject: [PATCH 13/13] tdefile-plugins: add support for poppler >= 26.01.0
+
+Closes: https://mirror.git.trinitydesktop.org/gitea/TDE/tdegraphics/issues/149
+Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
+---
+ .../dependencies/poppler-tqt/poppler-page.cpp        | 12 ++++++++++++
+ .../dependencies/poppler-tqt/poppler-private.cpp     |  2 ++
+ 2 files changed, 14 insertions(+)
+
+diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp
+index 7a64af81..75bd59a3 100644
+--- a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp
++++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp
+@@ -144,7 +144,11 @@ TQString Page::getText(const Rectangle &r) const
+   if (r.isNull())
+   {
+     rect = p->getCropBox();
++#if (POPPLER_VERSION_C >= 26001000)
++    s = output_dev->getText(PDFRectangle(rect->x1, rect->y1, rect->x2, rect->y2));
++#else
+     s = output_dev->getText(rect->x1, rect->y1, rect->x2, rect->y2);
++#endif
+   }
+   else
+   {
+@@ -152,7 +156,11 @@ TQString Page::getText(const Rectangle &r) const
+     height = p->getCropHeight();
+     y1 = height - r.m_y2;
+     y2 = height - r.m_y1;
++#if (POPPLER_VERSION_C >= 26001000)
++    s = output_dev->getText(PDFRectangle(r.m_x1, y1, r.m_x2, y2));
++#else
+     s = output_dev->getText(r.m_x1, y1, r.m_x2, y2);
++#endif
+   }
+ 
+ # if (POPPLER_VERSION_C >= 25001000)
+@@ -200,9 +208,13 @@ TQValueList<TextBox*> Page::textList() const
+   for (int i = 0; i < word_list->getLength(); i++) {
+     TextWord *word = word_list->get(i);
+ # endif
++# if (POPPLER_VERSION_C >= 26001000)
++    TQString string = TQString::fromUtf8(word->getText()->c_str());
++# else
+     GooString *word_str = word->getText();
+     TQString string = TQString::fromUtf8(word_str->GOO_GET_CSTR());
+     delete word_str;
++# endif
+     double xMin, yMin, xMax, yMax;
+     word->getBBox(&xMin, &yMin, &xMax, &yMax);
+ 
+diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp
+index d5c028d1..16312a34 100644
+--- a/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp
++++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp
+@@ -25,6 +25,8 @@
+ 
+ #include <tqstring.h>
+ 
++#include <goo/gmem.h>
++
+ #include <Outline.h>
+ #include <Link.h>
+ 
+-- 
+2.52.0
+
diff --git a/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-poppler-cxx20.patch b/trinity-base/tdegraphics-tdefile-plugins/files/tdegraphics-tdefile-plugins-poppler-cxx20.patch
old mode 100755
new mode 100644
diff --git a/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.2.ebuild b/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.2.ebuild
index 37dc9a2e..48d7220c 100644
--- a/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.2.ebuild
+++ b/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.2.ebuild
@@ -1,5 +1,5 @@
 # Copyright 1999-2024 Gentoo Authors
-# Copyright 2020-2024 The Trinity Desktop Project
+# Copyright 2020-2026 The Trinity Desktop Project
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI="8"
@@ -23,6 +23,9 @@ RDEPEND="${DEPEND}"
 
 PATCHES=(
 	"${FILESDIR}/${PN}-poppler-cxx20.patch"
+	"${FILESDIR}/${PN}-14.1.5-add-support-for-Poppler-25.10.patch"
+	"${FILESDIR}/${PN}-14.1.5-add-support-for-poppler-25.12.0.patch"
+	"${FILESDIR}/${PN}-14.1.5-add-support-for-poppler-26.01.0.patch"
 )
 
 src_configure() {
diff --git a/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.4.ebuild b/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.4.ebuild
index ea361ee0..97a554e0 100644
--- a/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.4.ebuild
+++ b/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.4.ebuild
@@ -1,5 +1,5 @@
 # Copyright 1999-2020 Gentoo Authors
-# Copyright 2020-2025 The Trinity Desktop Project
+# Copyright 2020-2026 The Trinity Desktop Project
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI="8"
@@ -22,6 +22,12 @@ DEPEND="
 	pdf? ( app-text/poppler )"
 RDEPEND="${DEPEND}"
 
+PATCHES=(
+	"${FILESDIR}/${PN}-14.1.5-add-support-for-Poppler-25.10.patch"
+	"${FILESDIR}/${PN}-14.1.5-add-support-for-poppler-25.12.0.patch"
+	"${FILESDIR}/${PN}-14.1.5-add-support-for-poppler-26.01.0.patch"
+)
+
 src_configure() {
 	local mycmakeargs=(
 		-DWITH_TIFF="$(usex tiff)"
diff --git a/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.5.ebuild b/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.5.ebuild
index 1612d008..a96eaac0 100644
--- a/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.5.ebuild
+++ b/trinity-base/tdegraphics-tdefile-plugins/tdegraphics-tdefile-plugins-14.1.5.ebuild
@@ -22,6 +22,12 @@ DEPEND="
 	pdf? ( app-text/poppler )"
 RDEPEND="${DEPEND}"
 
+PATCHES=(
+	"${FILESDIR}/${P}-add-support-for-Poppler-25.10.patch"
+	"${FILESDIR}/${P}-add-support-for-poppler-25.12.0.patch"
+	"${FILESDIR}/${P}-add-support-for-poppler-26.01.0.patch"
+)
+
 src_configure() {
 	local mycmakeargs=(
 		-DWITH_TIFF="$(usex tiff)"
-- 
cgit v1.2.3

