summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-28 13:39:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-28 14:18:52 +0200
commit42a73e2259d5937ffb8896f7cd24991f83b1ad82 (patch)
tree3ac5cd263a5ef11700371ec43d2a919a7a538707 /desktop
parentadc042f95d3dbd65b778260025d59283146916e5 (diff)
use more string_view in desktop
Change-Id: I16dbc8cb027f51703bc016e095096c868f6e2881 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140705 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/inc/dp_misc.h4
-rw-r--r--desktop/source/deployment/inc/dp_ucb.h2
-rw-r--r--desktop/source/deployment/inc/dp_update.hxx4
-rw-r--r--desktop/source/deployment/inc/dp_version.hxx2
-rw-r--r--desktop/source/deployment/manager/dp_manager.cxx4
-rw-r--r--desktop/source/deployment/misc/dp_dependencies.cxx4
-rw-r--r--desktop/source/deployment/misc/dp_misc.cxx17
-rw-r--r--desktop/source/deployment/misc/dp_ucb.cxx4
-rw-r--r--desktop/source/deployment/misc/dp_update.cxx6
-rw-r--r--desktop/source/deployment/misc/dp_version.cxx19
-rw-r--r--desktop/source/deployment/registry/component/dp_component.cxx14
-rw-r--r--desktop/source/deployment/registry/configuration/dp_configuration.cxx12
12 files changed, 47 insertions, 45 deletions
diff --git a/desktop/inc/dp_misc.h b/desktop/inc/dp_misc.h
index f4c222a943a7..f9ac5687e46a 100644
--- a/desktop/inc/dp_misc.h
+++ b/desktop/inc/dp_misc.h
@@ -64,7 +64,7 @@ OUString expandUnoRcUrl( OUString const & url );
be again encoded for use in an "expand" URL.
*/
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURL(
- OUString const & baseURL, OUString const & relPath );
+ std::u16string_view baseURL, OUString const & relPath );
/** appends a relative path to a url.
@@ -73,7 +73,7 @@ DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURL(
of an system path.
*/
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURLAppendSysPathSegment(
- OUString const & baseURL, OUString const & relPath );
+ std::u16string_view baseURL, OUString const & relPath );
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString generateRandomPipeId();
diff --git a/desktop/source/deployment/inc/dp_ucb.h b/desktop/source/deployment/inc/dp_ucb.h
index 291b28b9b972..e72a2cce9332 100644
--- a/desktop/source/deployment/inc/dp_ucb.h
+++ b/desktop/source/deployment/inc/dp_ucb.h
@@ -80,7 +80,7 @@ std::vector<sal_Int8> readFile( ::ucbhelper::Content & ucb_content );
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-bool readLine( OUString * res, OUString const & startingWith,
+bool readLine( OUString * res, std::u16string_view startingWith,
::ucbhelper::Content & ucb_content, rtl_TextEncoding textenc );
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
diff --git a/desktop/source/deployment/inc/dp_update.hxx b/desktop/source/deployment/inc/dp_update.hxx
index 8dce9b583729..f673d2f66a95 100644
--- a/desktop/source/deployment/inc/dp_update.hxx
+++ b/desktop/source/deployment/inc/dp_update.hxx
@@ -60,7 +60,7 @@ UPDATE_SOURCE isUpdateUserExtension(
OUString const & userVersion,
OUString const & sharedVersion,
OUString const & bundledVersion,
- OUString const & onlineVersion);
+ std::u16string_view onlineVersion);
/* determine if an update is available which is installed in the
shared repository.
@@ -74,7 +74,7 @@ UPDATE_SOURCE isUpdateSharedExtension(
bool bReadOnlyShared,
OUString const & sharedVersion,
OUString const & bundledVersion,
- OUString const & onlineVersion);
+ std::u16string_view onlineVersion);
/* determines the extension with the highest identifier and returns it
diff --git a/desktop/source/deployment/inc/dp_version.hxx b/desktop/source/deployment/inc/dp_version.hxx
index 342e2bf8c737..f088b6861a2f 100644
--- a/desktop/source/deployment/inc/dp_version.hxx
+++ b/desktop/source/deployment/inc/dp_version.hxx
@@ -30,7 +30,7 @@ namespace dp_misc {
enum Order { LESS, EQUAL, GREATER };
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC Order compareVersions(
- OUString const & version1, OUString const & version2);
+ std::u16string_view version1, std::u16string_view version2);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index 3e7802e01935..2c52741c2acb 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -1203,7 +1203,7 @@ bool PackageManagerImpl::synchronizeRemovedExtensions(
//shared repository including the temporary name
OUString url = makeURL(m_activePackages, elem.second.temporaryName);
if (bShared)
- url = makeURLAppendSysPathSegment( url + "_", elem.second.fileName);
+ url = makeURLAppendSysPathSegment( OUStringConcatenation(url + "_"), elem.second.fileName);
bool bRemoved = false;
//Check if the URL to the extension is still the same
@@ -1449,7 +1449,7 @@ Sequence< Reference<deployment::XPackage> > PackageManagerImpl::getExtensionsWit
//Prepare the URL to the extension
OUString url = makeURL(m_activePackages, elem.second.temporaryName);
if (bShared)
- url = makeURLAppendSysPathSegment( url + "_", elem.second.fileName);
+ url = makeURLAppendSysPathSegment( OUStringConcatenation(url + "_"), elem.second.fileName);
Reference<deployment::XPackage> p = m_xRegistry->bindPackage(
url, OUString(), false, OUString(), xCmdEnv );
diff --git a/desktop/source/deployment/misc/dp_dependencies.cxx b/desktop/source/deployment/misc/dp_dependencies.cxx
index e187a69746f1..7828279c71ce 100644
--- a/desktop/source/deployment/misc/dp_dependencies.cxx
+++ b/desktop/source/deployment/misc/dp_dependencies.cxx
@@ -73,13 +73,13 @@ OUString getReferenceOpenOfficeOrgMajorMinor() {
}
bool satisfiesMinimalVersion(
- OUString const & actual, OUString const & specified)
+ std::u16string_view actual, std::u16string_view specified)
{
return dp_misc::compareVersions(actual, specified) != dp_misc::LESS;
}
bool satisfiesMaximalVersion(
- OUString const & actual, OUString const & specified)
+ std::u16string_view actual, std::u16string_view specified)
{
return dp_misc::compareVersions(actual, specified) != dp_misc::GREATER;
}
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index df94e958292b..2983de24b959 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -24,6 +24,7 @@
#include <dp_misc.h>
#include <dp_interact.h>
#include <dp_shared.hxx>
+#include <o3tl/string_view.hxx>
#include <rtl/uri.hxx>
#include <rtl/digest.h>
#include <rtl/random.h>
@@ -224,12 +225,12 @@ bool needToSyncRepository(std::u16string_view name)
namespace {
-OUString encodeForRcFile( OUString const & str )
+OUString encodeForRcFile( std::u16string_view str )
{
// escape $\{} (=> rtl bootstrap files)
OUStringBuffer buf(64);
- sal_Int32 pos = 0;
- const sal_Int32 len = str.getLength();
+ size_t pos = 0;
+ const size_t len = str.size();
for ( ; pos < len; ++pos ) {
sal_Unicode c = str[ pos ];
switch (c) {
@@ -247,11 +248,11 @@ OUString encodeForRcFile( OUString const & str )
}
-OUString makeURL( OUString const & baseURL, OUString const & relPath_ )
+OUString makeURL( std::u16string_view baseURL, OUString const & relPath_ )
{
OUStringBuffer buf(128);
- if (baseURL.getLength() > 1 && baseURL[ baseURL.getLength() - 1 ] == '/')
- buf.append( baseURL.subView(0, baseURL.getLength() - 1) );
+ if (baseURL.size() > 1 && baseURL[ baseURL.size() - 1 ] == '/')
+ buf.append( baseURL.substr(0, baseURL.size() - 1) );
else
buf.append( baseURL );
OUString relPath(relPath_);
@@ -260,7 +261,7 @@ OUString makeURL( OUString const & baseURL, OUString const & relPath_ )
if (!relPath.isEmpty())
{
buf.append( '/' );
- if (baseURL.match( "vnd.sun.star.expand:" )) {
+ if (o3tl::starts_with(baseURL, u"vnd.sun.star.expand:" )) {
// encode for macro expansion: relPath is supposed to have no
// macros, so encode $, {} \ (bootstrap mimic)
relPath = encodeForRcFile(relPath);
@@ -277,7 +278,7 @@ OUString makeURL( OUString const & baseURL, OUString const & relPath_ )
return buf.makeStringAndClear();
}
-OUString makeURLAppendSysPathSegment( OUString const & baseURL, OUString const & segment )
+OUString makeURLAppendSysPathSegment( std::u16string_view baseURL, OUString const & segment )
{
OSL_ASSERT(segment.indexOf(u'/') == -1);
diff --git a/desktop/source/deployment/misc/dp_ucb.cxx b/desktop/source/deployment/misc/dp_ucb.cxx
index 28f4192eeca6..5ca42f31aeac 100644
--- a/desktop/source/deployment/misc/dp_ucb.cxx
+++ b/desktop/source/deployment/misc/dp_ucb.cxx
@@ -197,7 +197,7 @@ std::vector<sal_Int8> readFile( ::ucbhelper::Content & ucb_content )
}
-bool readLine( OUString * res, OUString const & startingWith,
+bool readLine( OUString * res, std::u16string_view startingWith,
::ucbhelper::Content & ucb_content, rtl_TextEncoding textenc )
{
// read whole file:
@@ -211,7 +211,7 @@ bool readLine( OUString * res, OUString const & startingWith,
{
OUStringBuffer buf;
sal_Int32 start = pos;
- pos += startingWith.getLength();
+ pos += startingWith.size();
for (;;)
{
pos = file.indexOf( LF, pos );
diff --git a/desktop/source/deployment/misc/dp_update.cxx b/desktop/source/deployment/misc/dp_update.cxx
index 7116be42bf44..650d648e8a3c 100644
--- a/desktop/source/deployment/misc/dp_update.cxx
+++ b/desktop/source/deployment/misc/dp_update.cxx
@@ -41,7 +41,7 @@ int determineHighestVersion(
OUString const & userVersion,
OUString const & sharedVersion,
OUString const & bundledVersion,
- OUString const & onlineVersion)
+ std::u16string_view onlineVersion)
{
int index = 0;
OUString greatest = userVersion;
@@ -236,7 +236,7 @@ UPDATE_SOURCE isUpdateUserExtension(
OUString const & userVersion,
OUString const & sharedVersion,
OUString const & bundledVersion,
- OUString const & onlineVersion)
+ std::u16string_view onlineVersion)
{
UPDATE_SOURCE retVal = UPDATE_SOURCE_NONE;
if (bReadOnlyShared)
@@ -285,7 +285,7 @@ UPDATE_SOURCE isUpdateSharedExtension(
bool bReadOnlyShared,
OUString const & sharedVersion,
OUString const & bundledVersion,
- OUString const & onlineVersion)
+ std::u16string_view onlineVersion)
{
if (bReadOnlyShared)
return UPDATE_SOURCE_NONE;
diff --git a/desktop/source/deployment/misc/dp_version.cxx b/desktop/source/deployment/misc/dp_version.cxx
index 703045ddebb1..8006e7b6cf8c 100644
--- a/desktop/source/deployment/misc/dp_version.cxx
+++ b/desktop/source/deployment/misc/dp_version.cxx
@@ -20,18 +20,19 @@
#include <sal/config.h>
+#include <o3tl/string_view.hxx>
#include <rtl/ustring.hxx>
#include <dp_version.hxx>
namespace {
-OUString getElement(OUString const & version, ::sal_Int32 * index)
+std::u16string_view getElement(std::u16string_view version, std::size_t * index)
{
- while (*index < version.getLength() && version[*index] == '0') {
+ while (*index < version.size() && version[*index] == '0') {
++*index;
}
- return version.getToken(0, '.', *index);
+ return o3tl::getToken(version, u'.', *index);
}
}
@@ -39,14 +40,14 @@ OUString getElement(OUString const & version, ::sal_Int32 * index)
namespace dp_misc {
::dp_misc::Order compareVersions(
- OUString const & version1, OUString const & version2)
+ std::u16string_view version1, std::u16string_view version2)
{
- for (::sal_Int32 i1 = 0, i2 = 0; i1 >= 0 || i2 >= 0;) {
- OUString e1(i1 >= 0 ? getElement(version1, &i1) : OUString());
- OUString e2(i2 >= 0 ? getElement(version2, &i2) : OUString());
- if (e1.getLength() < e2.getLength()) {
+ for (size_t i1 = 0, i2 = 0; i1 != std::u16string_view::npos || i2 != std::u16string_view::npos;) {
+ std::u16string_view e1(i1 != std::u16string_view::npos ? getElement(version1, &i1) : std::u16string_view());
+ std::u16string_view e2(i2 != std::u16string_view::npos ? getElement(version2, &i2) : std::u16string_view());
+ if (e1.size() < e2.size()) {
return ::dp_misc::LESS;
- } else if (e1.getLength() > e2.getLength()) {
+ } else if (e1.size() > e2.size()) {
return ::dp_misc::GREATER;
} else if (e1 < e2) {
return ::dp_misc::LESS;
diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index 2e42211e4f4d..234381d0657b 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -83,7 +83,7 @@ std::vector<OUString> getCmdBootstrapVariables()
}
bool jarManifestHeaderPresent(
- OUString const & url, OUString const & name,
+ OUString const & url, std::u16string_view name,
Reference<XCommandEnvironment> const & xCmdEnv )
{
OUString buf = "vnd.sun.star.zip://"
@@ -621,7 +621,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
else if (title.endsWithIgnoreAsciiCase(".jar"))
{
if (jarManifestHeaderPresent(
- url, "RegistrationClassName", xCmdEnv ))
+ url, u"RegistrationClassName", xCmdEnv ))
mediaType = "application/vnd.sun.star.uno-component;type=Java";
if (mediaType.isEmpty())
mediaType = "application/vnd.sun.star.uno-typelibrary;type=Java";
@@ -748,7 +748,7 @@ void BackendImpl::unorc_verify_init(
xCmdEnv, false /* no throw */ ))
{
OUString line;
- if (readLine( &line, "UNO_JAVA_CLASSPATH=", ucb_content,
+ if (readLine( &line, u"UNO_JAVA_CLASSPATH=", ucb_content,
RTL_TEXTENCODING_UTF8 ))
{
sal_Int32 index = sizeof ("UNO_JAVA_CLASSPATH=") - 1;
@@ -770,7 +770,7 @@ void BackendImpl::unorc_verify_init(
}
while (index >= 0);
}
- if (readLine( &line, "UNO_TYPES=", ucb_content,
+ if (readLine( &line, u"UNO_TYPES=", ucb_content,
RTL_TEXTENCODING_UTF8 )) {
sal_Int32 index = sizeof ("UNO_TYPES=") - 1;
do {
@@ -793,7 +793,7 @@ void BackendImpl::unorc_verify_init(
}
while (index >= 0);
}
- if (readLine( &line, "UNO_SERVICES=", ucb_content,
+ if (readLine( &line, u"UNO_SERVICES=", ucb_content,
RTL_TEXTENCODING_UTF8 ))
{
// The UNO_SERVICES line always has the BNF form
@@ -839,7 +839,7 @@ void BackendImpl::unorc_verify_init(
&ucb_content,
makeURL( getCachePath(), getPlatformString() + "rc"),
xCmdEnv, false /* no throw */ )) {
- if (readLine( &line, "UNO_SERVICES=", ucb_content,
+ if (readLine( &line, u"UNO_SERVICES=", ucb_content,
RTL_TEXTENCODING_UTF8 )) {
m_nativeRDB_orig = line.copy(
sizeof ("UNO_SERVICES=?$ORIGIN/") - 1 );
@@ -1376,7 +1376,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_(
impreg->registerImplementation(m_loader, url, rdb);
// Only write to unorc after successful registration; it may fail if
// there is no suitable java
- if (m_loader == "com.sun.star.loader.Java2" && !jarManifestHeaderPresent(url, "UNO-Type-Path", xCmdEnv))
+ if (m_loader == "com.sun.star.loader.Java2" && !jarManifestHeaderPresent(url, u"UNO-Type-Path", xCmdEnv))
{
that->addToUnoRc(RCITEM_JAR_TYPELIB, url, xCmdEnv);
data.javaTypeLibrary = true;
diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
index 62d5ab88fc68..1f4ba053ec55 100644
--- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx
+++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
@@ -381,7 +381,7 @@ void BackendImpl::configmgrini_verify_init(
xCmdEnv, false /* no throw */ ))
{
OUString line;
- if (readLine( &line, "SCHEMA=", ucb_content,
+ if (readLine( &line, u"SCHEMA=", ucb_content,
RTL_TEXTENCODING_UTF8 ))
{
sal_Int32 index = RTL_CONSTASCII_LENGTH("SCHEMA=");
@@ -397,7 +397,7 @@ void BackendImpl::configmgrini_verify_init(
}
while (index >= 0);
}
- if (readLine( &line, "DATA=", ucb_content,
+ if (readLine( &line, u"DATA=", ucb_content,
RTL_TEXTENCODING_UTF8 )) {
sal_Int32 index = RTL_CONSTASCII_LENGTH("DATA=");
do {
@@ -566,12 +566,12 @@ BackendImpl::PackageImpl::isRegistered_(
}
-OUString encodeForXml( OUString const & text )
+OUString encodeForXml( std::u16string_view text )
{
// encode conforming xml:
- sal_Int32 len = text.getLength();
+ size_t len = text.size();
OUStringBuffer buf;
- for ( sal_Int32 pos = 0; pos < len; ++pos )
+ for ( size_t pos = 0; pos < len; ++pos )
{
sal_Unicode c = text[ pos ];
switch (c) {
@@ -651,7 +651,7 @@ OUString replaceOrigin(
if (origin.isEmpty()) {
// encode only once
origin = OUStringToOString(
- encodeForXml( url.copy( 0, url.lastIndexOf( '/' ) ) ),
+ encodeForXml( url.subView( 0, url.lastIndexOf( '/' ) ) ),
// xxx todo: encode always for UTF-8? => lookup doc-header?
RTL_TEXTENCODING_UTF8 );
}