From a8d01c66b823c3556081f8678059911f1264547f Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 10 Feb 2023 13:25:53 +0300 Subject: [PATCH] tdf#153514: try to find exact match, even when searching case-insensitively Change-Id: Ib3bec382ef80a9078ffde8612c395cb0154fd476 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146747 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit 2a984c77ccb1aa77d9bbd02218d4dc76aaff4a9e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146769 Tested-by: Mike Kaganski Reviewed-by: Dennis Francis --- sc/source/core/data/stlpool.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx index a03cc61180ec..18f856aac2ae 100644 --- a/sc/source/core/data/stlpool.cxx +++ b/sc/source/core/data/stlpool.cxx @@ -409,14 +409,20 @@ ScStyleSheet* ScStyleSheetPool::FindCaseIns( const OUString& rName, SfxStyleFami CaseInsensitiveNamePredicate aPredicate(rName, eFam); std::vector aFoundPositions = GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate); + ScStyleSheet* first = nullptr; // first case insensitive match found for (const auto& rPos : aFoundPositions) { SfxStyleSheetBase *pFound = GetStyleSheetByPositionInIndex(rPos); // we do not know what kind of sheets we have. if (pFound->isScStyleSheet()) - return static_cast(pFound); + { + if (pFound->GetName() == rName) // exact case sensitive match + return static_cast(pFound); + if (!first) + first = static_cast(pFound); + } } - return nullptr; + return first; } void ScStyleSheetPool::setAllParaStandard() -- 2.11.4.GIT