accessibility/source/extended/AccessibleBrowseBoxTableCell.cxx | 4 +- accessibility/source/extended/AccessibleGridControlTableCell.cxx | 4 +- accessibility/source/standard/vclxaccessiblelistitem.cxx | 4 +- basctl/source/basicide/basobj2.cxx | 4 +- basctl/source/inc/basobj.hxx | 2 - basic/inc/sbxform.hxx | 4 +- basic/source/sbx/sbxform.cxx | 12 +++--- configmgr/source/access.cxx | 15 ++++--- configmgr/source/access.hxx | 2 - configmgr/source/data.cxx | 20 +++++----- configmgr/source/data.hxx | 2 - configmgr/source/partial.cxx | 8 ++-- 12 files changed, 41 insertions(+), 40 deletions(-)
New commits: commit 0a7eac8576f313dcaf27ee45326d71fd6b5aea1e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 27 09:37:15 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 27 13:31:20 2022 +0200 use more string_view in accessibility..configmgr Change-Id: Ie16d36faac7d06e275348ed68e6c6b2518534fd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140636 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/accessibility/source/extended/AccessibleBrowseBoxTableCell.cxx b/accessibility/source/extended/AccessibleBrowseBoxTableCell.cxx index 0b9110e361cf..12571484e69d 100644 --- a/accessibility/source/extended/AccessibleBrowseBoxTableCell.cxx +++ b/accessibility/source/extended/AccessibleBrowseBoxTableCell.cxx @@ -29,9 +29,9 @@ namespace accessibility namespace { /// @throws css::lang::IndexOutOfBoundsException - void checkIndex_Impl( sal_Int32 _nIndex, const OUString& _sText ) + void checkIndex_Impl( sal_Int32 _nIndex, std::u16string_view _sText ) { - if ( _nIndex >= _sText.getLength() ) + if ( _nIndex >= static_cast<sal_Int32>(_sText.size()) ) throw css::lang::IndexOutOfBoundsException(); } diff --git a/accessibility/source/extended/AccessibleGridControlTableCell.cxx b/accessibility/source/extended/AccessibleGridControlTableCell.cxx index f8a699f54823..91d84902bdee 100644 --- a/accessibility/source/extended/AccessibleGridControlTableCell.cxx +++ b/accessibility/source/extended/AccessibleGridControlTableCell.cxx @@ -33,9 +33,9 @@ namespace accessibility // FIXME this is a copy'n'paste from // source/extended/AccessibleBrowseBoxTableCell.cxx, get rid of that... /// @throws css::lang::IndexOutOfBoundsException - void checkIndex_Impl( sal_Int32 _nIndex, const OUString& _sText ) + void checkIndex_Impl( sal_Int32 _nIndex, std::u16string_view _sText ) { - if ( _nIndex >= _sText.getLength() ) + if ( _nIndex >= static_cast<sal_Int32>(_sText.size()) ) throw css::lang::IndexOutOfBoundsException(); } } diff --git a/accessibility/source/standard/vclxaccessiblelistitem.cxx b/accessibility/source/standard/vclxaccessiblelistitem.cxx index b7d7d9f50d79..55fd0693718d 100644 --- a/accessibility/source/standard/vclxaccessiblelistitem.cxx +++ b/accessibility/source/standard/vclxaccessiblelistitem.cxx @@ -41,9 +41,9 @@ namespace { /// @throws css::lang::IndexOutOfBoundsException - void checkIndex_Impl( sal_Int32 _nIndex, const OUString& _sText ) + void checkIndex_Impl( sal_Int32 _nIndex, std::u16string_view _sText ) { - if ( _nIndex < 0 || _nIndex > _sText.getLength() ) + if ( _nIndex < 0 || _nIndex > static_cast<sal_Int32>(_sText.size()) ) throw css::lang::IndexOutOfBoundsException(); } } diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index 1b63b99b092a..d145d14fb634 100644 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -77,9 +77,9 @@ void Organize(weld::Window* pParent, sal_Int16 tabId) weld::DialogController::runAsync(xDlg, [](int) {}); } -bool IsValidSbxName( const OUString& rName ) +bool IsValidSbxName( std::u16string_view rName ) { - for ( sal_Int32 nChar = 0; nChar < rName.getLength(); nChar++ ) + for ( size_t nChar = 0; nChar < rName.size(); nChar++ ) { sal_Unicode c = rName[nChar]; bool bValid = ( diff --git a/basctl/source/inc/basobj.hxx b/basctl/source/inc/basobj.hxx index 46d0f9392896..90cb82c13b61 100644 --- a/basctl/source/inc/basobj.hxx +++ b/basctl/source/inc/basobj.hxx @@ -45,7 +45,7 @@ namespace basctl void BasicStopped( bool* pbAppWindowDisabled = nullptr, bool* pbDispatcherLocked = nullptr, sal_uInt16* pnWaitCount = nullptr, SfxUInt16Item** ppSWActionCount = nullptr, SfxUInt16Item** ppSWLockViewCount = nullptr ); - bool IsValidSbxName( const OUString& rName ); + bool IsValidSbxName( std::u16string_view rName ); BasicManager* FindBasicManager( StarBASIC const * pLib ); diff --git a/basic/inc/sbxform.hxx b/basic/inc/sbxform.hxx index c14d950a8f6b..49ef777866c0 100644 --- a/basic/inc/sbxform.hxx +++ b/basic/inc/sbxform.hxx @@ -116,7 +116,7 @@ class SbxBasicFormater { static OUString GetNegFormatString( std::u16string_view sFormatStrg, bool & bFound ); static OUString Get0FormatString( std::u16string_view sFormatStrg, bool & bFound ); static OUString GetNullFormatString( std::u16string_view sFormatStrg, bool & bFound ); - static void AnalyseFormatString( const OUString& sFormatStrg, + static void AnalyseFormatString( std::u16string_view sFormatStrg, short& nNoOfDigitsLeft, short& nNoOfDigitsRight, short& nNoOfOptionalDigitsLeft, short& nNoOfExponentDigits, @@ -124,7 +124,7 @@ class SbxBasicFormater { bool& bPercent, bool& bCurrency, bool& bScientific, bool& bGenerateThousandSeparator, short& nMultipleThousandSeparators ); - void ScanFormatString( double dNumber, const OUString& sFormatStrg, + void ScanFormatString( double dNumber, std::u16string_view sFormatStrg, OUString& sReturnStrg, bool bCreateSign ); //*** Data *** diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx index bda6da33e248..76372bf23f2a 100644 --- a/basic/source/sbx/sbxform.cxx +++ b/basic/source/sbx/sbxform.cxx @@ -397,7 +397,7 @@ OUString SbxBasicFormater::GetNullFormatString( std::u16string_view sFormatStrg, } // returns value <> 0 in case of an error -void SbxBasicFormater::AnalyseFormatString( const OUString& sFormatStrg, +void SbxBasicFormater::AnalyseFormatString( std::u16string_view sFormatStrg, short& nNoOfDigitsLeft, short& nNoOfDigitsRight, short& nNoOfOptionalDigitsLeft, short& nNoOfExponentDigits, short& nNoOfOptionalExponentDigits, @@ -408,7 +408,7 @@ void SbxBasicFormater::AnalyseFormatString( const OUString& sFormatStrg, sal_Int32 nLen; short nState = 0; - nLen = sFormatStrg.getLength(); + nLen = sFormatStrg.size(); nNoOfDigitsLeft = 0; nNoOfDigitsRight = 0; nNoOfOptionalDigitsLeft = 0; @@ -419,7 +419,7 @@ void SbxBasicFormater::AnalyseFormatString( const OUString& sFormatStrg, bScientific = false; // from 11.7.97: as soon as a comma (point?) is found in the format string, // all three decimal powers are marked (i. e. thousand, million, ...) - bGenerateThousandSeparator = sFormatStrg.indexOf( ',' ) >= 0; + bGenerateThousandSeparator = sFormatStrg.find( ',' ) != std::u16string_view::npos; nMultipleThousandSeparators = 0; for( sal_Int32 i = 0; i < nLen; i++ ) @@ -513,7 +513,7 @@ void SbxBasicFormater::AnalyseFormatString( const OUString& sFormatStrg, // the flag bCreateSign says that at the mantissa a leading sign // shall be created void SbxBasicFormater::ScanFormatString( double dNumber, - const OUString& sFormatStrg, OUString& sReturnStrgFinal, + std::u16string_view sFormatStrg, OUString& sReturnStrgFinal, bool bCreateSign ) { short /*nErr,*/nNoOfDigitsLeft,nNoOfDigitsRight,nNoOfOptionalDigitsLeft, @@ -565,7 +565,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber, bSignHappend = false; bFoundFirstDigit = false; bIsNegative = dNumber < 0.0; - nLen = sFormatStrg.getLength(); + nLen = sFormatStrg.size(); dExponent = get_number_of_digits( dNumber ); nExponentPos = 0; nMaxExponentDigit = 0; @@ -837,7 +837,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber, if( nNoOfDigitsRight>0 ) { - ParseBack( sReturnStrg, sFormatStrg, sFormatStrg.getLength()-1 ); + ParseBack( sReturnStrg, sFormatStrg, sFormatStrg.size()-1 ); } sReturnStrgFinal = sReturnStrg.makeStringAndClear(); } diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index 865d383002d3..06c000dcdbd3 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -74,6 +74,7 @@ #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/weak.hxx> +#include <o3tl/string_view.hxx> #include <osl/interlck.h> #include <osl/mutex.hxx> #include <rtl/character.hxx> @@ -1970,10 +1971,10 @@ rtl::Reference< ChildAccess > Access::getUnmodifiedChild( return createUnmodifiedChild(name,node); } -rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) { +rtl::Reference< ChildAccess > Access::getSubChild(std::u16string_view path) { sal_Int32 i = 0; // For backwards compatibility, allow absolute paths where meaningful: - if( path.startsWith("/") ) { + if( o3tl::starts_with(path, u"/") ) { ++i; if (!getRootAccess().is()) { return rtl::Reference< ChildAccess >(); @@ -1986,7 +1987,7 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) { OUString templateName1; i = Data::parseSegment( path, i, &name1, &setElement1, &templateName1); - if (i == -1 || (i != path.getLength() && path[i] != '/')) { + if (i == -1 || (i != static_cast<sal_Int32>(path.size()) && path[i] != '/')) { return rtl::Reference< ChildAccess >(); } OUString name2; @@ -1999,7 +2000,7 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) { { return rtl::Reference< ChildAccess >(); } - if (i != path.getLength()) { + if (i != static_cast<sal_Int32>(path.size())) { ++i; } } @@ -2009,7 +2010,7 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) { bool setElement; OUString templateName; i = Data::parseSegment(path, i, &name, &setElement, &templateName); - if (i == -1 || (i != path.getLength() && path[i] != '/')) { + if (i == -1 || (i != static_cast<sal_Int32>(path.size()) && path[i] != '/')) { return rtl::Reference< ChildAccess >(); } rtl::Reference< ChildAccess > child(parent->getChild(name)); @@ -2041,9 +2042,9 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) { // For backwards compatibility, ignore a final slash after non-value // nodes: if (child->isValue()) { - return i == path.getLength() + return i == static_cast<sal_Int32>(path.size()) ? child : rtl::Reference< ChildAccess >(); - } else if (i >= path.getLength() - 1) { + } else if (i >= static_cast<sal_Int32>(path.size()) - 1) { return child; } ++i; diff --git a/configmgr/source/access.hxx b/configmgr/source/access.hxx index 51e43d5bcfcc..dba29c7c6495 100644 --- a/configmgr/source/access.hxx +++ b/configmgr/source/access.hxx @@ -366,7 +366,7 @@ private: rtl::Reference< ChildAccess > getUnmodifiedChild( OUString const & name); - rtl::Reference< ChildAccess > getSubChild(OUString const & path); + rtl::Reference< ChildAccess > getSubChild(std::u16string_view path); bool setChildProperty( OUString const & name, css::uno::Any const & value, diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx index f173ee1556fb..d321723eadda 100644 --- a/configmgr/source/data.cxx +++ b/configmgr/source/data.cxx @@ -110,18 +110,18 @@ OUString Data::createSegment( } sal_Int32 Data::parseSegment( - OUString const & path, sal_Int32 index, OUString * name, + std::u16string_view path, sal_Int32 index, OUString * name, bool * setElement, OUString * templateName) { assert( - index >= 0 && index <= path.getLength() && name != nullptr && + index >= 0 && index <= static_cast<sal_Int32>(path.size()) && name != nullptr && setElement != nullptr); - sal_Int32 i = index; - while (i < path.getLength() && path[i] != '/' && path[i] != '[') { + size_t i = index; + while (i < path.size() && path[i] != '/' && path[i] != '[') { ++i; } - if (i == path.getLength() || path[i] == '/') { - *name = path.copy(index, i - index); + if (i == path.size() || path[i] == '/') { + *name = path.substr(index, i - index); *setElement = false; return i; } @@ -129,18 +129,18 @@ sal_Int32 Data::parseSegment( if (i - index == 1 && path[index] == '*') { templateName->clear(); } else { - *templateName = path.copy(index, i - index); + *templateName = path.substr(index, i - index); } } - if (++i == path.getLength()) { + if (++i == path.size()) { return -1; } sal_Unicode del = path[i++]; if (del != '\'' && del != '"') { return -1; } - sal_Int32 j = path.indexOf(del, i); - if (j == -1 || j + 1 == path.getLength() || path[j + 1] != ']' || + size_t j = path.find(del, i); + if (j == std::u16string_view::npos || j + 1 == path.size() || path[j + 1] != ']' || !decode(path, i, j, name)) { return -1; diff --git a/configmgr/source/data.hxx b/configmgr/source/data.hxx index c3614e6435da..32a08e3437ce 100644 --- a/configmgr/source/data.hxx +++ b/configmgr/source/data.hxx @@ -54,7 +54,7 @@ struct Data { std::u16string_view templateName, OUString const & name); static sal_Int32 parseSegment( - OUString const & path, sal_Int32 index, OUString * name, + std::u16string_view path, sal_Int32 index, OUString * name, bool * setElement, OUString * templateName); static OUString fullTemplateName( diff --git a/configmgr/source/partial.cxx b/configmgr/source/partial.cxx index f31e98549684..ae8ec599906e 100644 --- a/configmgr/source/partial.cxx +++ b/configmgr/source/partial.cxx @@ -34,10 +34,10 @@ namespace configmgr { namespace { bool parseSegment( - OUString const & path, sal_Int32 * index, OUString * segment) + std::u16string_view path, sal_Int32 * index, OUString * segment) { assert( - index != nullptr && *index >= 0 && *index <= path.getLength() && + index != nullptr && *index >= 0 && *index <= static_cast<sal_Int32>(path.size()) && segment != nullptr); if (path[(*index)++] == '/') { OUString name; @@ -47,10 +47,10 @@ bool parseSegment( path, *index, &name, &setElement, &templateName); if (*index != -1) { *segment = Data::createSegment(templateName, name); - return *index == path.getLength(); + return *index == static_cast<sal_Int32>(path.size()); } } - throw css::uno::RuntimeException("bad path " + path); + throw css::uno::RuntimeException(OUString::Concat("bad path ") + path); } }