diff options
author | Justin Luth <justin.luth@collabora.com> | 2022-09-26 18:15:03 -0400 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-09-27 21:55:02 +0200 |
commit | 27c22bac5439908ecdd1aa05580d75998a5eb058 (patch) | |
tree | 37bff7f0216fe859bfb0c6fd8614e1201ca7ac57 /sc | |
parent | 70973680f05c587c866d2de2a16bff9ebf8007ca (diff) |
tdf#123990 sc condition: use GetTransliteration, not GetCollator
Thanks Eike
Eike said "This should not use collation (which should only be used
in sorting context) but ignore case transliteration instead."
I had just copied ancient code from
commit 952c2b02c73b30b011306faf2f0d6f2b4a935955
Author: Eike Rathke on Date: Wed Mar 14 14:57:39 2001 +0000
use CollatorWrapper instead of International
Apparently that code should also be changed
in a follow-up commit.
Interestingly, a \x000 - \x008 etc must be isEqual(""),
so an attempt to ScGlobal::getCharClass().lowercase
all variables at the beginning and use regular OUString
comparisons didn't work.
Also, a "" startsWith and endsWith each string.
In Excel, a "" is also contained in every string,
but not (yet) in Calc.
Change-Id: I44a07c482d2d67a76a939ba2d593a003398d52c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140633
Tested-by: Justin Luth <jluth@mail.com>
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/conditio.cxx | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 834c4a78f5e8..d126357dc38a 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1175,36 +1175,33 @@ bool ScConditionEntry::IsValidStr( const OUString& rArg, const ScAddress& rPos ) bValid = !bValid; break; case ScConditionMode::BeginsWith: - { - const sal_Int32 nLen = aUpVal1.getLength(); - if (!nLen || nLen > rArg.getLength()) - bValid = false; - else - { - bValid = (ScGlobal::GetCollator().compareSubstring(rArg, 0, nLen, - aUpVal1, 0, nLen) == 0); - } - } - break; + bValid = ScGlobal::GetTransliteration().isMatch(aUpVal1, rArg); + break; case ScConditionMode::EndsWith: { sal_Int32 nStart = rArg.getLength(); const sal_Int32 nLen = aUpVal1.getLength(); - if (!nLen || nLen > nStart) + if (nLen > nStart) bValid = false; else { nStart = nStart - nLen; - bValid = (ScGlobal::GetCollator().compareSubstring(rArg, nStart, nLen, - aUpVal1, 0, nLen) == 0); + sal_Int32 nMatch1(0), nMatch2(0); + bValid = ScGlobal::GetTransliteration().equals(rArg, nStart, nLen, nMatch1, + aUpVal1, 0, nLen, nMatch2); } } break; case ScConditionMode::ContainsText: case ScConditionMode::NotContainsText: - bValid = rArg.toAsciiLowerCase().indexOf(aUpVal1.toAsciiLowerCase()) != -1; + { + const OUString aArgStr(ScGlobal::getCharClass().lowercase(rArg)); + const OUString aValStr(ScGlobal::getCharClass().lowercase(aUpVal1)); + bValid = aArgStr.indexOf(aValStr) != -1; + if(eOp == ScConditionMode::NotContainsText) bValid = !bValid; + } break; default: { |