sc/qa/unit/ucalc_condformat.cxx | 3 ++- sc/source/core/data/conditio.cxx | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-)
New commits: commit 080b2e56300865782ae65978ed9e510d667672a6 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Fri Sep 23 07:41:23 2022 -0400 Commit: Eike Rathke <er...@redhat.com> CommitDate: Sat Oct 1 12:18:54 2022 +0200 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 <jl...@mail.com> (cherry picked from commit 3bfed17b047422a8c4e98ab80001f3158afb227e) Change-Id: I44a07c482d2d67a76a939ba2d593a003398d52c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140633 Tested-by: Justin Luth <jl...@mail.com> Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Eike Rathke <er...@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 c783b8808c46..5f71f27c1726 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 ab5bfce9814a..dae08455b0e9 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: {