sw/inc/calc.hxx                                |    2 -
 sw/inc/docufld.hxx                             |    2 -
 sw/inc/ndgrf.hxx                               |    2 -
 sw/inc/unochart.hxx                            |    4 +--
 sw/inc/unostyle.hxx                            |    2 -
 sw/qa/extras/tiledrendering/tiledrendering.cxx |    4 +--
 sw/source/core/bastyp/calc.cxx                 |   12 +++++------
 sw/source/core/fields/docufld.cxx              |   12 +++++------
 sw/source/core/graphic/ndgrf.cxx               |    9 ++++----
 sw/source/core/text/porlin.cxx                 |    4 +--
 sw/source/core/text/porlin.hxx                 |    2 -
 sw/source/core/undo/undel.cxx                  |    6 ++---
 sw/source/core/unocore/XMLRangeHelper.cxx      |    4 +--
 sw/source/core/unocore/unochart.cxx            |   26 ++++++++++++-------------
 sw/source/core/unocore/unostyle.cxx            |   19 +++++++++---------
 sw/source/filter/ww8/docxattributeoutput.cxx   |   12 +++++------
 sw/source/filter/ww8/docxattributeoutput.hxx   |    2 -
 sw/source/filter/ww8/wrtw8nds.cxx              |   12 +++++------
 sw/source/filter/ww8/wrtww8.hxx                |    2 -
 19 files changed, 70 insertions(+), 68 deletions(-)

New commits:
commit 7337c4181331eaf091050181d4c21be5911ac815
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sat Apr 16 19:52:04 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Apr 16 21:25:42 2022 +0200

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

diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index 5ff42c15c59e..1fabeede4dab 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -219,7 +219,7 @@ class SwCalc
     SwSbxValue  StdFunc(pfCalc pFnc, bool bChkTrig);
 
     static OUString  GetColumnName( const OUString& rName );
-    OUString  GetDBName( const OUString& rName );
+    OUString  GetDBName( std::u16string_view rName );
 
     SwCalc( const SwCalc& ) = delete;
     SwCalc& operator=( const SwCalc& ) = delete;
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index f1023e372970..1cb5d23e0e71 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -330,7 +330,7 @@ public:
 
     void         SetValue(bool bHidden)  { m_bIsHidden = bHidden; }
     static OUString     GetColumnName(const OUString& rName);
-    static OUString     GetDBName(const OUString& rName, SwDoc& rDoc);
+    static OUString     GetDBName(std::u16string_view rName, SwDoc& rDoc);
 
     /// Condition
     virtual void        SetPar1(const OUString& rStr) override;
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 9397156bb078..94569aafe4e1 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -66,7 +66,7 @@ class SW_DLLPUBLIC SwGrfNode final: public SwNoTextNode
                SwGrfFormatColl* pGrfColl,
                SwAttrSet const * pAutoAttr );
 
-    void InsertLink( const OUString& rGrfName, const OUString& rFltName );
+    void InsertLink( std::u16string_view rGrfName, const OUString& rFltName );
 
     /// allow reaction on change of content of GraphicObject, so always call
     /// when GraphicObject content changes
diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx
index a639127d97fb..e6373460f853 100644
--- a/sw/inc/unochart.hxx
+++ b/sw/inc/unochart.hxx
@@ -137,9 +137,9 @@ class SwChartDataProvider final :
     css::uno::Reference< css::chart2::data::XDataSource > 
Impl_createDataSource( const css::uno::Sequence< css::beans::PropertyValue >& 
aArguments, bool bTestOnly = false );
     /// @throws css::lang::IllegalArgumentException
     /// @throws css::uno::RuntimeException
-    css::uno::Reference< css::chart2::data::XDataSequence > 
Impl_createDataSequenceByRangeRepresentation( const OUString& 
aRangeRepresentation, bool bTestOnly = false );
+    css::uno::Reference< css::chart2::data::XDataSequence > 
Impl_createDataSequenceByRangeRepresentation( std::u16string_view 
aRangeRepresentation, bool bTestOnly = false );
 
-    static OUString GetBrokenCellRangeForExport( const OUString 
&rCellRangeRepresentation );
+    static OUString GetBrokenCellRangeForExport( std::u16string_view 
rCellRangeRepresentation );
 
 public:
     SwChartDataProvider( const SwDoc& rDoc );
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index a865a3880d75..d3f1124785b9 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -351,7 +351,7 @@ class SwXTextCellStyle final : public cppu::WeakImplHelper
     * @param pParentName Optional output. Pointer to an OUString where parsed 
