sc/qa/unit/data/functions/spreadsheet/fods/unique.fods |   60 +++++++++++++++++
 sc/source/core/tool/interpr1.cxx                       |    4 -
 2 files changed, 62 insertions(+), 2 deletions(-)

New commits:
commit 0ef05087b54621caec96e72fc8aaf13f86a90bf9
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Feb 3 12:11:34 2025 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Feb 3 16:41:12 2025 +0100

    tdf#162601: UNIQUE function is case-insensitive
    
    Change-Id: I12d67cb926c1e6dc8b7863529639dc252385b8e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181035
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods
index 5fce49310229..662338de546f 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/unique.fods
@@ -5044,6 +5044,66 @@
      </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: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 9498065f6bcf..fcc3e9e1ba58 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).second) // unique if inserted
+        if (aStrSet.insert(aStr.toAsciiLowerCase()).second) // unique if 
inserted
         {
             aResPos.emplace_back(std::make_pair(i, aStr));
         }
@@ -9404,7 +9404,7 @@ void ScInterpreter::ScUnique()
                 auto it = std::find_if(aResPos.begin(), aResPos.end(),
                     [&aStr](const std::pair<SCSIZE, OUString>& aRes)
                     {
-                        return aRes.second.equals(aStr);
+                        return 
aRes.second.toAsciiLowerCase().equals(aStr.toAsciiLowerCase());
                     }
                 );
                 if (it != aResPos.end())

Reply via email to