From 71075740aee2e15f574d19d452f0a586e25a6bd0 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Fri, 7 Apr 2023 09:48:41 +0200 Subject: Make encodeForXml accessible for other modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and share similar code Change-Id: I7729a46d40845893f577c273c1ab340f69ebb51b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151230 Tested-by: Jenkins CollaboraOffice Reviewed-by: Szymon Kłos Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151754 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- .../registry/configuration/dp_configuration.cxx | 36 ++-------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'desktop/source/deployment') diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index 1f4ba053ec55..622814248670 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -566,39 +567,6 @@ BackendImpl::PackageImpl::isRegistered_( } -OUString encodeForXml( std::u16string_view text ) -{ - // encode conforming xml: - size_t len = text.size(); - OUStringBuffer buf; - for ( size_t pos = 0; pos < len; ++pos ) - { - sal_Unicode c = text[ pos ]; - switch (c) { - case '<': - buf.append( "<" ); - break; - case '>': - buf.append( ">" ); - break; - case '&': - buf.append( "&" ); - break; - case '\'': - buf.append( "'" ); - break; - case '\"': - buf.append( """ ); - break; - default: - buf.append( c ); - break; - } - } - return buf.makeStringAndClear(); -} - - OUString replaceOrigin( OUString const & url, std::u16string_view destFolder, Reference< XCommandEnvironment > const & xCmdEnv, Reference< XComponentContext > const & xContext, bool & out_replaced) { @@ -651,7 +619,7 @@ OUString replaceOrigin( if (origin.isEmpty()) { // encode only once origin = OUStringToOString( - encodeForXml( url.subView( 0, url.lastIndexOf( '/' ) ) ), + comphelper::string::encodeForXml( url.subView( 0, url.lastIndexOf( '/' ) ) ), // xxx todo: encode always for UTF-8? => lookup doc-header? RTL_TEXTENCODING_UTF8 ); } -- cgit