@@ -0,0 +1,221 @@
|
|||||||
|
From 977b5fa8b413d9a181c964ca3c1fd048cd93f062 Mon Sep 17 00:00:00 2001
|
||||||
|
From: KrIr17 <elendil.krir17@gmail.com>
|
||||||
|
Date: Thu, 9 Apr 2026 12:45:19 +0200
|
||||||
|
Subject: [PATCH] Fix building with Poppler 26.04.0
|
||||||
|
|
||||||
|
Poppler's getString() et al now return &std::string and not
|
||||||
|
*GooString. So functions that expected *Goostring have been
|
||||||
|
modified to accept std::string, with wrappers for backwards
|
||||||
|
compatibility
|
||||||
|
|
||||||
|
Fixes https://gitlab.com/inkscape/inkscape/-/work_items/6090
|
||||||
|
|
||||||
|
(cherry-picked from 9fcd1ec79652e8092b4838ddafd1802f52c0642b)
|
||||||
|
---
|
||||||
|
.../internal/pdfinput/pdf-parser.cpp | 21 +++++---
|
||||||
|
src/extension/internal/pdfinput/pdf-parser.h | 5 +-
|
||||||
|
.../pdfinput/poppler-transition-api.h | 8 +--
|
||||||
|
.../internal/pdfinput/poppler-utils.cpp | 50 +++++++++++++++----
|
||||||
|
.../internal/pdfinput/poppler-utils.h | 2 +
|
||||||
|
5 files changed, 62 insertions(+), 24 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
|
||||||
|
index 62f1db2bd6..03f47a0f90 100644
|
||||||
|
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
|
||||||
|
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
|
||||||
|
@@ -2268,15 +2268,11 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
|
||||||
|
* This adds a string from a PDF file that is contained in one command ('Tj', ''', '"')
|
||||||
|
* or is one string in ShowSpacetext ('TJ').
|
||||||
|
*/
|
||||||
|
-#if POPPLER_CHECK_VERSION(0,64,0)
|
||||||
|
-void PdfParser::doShowText(const GooString *s) {
|
||||||
|
-#else
|
||||||
|
-void PdfParser::doShowText(GooString *s) {
|
||||||
|
-#endif
|
||||||
|
+void PdfParser::doShowText(const std::string &s) {
|
||||||
|
auto font = state->getFont();
|
||||||
|
_POPPLER_WMODE wMode = font->getWMode(); // Vertical/Horizontal/Invalid
|
||||||
|
|
||||||
|
- builder->beginString(state, get_goostring_length(*s));
|
||||||
|
+ builder->beginString(state, s.size());
|
||||||
|
|
||||||
|
// handle a Type 3 char
|
||||||
|
if (font->getType() == fontType3) {
|
||||||
|
@@ -2286,8 +2282,8 @@ void PdfParser::doShowText(GooString *s) {
|
||||||
|
double riseX, riseY;
|
||||||
|
state->textTransformDelta(0, state->getRise(), &riseX, &riseY);
|
||||||
|
|
||||||
|
- auto p = s->getCString(); // char* or const char*
|
||||||
|
- int len = get_goostring_length(*s);
|
||||||
|
+ auto p = s.c_str(); // char* or const char*
|
||||||
|
+ int len = s.size();
|
||||||
|
|
||||||
|
while (len > 0) {
|
||||||
|
|
||||||
|
@@ -2344,6 +2340,15 @@ void PdfParser::doShowText(GooString *s) {
|
||||||
|
builder->endString(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#if POPPLER_CHECK_VERSION(0,64,0)
|
||||||
|
+void PdfParser::doShowText(const GooString *s) {
|
||||||
|
+#else
|
||||||
|
+void PdfParser::doShowText(GooString *s) {
|
||||||
|
+#endif
|
||||||
|
+ const std::string str = s->toStr();
|
||||||
|
+ doShowText(str);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
// XObject operators
|
||||||
|
diff --git a/src/extension/internal/pdfinput/pdf-parser.h b/src/extension/internal/pdfinput/pdf-parser.h
|
||||||
|
index 2c3a57bf50..c136ebf1ef 100644
|
||||||
|
--- a/src/extension/internal/pdfinput/pdf-parser.h
|
||||||
|
+++ b/src/extension/internal/pdfinput/pdf-parser.h
|
||||||
|
@@ -283,10 +283,11 @@ private:
|
||||||
|
void opMoveShowText(Object args[], int numArgs);
|
||||||
|
void opMoveSetShowText(Object args[], int numArgs);
|
||||||
|
void opShowSpaceText(Object args[], int numArgs);
|
||||||
|
+ void doShowText(const std::string &s);
|
||||||
|
#if POPPLER_CHECK_VERSION(0,64,0)
|
||||||
|
- void doShowText(const GooString *s);
|
||||||
|
+ void doShowText(const GooString *s);
|
||||||
|
#else
|
||||||
|
- void doShowText(GooString *s);
|
||||||
|
+ void doShowText(GooString *s);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
|
||||||
|
index 65788128b7..7f299bd05a 100644
|
||||||
|
--- a/src/extension/internal/pdfinput/poppler-transition-api.h
|
||||||
|
+++ b/src/extension/internal/pdfinput/poppler-transition-api.h
|
||||||
|
@@ -72,11 +72,11 @@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if POPPLER_CHECK_VERSION(24, 5, 0)
|
||||||
|
-#define _POPPLER_HAS_UNICODE_BOM(value) (hasUnicodeByteOrderMark(value->toStr()))
|
||||||
|
-#define _POPPLER_HAS_UNICODE_BOMLE(value) (hasUnicodeByteOrderMarkLE(value->toStr()))
|
||||||
|
+#define _POPPLER_HAS_UNICODE_BOM(value) (hasUnicodeByteOrderMark(value))
|
||||||
|
+#define _POPPLER_HAS_UNICODE_BOMLE(value) (hasUnicodeByteOrderMarkLE(value))
|
||||||
|
#else
|
||||||
|
-#define _POPPLER_HAS_UNICODE_BOM(value) (value->hasUnicodeMarker())
|
||||||
|
-#define _POPPLER_HAS_UNICODE_BOMLE(value) (value->hasUnicodeMarkerLE())
|
||||||
|
+#define _POPPLER_HAS_UNICODE_BOM(value) (GooString(value).hasUnicodeMarker())
|
||||||
|
+#define _POPPLER_HAS_UNICODE_BOMLE(value) (GooString(value).hasUnicodeMarkerLE())
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if POPPLER_CHECK_VERSION(24, 3, 0)
|
||||||
|
diff --git a/src/extension/internal/pdfinput/poppler-utils.cpp b/src/extension/internal/pdfinput/poppler-utils.cpp
|
||||||
|
index b85963e65e..a65a5780ee 100644
|
||||||
|
--- a/src/extension/internal/pdfinput/poppler-utils.cpp
|
||||||
|
+++ b/src/extension/internal/pdfinput/poppler-utils.cpp
|
||||||
|
@@ -149,7 +149,6 @@ int InkFontDict::hashFontObject(Object *obj)
|
||||||
|
|
||||||
|
void InkFontDict::hashFontObject1(const Object *obj, FNVHash *h)
|
||||||
|
{
|
||||||
|
- const GooString *s;
|
||||||
|
const char *p;
|
||||||
|
double r;
|
||||||
|
int n, i;
|
||||||
|
@@ -169,11 +168,16 @@ void InkFontDict::hashFontObject1(const Object *obj, FNVHash *h)
|
||||||
|
r = obj->getReal();
|
||||||
|
h->hash((char *)&r, sizeof(double));
|
||||||
|
break;
|
||||||
|
- case objString:
|
||||||
|
+ case objString: {
|
||||||
|
h->hash('s');
|
||||||
|
- s = obj->getString();
|
||||||
|
+#if POPPLER_CHECK_VERSION(26, 4, 0)
|
||||||
|
+ const auto &s = obj->getString();
|
||||||
|
+ h->hash(s.c_str(), s.size());
|
||||||
|
+#else
|
||||||
|
+ const GooString* s = obj->getString();
|
||||||
|
h->hash(s->c_str(), get_goostring_length(*s));
|
||||||
|
- break;
|
||||||
|
+#endif
|
||||||
|
+ } break;
|
||||||
|
case objName:
|
||||||
|
h->hash('n');
|
||||||
|
p = obj->getName();
|
||||||
|
@@ -587,23 +591,45 @@ std::string getDictString(Dict *dict, const char *key)
|
||||||
|
if (!obj.isString()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
+ std::cout << obj.getString() << std::endl;
|
||||||
|
return getString(obj.getString());
|
||||||
|
}
|
||||||
|
|
||||||
|
+std::string getString(const std::unique_ptr<GooString> &value)
|
||||||
|
+{
|
||||||
|
+ return getString(value.get());
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+std::string getString(const GooString *value)
|
||||||
|
+{
|
||||||
|
+ if (value) {
|
||||||
|
+ return getString(value->toStr());
|
||||||
|
+ }
|
||||||
|
+ return "";
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Convert PDF strings, which can be formatted as UTF8, UTF16BE or UTF16LE into
|
||||||
|
* a predictable UTF8 string consistant with svg requirements.
|
||||||
|
*/
|
||||||
|
-std::string getString(const GooString *value)
|
||||||
|
+std::string getString(const std::string &value)
|
||||||
|
{
|
||||||
|
+ char *str = nullptr;
|
||||||
|
+
|
||||||
|
if (_POPPLER_HAS_UNICODE_BOM(value)) {
|
||||||
|
- return g_convert(value->getCString () + 2, get_goostring_length(*value) - 2,
|
||||||
|
- "UTF-8", "UTF-16BE", NULL, NULL, NULL);
|
||||||
|
+ str = g_convert(value.c_str() + 2, value.size() - 2,
|
||||||
|
+ "UTF-8", "UTF-16BE", NULL, NULL, NULL);
|
||||||
|
} else if (_POPPLER_HAS_UNICODE_BOMLE(value)) {
|
||||||
|
- return g_convert(value->getCString () + 2, get_goostring_length(*value) - 2,
|
||||||
|
- "UTF-8", "UTF-16LE", NULL, NULL, NULL);
|
||||||
|
+ str = g_convert(value.c_str() + 2, value.size() - 2,
|
||||||
|
+ "UTF-8", "UTF-16LE", NULL, NULL, NULL);
|
||||||
|
+ }
|
||||||
|
+ if (str) {
|
||||||
|
+ std::string copy = str;
|
||||||
|
+ g_free(str);
|
||||||
|
+ return copy;
|
||||||
|
}
|
||||||
|
- return value->toStr();
|
||||||
|
+ g_warning("Couldn't parse text in PDF from UTF16.");
|
||||||
|
+ return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pdf_debug_array(const Array *array, int depth, XRef *xref)
|
||||||
|
@@ -660,7 +686,11 @@ void pdf_debug_object(const Object *obj, int depth, XRef *xref)
|
||||||
|
} else if (obj->isArray()) {
|
||||||
|
pdf_debug_array(obj->getArray(), depth, xref);
|
||||||
|
} else if (obj->isString()) {
|
||||||
|
+#if POPPLER_CHECK_VERSION(26, 4, 0)
|
||||||
|
+ std::cout << " STR '" << obj->getString().c_str() << "'";
|
||||||
|
+#else
|
||||||
|
std::cout << " STR '" << obj->getString()->getCString() << "'";
|
||||||
|
+#endif
|
||||||
|
} else if (obj->isName()) {
|
||||||
|
std::cout << " NAME '" << obj->getName() << "'";
|
||||||
|
} else if (obj->isBool()) {
|
||||||
|
diff --git a/src/extension/internal/pdfinput/poppler-utils.h b/src/extension/internal/pdfinput/poppler-utils.h
|
||||||
|
index c19f30d0bc..13123d79a9 100644
|
||||||
|
--- a/src/extension/internal/pdfinput/poppler-utils.h
|
||||||
|
+++ b/src/extension/internal/pdfinput/poppler-utils.h
|
||||||
|
@@ -83,6 +83,8 @@ typedef std::shared_ptr<std::map<FontPtr, FontData>> FontList;
|
||||||
|
FontList getPdfFonts(std::shared_ptr<PDFDoc> pdf_doc);
|
||||||
|
std::string getNameWithoutSubsetTag(std::string name);
|
||||||
|
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 validateString(std::string const &in);
|
||||||
|
|
||||||
|
--
|
||||||
|
GitLab
|
||||||
|
|
||||||
|
|
||||||
@@ -188,6 +188,13 @@
|
|||||||
</Package>
|
</Package>
|
||||||
|
|
||||||
<History>
|
<History>
|
||||||
|
<Update release="24">
|
||||||
|
<Date>2026-04-18</Date>
|
||||||
|
<Version>1.4.3</Version>
|
||||||
|
<Comment>Rebuild.</Comment>
|
||||||
|
<Name>Pisi Linux Community</Name>
|
||||||
|
<Email>admin@pisilinux.org</Email>
|
||||||
|
</Update>
|
||||||
<Update release="23">
|
<Update release="23">
|
||||||
<Date>2026-02-21</Date>
|
<Date>2026-02-21</Date>
|
||||||
<Version>1.4.3</Version>
|
<Version>1.4.3</Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user