summaryrefslogtreecommitdiffstats
path: root/configmgr/source/data.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr/source/data.cxx')
-rw-r--r--configmgr/source/data.cxx39
1 files changed, 21 insertions, 18 deletions
diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx
index 6e95f1665726..dd15026c17de 100644
--- a/configmgr/source/data.cxx
+++ b/configmgr/source/data.cxx
@@ -21,6 +21,7 @@
#include <algorithm>
#include <cassert>
+#include <cstddef>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <rtl/ref.hxx>
@@ -30,6 +31,7 @@
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
#include <sal/types.h>
+#include <o3tl/string_view.hxx>
#include "additions.hxx"
#include "data.hxx"
@@ -43,23 +45,23 @@ namespace configmgr {
namespace {
bool decode(
- OUString const & encoded, sal_Int32 begin, sal_Int32 end,
+ std::u16string_view encoded, std::size_t begin, std::size_t end,
OUString * decoded)
{
assert(
- begin >= 0 && begin <= end && end <= encoded.getLength() &&
+ begin <= end && end <= encoded.size() &&
decoded != nullptr);
OUStringBuffer buf(end - begin);
while (begin != end) {
sal_Unicode c = encoded[begin++];
if (c == '&') {
- if (encoded.match("amp;", begin)) {
+ if (o3tl::starts_with(encoded.substr(begin), u"amp;")) {
buf.append('&');
begin += RTL_CONSTASCII_LENGTH("amp;");
- } else if (encoded.match("quot;", begin)) {
+ } else if (o3tl::starts_with(encoded.substr(begin), u"quot;")) {
buf.append('"');
begin += RTL_CONSTASCII_LENGTH("quot;");
- } else if (encoded.match("apos;", begin)) {
+ } else if (o3tl::starts_with(encoded.substr(begin), u"apos;")) {
buf.append('\'');
begin += RTL_CONSTASCII_LENGTH("apos;");
} else {
@@ -83,9 +85,8 @@ OUString Data::createSegment(
return name;
}
OUStringBuffer buf(128);
- buf.append(templateName);
- //TODO: verify template name contains no bad chars?
- buf.append("['");
+ //TODO: verify template name contains no bad chars?
+ buf.append(OUString::Concat(templateName) + "['");
for (sal_Int32 i = 0; i < name.getLength(); ++i) {
sal_Unicode c = name[i];
switch (c) {
@@ -123,10 +124,14 @@ sal_Int32 Data::parseSegment(
*setElement = false;
return i;
}
- if (templateName != nullptr) {
- if (i - index == 1 && path[index] == '*') {
+ if (i - index == 1 && path[index] == '*') {
+ *setElement = true;
+ if (templateName != nullptr) {
templateName->clear();
- } else {
+ }
+ } else {
+ *setElement = i != index;
+ if (templateName != nullptr) {
*templateName = path.copy(index, i - index);
}
}
@@ -143,19 +148,18 @@ sal_Int32 Data::parseSegment(
{
return -1;
}
- *setElement = true;
return j + 2;
}
OUString Data::fullTemplateName(
- OUString const & component, OUString const & name)
+ std::u16string_view component, std::u16string_view name)
{
- if (component.indexOf(':') != -1 || name.indexOf(':') != -1) {
+ if (component.find(':') != std::u16string_view::npos || name.find(':') != std::u16string_view::npos) {
throw css::uno::RuntimeException(
- "bad component/name pair containing colon " + component + "/" +
+ OUString::Concat("bad component/name pair containing colon ") + component + "/" +
name);
}
- return component + ":" + name;
+ return OUString::Concat(component) + ":" + name;
}
bool Data::equalTemplateNames(
@@ -216,8 +220,7 @@ rtl::Reference< Node > Data::resolvePathRepresentation(
return p;
}
if (canonicRepresentation != nullptr) {
- canonic.append('/');
- canonic.append(createSegment(templateName, seg));
+ canonic.append("/" + createSegment(templateName, seg));
}
if (path != nullptr) {
path->push_back(seg);