summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-13 16:14:26 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-13 20:36:16 +0200
commit0d55188fbf7b0399f01bae521f1a34d22ad8ba18 (patch)
tree7094b0fe13c8d6d7a288d160ae595acaac23e83c /xmloff
parent902e81b1b0c62993270846962d44aea6774e9687 (diff)
use more string_view in xmloff
Change-Id: I0d860fa6e3d3261f3393e912b27930066dd93f7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132972 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/txtflde.hxx2
-rw-r--r--xmloff/source/chart/SchXMLTools.cxx8
-rw-r--r--xmloff/source/core/unoatrcn.cxx10
-rw-r--r--xmloff/source/core/xmlexp.cxx8
-rw-r--r--xmloff/source/draw/shapeexport.cxx23
-rw-r--r--xmloff/source/text/txtflde.cxx10
6 files changed, 31 insertions, 30 deletions
diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx
index 66c5eed3f67e..8670cac40cf6 100644
--- a/xmloff/inc/txtflde.hxx
+++ b/xmloff/inc/txtflde.hxx
@@ -395,7 +395,7 @@ private:
/// explode a field master name into field type and field name
static void ExplodeFieldMasterName(
- const OUString& sMasterName, /// name as returned by SO API
+ std::u16string_view sMasterName, /// name as returned by SO API
OUString& sFieldType, /// out: field type
OUString& sVarName); /// out: variable name
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index 27fa23987b59..828d550e9f56 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -86,15 +86,15 @@ OUString lcl_getGeneratorFromModelOrItsParent( const uno::Reference< frame::XMod
return aGenerator;
}
-sal_Int32 lcl_getBuildIDFromGenerator( const OUString& rGenerator )
+sal_Int32 lcl_getBuildIDFromGenerator( std::u16string_view rGenerator )
{
//returns -1 if nothing found
sal_Int32 nBuildId = -1;
static const OUStringLiteral sBuildCompare( u"$Build-" );
- sal_Int32 nBegin = rGenerator.indexOf( sBuildCompare );
- if( nBegin >= 0 )
+ size_t nBegin = rGenerator.find( sBuildCompare );
+ if( nBegin != std::u16string_view::npos )
{
- OUString sBuildId( rGenerator.copy( nBegin + sBuildCompare.getLength() ) );
+ OUString sBuildId( rGenerator.substr( nBegin + sBuildCompare.getLength() ) );
nBuildId = sBuildId.toInt32();
}
return nBuildId;
diff --git a/xmloff/source/core/unoatrcn.cxx b/xmloff/source/core/unoatrcn.cxx
index 9125e6cfb93c..354cd47b49ce 100644
--- a/xmloff/source/core/unoatrcn.cxx
+++ b/xmloff/source/core/unoatrcn.cxx
@@ -56,12 +56,12 @@ sal_Bool SAL_CALL SvUnoAttributeContainer::hasElements()
return mpContainer->GetAttrCount() != 0;
}
-sal_uInt16 SvUnoAttributeContainer::getIndexByName(const OUString& aName ) const
+sal_uInt16 SvUnoAttributeContainer::getIndexByName(std::u16string_view aName ) const
{
const sal_uInt16 nAttrCount = mpContainer->GetAttrCount();
- sal_Int32 nPos = aName.indexOf( ':' );
- if( nPos == -1 )
+ size_t nPos = aName.find( ':' );
+ if( nPos == std::u16string_view::npos )
{
for( sal_uInt16 nAttr = 0; nAttr < nAttrCount; nAttr++ )
{
@@ -72,8 +72,8 @@ sal_uInt16 SvUnoAttributeContainer::getIndexByName(const OUString& aName ) const
}
else
{
- const OUString aPrefix( aName.copy( 0L, nPos ) );
- const OUString aLName( aName.copy( nPos+1 ) );
+ const std::u16string_view aPrefix( aName.substr( 0L, nPos ) );
+ const std::u16string_view aLName( aName.substr( nPos+1 ) );
for( sal_uInt16 nAttr = 0; nAttr < nAttrCount; nAttr++ )
{
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index e0110892a6f3..cc4eb39b3bd8 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -265,11 +265,11 @@ public:
bool mbExportTextNumberElement;
bool mbNullDateInitialized;
- void SetSchemeOf( const OUString& rOrigFileName )
+ void SetSchemeOf( std::u16string_view rOrigFileName )
{
- sal_Int32 nSep = rOrigFileName.indexOf(':');
- if( nSep != -1 )
- msPackageURIScheme = rOrigFileName.copy( 0, nSep );
+ size_t nSep = rOrigFileName.find(':');
+ if( nSep != std::u16string_view::npos )
+ msPackageURIScheme = rOrigFileName.substr( 0, nSep );
}
};
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index bc642d344e68..55de243f07aa 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -90,6 +90,7 @@
#include <o3tl/any.hxx>
#include <o3tl/typed_flags_set.hxx>
+#include <o3tl/string_view.hxx>
#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
@@ -2408,22 +2409,22 @@ void XMLShapeExport::ImpExportPolygonShape(
namespace
{
-OUString getNameFromStreamURL(OUString const & rURL)
+OUString getNameFromStreamURL(std::u16string_view rURL)
{
- static const OUStringLiteral sPackageURL(u"vnd.sun.star.Package:");
+ static constexpr std::u16string_view sPackageURL(u"vnd.sun.star.Package:");
OUString sResult;
- if (rURL.match(sPackageURL))
+ if (o3tl::starts_with(rURL, sPackageURL))
{
- OUString sRequestedName = rURL.copy(sPackageURL.getLength());
- sal_Int32 nLastIndex = sRequestedName.lastIndexOf('/') + 1;
- if ((nLastIndex > 0) && (nLastIndex < sRequestedName.getLength()))
- sRequestedName = sRequestedName.copy(nLastIndex);
- nLastIndex = sRequestedName.lastIndexOf('.');
- if (nLastIndex >= 0)
- sRequestedName = sRequestedName.copy(0, nLastIndex);
- if (!sRequestedName.isEmpty())
+ std::u16string_view sRequestedName = rURL.substr(sPackageURL.size());
+ size_t nLastIndex = sRequestedName.rfind('/') + 1;
+ if ((nLastIndex > 0) && (nLastIndex < sRequestedName.size()))
+ sRequestedName = sRequestedName.substr(nLastIndex);
+ nLastIndex = sRequestedName.rfind('.');
+ if (nLastIndex != std::u16string_view::npos)
+ sRequestedName = sRequestedName.substr(0, nLastIndex);
+ if (!sRequestedName.empty())
sResult = sRequestedName;
}
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index 1fe5da65caf6..fb6cd419b923 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -2847,19 +2847,19 @@ void XMLTextFieldExport::ExportDataBaseElement(
// explode a field master name into field type and field name
void XMLTextFieldExport::ExplodeFieldMasterName(
- const OUString& sMasterName, OUString& sFieldType, OUString& sVarName)
+ std::u16string_view sMasterName, OUString& sFieldType, OUString& sVarName)
{
sal_Int32 nLength = gsFieldMasterPrefix.getLength();
- sal_Int32 nSeparator = sMasterName.indexOf('.', nLength);
+ size_t nSeparator = sMasterName.find('.', nLength);
// '.' found?
- if (nSeparator <= nLength) {
+ if (static_cast<sal_Int32>(nSeparator) == nLength || nSeparator == std::u16string_view::npos) {
SAL_WARN("xmloff.text", "no field var name!");
}
else
{
- sFieldType = sMasterName.copy(nLength, nSeparator-nLength);
- sVarName = sMasterName.copy(nSeparator+1);
+ sFieldType = sMasterName.substr(nLength, nSeparator-nLength);
+ sVarName = sMasterName.substr(nSeparator+1);
}
}