diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-03 10:34:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-17 10:27:33 +0200 |
commit | 33bd16b344e273c427091ee68e946bf67b371dd7 (patch) | |
tree | 85fb383ea8e3d30f393bb197b5c74f73f6ca247f /basic | |
parent | fe597a337914decd62480d3eba84258333116db9 (diff) |
loplugin:stringviewparam convert methods using copy()
which converts to std::string_view::substr()
Change-Id: I3f42213b41a97e77ddcc79d84d512f49d68ca559
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132729
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic')
-rw-r--r-- | basic/inc/sbxform.hxx | 10 | ||||
-rw-r--r-- | basic/source/sbx/sbxform.cxx | 68 |
2 files changed, 39 insertions, 39 deletions
diff --git a/basic/inc/sbxform.hxx b/basic/inc/sbxform.hxx index 8ae9cb2db3f4..8accc399547a 100644 --- a/basic/inc/sbxform.hxx +++ b/basic/inc/sbxform.hxx @@ -93,7 +93,7 @@ class SbxBasicFormater { String containing the formatted output */ OUString BasicFormat( double dNumber, const OUString& sFormatStrg ); - static OUString BasicFormatNull( const OUString& sFormatStrg ); + static OUString BasicFormatNull( std::u16string_view sFormatStrg ); static bool isBasicFormat( std::u16string_view sFormatStrg ); @@ -112,10 +112,10 @@ class SbxBasicFormater { short GetDigitAtPosExpScan( double dNewExponent, short nPos, bool& bFoundFirstDigit ); short GetDigitAtPosExpScan( short nPos, bool& bFoundFirstDigit ); - static OUString GetPosFormatString( const OUString& sFormatStrg, bool & bFound ); - static OUString GetNegFormatString( const OUString& sFormatStrg, bool & bFound ); - static OUString Get0FormatString( const OUString& sFormatStrg, bool & bFound ); - static OUString GetNullFormatString( const OUString& sFormatStrg, bool & bFound ); + static OUString GetPosFormatString( std::u16string_view sFormatStrg, bool & bFound ); + 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, short& nNoOfDigitsLeft, short& nNoOfDigitsRight, short& nNoOfOptionalDigitsLeft, diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx index ef273c1f392b..4bd0c09ac99f 100644 --- a/basic/source/sbx/sbxform.cxx +++ b/basic/source/sbx/sbxform.cxx @@ -296,71 +296,71 @@ short SbxBasicFormater::GetDigitAtPosExpScan( double dNewExponent, short nPos, // Copies the respective part of the format-string, if existing, and returns it. // So a new string is created, which has to be freed by the caller later. -OUString SbxBasicFormater::GetPosFormatString( const OUString& sFormatStrg, bool & bFound ) +OUString SbxBasicFormater::GetPosFormatString( std::u16string_view sFormatStrg, bool & bFound ) { bFound = false; // default... - sal_Int32 nPos = sFormatStrg.indexOf( FORMAT_SEPARATOR ); + size_t nPos = sFormatStrg.find( FORMAT_SEPARATOR ); - if( nPos >= 0 ) + if( nPos != std::u16string_view::npos ) { bFound = true; // the format-string for positive numbers is // everything before the first ';' - return sFormatStrg.copy( 0,nPos ); + return OUString(sFormatStrg.substr( 0,nPos )); } return OUString(); } // see also GetPosFormatString() -OUString SbxBasicFormater::GetNegFormatString( const OUString& sFormatStrg, bool & bFound ) +OUString SbxBasicFormater::GetNegFormatString( std::u16string_view sFormatStrg, bool & bFound ) { bFound = false; // default... - sal_Int32 nPos = sFormatStrg.indexOf( FORMAT_SEPARATOR ); + size_t nPos = sFormatStrg.find( FORMAT_SEPARATOR ); - if( nPos >= 0) + if( nPos != std::u16string_view::npos) { // the format-string for negative numbers is // everything between the first and the second ';' - OUString sTempStrg = sFormatStrg.copy( nPos+1 ); - nPos = sTempStrg.indexOf( FORMAT_SEPARATOR ); + std::u16string_view sTempStrg = sFormatStrg.substr( nPos+1 ); + nPos = sTempStrg.find( FORMAT_SEPARATOR ); bFound = true; - if( nPos < 0 ) + if( nPos == std::u16string_view::npos ) { - return sTempStrg; + return OUString(sTempStrg); } else { - return sTempStrg.copy( 0,nPos ); + return OUString(sTempStrg.substr( 0,nPos )); } } return OUString(); } // see also GetPosFormatString() -OUString SbxBasicFormater::Get0FormatString( const OUString& sFormatStrg, bool & bFound ) +OUString SbxBasicFormater::Get0FormatString( std::u16string_view sFormatStrg, bool & bFound ) { bFound = false; // default... - sal_Int32 nPos = sFormatStrg.indexOf( FORMAT_SEPARATOR ); + size_t nPos = sFormatStrg.find( FORMAT_SEPARATOR ); - if( nPos >= 0 ) + if( nPos != std::u16string_view::npos ) { // the format string for the zero is // everything after the second ';' - OUString sTempStrg = sFormatStrg.copy( nPos+1 ); - nPos = sTempStrg.indexOf( FORMAT_SEPARATOR ); - if( nPos >= 0 ) + std::u16string_view sTempStrg = sFormatStrg.substr( nPos+1 ); + nPos = sTempStrg.find( FORMAT_SEPARATOR ); + if( nPos != std::u16string_view::npos ) { bFound = true; - sTempStrg = sTempStrg.copy( nPos+1 ); - nPos = sTempStrg.indexOf( FORMAT_SEPARATOR ); - if( nPos < 0 ) + sTempStrg = sTempStrg.substr( nPos+1 ); + nPos = sTempStrg.find( FORMAT_SEPARATOR ); + if( nPos == std::u16string_view::npos ) { - return sTempStrg; + return OUString(sTempStrg); } else { - return sTempStrg.copy( 0,nPos ); + return OUString(sTempStrg.substr( 0,nPos )); } } } @@ -369,25 +369,25 @@ OUString SbxBasicFormater::Get0FormatString( const OUString& sFormatStrg, bool & } // see also GetPosFormatString() -OUString SbxBasicFormater::GetNullFormatString( const OUString& sFormatStrg, bool & bFound ) +OUString SbxBasicFormater::GetNullFormatString( std::u16string_view sFormatStrg, bool & bFound ) { bFound = false; // default... - sal_Int32 nPos = sFormatStrg.indexOf( FORMAT_SEPARATOR ); + size_t nPos = sFormatStrg.find( FORMAT_SEPARATOR ); - if( nPos >= 0 ) + if( nPos != std::u16string_view::npos ) { // the format-string for the Null is // everything after the third ';' - OUString sTempStrg = sFormatStrg.copy( nPos+1 ); - nPos = sTempStrg.indexOf( FORMAT_SEPARATOR ); - if( nPos >= 0 ) + std::u16string_view sTempStrg = sFormatStrg.substr( nPos+1 ); + nPos = sTempStrg.find( FORMAT_SEPARATOR ); + if( nPos != std::u16string_view::npos ) { - sTempStrg = sTempStrg.copy( nPos+1 ); - nPos = sTempStrg.indexOf( FORMAT_SEPARATOR ); - if( nPos >= 0 ) + sTempStrg = sTempStrg.substr( nPos+1 ); + nPos = sTempStrg.find( FORMAT_SEPARATOR ); + if( nPos != std::u16string_view::npos ) { bFound = true; - return sTempStrg.copy( nPos+1 ); + return OUString(sTempStrg.substr( nPos+1 )); } } } @@ -841,7 +841,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber, sReturnStrgFinal = sReturnStrg.makeStringAndClear(); } -OUString SbxBasicFormater::BasicFormatNull( const OUString& sFormatStrg ) +OUString SbxBasicFormater::BasicFormatNull( std::u16string_view sFormatStrg ) { bool bNullFormatFound; OUString sNullFormatStrg = GetNullFormatString( sFormatStrg, bNullFormatFound ); |