diff options
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/config/configitem.cxx | 4 | ||||
-rw-r--r-- | unotools/source/config/configpaths.cxx | 21 | ||||
-rw-r--r-- | unotools/source/i18n/localedatawrapper.cxx | 62 | ||||
-rw-r--r-- | unotools/source/misc/datetime.cxx | 32 |
4 files changed, 60 insertions, 59 deletions
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx index dd8c567e639f..d6741142a9a5 100644 --- a/unotools/source/config/configitem.cxx +++ b/unotools/source/config/configitem.cxx @@ -819,14 +819,14 @@ bool ConfigItem::ClearNodeElements(const OUString& rNode, Sequence< OUString > c return bRet; } -static OUString lcl_extractSetPropertyName( const OUString& rInPath, const OUString& rPrefix ) +static OUString lcl_extractSetPropertyName( const OUString& rInPath, std::u16string_view rPrefix ) { OUString const sSubPath = dropPrefixFromConfigurationPath( rInPath, rPrefix); return extractFirstFromConfigurationPath( sSubPath ); } static -Sequence< OUString > lcl_extractSetPropertyNames( const Sequence< PropertyValue >& rValues, const OUString& rPrefix ) +Sequence< OUString > lcl_extractSetPropertyNames( const Sequence< PropertyValue >& rValues, std::u16string_view rPrefix ) { Sequence< OUString > aSubNodeNames(rValues.getLength()); OUString* pSubNodeNames = aSubNodeNames.getArray(); diff --git a/unotools/source/config/configpaths.cxx b/unotools/source/config/configpaths.cxx index 8c3ee31f2641..9cf537738889 100644 --- a/unotools/source/config/configpaths.cxx +++ b/unotools/source/config/configpaths.cxx @@ -25,6 +25,7 @@ #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> namespace utl { @@ -182,22 +183,22 @@ OUString extractFirstFromConfigurationPath(OUString const& _sInPath, OUString* _ } // find the position after the prefix in the nested path -static sal_Int32 lcl_findPrefixEnd(OUString const& _sNestedPath, OUString const& _sPrefixPath) +static sal_Int32 lcl_findPrefixEnd(std::u16string_view _sNestedPath, std::u16string_view _sPrefixPath) { // TODO: currently handles only exact prefix matches - sal_Int32 nPrefixLength = _sPrefixPath.getLength(); + size_t nPrefixLength = _sPrefixPath.size(); OSL_ENSURE(nPrefixLength == 0 || _sPrefixPath[nPrefixLength-1] != '/', "Cannot handle slash-terminated prefix paths"); bool bIsPrefix; - if (_sNestedPath.getLength() > nPrefixLength) + if (_sNestedPath.size() > nPrefixLength) { bIsPrefix = _sNestedPath[nPrefixLength] == '/' && - _sNestedPath.startsWith(_sPrefixPath); + o3tl::starts_with(_sNestedPath, _sPrefixPath); ++nPrefixLength; } - else if (_sNestedPath.getLength() == nPrefixLength) + else if (_sNestedPath.size() == nPrefixLength) { bIsPrefix = _sNestedPath == _sPrefixPath; } @@ -209,14 +210,14 @@ static sal_Int32 lcl_findPrefixEnd(OUString const& _sNestedPath, OUString const& return bIsPrefix ? nPrefixLength : 0; } -bool isPrefixOfConfigurationPath(OUString const& _sNestedPath, - OUString const& _sPrefixPath) +bool isPrefixOfConfigurationPath(std::u16string_view _sNestedPath, + std::u16string_view _sPrefixPath) { - return _sPrefixPath.isEmpty() || lcl_findPrefixEnd(_sNestedPath,_sPrefixPath) != 0; + return _sPrefixPath.empty() || lcl_findPrefixEnd(_sNestedPath,_sPrefixPath) != 0; } OUString dropPrefixFromConfigurationPath(OUString const& _sNestedPath, - OUString const& _sPrefixPath) + std::u16string_view _sPrefixPath) { if ( sal_Int32 nPrefixEnd = lcl_findPrefixEnd(_sNestedPath,_sPrefixPath) ) { @@ -224,7 +225,7 @@ OUString dropPrefixFromConfigurationPath(OUString const& _sNestedPath, } else { - OSL_ENSURE(_sPrefixPath.isEmpty(), "Path does not start with expected prefix"); + OSL_ENSURE(_sPrefixPath.empty(), "Path does not start with expected prefix"); return _sNestedPath; } diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index 904808c6a247..83a2d65ac41f 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -685,7 +685,7 @@ LongDateOrder LocaleDataWrapper::getLongDateOrder() const return nLongDateOrder; } -LongDateOrder LocaleDataWrapper::scanDateOrderImpl( const OUString& rCode ) const +LongDateOrder LocaleDataWrapper::scanDateOrderImpl( std::u16string_view rCode ) const { // Only some european versions were translated, the ones with different // keyword combinations are: @@ -693,35 +693,35 @@ LongDateOrder LocaleDataWrapper::scanDateOrderImpl( const OUString& rCode ) cons // Dutch DMJ, Finnish PKV // default is English keywords for every other language - sal_Int32 nDay = rCode.indexOf('D'); - sal_Int32 nMonth = rCode.indexOf('M'); - sal_Int32 nYear = rCode.indexOf('Y'); - if (nDay == -1 || nMonth == -1 || nYear == -1) + size_t nDay = rCode.find('D'); + size_t nMonth = rCode.find('M'); + size_t nYear = rCode.find('Y'); + if (nDay == std::u16string_view::npos || nMonth == std::u16string_view::npos || nYear == std::u16string_view::npos) { // This algorithm assumes that all three parts (DMY) are present - if (nMonth == -1) + if (nMonth == std::u16string_view::npos) { // only Finnish has something else than 'M' for month - nMonth = rCode.indexOf('K'); - if (nMonth != -1) + nMonth = rCode.find('K'); + if (nMonth != std::u16string_view::npos) { - nDay = rCode.indexOf('P'); - nYear = rCode.indexOf('V'); + nDay = rCode.find('P'); + nYear = rCode.find('V'); } } - else if (nDay == -1) + else if (nDay == std::u16string_view::npos) { // We have a month 'M' if we reach this branch. // Possible languages containing 'M' but no 'D': // German, French, Italian - nDay = rCode.indexOf('T'); // German - if (nDay != -1) - nYear = rCode.indexOf('J'); + nDay = rCode.find('T'); // German + if (nDay != std::u16string_view::npos) + nYear = rCode.find('J'); else { - nYear = rCode.indexOf('A'); // French, Italian - if (nYear != -1) + nYear = rCode.find('A'); // French, Italian + if (nYear != std::u16string_view::npos) { - nDay = rCode.indexOf('J'); // French - if (nDay == -1) - nDay = rCode.indexOf('G'); // Italian + nDay = rCode.find('J'); // French + if (nDay == std::u16string_view::npos) + nDay = rCode.find('G'); // Italian } } } @@ -729,22 +729,22 @@ LongDateOrder LocaleDataWrapper::scanDateOrderImpl( const OUString& rCode ) cons { // We have a month 'M' and a day 'D'. // Possible languages containing 'D' and 'M' but not 'Y': // Spanish, Dutch - nYear = rCode.indexOf('A'); // Spanish - if (nYear == -1) - nYear = rCode.indexOf('J'); // Dutch + nYear = rCode.find('A'); // Spanish + if (nYear == std::u16string_view::npos) + nYear = rCode.find('J'); // Dutch } - if (nDay == -1 || nMonth == -1 || nYear == -1) + if (nDay == std::u16string_view::npos || nMonth == std::u16string_view::npos || nYear == std::u16string_view::npos) { if (areChecksEnabled()) { outputCheckMessage( appendLocaleInfo( u"LocaleDataWrapper::scanDateOrder: not all DMY present" ) ); } - if (nDay == -1) - nDay = rCode.getLength(); - if (nMonth == -1) - nMonth = rCode.getLength(); - if (nYear == -1) - nYear = rCode.getLength(); + if (nDay == std::u16string_view::npos) + nDay = rCode.size(); + if (nMonth == std::u16string_view::npos) + nMonth = rCode.size(); + if (nYear == std::u16string_view::npos) + nYear = rCode.size(); } } // compare with <= because each position may equal rCode.getLength() @@ -1226,14 +1226,14 @@ OUString LocaleDataWrapper::getNum( sal_Int64 nNumber, sal_uInt16 nDecimals, } OUString LocaleDataWrapper::getCurr( sal_Int64 nNumber, sal_uInt16 nDecimals, - const OUString& rCurrencySymbol, bool bUseThousandSep ) const + std::u16string_view rCurrencySymbol, bool bUseThousandSep ) const { sal_Unicode cZeroChar = getCurrZeroChar(); // check if digits and separators will fit into fixed buffer or allocate size_t nGuess = ImplGetNumberStringLengthGuess( aLocaleDataItem, nDecimals ); OUStringBuffer aNumBuf(int(nGuess + 16)); - OUStringBuffer aBuf(int(rCurrencySymbol.getLength() + nGuess + 20 )); + OUStringBuffer aBuf(int(rCurrencySymbol.size() + nGuess + 20 )); bool bNeg; if ( nNumber < 0 ) diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx index 703ce91273aa..5bb7280bdf50 100644 --- a/unotools/source/misc/datetime.cxx +++ b/unotools/source/misc/datetime.cxx @@ -31,10 +31,10 @@ namespace { - bool checkAllNumber(const OUString& rString) + bool checkAllNumber(std::u16string_view rString) { sal_Int32 nPos = 0; - sal_Int32 nLen = rString.getLength(); + sal_Int32 nLen = rString.size(); // skip white space while( nPos < nLen && ' ' == rString[nPos] ) @@ -99,7 +99,7 @@ namespace // o_strInt: output; integer part of token // o_bFraction: output; was there a fractional part? // o_strFrac: output; fractional part of token - bool impl_getISO8601TimeToken(const OUString &i_str, sal_Int32 &nPos, OUString &resInt, bool &bFraction, OUString &resFrac) + bool impl_getISO8601TimeToken(std::u16string_view i_str, sal_Int32 &nPos, OUString &resInt, bool &bFraction, OUString &resFrac) { bFraction = false; // all tokens are of length 2 @@ -107,7 +107,7 @@ namespace const sal_Unicode c0 = '0'; const sal_Unicode c9 = '9'; const sal_Unicode sep = ':'; - for (;nPos < nEndPos && nPos < i_str.getLength(); ++nPos) + for (;nPos < nEndPos && nPos < static_cast<sal_Int32>(i_str.size()); ++nPos) { const sal_Unicode c = i_str[nPos]; if (c == sep) @@ -116,13 +116,13 @@ namespace return false; resInt += OUStringChar(c); } - if (nPos == i_str.getLength() || i_str[nPos] == sep) + if (nPos == static_cast<sal_Int32>(i_str.size()) || i_str[nPos] == sep) return true; if (i_str[nPos] == ',' || i_str[nPos] == '.') { bFraction = true; ++nPos; - for (; nPos < i_str.getLength(); ++nPos) + for (; nPos < static_cast<sal_Int32>(i_str.size()); ++nPos) { const sal_Unicode c = i_str[nPos]; if (c == 'Z' || c == '+' || c == '-') @@ -137,7 +137,7 @@ namespace return false; resFrac += OUStringChar(c); } - OSL_ENSURE(nPos == i_str.getLength(), "impl_getISO8601TimeToken internal error; expected to be at end of string"); + OSL_ENSURE(nPos == static_cast<sal_Int32>(i_str.size()), "impl_getISO8601TimeToken internal error; expected to be at end of string"); return true; } if (i_str[nPos] == 'Z' || i_str[nPos] == '+' || i_str[nPos] == '-') @@ -148,7 +148,7 @@ namespace else return false; } - bool getISO8601TimeToken(const OUString &i_str, sal_Int32 &io_index, OUString &o_strInt, bool &o_bFraction, OUString &o_strFrac) + bool getISO8601TimeToken(std::u16string_view i_str, sal_Int32 &io_index, OUString &o_strInt, bool &o_bFraction, OUString &o_strFrac) { OUString resInt; OUString resFrac; @@ -165,7 +165,7 @@ namespace return true; } } - bool getISO8601TimeZoneToken(const OUString &i_str, sal_Int32 &io_index, OUString &o_strInt) + bool getISO8601TimeZoneToken(std::u16string_view i_str, sal_Int32 &io_index, OUString &o_strInt) { const sal_Unicode c0 = '0'; const sal_Unicode c9 = '9'; @@ -180,7 +180,7 @@ namespace { ++io_index; o_strInt.clear(); - for (; io_index < i_str.getLength(); ++io_index) + for (; io_index < static_cast<sal_Int32>(i_str.size()); ++io_index) { const sal_Unicode c = i_str[io_index]; if ((c < c0 || c > c9) && c != sep) @@ -367,7 +367,7 @@ bool ISO8601parseDate(const OUString &aDateStr, css::util::Date& rDate) } /** convert ISO8601 Time String to util::Time */ -bool ISO8601parseTime(const OUString &aTimeStr, css::util::Time& rTime) +bool ISO8601parseTime(std::u16string_view aTimeStr, css::util::Time& rTime) { sal_Int32 nHour = 0; sal_Int32 nMin = 0; @@ -384,7 +384,7 @@ bool ISO8601parseTime(const OUString &aTimeStr, css::util::Time& rTime) if (!bSuccess) return false; - if ( bFrac && n < aTimeStr.getLength()) + if ( bFrac && n < static_cast<sal_Int32>(aTimeStr.size())) { // is it junk or the timezone? bSuccess = getISO8601TimeZoneToken(aTimeStr, n, tokTz); @@ -419,14 +419,14 @@ bool ISO8601parseTime(const OUString &aTimeStr, css::util::Time& rTime) } goto end; } - if(n >= aTimeStr.getLength()) + if(n >= static_cast<sal_Int32>(aTimeStr.size())) goto end; // minutes bSuccess = getISO8601TimeToken(aTimeStr, n, tokInt, bFrac, tokFrac); if (!bSuccess) return false; - if ( bFrac && n < aTimeStr.getLength()) + if ( bFrac && n < static_cast<sal_Int32>(aTimeStr.size())) { // is it junk or the timezone? bSuccess = getISO8601TimeZoneToken(aTimeStr, n, tokTz); @@ -455,14 +455,14 @@ bool ISO8601parseTime(const OUString &aTimeStr, css::util::Time& rTime) } goto end; } - if(n >= aTimeStr.getLength()) + if(n >= static_cast<sal_Int32>(aTimeStr.size())) goto end; // seconds bSuccess = getISO8601TimeToken(aTimeStr, n, tokInt, bFrac, tokFrac); if (!bSuccess) return false; - if (n < aTimeStr.getLength()) + if (n < static_cast<sal_Int32>(aTimeStr.size())) { // is it junk or the timezone? bSuccess = getISO8601TimeZoneToken(aTimeStr, n, tokTz); |