sc/qa/unit/tiledrendering/tiledrendering.cxx   |    4 ++--
 sc/source/filter/inc/namebuff.hxx              |    2 +-
 sc/source/filter/lotus/tool.cxx                |    6 +++---
 sc/source/filter/xml/XMLStylesExportHelper.cxx |   13 +++++++------
 sc/source/filter/xml/XMLStylesExportHelper.hxx |    4 ++--
 sc/source/filter/xml/xmlexprt.cxx              |    4 ++--
 6 files changed, 17 insertions(+), 16 deletions(-)

New commits:
commit 00e5bf746f85edf32ab7464abec2f4fccfc46bcd
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sat Apr 16 19:51:34 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Apr 17 08:45:20 2022 +0200

    use more string_view in sc
    
    Change-Id: I5f77167ad874200fa4f7bc16e5de8a3348cb1886
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133097
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 935c04d14d46..296e2703ef87 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -846,9 +846,9 @@ void ScTiledRenderingTest::testViewLock()
     CPPUNIT_ASSERT(!aView1.m_bViewLock);
 }
 
-void lcl_extractHandleParameters(const OString& selection, sal_uInt32& id, 
sal_uInt32& x, sal_uInt32& y)
+void lcl_extractHandleParameters(std::string_view selection, sal_uInt32& id, 
sal_uInt32& x, sal_uInt32& y)
 {
-    OString extraInfo = selection.copy(selection.indexOf("{"));
+    OString extraInfo( selection.substr(selection.find("{")) );
     std::stringstream aStream(extraInfo.getStr());
     boost::property_tree::ptree aTree;
     boost::property_tree::read_json(aStream, aTree);
diff --git a/sc/source/filter/inc/namebuff.hxx 
b/sc/source/filter/inc/namebuff.hxx
index 24ff4dc395bd..4ad7bc102c6d 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -100,7 +100,7 @@ public:
     void                    Add( const ScDocument& rDoc, const OUString& 
rName, const ScComplexRefData& rCRD );
     inline void             Add( const ScDocument& rDoc, const OUString& 
rName, const ScRange& aScRange );
     bool                    FindRel( const OUString& rRef, sal_uInt16& rIndex 
);
-    bool                    FindAbs( const OUString& rRef, sal_uInt16& rIndex 
);
+    bool                    FindAbs( std::u16string_view rRef, sal_uInt16& 
rIndex );
 };
 
 inline void RangeNameBufferWK3::Add( const ScDocument& rDoc, const OUString& 
rName, const ScRange& aScRange )
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index a38a7286385e..c3bf46b4f8ad 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -478,11 +478,11 @@ bool RangeNameBufferWK3::FindRel( const OUString& rRef, 
sal_uInt16& rIndex )
     return false;
 }
 
-bool RangeNameBufferWK3::FindAbs( const OUString& rRef, sal_uInt16& rIndex )
+bool RangeNameBufferWK3::FindAbs( std::u16string_view rRef, sal_uInt16& rIndex 
)
 {
-    if (rRef.isEmpty())
+    if (rRef.empty())
         return false;
-    StringHashEntry aRef(rRef.copy(1)); // search w/o '$'!
+    StringHashEntry aRef(OUString(rRef.substr(1))); // search w/o '$'!
 
     std::vector<Entry>::iterator itr = std::find_if(maEntries.begin(), 
maEntries.end(),
         [&aRef](const Entry& rEntry) { return aRef == rEntry.aStrHashEntry; });
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx 
b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index 0a403ac9de98..81c30e4241e8 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -35,6 +35,7 @@
 #include <comphelper/propertysequence.hxx>
 #include <sfx2/app.hxx>
 #include <o3tl/safeint.hxx>
+#include <o3tl/string_view.hxx>
 #include <osl/diagnose.h>
 
 using namespace com::sun::star;
@@ -701,11 +702,11 @@ bool ScFormatRangeStyles::AddStyleName(OUString const & 
rString, sal_Int32& rInd
     }
 }
 
-sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const OUString& rString, 
const OUString& rPrefix, bool& bIsAutoStyle)
+sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(std::u16string_view 
rString, const OUString& rPrefix, bool& bIsAutoStyle)
 {
     sal_Int32 nPrefixLength(rPrefix.getLength());
-    OUString sTemp(rString.copy(nPrefixLength));
-    sal_Int32 nIndex(sTemp.toInt32());
+    std::u16string_view sTemp(rString.substr(nPrefixLength));
+    sal_Int32 nIndex(o3tl::toInt32(sTemp));
     if (nIndex > 0 && o3tl::make_unsigned(nIndex-1) < aAutoStyleNames.size() 
&& aAutoStyleNames.at(nIndex - 1) == rString)
     {
         bIsAutoStyle = true;
@@ -913,11 +914,11 @@ sal_Int32 ScColumnRowStylesBase::AddStyleName(const 
OUString & rString)
     return aStyleNames.size() - 1;
 }
 
-sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(const OUString& rString, 
const OUString& rPrefix)
+sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(std::u16string_view 
rString, const OUString& rPrefix)
 {
     sal_Int32 nPrefixLength(rPrefix.getLength());
-    OUString sTemp(rString.copy(nPrefixLength));
-    sal_Int32 nIndex(sTemp.toInt32());
+    std::u16string_view sTemp(rString.substr(nPrefixLength));
+    sal_Int32 nIndex(o3tl::toInt32(sTemp));
     if (nIndex > 0 && o3tl::make_unsigned(nIndex-1) < aStyleNames.size() && 
aStyleNames.at(nIndex - 1) == rString)
         return nIndex - 1;
     else
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.hxx 
b/sc/source/filter/xml/XMLStylesExportHelper.hxx
index 5f539ea7e6a9..844ffc4185a1 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.hxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.hxx
@@ -172,7 +172,7 @@ public:
     void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults 
= pDefaults; }
     void AddNewTable(const sal_Int32 nTable);
     bool AddStyleName(const OUString& rString, sal_Int32& rIndex, const bool 
bIsAutoStyle = true);
-    sal_Int32 GetIndexOfStyleName(const OUString& rString, const OUString& 
rPrefix, bool& bIsAutoStyle);
+    sal_Int32 GetIndexOfStyleName(std::u16string_view rString, const OUString& 
rPrefix, bool& bIsAutoStyle);
     // does not delete ranges
     sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 
nColumn, const sal_Int32 nRow,
         bool& bIsAutoStyle) const;
@@ -197,7 +197,7 @@ public:
 
     virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) 
= 0;
     sal_Int32 AddStyleName(const OUString & rString);
-    sal_Int32 GetIndexOfStyleName(const OUString& rString, const OUString& 
rPrefix);
+    sal_Int32 GetIndexOfStyleName(std::u16string_view rString, const OUString& 
rPrefix);
     OUString& GetStyleNameByIndex(const sal_Int32 nIndex);
 };
 
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 95efb4bb255f..9978db86c010 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3085,7 +3085,7 @@ void writeContent(
 }
 
 void flushParagraph(
-    ScXMLExport& rExport, const OUString& rParaText,
+    ScXMLExport& rExport, std::u16string_view rParaText,
     rtl::Reference<XMLPropertySetMapper> const & xMapper, 
rtl::Reference<SvXMLAutoStylePoolP> const & xStylePool,
     const ScXMLEditAttributeMap& rAttrMap,
     std::vector<editeng::Section>::const_iterator it, 
std::vector<editeng::Section>::const_iterator const & itEnd )
@@ -3098,7 +3098,7 @@ void flushParagraph(
     {
         const editeng::Section& rSec = *it;
 
-        OUString aContent(rParaText.copy(rSec.mnStart, rSec.mnEnd - 
rSec.mnStart));
+        OUString aContent(rParaText.substr(rSec.mnStart, rSec.mnEnd - 
rSec.mnStart));
 
         std::vector<XMLPropertyState> aPropStates;
         const SvxFieldData* pField = toXMLPropertyStates(aPropStates, 
rSec.maAttributes, xMapper, rAttrMap);

Reply via email to