summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2023-04-07 09:48:41 +0200
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-06-14 13:27:04 +0200
commit71075740aee2e15f574d19d452f0a586e25a6bd0 (patch)
treeb93c1fcfc73ef99400818a20e4b045069c50ebea /vcl
parent427769a751d3f45e41e5a0f4aed385bb2727998c (diff)
Make encodeForXml accessible for other modules
and share similar code Change-Id: I7729a46d40845893f577c273c1ab340f69ebb51b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151230 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151754 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx39
1 files changed, 4 insertions, 35 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 718433aafc02..48ed2ffe3be5 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/util/URLTransformer.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
+#include <comphelper/xmlencode.hxx>
#include <cppuhelper/implbase.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <o3tl/numeric.hxx>
@@ -5885,43 +5886,11 @@ sal_Int32 PDFWriterImpl::emitOutputIntent()
return nOIObject;
}
-// formats the string for the XML stream
-void escapeStringXML(const OUString& rStr, OUString &rValue)
+static void lcl_assignMeta(std::u16string_view aValue, OString& aMeta)
{
- const sal_Unicode* pUni = rStr.getStr();
- int nLen = rStr.getLength();
- for( ; nLen; nLen--, pUni++ )
+ if (!aValue.empty())
{
- switch( *pUni )
- {
- case u'&':
- rValue += "&amp;";
- break;
- case u'<':
- rValue += "&lt;";
- break;
- case u'>':
- rValue += "&gt;";
- break;
- case u'\'':
- rValue += "&apos;";
- break;
- case u'"':
- rValue += "&quot;";
- break;
- default:
- rValue += OUStringChar( *pUni );
- break;
- }
- }
-}
-
-static void lcl_assignMeta(const OUString& aValue, OString& aMeta)
-{
- if (!aValue.isEmpty())
- {
- OUString aTempString;
- escapeStringXML(aValue, aTempString);
+ OUString aTempString = comphelper::string::encodeForXml(aValue);
aMeta = OUStringToOString(aTempString, RTL_TEXTENCODING_UTF8);
}
}