sc/qa/unit/data/functions/spreadsheet/fods/unique.fods | 51 +++++++++++++++++ sc/source/core/tool/interpr1.cxx | 6 +- 2 files changed, 54 insertions(+), 3 deletions(-)
New commits: commit 11e62f3a0566464186cef88f6133dbf88fe60a08 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Feb 3 20:56:35 2025 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Feb 4 01:53:56 2025 +0100 related: tdf#162601 UNIQUE function is case-insensitive also for non ASCII Kudos to M. Kaganski for flagging it Change-Id: I061a66f2e58bc48025575f20f97479059d0f4453 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181077 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods b/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods index 662338de546f..ac9674441351 100644 --- a/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods +++ b/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods @@ -5104,6 +5104,57 @@ </table:table-cell> <table:table-cell table:number-columns-repeated="25"/> </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:number-matrix-columns-spanned="1" table:number-matrix-rows-spanned="2" table:formula="of:=COM.MICROSOFT.UNIQUE({"Á"|"á"|"é"|"É"})" office:value-type="string" office:string-value="Á" calcext:value-type="string"> + <text:p>Á</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Á</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell table:style-name="ce38" table:formula="of:=([.A74]=[.E74])AND([.B74]=[.F74])" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:formula="of:=FORMULA([.A74])" office:value-type="string" office:string-value="{=UNIQUE({"Á";"á";"é";"É"})}" calcext:value-type="string"> + <text:p>{=UNIQUE({"Á";"á";"é";"É"})}</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="25"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell office:value-type="string" office:string-value="é" calcext:value-type="string"> + <text:p>é</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>é</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell table:style-name="ce38" table:formula="of:=([.A75]=[.E75])AND([.B75]=[.F75])" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:formula="of:=FORMULA([.A75])" office:value-type="string" office:string-value="{=UNIQUE({"Á";"á";"é";"É"})}" calcext:value-type="string"> + <text:p>{=UNIQUE({"Á";"á";"é";"É"})}</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="25"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:number-matrix-columns-spanned="1" table:number-matrix-rows-spanned="1" table:formula="of:=COM.MICROSOFT.UNIQUE({"Á"|"á"|"é"|"É"|"c"}; ; 1)" office:value-type="string" office:string-value="c" calcext:value-type="string"> + <text:p>c</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>c</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell table:style-name="ce38" table:formula="of:=([.A76]=[.E76])AND([.B76]=[.F76])" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:formula="of:=FORMULA([.A76])" office:value-type="string" office:string-value="{=UNIQUE({"Á";"á";"é";"É";"c"}; ; 1)}" calcext:value-type="string"> + <text:p>{=UNIQUE({"Á";"á";"é";"É";"c"}; ; 1)}</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="25"/> + </table:table-row> <table:table-row table:style-name="ro2" table:number-rows-repeated="140"> <table:table-cell table:number-columns-repeated="8"/> <table:table-cell table:style-name="ce37"/> diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index fcc3e9e1ba58..487e495b6d48 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -9393,7 +9393,7 @@ void ScInterpreter::ScUnique() aStr += aCellStr + u"\x0001"; } - if (aStrSet.insert(aStr.toAsciiLowerCase()).second) // unique if inserted + if (aStrSet.insert(ScGlobal::getCharClass().lowercase(aStr)).second) // unique if inserted { aResPos.emplace_back(std::make_pair(i, aStr)); } @@ -9402,9 +9402,9 @@ void ScInterpreter::ScUnique() if (bExactly_once) { auto it = std::find_if(aResPos.begin(), aResPos.end(), - [&aStr](const std::pair<SCSIZE, OUString>& aRes) + [str = ScGlobal::getCharClass().lowercase(aStr)](const std::pair<SCSIZE, OUString>& aRes) { - return aRes.second.toAsciiLowerCase().equals(aStr.toAsciiLowerCase()); + return ScGlobal::getCharClass().lowercase(aRes.second).equals(str); } ); if (it != aResPos.end())