basctl/source/basicide/baside2.hxx              |    2 
 basctl/source/basicide/baside2b.cxx             |    9 +-
 comphelper/qa/unit/syntaxhighlighttest.cxx      |   10 +-
 comphelper/source/misc/accessibletexthelper.cxx |   40 +++++-----
 comphelper/source/misc/docpasswordhelper.cxx    |    8 +-
 comphelper/source/misc/storagehelper.cxx        |    4 -
 comphelper/source/misc/syntaxhighlight.cxx      |   88 +++++++++++++-----------
 comphelper/source/misc/xmlsechelper.cxx         |   43 ++++++-----
 include/comphelper/accessibletexthelper.hxx     |    6 -
 include/comphelper/docpasswordhelper.hxx        |    2 
 include/comphelper/storagehelper.hxx            |    2 
 include/comphelper/syntaxhighlight.hxx          |    2 
 include/comphelper/xmlsechelper.hxx             |    5 -
 13 files changed, 117 insertions(+), 104 deletions(-)

New commits:
commit b1148c31ed2786396f0b018a988fce8288f1797d
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Apr 27 16:47:53 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Apr 28 13:40:36 2022 +0200

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

diff --git a/basctl/source/basicide/baside2.hxx 
b/basctl/source/basicide/baside2.hxx
index f43ee79d2c4f..2c9822610d64 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -153,7 +153,7 @@ public:
     void            ChangeFontColor( Color aColor );
     void            UpdateSyntaxHighlighting ();
 
-    bool            GetProcedureName(OUString const & rLine, OUString& 
rProcType, OUString& rProcName) const;
+    bool            GetProcedureName(std::u16string_view rLine, OUString& 
rProcType, OUString& rProcName) const;
 
     FactoryFunction GetUITestFactory() const override;
 };
diff --git a/basctl/source/basicide/baside2b.cxx 
b/basctl/source/basicide/baside2b.cxx
index 262f9e49a248..c080ea325807 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -40,6 +40,7 @@
 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
 #include <com/sun/star/script/XLibraryContainer2.hpp>
 #include <comphelper/string.hxx>
+#include <o3tl/string_view.hxx>
 #include <officecfg/Office/Common.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/progress.hxx>
@@ -811,7 +812,7 @@ void EditorWindow::HandleProcedureCompletion()
     }
 }
 
