sc/qa/unit/data/functions/spreadsheet/fods/unique.fods |  111 +++++++++++++++++
 sc/source/core/tool/interpr1.cxx                       |    6 
 2 files changed, 114 insertions(+), 3 deletions(-)

New commits:
commit 28e3f195794f4ea00d097b1eecea84ea2f604113
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Feb 3 12:11:34 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Feb 11 22:23:10 2025 +0100

    tdf#162601: UNIQUE function is case-insensitive
    
    This patch also includes
    commit 11e62f3a0566464186cef88f6133dbf88fe60a08 (origin/master, origin/HEAD)
    Author: Xisco Fauli <xiscofa...@libreoffice.org>
    Date:   Mon Feb 3 20:56:35 2025 +0100
    
        related: tdf#162601 UNIQUE function is case-insensitive also for non 
ASCII
    
        Kudos to M. Kaganski for flagging it
    
    Change-Id: I12d67cb926c1e6dc8b7863529639dc252385b8e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181035
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins
    (cherry picked from commit 0ef05087b54621caec96e72fc8aaf13f86a90bf9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181063
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de>
    (cherry picked from commit 29c9a61b96c88856784d2c4f9abafcfc0e979bc1)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181064
    (cherry picked from commit e348153cbd05391f0be124c026341b3055ada429)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181114
    Reviewed-by: Jonathan Clark <jonat...@libreoffice.org>
    Tested-by: Michael Weghorn <m.wegh...@posteo.de>
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@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 5fce49310229..ac9674441351 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods
@@ -5044,6 +5044,117 @@
      </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-columns-repeated="8"/>
+     <table:table-cell table:style-name="ce38"/>
+     <table:table-cell/>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>case insensitive</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="24"/>
+    </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({&quot;A&quot;|&quot;a&quot;|&quot;b&quot;|&quot;B&quot;})"
 office:value-type="string" office:string-value="A" calcext:value-type="string">
+      <text:p>A</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>A</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce38" 
table:formula="of:=([.A71]=[.E71])AND([.B71]=[.F71])" 
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([.A71])" 
office:value-type="string" 
office:string-value="{=UNIQUE({&quot;A&quot;;&quot;a&quot;;&quot;b&quot;;&quot;B&quot;})}"
 calcext:value-type="string">
+      
<text:p>{=UNIQUE({&quot;A&quot;;&quot;a&quot;;&quot;b&quot;;&quot;B&quot;})}</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="b" 
calcext:value-type="string">
+      <text:p>b</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>b</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce38" 
table:formula="of:=([.A72]=[.E72])AND([.B72]=[.F72])" 
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([.A72])" 
office:value-type="string" 
office:string-value="{=UNIQUE({&quot;A&quot;;&quot;a&quot;;&quot;b&quot;;&quot;B&quot;})}"
 calcext:value-type="string">
+      
<text:p>{=UNIQUE({&quot;A&quot;;&quot;a&quot;;&quot;b&quot;;&quot;B&quot;})}</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({&quot;A&quot;|&quot;a&quot;|&quot;b&quot;|&quot;B&quot;|&quot;c&quot;};
 ; 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:=([.A73]=[.E73])AND([.B73]=[.F73])" 
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([.A73])" 
office:value-type="string" 
office:string-value="{=UNIQUE({&quot;A&quot;;&quot;a&quot;;&quot;b&quot;;&quot;B&quot;;&quot;c&quot;};
 ; 1)}" calcext:value-type="string">
+      
<text:p>{=UNIQUE({&quot;A&quot;;&quot;a&quot;;&quot;b&quot;;&quot;B&quot;;&quot;c&quot;};
 ; 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:table-cell table:number-matrix-columns-spanned="1" 
table:number-matrix-rows-spanned="2" 
table:formula="of:=COM.MICROSOFT.UNIQUE({&quot;Á&quot;|&quot;á&quot;|&quot;é&quot;|&quot;É&quot;})"
 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({&quot;Á&quot;;&quot;á&quot;;&quot;é&quot;;&quot;É&quot;})}"
 calcext:value-type="string">
+      
<text:p>{=UNIQUE({&quot;Á&quot;;&quot;á&quot;;&quot;é&quot;;&quot;É&quot;})}</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({&quot;Á&quot;;&quot;á&quot;;&quot;é&quot;;&quot;É&quot;})}"
 calcext:value-type="string">
+      
<text:p>{=UNIQUE({&quot;Á&quot;;&quot;á&quot;;&quot;é&quot;;&quot;É&quot;})}</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({&quot;Á&quot;|&quot;á&quot;|&quot;é&quot;|&quot;É&quot;|&quot;c&quot;};
 ; 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({&quot;Á&quot;;&quot;á&quot;;&quot;é&quot;;&quot;É&quot;;&quot;c&quot;};
 ; 1)}" calcext:value-type="string">
+      
<text:p>{=UNIQUE({&quot;Á&quot;;&quot;á&quot;;&quot;é&quot;;&quot;É&quot;;&quot;c&quot;};
 ; 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 e8ccc4570acb..01b06bd45218 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8854,7 +8854,7 @@ void ScInterpreter::ScUnique()
             aStr += aCellStr + u"\x0001";
         }
 
-        if (aStrSet.insert(aStr).second) // unique if inserted
+        if (aStrSet.insert(ScGlobal::getCharClass().lowercase(aStr)).second) 
// unique if inserted
         {
             aResPos.emplace_back(std::make_pair(i, aStr));
         }
@@ -8863,9 +8863,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.equals(aStr);
+                        return 
ScGlobal::getCharClass().lowercase(aRes.second).equals(str);
                     }
                 );
                 if (it != aResPos.end())

Reply via email to