tdf#123990 sc condformat: case insensitive begins/ends/contains
squashed commit
This is how Excel handles these.
At first I was afraid that this would upset LibreOffice users,
but then I realized that equals already is case insensitive,
so this change ought to be more consistent, and thus there should
be fewer outcrys.
Change-Id: Ia3de78d5888672ba8b774866d41ecd65293397c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140484
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
(cherry picked from commit 3bfed17b047422a8c4e98ab80001f3158afb227e)
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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140685
Tested-by: Jenkins
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index c783b88..5f71f27 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -817,7 +817,8 @@ void TestCondformat::testCondFormatEndsWithStr()
{
m_pDoc->InsertTab(0, "Test");
ScConditionEntry aEntry(ScConditionMode::EndsWith, "\"TestString\"", "", *m_pDoc, ScAddress(),
// case insnsitive matching
ScConditionEntry aEntry(ScConditionMode::EndsWith, "\"teststring\"", "", *m_pDoc, ScAddress(),
"", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
svl::SharedStringPool& rStringPool = m_pDoc->GetSharedStringPool();
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index ab5bfce..dae0845 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1171,16 +1171,33 @@ bool ScConditionEntry::IsValidStr( const OUString& rArg, const ScAddress& rPos )
bValid = !bValid;
break;
case ScConditionMode::BeginsWith:
bValid = rArg.startsWith(aUpVal1);
bValid = ScGlobal::GetTransliteration().isMatch(aUpVal1, rArg);
break;
case ScConditionMode::EndsWith:
bValid = rArg.endsWith(aUpVal1);
{
sal_Int32 nStart = rArg.getLength();
const sal_Int32 nLen = aUpVal1.getLength();
if (nLen > nStart)
bValid = false;
else
{
nStart = nStart - nLen;
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.indexOf(aUpVal1) != -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:
{