summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-29 10:41:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-29 17:21:50 +0200
commitdc3d56e5cf49a23b3c3fd08590fa497b72e6ff20 (patch)
tree909cb0a0472cafa7f3e8638d40661690f4e31942
parent7cc3d290779796b54f5b6fb1a4a32066f177d323 (diff)
use more string_view in xmloff
found by examining uses of OUString::copy() for likely places Change-Id: I50adefbcdbfde8aa71134e5f162b6986a6d566a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133623 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--xmloff/inc/xmlversion.hxx2
-rw-r--r--xmloff/source/chart/SchXMLTools.cxx28
-rw-r--r--xmloff/source/core/namespacemap.cxx5
-rw-r--r--xmloff/source/draw/sdxmlexp.cxx2
-rw-r--r--xmloff/source/draw/ximpbody.cxx2
-rw-r--r--xmloff/source/draw/ximpcustomshape.cxx2
-rw-r--r--xmloff/source/forms/elementimport.cxx13
-rw-r--r--xmloff/source/meta/xmlversion.cxx24
-rw-r--r--xmloff/source/style/xmlbahdl.cxx2
9 files changed, 40 insertions, 40 deletions
diff --git a/xmloff/inc/xmlversion.hxx b/xmloff/inc/xmlversion.hxx
index 284e998c5bf1..5039fc7d7cce 100644
--- a/xmloff/inc/xmlversion.hxx
+++ b/xmloff/inc/xmlversion.hxx
@@ -85,7 +85,7 @@ class XMLVersionContext final : public SvXMLImportContext
{
private:
static bool ParseISODateTimeString(
- const OUString& rString,
+ std::u16string_view rString,
css::util::DateTime& rDateTime );
public:
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index 2e90a3e37f5e..b6bfaab104aa 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -295,30 +295,30 @@ XMLTokenEnum getTokenByChartType(
// if postfix matches and leaves a non-empty type
if( nTypeLength > 0 && rChartTypeService.match( aPostfix, nSkip + nTypeLength ))
{
- OUString aServiceName( rChartTypeService.copy( nSkip, nTypeLength ));
+ std::u16string_view aServiceName( rChartTypeService.subView( nSkip, nTypeLength ));
- if ( aServiceName == "Line" )
+ if ( aServiceName == u"Line" )
eResult = XML_LINE;
- else if ( aServiceName == "Area" )
+ else if ( aServiceName == u"Area" )
eResult = XML_AREA;
- else if( aServiceName == "Bar" ||
- (!bUseOldNames && aServiceName == "Column"))
+ else if( aServiceName == u"Bar" ||
+ (!bUseOldNames && aServiceName == u"Column"))
eResult = XML_BAR;
- else if ( aServiceName == "Pie" )
+ else if ( aServiceName == u"Pie" )
eResult = XML_CIRCLE;
- else if ( aServiceName == "Donut" )
+ else if ( aServiceName == u"Donut" )
eResult = XML_RING;
- else if( (bUseOldNames && aServiceName == "XY") ||
- (!bUseOldNames && aServiceName == "Scatter"))
+ else if( (bUseOldNames && aServiceName == u"XY") ||
+ (!bUseOldNames && aServiceName == u"Scatter"))
eResult = XML_SCATTER;
- else if ( aServiceName == "Bubble" )
+ else if ( aServiceName == u"Bubble" )
eResult = XML_BUBBLE;
- else if ( aServiceName == "Net" )
+ else if ( aServiceName == u"Net" )
eResult = XML_RADAR;
- else if ( aServiceName == "FilledNet" )
+ else if ( aServiceName == u"FilledNet" )
eResult = XML_FILLED_RADAR;
- else if( (bUseOldNames && aServiceName == "Stock") ||
- (!bUseOldNames && aServiceName == "CandleStick"))
+ else if( (bUseOldNames && aServiceName == u"Stock") ||
+ (!bUseOldNames && aServiceName == u"CandleStick"))
eResult = XML_STOCK;
}
}
diff --git a/xmloff/source/core/namespacemap.cxx b/xmloff/source/core/namespacemap.cxx
index 4d5ec0d503da..e6e2a68a84c9 100644
--- a/xmloff/source/core/namespacemap.cxx
+++ b/xmloff/source/core/namespacemap.cxx
@@ -27,6 +27,7 @@
#include <xmloff/namespacemap.hxx>
#include <xmloff/xmlnamespace.hxx>
+#include <o3tl/string_view.hxx>
using namespace ::xmloff::token;
@@ -517,9 +518,9 @@ bool SvXMLNamespaceMap::NormalizeOasisURN( OUString& rName )
// :urn:oasis:names:tc:[^:]:xmlns.*
nPos = nTCIdEnd + 1;
- OUString sTmp( rName.copy( nPos ) );
+ std::u16string_view sTmp( rName.subView( nPos ) );
const OUString& rXMLNS = GetXMLToken( XML_XMLNS );
- if( !sTmp.startsWith( rXMLNS ) )
+ if( !o3tl::starts_with(sTmp, rXMLNS ) )
return false;
// :urn:oasis:names:tc:[^:]:xmlns:.*
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index b789f7342d90..3cb6034193b0 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -1693,7 +1693,7 @@ void SdXMLExport::ExportContent_()
if( nIndex != -1 )
{
OUString aFileName( aBookmarkURL.copy( 0, nIndex ) );
- OUString aBookmarkName( aBookmarkURL.copy( nIndex+1 ) );
+ std::u16string_view aBookmarkName( aBookmarkURL.subView( nIndex+1 ) );
aBookmarkURL = GetRelativeReference( aFileName ) + "#" + aBookmarkName;
}
diff --git a/xmloff/source/draw/ximpbody.cxx b/xmloff/source/draw/ximpbody.cxx
index d77ae15ed4e5..1f869f520b79 100644
--- a/xmloff/source/draw/ximpbody.cxx
+++ b/xmloff/source/draw/ximpbody.cxx
@@ -190,7 +190,7 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport,
if( nIndex != -1 )
{
OUString aFileName( sHREF.copy( 0, nIndex ) );
- OUString aBookmarkName( sHREF.copy( nIndex+1 ) );
+ std::u16string_view aBookmarkName( sHREF.subView( nIndex+1 ) );
sHREF = GetImport().GetAbsoluteReference( aFileName ) + "#"
+ aBookmarkName;
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx
index c8b90dcf26df..6f4c586a9626 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -383,7 +383,7 @@ static bool GetNextParameter( css::drawing::EnhancedCustomShapeParameter& rParam
bValid = false;
if ( bValid )
{
- OUString aNumber( rParaString.copy( nStartIndex, nIndex - nStartIndex ) );
+ std::u16string_view aNumber( rParaString.subView( nStartIndex, nIndex - nStartIndex ) );
if ( bE || bDot )
{
double fAttrDouble;
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx
index 0bbc1d51b883..bfcad5b55c0b 100644
--- a/xmloff/source/forms/elementimport.cxx
+++ b/xmloff/source/forms/elementimport.cxx
@@ -49,6 +49,7 @@
#include <comphelper/extract.hxx>
#include <comphelper/types.hxx>
#include <comphelper/sequence.hxx>
+#include <o3tl/string_view.hxx>
#include <algorithm>
@@ -2002,8 +2003,6 @@ namespace xmloff
sal_Int32 nElementStart = 0;
sal_Int32 nNextSep = 0;
- sal_Int32 nElementLength;
- OUString sElement;
do
{
// extract the current element
@@ -2011,15 +2010,15 @@ namespace xmloff
_rValue, nElementStart);
if (-1 == nNextSep)
nNextSep = nLength;
- sElement = _rValue.copy(nElementStart, nNextSep - nElementStart);
+ std::u16string_view sElement = _rValue.subView(nElementStart, nNextSep - nElementStart);
- nElementLength = sElement.getLength();
+ size_t nElementLength = sElement.size();
// when writing the sequence, we quoted the single elements with " characters
- OSL_ENSURE( sElement.startsWith("\"") && sElement.endsWith("\""),
+ OSL_ENSURE( o3tl::starts_with(sElement, u"\"") && o3tl::ends_with(sElement, u"\""),
"OFormImport::implTranslateStringListProperty: invalid quoted element name.");
- sElement = sElement.copy(1, nElementLength - 2);
+ sElement = sElement.substr(1, nElementLength - 2);
- aElements.push_back(sElement);
+ aElements.push_back(OUString(sElement));
// switch to the next element
nElementStart = 1 + nNextSep;
diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx
index 47acf7737be6..c39d8f77f3cc 100644
--- a/xmloff/source/meta/xmlversion.cxx
+++ b/xmloff/source/meta/xmlversion.cxx
@@ -202,17 +202,17 @@ XMLVersionContext::~XMLVersionContext()
{}
bool XMLVersionContext::ParseISODateTimeString(
- const OUString& rString,
+ std::u16string_view rString,
util::DateTime& rDateTime )
{
bool bSuccess = true;
- OUString aDateStr, aTimeStr;
- sal_Int32 nPos = rString.indexOf( 'T' );
- if ( nPos >= 0 )
+ std::u16string_view aDateStr, aTimeStr;
+ size_t nPos = rString.find( 'T' );
+ if ( nPos != std::u16string_view::npos )
{
- aDateStr = rString.copy( 0, nPos );
- aTimeStr = rString.copy( nPos + 1 );
+ aDateStr = rString.substr( 0, nPos );
+ aTimeStr = rString.substr( nPos + 1 );
}
else
aDateStr = rString; // no separator: only date part
@@ -224,15 +224,15 @@ bool XMLVersionContext::ParseISODateTimeString(
sal_Int32 nMin = 0;
sal_Int32 nSec = 0;
- const sal_Unicode* pStr = aDateStr.getStr();
+ auto pStr = aDateStr.begin();
sal_Int32 nDateTokens = 1;
- while ( *pStr )
+ while ( pStr != aDateStr.end() )
{
if ( *pStr == '-' )
nDateTokens++;
pStr++;
}
- if ( nDateTokens > 3 || aDateStr.isEmpty() )
+ if ( nDateTokens > 3 || aDateStr.empty() )
bSuccess = false;
else
{
@@ -254,11 +254,11 @@ bool XMLVersionContext::ParseISODateTimeString(
}
}
- if ( bSuccess && !aTimeStr.isEmpty() ) // time is optional
+ if ( bSuccess && !aTimeStr.empty() ) // time is optional
{
- pStr = aTimeStr.getStr();
+ pStr = aTimeStr.begin();
sal_Int32 nTimeTokens = 1;
- while ( *pStr )
+ while ( pStr != aTimeStr.end() )
{
if ( *pStr == ':' )
nTimeTokens++;
diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx
index 06ac88fe8fa9..2f5af33b4eb1 100644
--- a/xmloff/source/style/xmlbahdl.cxx
+++ b/xmloff/source/style/xmlbahdl.cxx
@@ -473,7 +473,7 @@ bool XMLColorPropHdl::importXML( const OUString& rStrImpValue, Any& rValue, cons
if( (nOpen != -1) && (nClose > nOpen) )
{
- const OUString aTmp( rStrImpValue.copy( nOpen+1, nClose - nOpen-1) );
+ const std::u16string_view aTmp( rStrImpValue.subView( nOpen+1, nClose - nOpen-1) );
sal_Int32 nIndex = 0;