-bool EditorWindow::GetProcedureName(OUString const & rLine, OUString& 
rProcType, OUString& rProcName) const
+bool EditorWindow::GetProcedureName(std::u16string_view rLine, OUString& 
rProcType, OUString& rProcName) const
 {
     std::vector<HighlightPortion> aPortions;
     aHighlighter.getHighlightPortions(rLine, aPortions);
@@ -824,10 +825,10 @@ bool EditorWindow::GetProcedureName(OUString const & 
rLine, OUString& rProcType,
 
     for (auto const& portion : aPortions)
     {
-        OUString sTokStr = rLine.copy(portion.nBegin, portion.nEnd - 
portion.nBegin);
+        std::u16string_view sTokStr = rLine.substr(portion.nBegin, 
portion.nEnd - portion.nBegin);
 
-        if( portion.tokenType == TokenType::Keywords && ( 
sTokStr.equalsIgnoreAsciiCase("sub")
-            || sTokStr.equalsIgnoreAsciiCase("function")) )
+        if( portion.tokenType == TokenType::Keywords && ( 
o3tl::equalsIgnoreAsciiCase(sTokStr, u"sub")
+            || o3tl::equalsIgnoreAsciiCase(sTokStr, u"function")) )
         {
             rProcType = sTokStr;
             bFoundType = true;
diff --git a/comphelper/qa/unit/syntaxhighlighttest.cxx 
b/comphelper/qa/unit/syntaxhighlighttest.cxx
index c28941339085..eab382b85a65 100644
--- a/comphelper/qa/unit/syntaxhighlighttest.cxx
+++ b/comphelper/qa/unit/syntaxhighlighttest.cxx
@@ -38,7 +38,7 @@ public:
 
 void SyntaxHighlightTest::testBasicString() {
     std::vector<HighlightPortion> ps;
-    
SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions("\"foo\"", 
ps);
+    
SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions(u"\"foo\"", 
ps);
     CPPUNIT_ASSERT_EQUAL(
         static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size());
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin);
@@ -48,7 +48,7 @@ void SyntaxHighlightTest::testBasicString() {
 
 void SyntaxHighlightTest::testBasicComment() {
     std::vector<HighlightPortion> ps;
-    SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions("' 
foo", ps);
+    SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions(u"' 
foo", ps);
     CPPUNIT_ASSERT_EQUAL(
         static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size());
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin);
@@ -58,7 +58,7 @@ void SyntaxHighlightTest::testBasicComment() {
 
 void SyntaxHighlightTest::testBasicCommentNewline() {
     std::vector<HighlightPortion> ps;
-    SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions("' 
foo\n", ps);
+    SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions(u"' 
foo\n", ps);
     CPPUNIT_ASSERT_EQUAL(
         static_cast<std::vector<HighlightPortion>::size_type>(2), ps.size());
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin);
@@ -71,7 +71,7 @@ void SyntaxHighlightTest::testBasicCommentNewline() {
 
 void SyntaxHighlightTest::testBasicEmptyComment() {
     std::vector<HighlightPortion> ps;
-    SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions("'", 
ps);
+    SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions(u"'", 
ps);
     CPPUNIT_ASSERT_EQUAL(
         static_cast<std::vector<HighlightPortion>::size_type>(1), ps.size());
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin);
@@ -81,7 +81,7 @@ void SyntaxHighlightTest::testBasicEmptyComment() {
 
 void SyntaxHighlightTest::testBasicEmptyCommentNewline() {
     std::vector<HighlightPortion> ps;
-    SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions("'\n", 
ps);
+    SyntaxHighlighter(HighlighterLanguage::Basic).getHighlightPortions(u"'\n", 
ps);
     CPPUNIT_ASSERT_EQUAL(
         static_cast<std::vector<HighlightPortion>::size_type>(2), ps.size());
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ps[0].nBegin);
diff --git a/comphelper/source/misc/accessibletexthelper.cxx 
b/comphelper/source/misc/accessibletexthelper.cxx
index 0678456192d7..bd2253ace23e 100644
--- a/comphelper/source/misc/accessibletexthelper.cxx
+++ b/comphelper/source/misc/accessibletexthelper.cxx
@@ -265,16 +265,16 @@ namespace comphelper
     }
 
 
-    OUString OCommonAccessibleText::implGetTextRange( const OUString& rText, 
sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+    OUString OCommonAccessibleText::implGetTextRange( std::u16string_view 
rText, sal_Int32 nStartIndex, sal_Int32 nEndIndex )
     {
 
-        if ( !implIsValidRange( nStartIndex, nEndIndex, rText.getLength() ) )
+        if ( !implIsValidRange( nStartIndex, nEndIndex, rText.size() ) )
             throw IndexOutOfBoundsException();
 
         sal_Int32 nMinIndex = std::min( nStartIndex, nEndIndex );
         sal_Int32 nMaxIndex = std::max( nStartIndex, nEndIndex );
 
-        return rText.copy( nMinIndex, nMaxIndex - nMinIndex );
+        return OUString(rText.substr( nMinIndex, nMaxIndex - nMinIndex ));
     }
 
     TextSegment OCommonAccessibleText::getTextAtIndex( sal_Int32 nIndex, 
sal_Int16 aTextType )
@@ -634,13 +634,13 @@ namespace comphelper
 
 
     bool OCommonAccessibleText::implInitTextChangedEvent(
-        const OUString& rOldString,
-        const OUString& rNewString,
+        std::u16string_view rOldString,
+        std::u16string_view rNewString,
         css::uno::Any& rDeleted,
         css::uno::Any& rInserted) // throw()
     {
-        sal_uInt32 nLenOld = rOldString.getLength();
-        sal_uInt32 nLenNew = rNewString.getLength();
+        size_t nLenOld = rOldString.size();
+        size_t nLenNew = rNewString.size();
 
         // equal
         if ((0 == nLenOld) && (0 == nLenNew))
@@ -659,7 +659,7 @@ namespace comphelper
         {
             aInsertedText.SegmentStart = 0;
             aInsertedText.SegmentEnd = nLenNew;
-            aInsertedText.SegmentText = rNewString.copy( 
aInsertedText.SegmentStart, aInsertedText.SegmentEnd - 
aInsertedText.SegmentStart );
+            aInsertedText.SegmentText = rNewString.substr( 
aInsertedText.SegmentStart, aInsertedText.SegmentEnd - 
aInsertedText.SegmentStart );
 
             rInserted <<= aInsertedText;
             return true;
@@ -670,16 +670,16 @@ namespace comphelper
         {
             aDeletedText.SegmentStart = 0;
             aDeletedText.SegmentEnd = nLenOld;
-            aDeletedText.SegmentText = rOldString.copy( 
aDeletedText.SegmentStart, aDeletedText.SegmentEnd - aDeletedText.SegmentStart 
);
+            aDeletedText.SegmentText = rOldString.substr( 
aDeletedText.SegmentStart, aDeletedText.SegmentEnd - aDeletedText.SegmentStart 
);
 
             rDeleted <<= aDeletedText;
             return true;
         }
 
-        const sal_Unicode* pFirstDiffOld = rOldString.getStr();
-        const sal_Unicode* pLastDiffOld  = rOldString.getStr() + nLenOld;
-        const sal_Unicode* pFirstDiffNew = rNewString.getStr();
-        const sal_Unicode* pLastDiffNew  = rNewString.getStr() + nLenNew;
+        auto pFirstDiffOld = rOldString.begin();
+        auto pLastDiffOld  = rOldString.end();
+        auto pFirstDiffNew = rNewString.begin();
+        auto pLastDiffNew  = rNewString.end();
 
         // find first difference
         while ((*pFirstDiffOld == *pFirstDiffNew) &&
@@ -691,7 +691,7 @@ namespace comphelper
         }
 
         // equality test
-        if ((0 == *pFirstDiffOld) && (0 == *pFirstDiffNew))
+        if (pFirstDiffOld == pLastDiffOld && pFirstDiffNew == pLastDiffNew)
             return false;
 
         // find last difference
@@ -705,18 +705,18 @@ namespace comphelper
 
         if (pFirstDiffOld < pLastDiffOld)
         {
-            aDeletedText.SegmentStart = pFirstDiffOld - rOldString.getStr();
-            aDeletedText.SegmentEnd = pLastDiffOld  - rOldString.getStr();
-            aDeletedText.SegmentText = rOldString.copy( 
aDeletedText.SegmentStart, aDeletedText.SegmentEnd - aDeletedText.SegmentStart 
);
+            aDeletedText.SegmentStart = pFirstDiffOld - rOldString.begin();
+            aDeletedText.SegmentEnd = pLastDiffOld  - rOldString.begin();
+            aDeletedText.SegmentText = rOldString.substr( 
aDeletedText.SegmentStart, aDeletedText.SegmentEnd - aDeletedText.SegmentStart 
);
 
             rDeleted <<= aDeletedText;
         }
 
         if (pFirstDiffNew < pLastDiffNew)
         {
-            aInsertedText.SegmentStart = pFirstDiffNew - rNewString.getStr();
-            aInsertedText.SegmentEnd = pLastDiffNew  - rNewString.getStr();
-            aInsertedText.SegmentText = rNewString.copy( 
aInsertedText.SegmentStart, aInsertedText.SegmentEnd - 
aInsertedText.SegmentStart );
+            aInsertedText.SegmentStart = pFirstDiffNew - rNewString.begin();
+            aInsertedText.SegmentEnd = pLastDiffNew  - rNewString.begin();
+            aInsertedText.SegmentText = rNewString.substr( 
aInsertedText.SegmentStart, aInsertedText.SegmentEnd - 
aInsertedText.SegmentStart );
 
             rInserted <<= aInsertedText;
         }
diff --git a/comphelper/source/misc/docpasswordhelper.cxx 
b/comphelper/source/misc/docpasswordhelper.cxx
index e32c3d8b1303..e894b0d77bb7 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -376,15 +376,15 @@ OUString DocPasswordHelper::GetOoxHashAsBase64(
 }
 
 
-/*static*/ uno::Sequence< sal_Int8 > DocPasswordHelper::GenerateStd97Key( 
const OUString& aPassword, const uno::Sequence< sal_Int8 >& aDocId )
+/*static*/ uno::Sequence< sal_Int8 > DocPasswordHelper::GenerateStd97Key( 
std::u16string_view aPassword, const uno::Sequence< sal_Int8 >& aDocId )
 {
     uno::Sequence< sal_Int8 > aResultKey;
-    if ( !aPassword.isEmpty() && aDocId.getLength() == 16 )
+    if ( !aPassword.empty() && aDocId.getLength() == 16 )
     {
         sal_uInt16 pPassData[16] = {};
 
-        sal_Int32 nPassLen = std::min< sal_Int32 >( aPassword.getLength(), 15 
);
-        memcpy( pPassData, aPassword.getStr(), nPassLen * sizeof(pPassData[0]) 
);
+        sal_Int32 nPassLen = std::min< sal_Int32 >( aPassword.size(), 15 );
+        memcpy( pPassData, aPassword.data(), nPassLen * sizeof(pPassData[0]) );
 
         aResultKey = GenerateStd97Key( pPassData, aDocId );
     }
diff --git a/comphelper/source/misc/storagehelper.cxx 
b/comphelper/source/misc/storagehelper.cxx
index b2a4512e4e79..8e08612b0699 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -528,9 +528,9 @@ uno::Sequence< beans::NamedValue > 
OStorageHelper::CreateGpgPackageEncryptionDat
 #endif
 }
 
-bool OStorageHelper::IsValidZipEntryFileName( const OUString& aName, bool 
bSlashAllowed )
+bool OStorageHelper::IsValidZipEntryFileName( std::u16string_view aName, bool 
bSlashAllowed )
 {
-    return IsValidZipEntryFileName( aName.getStr(), aName.getLength(), 
bSlashAllowed );
+    return IsValidZipEntryFileName( aName.data(), aName.size(), bSlashAllowed 
);
 }
 
 
diff --git a/comphelper/source/misc/syntaxhighlight.cxx 
b/comphelper/source/misc/syntaxhighlight.cxx
index f6eccc7b4fc3..304e9e6b271f 100644
--- a/comphelper/source/misc/syntaxhighlight.cxx
+++ b/comphelper/source/misc/syntaxhighlight.cxx
@@ -279,8 +279,8 @@ class SyntaxHighlighter::Tokenizer
     bool testCharFlags(sal_Unicode c, CharFlags nTestFlags) const;
 
     // Get new token, EmptyString == nothing more over there
-    bool getNextToken(const sal_Unicode*& pos, /*out*/TokenType& reType,
-        /*out*/const sal_Unicode*& rpStartPos, /*out*/const sal_Unicode*& 
rpEndPos) const;
+    bool getNextToken(std::u16string_view::const_iterator& pos, 
std::u16string_view::const_iterator end, /*out*/TokenType& reType,
+        /*out*/std::u16string_view::const_iterator& rpStartPos, 
/*out*/std::u16string_view::const_iterator& rpEndPos) const;
 
     const char** ppListKeyWords;
     sal_uInt16 nKeyWordCount;
@@ -290,7 +290,7 @@ public:
 
     explicit Tokenizer( HighlighterLanguage aLang );
 
-    void getHighlightPortions(const OUString& rLine,
+    void getHighlightPortions(std::u16string_view rLine,
                                /*out*/std::vector<HighlightPortion>& portions) 
const;
     void setKeyWords( const char** ppKeyWords, sal_uInt16 nCount );
 };
@@ -317,24 +317,25 @@ void SyntaxHighlighter::Tokenizer::setKeyWords( const 
char** ppKeyWords, sal_uIn
     nKeyWordCount = nCount;
 }
 
-bool SyntaxHighlighter::Tokenizer::getNextToken(const sal_Unicode*& pos, 
/*out*/TokenType& reType,
-    /*out*/const sal_Unicode*& rpStartPos, /*out*/const sal_Unicode*& 
rpEndPos) const
+bool 
SyntaxHighlighter::Tokenizer::getNextToken(std::u16string_view::const_iterator& 
pos, std::u16string_view::const_iterator end,
+    /*out*/TokenType& reType,
+    /*out*/std::u16string_view::const_iterator& rpStartPos, 
/*out*/std::u16string_view::const_iterator& rpEndPos) const
 {
     reType = TokenType::Unknown;
 
     rpStartPos = pos;
 
-    sal_Unicode c = *pos;
-    if( c == 0 )
+    if( pos == end )
         return false;
 
+    sal_Unicode c = *pos;
     ++pos;
 
     //*** Go through all possibilities ***
     // Space?
     if ( testCharFlags( c, CharFlags::Space ) )
     {
-        while( testCharFlags( *pos, CharFlags::Space ) )
+        while( pos != end && testCharFlags( *pos, CharFlags::Space ) )
             ++pos;
 
         reType = TokenType::Whitespace;
@@ -346,6 +347,8 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
         bool bIdentifierChar;
         do
         {
+            if (pos == end)
+                break;
             // Fetch next character
             c = *pos;
             bIdentifierChar = testCharFlags( c, CharFlags::InIdentifier );
@@ -374,7 +377,7 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
 
             if( bCanBeKeyword )
             {
-                OUString aKWString(rpStartPos, nCount);
+                std::u16string_view aKWString(&*rpStartPos, nCount);
                 OString aByteStr = OUStringToOString(aKWString,
                     RTL_TEXTENCODING_ASCII_US).toAsciiLowerCase();
                 if ( bsearch( aByteStr.getStr(), ppListKeyWords, 
nKeyWordCount, sizeof( char* ),
@@ -385,10 +388,14 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
                     if( aByteStr == "rem" )
                     {
                         // Remove all characters until end of line or EOF
-                        sal_Unicode cPeek = *pos;
-                        while( cPeek != 0 && !testCharFlags( cPeek, 
CharFlags::EOL ) )
+                        for (;;)
                         {
-                            cPeek = *++pos;
+                            if (pos == end)
+                                break;
+                            sal_Unicode cPeek = *pos;
+                            if ( testCharFlags( cPeek, CharFlags::EOL ) )
+                                break;
+                            ++pos;
                         }
 
                         reType = TokenType::Comment;
@@ -411,6 +418,8 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
                 do
                 {
                     // Get next character
+                    if (pos == end)
+                        break;
                     c = *pos;
                     bIdentifierChar = isAlpha(c);
                     if( bIdentifierChar )
@@ -422,14 +431,12 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
         }
         else if ((c=='-') && (aLanguage == HighlighterLanguage::SQL))
         {
-            sal_Unicode cPeekNext = *pos;
-            if (cPeekNext=='-')
+            if (pos != end && *pos=='-')
             {
                 // Remove all characters until end of line or EOF
-                while( cPeekNext != 0 && !testCharFlags( cPeekNext, 
CharFlags::EOL ) )
+                while( pos != end && !testCharFlags( *pos, CharFlags::EOL ) )
                 {
                     ++pos;
-                    cPeekNext = *pos;
                 }
                 reType = TokenType::Comment;
             }
@@ -438,14 +445,12 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
         }
         else if ((c=='/') && (aLanguage == HighlighterLanguage::SQL))
         {
-            sal_Unicode cPeekNext = *pos;
-            if (cPeekNext=='/')
+            if (pos != end && *pos=='/')
             {
                 // Remove all characters until end of line or EOF
-                while( cPeekNext != 0 && !testCharFlags( cPeekNext, 
CharFlags::EOL ) )
+                while( pos != end && !testCharFlags( *pos, CharFlags::EOL ) )
                 {
                     ++pos;
-                    cPeekNext = *pos;
                 }
                 reType = TokenType::Comment;
             }
@@ -459,8 +464,10 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
             {
                 // Skip all characters until end of input or end of line:
                 for (;;) {
+                    if (pos == end)
+                        break;
                     c = *pos;
-                    if (c == 0 || testCharFlags(c, CharFlags::EOL)) {
+                    if (testCharFlags(c, CharFlags::EOL)) {
                         break;
                     }
                     ++pos;
@@ -497,25 +504,25 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
         if( c == '&' )
         {
             // Octal?
-            if( *pos == 'o' || *pos == 'O' )
+            if( pos != end && (*pos == 'o' || *pos == 'O' ))
             {
                 // remove o
                 ++pos;
                 nRadix = 8;     // Octal base
 
                 // Read all numbers
-                while( testCharFlags( *pos, CharFlags::InOctNumber ) )
+                while( pos != end && testCharFlags( *pos, 
CharFlags::InOctNumber ) )
                     ++pos;
             }
             // Hexadecimal?
-            else if( *pos == 'h' || *pos == 'H' )
+            else if( pos != end && (*pos == 'h' || *pos == 'H' ))
             {
                 // remove x
                 ++pos;
                 nRadix = 16;     // Hexadecimal base
 
                 // Read all numbers
-                while( testCharFlags( *pos, CharFlags::InHexNumber ) )
+                while( pos != end && testCharFlags( *pos, 
CharFlags::InHexNumber ) )
                     ++pos;
             }
             else
@@ -531,9 +538,9 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
             bool bAfterExpChar = false;
 
             // Read all numbers
-            while( testCharFlags( *pos, CharFlags::InNumber ) ||
+            while( pos != end && (testCharFlags( *pos, CharFlags::InNumber ) ||
                     (bAfterExpChar && *pos == '+' ) ||
-                    (bAfterExpChar && *pos == '-' ) )
+                    (bAfterExpChar && *pos == '-' ) ))
                     // After exponent +/- are OK, too
             {
                 c = *pos++;
@@ -551,10 +558,10 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
             cEndString = ']';
 
         // Read all characters
-        while( *pos != cEndString )
+        while( pos == end || *pos != cEndString )
         {
             // Detect EOF before reading next char, so we do not lose EOF
-            if( *pos == 0 )
+            if( pos == end )
             {
                 // ERROR: unterminated string literal
                 reType = TokenType::Error;
@@ -583,9 +590,12 @@ bool SyntaxHighlighter::Tokenizer::getNextToken(const 
sal_Unicode*& pos, /*out*/
     else if( testCharFlags( c, CharFlags::EOL ) )
     {
         // If another EOL character comes, read it
-        sal_Unicode cNext = *pos;
-        if( cNext != c && testCharFlags( cNext, CharFlags::EOL ) )
-            ++pos;
+        if (pos != end)
+        {
+            sal_Unicode cNext = *pos;
+            if( cNext != c && testCharFlags( cNext, CharFlags::EOL ) )
+                ++pos;
+        }
 
         reType = TokenType::EOL;
     }
@@ -676,22 +686,22 @@ SyntaxHighlighter::Tokenizer::Tokenizer( 
HighlighterLanguage aLang ): aLanguage(
     nKeyWordCount = 0;
 }
 
-void SyntaxHighlighter::Tokenizer::getHighlightPortions(const OUString& rLine,
+void SyntaxHighlighter::Tokenizer::getHighlightPortions(std::u16string_view 
rLine,
                                                  
/*out*/std::vector<HighlightPortion>& portions) const
 {
     // Set the position to the beginning of the source string
-    const sal_Unicode* pos = rLine.getStr();
+    auto pos = rLine.begin();
 
     // Variables for the out parameter
     TokenType eType;
-    const sal_Unicode* pStartPos;
-    const sal_Unicode* pEndPos;
+    std::u16string_view::const_iterator pStartPos;
+    std::u16string_view::const_iterator pEndPos;
 
     // Loop over all the tokens
-    while( getNextToken( pos, eType, pStartPos, pEndPos ) )
+    while( getNextToken( pos, rLine.end(), eType, pStartPos, pEndPos ) )
     {
         portions.emplace_back(
-                pStartPos - rLine.getStr(), pEndPos - rLine.getStr(), eType);
+                pStartPos - rLine.begin(), pEndPos - rLine.begin(), eType);
     }
 }
 
@@ -716,7 +726,7 @@ SyntaxHighlighter::SyntaxHighlighter(HighlighterLanguage 
language):
 
 SyntaxHighlighter::~SyntaxHighlighter() {}
 
-void SyntaxHighlighter::getHighlightPortions(const OUString& rLine,
+void SyntaxHighlighter::getHighlightPortions(std::u16string_view rLine,
                                               
/*out*/std::vector<HighlightPortion>& portions) const
 {
     m_tokenizer->getHighlightPortions( rLine, portions );
diff --git a/comphelper/source/misc/xmlsechelper.cxx 
b/comphelper/source/misc/xmlsechelper.cxx
index bc2cb280a710..5b1a438abbea 100644
--- a/comphelper/source/misc/xmlsechelper.cxx
+++ b/comphelper/source/misc/xmlsechelper.cxx
@@ -21,6 +21,7 @@
 
 #include <rtl/ustrbuf.hxx>
 #include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
 
 #include <utility>
 #include <vector>
@@ -48,7 +49,7 @@ namespace comphelper::xmlsec
         The second string is for the details view at the bottom. It shows the 
attribute/value
         pairs on different lines. All escape characters ('"') are removed.
     */
-    std::pair< OUString, OUString> GetDNForCertDetailsView( const OUString & 
rRawString)
+    std::pair< OUString, OUString> GetDNForCertDetailsView( 
std::u16string_view rRawString)
     {
         std::vector< std::pair< OUString, OUString > > vecAttrValueOfDN = 
parseDN(rRawString);
         OUStringBuffer s1, s2;
@@ -72,18 +73,18 @@ namespace comphelper::xmlsec
     they are escaped with a double quote. This function removes the escape 
characters.
 */
 #ifdef _WIN32
-std::vector< std::pair< OUString, OUString> > parseDN(const OUString& 
rRawString)
+std::vector< std::pair< OUString, OUString> > parseDN(std::u16string_view 
rRawString)
 {
         std::vector< std::pair<OUString, OUString> > retVal;
         bool bInEscape = false;
         bool bInValue = false;
         bool bInType = true;
         sal_Int32 nTypeNameStart = 0;
-        OUString sType;
+        std::u16string_view sType;
         OUStringBuffer sbufValue;
-        sal_Int32 length = rRawString.getLength();
+        size_t length = rRawString.size();
 
-        for (sal_Int32 i = 0; i < length; i++)
+        for (size_t i = 0; i < length; i++)
         {
             sal_Unicode c = rRawString[i];
 
@@ -91,8 +92,8 @@ std::vector< std::pair< OUString, OUString> > parseDN(const 
OUString& rRawString
             {
                 if (! bInValue)
                 {
-                    sType = rRawString.copy(nTypeNameStart, i - 
nTypeNameStart);
-                    sType = sType.trim();
+                    sType = rRawString.substr(nTypeNameStart, i - 
nTypeNameStart);
+                    sType = o3tl::trim(sType);
                     bInType = false;
                 }
                 else
@@ -128,9 +129,9 @@ std::vector< std::pair< OUString, OUString> > parseDN(const 
OUString& rRawString
                 //then we have reached the end of the value
                 if (!bInValue)
                 {
-                    OSL_ASSERT(!sType.isEmpty());
-                    retVal.push_back(std::make_pair(sType, 
sbufValue.makeStringAndClear()));
-                    sType.clear();
+                    OSL_ASSERT(!sType.empty());
+                    retVal.push_back(std::make_pair(OUString(sType), 
sbufValue.makeStringAndClear()));
+                    sType = {};
                     //The next char is the start of the new type
                     nTypeNameStart = i + 1;
                     bInType = true;
@@ -151,13 +152,13 @@ std::vector< std::pair< OUString, OUString> > 
parseDN(const OUString& rRawString
         }
         if (sbufValue.getLength())
         {
-            OSL_ASSERT(!sType.isEmpty());
-            retVal.push_back(std::make_pair(sType, 
sbufValue.makeStringAndClear()));
+            OSL_ASSERT(!sType.empty());
+            retVal.push_back(std::make_pair(OUString(sType), 
sbufValue.makeStringAndClear()));
         }
         return retVal;
     }
 #else
-std::vector< std::pair< OUString, OUString> > parseDN(const OUString& 
rRawString)
+std::vector< std::pair< OUString, OUString> > parseDN(std::u16string_view 
rRawString)
     {
         std::vector< std::pair<OUString, OUString> > retVal;
         //bInEscape == true means that the preceding character is an escape 
character
@@ -165,11 +166,11 @@ std::vector< std::pair< OUString, OUString> > 
parseDN(const OUString& rRawString
         bool bInValue = false;
         bool bInType = true;
         sal_Int32 nTypeNameStart = 0;
-        OUString sType;
+        std::u16string_view sType;
         OUStringBuffer sbufValue;
-        sal_Int32 length = rRawString.getLength();
+        size_t length = rRawString.size();
 
-        for (sal_Int32 i = 0; i < length; i++)
+        for (size_t i = 0; i < length; i++)
         {
             sal_Unicode c = rRawString[i];
 
@@ -177,8 +178,8 @@ std::vector< std::pair< OUString, OUString> > parseDN(const 
OUString& rRawString
             {
                 if (! bInValue)
                 {
-                    sType = rRawString.copy(nTypeNameStart, i - 
nTypeNameStart);
-                    sType = sType.trim();
+                    sType = rRawString.substr(nTypeNameStart, i - 
nTypeNameStart);
+                    sType = o3tl::trim(sType);
                     bInType = false;
                 }
                 else
@@ -223,9 +224,9 @@ std::vector< std::pair< OUString, OUString> > parseDN(const 
OUString& rRawString
                 //then we have reached the end of the value
                 if (!bInValue)
                 {
-                    OSL_ASSERT(!sType.isEmpty());
+                    OSL_ASSERT(!sType.empty());
                     retVal.emplace_back(sType, sbufValue.makeStringAndClear());
-                    sType.clear();
+                    sType = {};
                     //The next char is the start of the new type
                     nTypeNameStart = i + 1;
                     bInType = true;
@@ -249,7 +250,7 @@ std::vector< std::pair< OUString, OUString> > parseDN(const 
OUString& rRawString
         }
         if (!sbufValue.isEmpty())
         {
-            OSL_ASSERT(!sType.isEmpty());
+            OSL_ASSERT(!sType.empty());
             retVal.emplace_back(sType, sbufValue.makeStringAndClear());
         }
         return retVal;
diff --git a/include/comphelper/accessibletexthelper.hxx 
b/include/comphelper/accessibletexthelper.hxx
index 2c1e464d7e2f..607004aee30f 100644
--- a/include/comphelper/accessibletexthelper.hxx
+++ b/include/comphelper/accessibletexthelper.hxx
@@ -55,7 +55,7 @@ namespace comphelper
         static bool                      implIsValidIndex( sal_Int32 nIndex, 
sal_Int32 nLength );
         static bool                      implIsValidRange( sal_Int32 
nStartIndex, sal_Int32 nEndIndex, sal_Int32 nLength );
         static sal_Unicode               implGetCharacter( std::u16string_view 
rText, sal_Int32 nIndex );
-        static OUString                  implGetTextRange( const OUString& 
rText, sal_Int32 nStartIndex, sal_Int32 nEndIndex );
+        static OUString                  implGetTextRange( std::u16string_view 
rText, sal_Int32 nStartIndex, sal_Int32 nEndIndex );
         virtual OUString                 implGetText() = 0;
         virtual css::lang::Locale        implGetLocale() = 0;
         virtual void                     implGetSelection( sal_Int32& 
nStartIndex, sal_Int32& nEndIndex ) = 0;
@@ -101,8 +101,8 @@ namespace comphelper
                  css::accessibility::TextSegment
         */
         static bool implInitTextChangedEvent(
-            const OUString& rOldString,
-            const OUString& rNewString,
+            std::u16string_view rOldString,
+            std::u16string_view rNewString,
             /*out*/ css::uno::Any& rDeleted,
             /*out*/ css::uno::Any& rInserted); // throw()
     };
diff --git a/include/comphelper/docpasswordhelper.hxx 
b/include/comphelper/docpasswordhelper.hxx
index a5b99d201831..0b9e646bd2b8 100644
--- a/include/comphelper/docpasswordhelper.hxx
+++ b/include/comphelper/docpasswordhelper.hxx
@@ -331,7 +331,7 @@ public:
       */
 
     static css::uno::Sequence< sal_Int8 > GenerateStd97Key(
-                const OUString& aPassword,
+                std::u16string_view aPassword,
                 const css::uno::Sequence< sal_Int8 >& aDocId );
 
 
diff --git a/include/comphelper/storagehelper.hxx 
b/include/comphelper/storagehelper.hxx
index 10cbb1562d23..c6c47c1a5a11 100644
--- a/include/comphelper/storagehelper.hxx
+++ b/include/comphelper/storagehelper.hxx
@@ -177,7 +177,7 @@ public:
     static css::uno::Sequence< css::beans::NamedValue >
         CreateGpgPackageEncryptionData();
 
-    static bool IsValidZipEntryFileName( const OUString& aName, bool 
bSlashAllowed );
+    static bool IsValidZipEntryFileName( std::u16string_view aName, bool 
bSlashAllowed );
     static bool IsValidZipEntryFileName( const sal_Unicode *pChar, sal_Int32 
nLength, bool bSlashAllowed );
 
     static bool PathHasSegment( std::u16string_view aPath, std::u16string_view 
aSegment );
diff --git a/include/comphelper/syntaxhighlight.hxx 
b/include/comphelper/syntaxhighlight.hxx
index 26cfd9baad62..c8bc100d362b 100644
--- a/include/comphelper/syntaxhighlight.hxx
+++ b/include/comphelper/syntaxhighlight.hxx
@@ -73,7 +73,7 @@ public:
     SyntaxHighlighter(HighlighterLanguage language);
     ~SyntaxHighlighter();
 
-    void getHighlightPortions( const OUString& rLine,
+    void getHighlightPortions( std::u16string_view rLine,
                                std::vector<HighlightPortion>& pPortions ) 
const;
 
     HighlighterLanguage GetLanguage() const;
diff --git a/include/comphelper/xmlsechelper.hxx 
b/include/comphelper/xmlsechelper.hxx
index 48703053c230..9a245877f6ae 100644
--- a/include/comphelper/xmlsechelper.hxx
+++ b/include/comphelper/xmlsechelper.hxx
@@ -31,9 +31,10 @@ namespace comphelper::xmlsec
 {
 COMPHELPER_DLLPUBLIC OUString GetCertificateKind(const 
css::security::CertificateKind& rKind);
 
-COMPHELPER_DLLPUBLIC std::vector<std::pair<OUString, OUString>> parseDN(const 
OUString& rRawString);
+COMPHELPER_DLLPUBLIC std::vector<std::pair<OUString, OUString>>
+parseDN(std::u16string_view rRawString);
 COMPHELPER_DLLPUBLIC std::pair<OUString, OUString>
-GetDNForCertDetailsView(const OUString& rRawString);
+GetDNForCertDetailsView(std::u16string_view rRawString);
 COMPHELPER_DLLPUBLIC OUString GetContentPart(const OUString& _rRawString,
                                              const 
css::security::CertificateKind& rKind);
 

Reply via email to