parent name will be returned.
     * @return Pointer to a SwBoxAutoFormat, nullptr if not found.
     */
-    static SwBoxAutoFormat* GetBoxAutoFormat(SwDocShell* pDocShell, const 
OUString& sName, OUString* pParentName);
+    static SwBoxAutoFormat* GetBoxAutoFormat(SwDocShell* pDocShell, 
std::u16string_view sName, OUString* pParentName);
     /// returns box format assigned to this style
     SwBoxAutoFormat* GetBoxFormat();
     /// Sets the address of SwBoxAutoFormat this style is bound to. Usable 
only when style is physical.
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 9d603643e652..826f7fbfa5c6 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3259,9 +3259,9 @@ void 
SwTiledRenderingTest::testDropDownFormFieldButtonNoSelection()
     }
 }
 
-static void lcl_extractHandleParameters(const OString& selection, sal_Int32& 
id, sal_Int32& x, sal_Int32& y)
+static void lcl_extractHandleParameters(std::string_view selection, sal_Int32& 
id, sal_Int32& x, sal_Int32& 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/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 07efe7528f3b..04b3e94490c7 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -1336,15 +1336,15 @@ OUString SwCalc::GetColumnName(const OUString& rName)
     return rName;
 }
 
-OUString SwCalc::GetDBName(const OUString& rName)
+OUString SwCalc::GetDBName(std::u16string_view rName)
 {
-    sal_Int32 nPos = rName.indexOf(DB_DELIM);
-    if( -1 != nPos )
+    size_t nPos = rName.find(DB_DELIM);
+    if( std::u16string_view::npos != nPos )
     {
-        nPos = rName.indexOf(DB_DELIM, nPos + 1);
+        nPos = rName.find(DB_DELIM, nPos + 1);
 
-        if( -1 != nPos )
-            return rName.copy( 0, nPos );
+        if( std::u16string_view::npos != nPos )
+            return OUString(rName.substr( 0, nPos ));
     }
     SwDBData aData = m_rDoc.GetDBData();
     return aData.sDataSource + OUStringChar(DB_DELIM) + aData.sCommand;
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index 798cd337f5c8..208ee379e245 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -1514,15 +1514,15 @@ OUString SwHiddenTextField::GetColumnName(const 
OUString& rName)
     return rName;
 }
 
-OUString SwHiddenTextField::GetDBName(const OUString& rName, SwDoc& rDoc)
+OUString SwHiddenTextField::GetDBName(std::u16string_view rName, SwDoc& rDoc)
 {
-    sal_Int32 nPos = rName.indexOf(DB_DELIM);
-    if( nPos>=0 )
+    size_t nPos = rName.find(DB_DELIM);
+    if( nPos != std::u16string_view::npos )
     {
-        nPos = rName.indexOf(DB_DELIM, nPos + 1);
+        nPos = rName.find(DB_DELIM, nPos + 1);
 
-        if( nPos>=0 )
-            return rName.copy(0, nPos);
+        if( nPos != std::u16string_view::npos )
+            return OUString(rName.substr(0, nPos));
     }
 
     SwDBData aData = rDoc.GetDBData();
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 04d609d80a50..3eabac3a84b5 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -49,6 +49,7 @@
 
 #include <rtl/ustring.hxx>
 #include <o3tl/deleter.hxx>
+#include <o3tl/string_view.hxx>
 #include <osl/diagnose.h>
 #include <retrieveinputstreamconsumer.hxx>
 #include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
@@ -563,7 +564,7 @@ bool SwGrfNode::RestorePersistentData()
     return true;
 }
 
