summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2024-04-17 10:23:11 +0200
committerAlbert Astals Cid <aacid@kde.org>2024-04-20 10:30:56 +0000
commit05121ab78f8208aa3d35cf5ccf96e84092089acc (patch)
treeb6ed8e3798d42410bc9d1a5d7faff72042cf542f
parent1f06dca08c32ed18c3030530d98a0e30d41dd7a2 (diff)
Move move prependUnicodeMarker to UTF.h
... and rename it to prependUnicodeByteOrderMark. Now all unicode code has moved from GooString.h to UTF.h.
-rw-r--r--glib/poppler-document.cc2
-rw-r--r--goo/GooString.cc5
-rw-r--r--goo/GooString.h2
-rw-r--r--poppler/Annot.cc12
-rw-r--r--poppler/Form.cc6
-rw-r--r--poppler/UTF.h6
6 files changed, 16 insertions, 17 deletions
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index 5dc034c5..fac52af8 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -1140,7 +1140,7 @@ static GooString *_poppler_goo_string_from_utf8(const gchar *src)
g_free(utf16);
if (!hasUnicodeByteOrderMark(result->toStr())) {
- result->prependUnicodeMarker();
+ prependUnicodeByteOrderMark(result->toNonConstStr());
}
return result;
diff --git a/goo/GooString.cc b/goo/GooString.cc
index ff845597..a657e82f 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -620,8 +620,3 @@ std::string GooString::toLowerCase(const std::string &s)
lowerCase(newString);
return s;
}
-
-void GooString::prependUnicodeMarker()
-{
- insert(0, "\xFE\xFF", 2);
-}
diff --git a/goo/GooString.h b/goo/GooString.h
index 05aa630f..5659b34b 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -242,8 +242,6 @@ public:
// Return true if string ends with suffix
using std::string::ends_with;
-
- POPPLER_PRIVATE_EXPORT void prependUnicodeMarker();
};
#endif
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 5736c990..7841637c 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1504,7 +1504,7 @@ void Annot::setContents(std::unique_ptr<GooString> &&new_content)
contents = std::move(new_content);
// append the unicode marker <FE FF> if needed
if (!hasUnicodeByteOrderMark(contents->toStr())) {
- contents->prependUnicodeMarker();
+ prependUnicodeByteOrderMark(contents->toNonConstStr());
}
} else {
contents = std::make_unique<GooString>();
@@ -2211,7 +2211,7 @@ void AnnotMarkup::setLabel(std::unique_ptr<GooString> &&new_label)
label = std::move(new_label);
// append the unicode marker <FE FF> if needed
if (!hasUnicodeByteOrderMark(label->toStr())) {
- label->prependUnicodeMarker();
+ prependUnicodeByteOrderMark(label->toNonConstStr());
}
} else {
label = std::make_unique<GooString>();
@@ -2936,7 +2936,7 @@ void AnnotFreeText::setStyleString(GooString *new_string)
styleString = std::make_unique<GooString>(new_string);
// append the unicode marker <FE FF> if needed
if (!hasUnicodeByteOrderMark(styleString->toStr())) {
- styleString->prependUnicodeMarker();
+ prependUnicodeByteOrderMark(styleString->toNonConstStr());
}
} else {
styleString = std::make_unique<GooString>();
@@ -3058,7 +3058,7 @@ public:
// Here we just layout one char, we don't know if the one afterwards can be layouted with the original font
GooString auxContents = GooString(text->toStr().substr(i, isUnicode ? 2 : 1));
if (isUnicode) {
- auxContents.prependUnicodeMarker();
+ prependUnicodeByteOrderMark(auxContents.toNonConstStr());
}
int auxI = 0;
Annot::layoutText(&auxContents, &outputText, &auxI, *auxFont, &blockWidth, availableWidth ? *availableWidth : 0.0, &charCount, false, &newFontNeeded);
@@ -3145,7 +3145,7 @@ double Annot::calculateFontSize(const Form *form, const GfxFont *font, const Goo
while (i < text->getLength()) {
GooString lineText(text->toStr().substr(i));
if (!hasUnicodeByteOrderMark(lineText.toStr()) && isUnicode) {
- lineText.prependUnicodeMarker();
+ prependUnicodeByteOrderMark(lineText.toNonConstStr());
}
const HorizontalTextLayouter textLayouter(&lineText, form, font, availableWidthInFontSize, forceZapfDingbats);
y -= fontSize;
@@ -3181,7 +3181,7 @@ static DrawMultiLineTextResult drawMultiLineText(const GooString &text, double a
while (i < text.getLength()) {
GooString lineText(text.toStr().substr(i));
if (!hasUnicodeByteOrderMark(lineText.toStr()) && hasUnicodeByteOrderMark(text.toStr())) {
- lineText.prependUnicodeMarker();
+ prependUnicodeByteOrderMark(lineText.toNonConstStr());
}
const HorizontalTextLayouter textLayouter(&lineText, form, &font, availableTextWidthInFontPtSize, false);
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 3acf81f5..985f4870 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -1308,7 +1308,7 @@ GooString *FormField::getFullyQualifiedName()
}
if (unicode_encoded) {
- fullyQualifiedName->prependUnicodeMarker();
+ prependUnicodeByteOrderMark(fullyQualifiedName->toNonConstStr());
}
return fullyQualifiedName;
@@ -1718,7 +1718,7 @@ void FormFieldText::setContentCopy(const GooString *new_content)
// append the unicode marker <FE FF> if needed
if (!hasUnicodeByteOrderMark(content->toStr())) {
- content->prependUnicodeMarker();
+ prependUnicodeByteOrderMark(content->toNonConstStr());
}
Form *form = doc->getCatalog()->getForm();
if (form) {
@@ -2167,7 +2167,7 @@ void FormFieldChoice::setEditChoice(const GooString *new_content)
// append the unicode marker <FE FF> if needed
if (!hasUnicodeByteOrderMark(editedChoice->toStr())) {
- editedChoice->prependUnicodeMarker();
+ prependUnicodeByteOrderMark(editedChoice->toNonConstStr());
}
}
updateSelection();
diff --git a/poppler/UTF.h b/poppler/UTF.h
index 812506eb..74c31cd3 100644
--- a/poppler/UTF.h
+++ b/poppler/UTF.h
@@ -63,6 +63,12 @@ inline bool hasUnicodeByteOrderMarkLE(const std::string &s)
return s.starts_with(unicodeByteOrderMarkLE);
}
+// put big-endian unicode byte order mark at the beginning of a string
+inline void prependUnicodeByteOrderMark(std::string &s)
+{
+ s.insert(0, unicodeByteOrderMark);
+}
+
// is a unicode whitespace character
bool UnicodeIsWhitespace(Unicode ucs4);