summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-01 17:42:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-02 13:31:19 +0200
commit1927b51993fb68907a75765676179b08ab195196 (patch)
tree1b7d09c1b5e7ea945fb6ea618a4c100e8630ebb4 /vcl
parent0dfa444f393a5766d36fe7d2480d0c8ec832e329 (diff)
loplugin:stringviewparam convert methods using indexOf
.. and lastIndexOf, which convert to find and rfind Change-Id: I6c4156cf904774c0d867f85a4c2785dba7593f62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132445 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/field2.cxx28
1 files changed, 14 insertions, 14 deletions
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index 1fa8d4d0be5b..67c0357a8ebf 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -1617,7 +1617,7 @@ bool DateFormatter::ImplAllowMalformedInput() const
return !IsEnforceValidValue();
}
-int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper)
+int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, std::u16string_view rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper)
{
sal_Int8 nDateArea = 0;
@@ -1629,12 +1629,12 @@ int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText
else
{
// search area
- sal_Int32 nPos = 0;
+ size_t nPos = 0;
OUString aDateSep = ImplGetDateSep(rLocaleDataWrapper, eFormat);
for ( sal_Int8 i = 1; i <= 3; i++ )
{
- nPos = rText.indexOf( aDateSep, nPos );
- if (nPos < 0 || nPos >= nCursor)
+ nPos = rText.find( aDateSep, nPos );
+ if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
{
nDateArea = i;
break;
@@ -2581,7 +2581,7 @@ bool TimeFormatter::ImplAllowMalformedInput() const
return !IsEnforceValidValue();
}
-int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, int nCursor,
+int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper)
{
int nTimeArea = 0;
@@ -2590,18 +2590,18 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
if (eFormat != TimeFieldFormat::F_SEC_CS)
{
//Which area is the cursor in of HH:MM:SS.TT
- for ( sal_Int32 i = 1, nPos = 0; i <= 4; i++ )
+ for ( size_t i = 1, nPos = 0; i <= 4; i++ )
{
- sal_Int32 nPos1 = rText.indexOf(rLocaleDataWrapper.getTimeSep(), nPos);
- sal_Int32 nPos2 = rText.indexOf(rLocaleDataWrapper.getTime100SecSep(), nPos);
+ size_t nPos1 = rText.find(rLocaleDataWrapper.getTimeSep(), nPos);
+ size_t nPos2 = rText.find(rLocaleDataWrapper.getTime100SecSep(), nPos);
//which ever comes first, bearing in mind that one might not be there
- if (nPos1 >= 0 && nPos2 >= 0)
+ if (nPos1 != std::u16string_view::npos && nPos2 != std::u16string_view::npos)
nPos = std::min(nPos1, nPos2);
- else if (nPos1 >= 0)
+ else if (nPos1 != std::u16string_view::npos)
nPos = nPos1;
else
nPos = nPos2;
- if (nPos < 0 || nPos >= nCursor)
+ if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
{
nTimeArea = i;
break;
@@ -2612,8 +2612,8 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
}
else
{
- sal_Int32 nPos = rText.indexOf(rLocaleDataWrapper.getTime100SecSep());
- if (nPos < 0 || nPos >= nCursor)
+ size_t nPos = rText.find(rLocaleDataWrapper.getTime100SecSep());
+ if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
nTimeArea = 3;
else
nTimeArea = 4;
@@ -2623,7 +2623,7 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
}
tools::Time TimeFormatter::SpinTime(bool bUp, const tools::Time& rTime, TimeFieldFormat eFormat,
- bool bDuration, const OUString& rText, int nCursor,
+ bool bDuration, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper)
{
tools::Time aTime(rTime);