-void SwGrfNode::InsertLink( const OUString& rGrfName, const OUString& rFltName 
)
+void SwGrfNode::InsertLink( std::u16string_view rGrfName, const OUString& 
rFltName )
 {
     mxLink = new SwBaseLink( SfxLinkUpdateMode::ONCALL, 
SotClipboardFormatId::GDIMETAFILE, this );
 
@@ -575,9 +576,9 @@ void SwGrfNode::InsertLink( const OUString& rGrfName, const 
OUString& rFltName )
     if( rFltName == "DDE" )
     {
         sal_Int32 nTmp = 0;
-        const OUString sApp{ rGrfName.getToken( 0, sfx2::cTokenSeparator, nTmp 
) };
-        const OUString sTopic{ rGrfName.getToken( 0, sfx2::cTokenSeparator, 
nTmp ) };
-        const OUString sItem{ rGrfName.copy( nTmp ) };
+        const OUString sApp{ o3tl::getToken(rGrfName, 0, 
sfx2::cTokenSeparator, nTmp ) };
+        const OUString sTopic{ o3tl::getToken(rGrfName, 0, 
sfx2::cTokenSeparator, nTmp ) };
+        const OUString sItem{ rGrfName.substr( nTmp ) };
         rIDLA.GetLinkManager().InsertDDELink( mxLink.get(), sApp, sTopic, 
sItem );
     }
     else
diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx
index 16bc46b58ebf..d7b3a1a41e5b 100644
--- a/sw/source/core/text/porlin.cxx
+++ b/sw/source/core/text/porlin.cxx
@@ -326,7 +326,7 @@ void SwLinePortion::dumpAsXml(xmlTextWriterPtr pWriter, 
const OUString& rText, T
     (void)xmlTextWriterEndElement(pWriter);
 }
 
-void SwLinePortion::dumpAsXmlAttributes(xmlTextWriterPtr pWriter, const 
OUString& rText, TextFrameIndex nOffset) const
+void SwLinePortion::dumpAsXmlAttributes(xmlTextWriterPtr pWriter, 
std::u16string_view rText, TextFrameIndex nOffset) const
 {
     (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), 
BAD_CAST(typeid(*this).name()));
@@ -342,7 +342,7 @@ void SwLinePortion::dumpAsXmlAttributes(xmlTextWriterPtr 
pWriter, const OUString
     (void)xmlTextWriterWriteAttribute(
         pWriter, BAD_CAST("type"),
         BAD_CAST(sw::PortionTypeToString(GetWhichPor())));
-    OUString aText = rText.copy(sal_Int32(nOffset), sal_Int32(GetLen()));
+    OUString aText( rText.substr(sal_Int32(nOffset), sal_Int32(GetLen())) );
     for (int i = 0; i < 32; ++i)
         aText = aText.replace(i, '*');
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("portion"),
diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx
index 3da76ce5cfb2..fb820f9bc577 100644
--- a/sw/source/core/text/porlin.hxx
+++ b/sw/source/core/text/porlin.hxx
@@ -175,7 +175,7 @@ public:
 
     virtual void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText,
                            TextFrameIndex& rOffset) const;
-    void dumpAsXmlAttributes(xmlTextWriterPtr writer, const OUString& rText,
+    void dumpAsXmlAttributes(xmlTextWriterPtr writer, std::u16string_view 
rText,
                              TextFrameIndex nOffset) const;
 };
 
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index 1d75e677f9d8..dd6b55ea2f8f 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -659,7 +659,7 @@ static bool lcl_IsSpecialCharacter(sal_Unicode nChar)
     return false;
 }
 
