cui/source/dialogs/about.cxx | 4 ++-- cui/source/dialogs/scriptdlg.cxx | 12 ++++++------ cui/source/inc/about.hxx | 2 +- extensions/source/logging/csvformatter.cxx | 14 ++++++++------ extensions/source/propctrlr/eventhandler.cxx | 8 ++++---- extensions/source/propctrlr/newdatatype.cxx | 6 +++--- extensions/source/propctrlr/newdatatype.hxx | 2 +- 7 files changed, 25 insertions(+), 23 deletions(-)
New commits: commit 97eccc5d55d8786f91c88a0f3de36640c112e68e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 27 09:37:44 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 27 14:06:42 2022 +0200 use more string_view in cui,extensions Change-Id: I76253ae06af53f63206a47a84035317c6a5058b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140637 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx index abeafa411865..9e5be496881e 100644 --- a/cui/source/dialogs/about.cxx +++ b/cui/source/dialogs/about.cxx @@ -136,8 +136,8 @@ AboutDialog::AboutDialog(weld::Window *pParent) AboutDialog::~AboutDialog() {} -bool AboutDialog::IsStringValidGitHash(const OUString &hash) { - for (int i = 0; i < hash.getLength(); i++) { +bool AboutDialog::IsStringValidGitHash(std::u16string_view hash) { + for (size_t i = 0; i < hash.size(); i++) { if (!std::isxdigit(hash[i])) { return false; } diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx index c7784393ac6b..9742bc2ebaab 100644 --- a/cui/source/dialogs/scriptdlg.cxx +++ b/cui/source/dialogs/scriptdlg.cxx @@ -1091,14 +1091,14 @@ namespace { OUString ReplaceString( const OUString& source, - const OUString& token, + std::u16string_view token, std::u16string_view value ) { sal_Int32 pos = source.indexOf( token ); if ( pos != -1 && !value.empty() ) { - return source.replaceAt( pos, token.getLength(), value ); + return source.replaceAt( pos, token.size(), value ); } else { @@ -1116,9 +1116,9 @@ OUString FormatErrorString( { OUString result = unformatted; - result = ReplaceString(result, "%LANGUAGENAME", language ); - result = ReplaceString(result, "%SCRIPTNAME", script ); - result = ReplaceString(result, "%LINENUMBER", line ); + result = ReplaceString(result, u"%LANGUAGENAME", language ); + result = ReplaceString(result, u"%SCRIPTNAME", script ); + result = ReplaceString(result, u"%LINENUMBER", line ); if ( !type.empty() ) { @@ -1239,7 +1239,7 @@ OUString GetErrorMessage( if ( sError.errorType == provider::ScriptFrameworkErrorType::NOTSUPPORTED ) { message = CuiResId(RID_CUISTR_ERROR_LANG_NOT_SUPPORTED); - message = ReplaceString(message, "%LANGUAGENAME", language ); + message = ReplaceString(message, u"%LANGUAGENAME", language ); } else diff --git a/cui/source/inc/about.hxx b/cui/source/inc/about.hxx index 2cfc65a894f4..42eae5467eab 100644 --- a/cui/source/inc/about.hxx +++ b/cui/source/inc/about.hxx @@ -46,7 +46,7 @@ private: static OUString GetMiscString(); static OUString GetCopyrightString(); - static bool IsStringValidGitHash(const OUString& hash); + static bool IsStringValidGitHash(std::u16string_view hash); DECL_LINK(HandleClick, weld::Button&, void); diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx index 8e749db42831..ddbf3a9a2c36 100644 --- a/extensions/source/logging/csvformatter.cxx +++ b/extensions/source/logging/csvformatter.cxx @@ -97,25 +97,27 @@ namespace return str.find_first_of(u"\",\n\r") != std::u16string_view::npos; }; - void appendEncodedString(OUStringBuffer& buf, const OUString& str) + void appendEncodedString(OUStringBuffer& buf, std::u16string_view str) { if(needsQuoting(str)) { // each double-quote will get replaced by two double-quotes buf.append(quote_char); const sal_Int32 buf_offset = buf.getLength(); - const sal_Int32 str_length = str.getLength(); + const size_t str_length = str.size(); buf.append(str); // special treatment for the last character if(quote_char==str[str_length-1]) buf.append(quote_char); // iterating backwards because the index at which we insert won't be shifted // when moving that way. - for(sal_Int32 i = str_length; i>=0; ) + for(size_t i = str_length;; ) { - i=str.lastIndexOf(quote_char, --i); - if(i!=-1) - buf.insert(buf_offset + i, quote_char); + --i; + i=str.substr(i).rfind(quote_char); + if(i==std::u16string_view::npos) + break; + buf.insert(buf_offset + i, quote_char); } buf.append(quote_char); } diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index 9d158b8d467c..ea99755244af 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -973,14 +973,14 @@ namespace pcr namespace { - bool lcl_endsWith( const OUString& _rText, const OUString& _rCheck ) + bool lcl_endsWith( std::u16string_view _rText, std::u16string_view _rCheck ) { - sal_Int32 nTextLen = _rText.getLength(); - sal_Int32 nCheckLen = _rCheck.getLength(); + size_t nTextLen = _rText.size(); + size_t nCheckLen = _rCheck.size(); if ( nCheckLen > nTextLen ) return false; - return _rText.indexOf( _rCheck ) == ( nTextLen - nCheckLen ); + return _rText.find( _rCheck ) == ( nTextLen - nCheckLen ); } } diff --git a/extensions/source/propctrlr/newdatatype.cxx b/extensions/source/propctrlr/newdatatype.cxx index 09c774d3aa42..b2399d680668 100644 --- a/extensions/source/propctrlr/newdatatype.cxx +++ b/extensions/source/propctrlr/newdatatype.cxx @@ -26,7 +26,7 @@ namespace pcr //= NewDataTypeDialog - NewDataTypeDialog::NewDataTypeDialog(weld::Window* pParent, const OUString& _rNameBase, const std::vector< OUString >& _rProhibitedNames) + NewDataTypeDialog::NewDataTypeDialog(weld::Window* pParent, std::u16string_view _rNameBase, const std::vector< OUString >& _rProhibitedNames) : GenericDialogController(pParent, "modules/spropctrlr/ui/datatypedialog.ui", "DataTypeDialog") , m_aProhibitedNames( _rProhibitedNames.begin(), _rProhibitedNames.end() ) , m_xName(m_xBuilder->weld_entry("entry")) @@ -36,7 +36,7 @@ namespace pcr // find an initial name // for this, first remove trailing digits - sal_Int32 nStripUntil = _rNameBase.getLength(); + sal_Int32 nStripUntil = _rNameBase.size(); while ( nStripUntil > 0 ) { sal_Unicode nChar = _rNameBase[ --nStripUntil ]; @@ -48,7 +48,7 @@ namespace pcr } } - OUString sNameBase = OUString::Concat(_rNameBase.subView( 0, nStripUntil ? nStripUntil + 1 : 0 )) + " "; + OUString sNameBase = OUString::Concat(_rNameBase.substr( 0, nStripUntil ? nStripUntil + 1 : 0 )) + " "; OUString sInitialName; sal_Int32 nPostfixNumber = 1; do diff --git a/extensions/source/propctrlr/newdatatype.hxx b/extensions/source/propctrlr/newdatatype.hxx index e6d46f1af329..ba4b6fa38269 100644 --- a/extensions/source/propctrlr/newdatatype.hxx +++ b/extensions/source/propctrlr/newdatatype.hxx @@ -36,7 +36,7 @@ namespace pcr std::unique_ptr<weld::Entry> m_xName; std::unique_ptr<weld::Button> m_xOK; public: - NewDataTypeDialog(weld::Window* _pParent, const OUString& _rNameBase, + NewDataTypeDialog(weld::Window* _pParent, std::u16string_view _rNameBase, const std::vector< OUString >& _rProhibitedNames ); virtual ~NewDataTypeDialog() override;