-static OUString lcl_DenotedPortion(const OUString& rStr, sal_Int32 nStart, 
sal_Int32 nEnd, bool bQuoted)
+static OUString lcl_DenotedPortion(std::u16string_view rStr, sal_Int32 nStart, 
sal_Int32 nEnd, bool bQuoted)
 {
     OUString aResult;
 
@@ -704,11 +704,11 @@ static OUString lcl_DenotedPortion(const OUString& rStr, 
sal_Int32 nStart, sal_I
         else if (bQuoted)
         {
             aResult = SwResId(STR_START_QUOTE) +
-                rStr.subView(nStart, nCount) +
+                rStr.substr(nStart, nCount) +
                 SwResId(STR_END_QUOTE);
         }
         else
-            aResult = rStr.copy(nStart, nCount);
+            aResult = rStr.substr(nStart, nCount);
     }
 
     return aResult;
diff --git a/sw/source/core/unocore/XMLRangeHelper.cxx 
b/sw/source/core/unocore/XMLRangeHelper.cxx
index 0a565b2cf293..6464543d51ca 100644
--- a/sw/source/core/unocore/XMLRangeHelper.cxx
+++ b/sw/source/core/unocore/XMLRangeHelper.cxx
@@ -102,7 +102,7 @@ void lcl_getXMLStringForCell( const 
/*::chart::*/XMLRangeHelper::Cell & rCell, O
 }
 
 void lcl_getSingleCellAddressFromXMLString(
-    const OUString& rXMLString,
+    std::u16string_view rXMLString,
     sal_Int32 nStartPos, sal_Int32 nEndPos,
     /*::chart::*/XMLRangeHelper::Cell & rOutCell )
 {
@@ -110,7 +110,7 @@ void lcl_getSingleCellAddressFromXMLString(
     static const sal_Unicode aDollar( '$' );
     static const sal_Unicode aLetterA( 'A' );
 
-    OUString aCellStr = rXMLString.copy( nStartPos, nEndPos - nStartPos + 1 
).toAsciiUpperCase();
+    OUString aCellStr = OUString(rXMLString.substr( nStartPos, nEndPos - 
nStartPos + 1 )).toAsciiUpperCase();
     const sal_Unicode* pStrArray = aCellStr.getStr();
     sal_Int32 nLength = aCellStr.getLength();
     sal_Int32 i = nLength - 1, nColumn = 0;
diff --git a/sw/source/core/unocore/unochart.cxx 
b/sw/source/core/unocore/unochart.cxx
index 192ad33ed801..84da9ee071b4 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -268,7 +268,7 @@ static OUString GetRangeRepFromTableAndCells( 
std::u16string_view rTableName,
 }
 
 static bool GetTableAndCellsFromRangeRep(
-        const OUString &rRangeRepresentation,
+        std::u16string_view rRangeRepresentation,
         OUString &rTableName,
         OUString &rStartCell,
         OUString &rEndCell,
@@ -279,16 +279,16 @@ static bool GetTableAndCellsFromRangeRep(
     OUString aTableName;    // table name
     OUString aStartCell;  // name of top left cell
     OUString aEndCell;    // name of bottom right cell
-    sal_Int32 nIdx = rRangeRepresentation.indexOf( '.' );
-    if (nIdx >= 0)
+    size_t nIdx = rRangeRepresentation.find( '.' );
+    if (nIdx != std::u16string_view::npos)
     {
-        aTableName = rRangeRepresentation.copy( 0, nIdx );
-        OUString aRange = rRangeRepresentation.copy( nIdx + 1 ); // cell range
-        sal_Int32 nPos = aRange.indexOf( ':' );
-        if (nPos >= 0) // a cell-range like "Table1.A2:D4"
+        aTableName = rRangeRepresentation.substr( 0, nIdx );
+        std::u16string_view aRange = rRangeRepresentation.substr( nIdx + 1 ); 
// cell range
+        size_t nPos = aRange.find( ':' );
+        if (nPos != std::u16string_view::npos) // a cell-range like 
"Table1.A2:D4"
         {
-            aStartCell = aRange.copy( 0, nPos );
-            aEndCell   = aRange.copy( nPos + 1 );
+            aStartCell = aRange.substr( 0, nPos );
+            aEndCell   = aRange.substr( nPos + 1 );
 
             // need to switch start and end cell ?
             // (does not check for normalization here)
@@ -340,7 +340,7 @@ static void GetTableByName( const SwDoc &rDoc, 
std::u16string_view rTableName,
 
 static void GetFormatAndCreateCursorFromRangeRep(
         const SwDoc    *pDoc,
-        const OUString &rRangeRepresentation,   // must be a single range 
(i.e. so called sub-range)
+        std::u16string_view rRangeRepresentation,   // must be a single range 
(i.e. so called sub-range)
         SwFrameFormat    **ppTableFormat,     // will be set to the table 
format of the table used in the range representation
         std::shared_ptr<SwUnoCursor>&   rpUnoCursor )   // will be set to 
cursor spanning the cell range (cursor will be created!)
 {
@@ -928,10 +928,10 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL 
SwChartDataProvider::create
  * contains multiple ranges.
  */
 OUString SwChartDataProvider::GetBrokenCellRangeForExport(
-    const OUString &rCellRangeRepresentation )
+    std::u16string_view rCellRangeRepresentation )
 {
     // check that we do not have multiple ranges
-    if (-1 == rCellRangeRepresentation.indexOf( ';' ))
+    if (std::u16string_view::npos == rCellRangeRepresentation.find( ';' ))
     {
         // get current cell and table names
         OUString aTableName, aStartCell, aEndCell;
@@ -1289,7 +1289,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL 
SwChartDataProvider::detectArgume
 }
 
 uno::Reference< chart2::data::XDataSequence > 
SwChartDataProvider::Impl_createDataSequenceByRangeRepresentation(
-        const OUString& rRangeRepresentation, bool bTestOnly )
+        std::u16string_view rRangeRepresentation, bool bTestOnly )
 {
     if (m_bDisposed)
         throw lang::DisposedException();
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index b49e4729a54f..fe4f0bdfadc3 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -4727,24 +4727,25 @@ bool SwXTextCellStyle::IsPhysical() const
     return m_bPhysical;
 }
 
-SwBoxAutoFormat* SwXTextCellStyle::GetBoxAutoFormat(SwDocShell* pDocShell, 
const OUString& sName, OUString* pParentName)
+SwBoxAutoFormat* SwXTextCellStyle::GetBoxAutoFormat(SwDocShell* pDocShell, 
std::u16string_view sName, OUString* pParentName)
 {
-    if (sName.isEmpty())
+    if (sName.empty())
         return nullptr;
 
     SwBoxAutoFormat* pBoxAutoFormat = 
pDocShell->GetDoc()->GetCellStyles().GetBoxFormat(sName);
     if (!pBoxAutoFormat)
     {
-        sal_Int32 nSeparatorIndex, nTemplateIndex;
-        OUString sParentName, sCellSubName;
+        sal_Int32 nTemplateIndex;
+        OUString sParentName;
+        std::u16string_view sCellSubName;
 
-        nSeparatorIndex = sName.lastIndexOf('.');
-        if (0 >= nSeparatorIndex)
+        size_t nSeparatorIndex = sName.rfind('.');
+        if (nSeparatorIndex == std::u16string_view::npos)
             return nullptr;
 
-        sParentName = sName.copy(0, nSeparatorIndex);
-        sCellSubName = sName.copy(nSeparatorIndex+1);
-        nTemplateIndex = sCellSubName.toInt32()-1; // -1 because cell styles 
names start from 1, but internally are indexed from 0
+        sParentName = sName.substr(0, nSeparatorIndex);
+        sCellSubName = sName.substr(nSeparatorIndex+1);
+        nTemplateIndex = o3tl::toInt32(sCellSubName)-1; // -1 because cell 
styles names start from 1, but internally are indexed from 0
         if (0 > nTemplateIndex)
             return nullptr;
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 620841b27537..6daca466f1ff 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1933,7 +1933,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, 
sal_Int32 nPos, bool /
     DoWriteBookmarkEndIfExist(nPos);
 }
 
-void DocxAttributeOutput::DoWriteBookmarkTagStart(const OUString & 
bookmarkName)
+void DocxAttributeOutput::DoWriteBookmarkTagStart(std::u16string_view 
bookmarkName)
 {
     m_pSerializer->singleElementNS(XML_w, XML_bookmarkStart,
         FSNS(XML_w, XML_id), OString::number(m_nNextBookmarkId),
@@ -2079,8 +2079,8 @@ void 
DocxAttributeOutput::DoWritePermissionTagStart(std::u16string_view permissi
         const std::u16string_view permissionName = 
permissionIdAndName.substr(separatorIndex + 1);
 
         m_pSerializer->singleElementNS(XML_w, XML_permStart,
-            FSNS(XML_w, XML_id), BookmarkToWord(OUString(permissionId)),
-            FSNS(XML_w, XML_edGrp), BookmarkToWord(OUString(permissionName)));
+            FSNS(XML_w, XML_id), BookmarkToWord(permissionId),
+            FSNS(XML_w, XML_edGrp), BookmarkToWord(permissionName));
     }
     else
     {
@@ -2093,8 +2093,8 @@ void 
DocxAttributeOutput::DoWritePermissionTagStart(std::u16string_view permissi
         const std::u16string_view permissionName = 
permissionIdAndName.substr(separatorIndex + 1);
 
         m_pSerializer->singleElementNS(XML_w, XML_permStart,
-            FSNS(XML_w, XML_id), BookmarkToWord(OUString(permissionId)),
-            FSNS(XML_w, XML_ed), BookmarkToWord(OUString(permissionName)));
+            FSNS(XML_w, XML_id), BookmarkToWord(permissionId),
+            FSNS(XML_w, XML_ed), BookmarkToWord(permissionName));
     }
 }
 
@@ -2119,7 +2119,7 @@ void 
DocxAttributeOutput::DoWritePermissionTagEnd(std::u16string_view permission
     const std::u16string_view permissionId   = permissionIdAndName.substr(0, 
separatorIndex);
 
     m_pSerializer->singleElementNS(XML_w, XML_permEnd,
-        FSNS(XML_w, XML_id), BookmarkToWord(OUString(permissionId)));
+        FSNS(XML_w, XML_id), BookmarkToWord(permissionId));
 }
 
 /// Write the start permissions
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 00549f5d8beb..2c847e0e5320 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -741,7 +741,7 @@ protected:
 
 private:
 
-    void DoWriteBookmarkTagStart(const OUString & bookmarkName);
+    void DoWriteBookmarkTagStart(std::u16string_view bookmarkName);
     void DoWriteBookmarkTagEnd(sal_Int32 nId);
     void DoWriteMoveRangeTagStart(const OString & bookmarkName,
             bool bFrom, const SwRedlineData* pRedlineData);
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index 36750bf6005a..1a600e33e799 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1200,30 +1200,30 @@ bool WW8AttributeOutput::EndURL(bool const)
     return true;
 }
 
-OUString BookmarkToWord(const OUString &rBookmark, bool* pIsMove, bool* 
pIsFrom)
+OUString BookmarkToWord(std::u16string_view rBookmark, bool* pIsMove, bool* 
pIsFrom)
 {
     sal_Int32 nTrim = 0; // position to remove "__RefMoveRange" from bookmark 
names
     if ( pIsMove )
     {
         static constexpr OUStringLiteral MoveFrom_Bookmark_NamePrefix = 
u"__RefMoveFrom__";
         static constexpr OUStringLiteral MoveTo_Bookmark_NamePrefix = 
u"__RefMoveTo__";
-        if ( rBookmark.startsWith(MoveFrom_Bookmark_NamePrefix) )
+        if ( o3tl::starts_with(rBookmark, MoveFrom_Bookmark_NamePrefix) )
         {
             *pIsMove = true;
             *pIsFrom = true;
             nTrim = MoveFrom_Bookmark_NamePrefix.getLength();
         }
-        else if ( rBookmark.startsWith(MoveTo_Bookmark_NamePrefix) )
+        else if ( o3tl::starts_with(rBookmark, MoveTo_Bookmark_NamePrefix) )
         {
             *pIsMove = true;
             *pIsFrom = false;
             nTrim = MoveTo_Bookmark_NamePrefix.getLength();
         }
     }
-    OUString sRet(INetURLObject::encode(
-        rBookmark.copy(nTrim).replace(' ', '_'), // Spaces are prohibited in 
bookmark name
+    OUString sRet = INetURLObject::encode(
+        OUString(rBookmark.substr(nTrim)).replace(' ', '_'), // Spaces are 
prohibited in bookmark name
         INetURLObject::PART_REL_SEGMENT_EXTRA,
-        INetURLObject::EncodeMechanism::All, RTL_TEXTENCODING_ASCII_US));
+        INetURLObject::EncodeMechanism::All, RTL_TEXTENCODING_ASCII_US);
     // Unicode letters are allowed
     sRet = INetURLObject::decode(sRet, 
INetURLObject::DecodeMechanism::Unambiguous, RTL_TEXTENCODING_UTF8);
     return TruncateBookmark(sRet);
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index fc2e6e07a467..7e3046214fdd 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1646,7 +1646,7 @@ public:
 sal_Int16 GetWordFirstLineOffset(const SwNumFormat &rFormat);
 // A bit of a bag on the side for now
 OUString FieldString(ww::eField eIndex);
-OUString BookmarkToWord(const OUString &rBookmark, bool* pIsMove = nullptr, 
bool* pIsFrom = nullptr);
+OUString BookmarkToWord(std::u16string_view rBookmark, bool* pIsMove = 
nullptr, bool* pIsFrom = nullptr);
 
 class WW8SHDLong
 {

Reply via email to