[Libreoffice-commits] core.git: sc/qa sc/source

Winfried Donkers winfrieddonkers at libreoffice.org
Fri Nov 24 20:14:53 UTC 2017


 sc/qa/unit/data/functions/text/fods/search.fods |  160 +++++++++++++++++++++---
 sc/source/core/tool/interpr1.cxx                |   11 +
 2 files changed, 156 insertions(+), 15 deletions(-)

New commits:
commit 78b7e5f76e72647e0cab662ad2c9342d4538704f
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Thu Nov 23 18:21:19 2017 +0100

    tdf#97198 Make Calc function SEARCH work with UniCode non-BMP characters.
    
    Change-Id: I99b44dc88fe9c8d4d5d7a319bd6bc84dd2bff4f3
    Reviewed-on: https://gerrit.libreoffice.org/45170
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/qa/unit/data/functions/text/fods/search.fods b/sc/qa/unit/data/functions/text/fods/search.fods
index 12723d0e1154..c09827350d89 100644
--- a/sc/qa/unit/data/functions/text/fods/search.fods
+++ b/sc/qa/unit/data/functions/text/fods/search.fods
@@ -1416,21 +1416,153 @@
      <table:table-cell table:style-name="Default"/>
      <table:table-cell table:number-columns-repeated="8"/>
     </table:table-row>
-    <table:table-row table:style-name="ro5">
-     <table:table-cell table:style-name="ce9"/>
-     <table:table-cell table:style-name="ce17"/>
-     <table:table-cell table:style-name="ce39"/>
-     <table:table-cell table:style-name="ce11"/>
-     <table:table-cell table:number-columns-repeated="7"/>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell table:formula="of:=SEARCH([.I21];[.J21])" office:value-type="float" office:value="2" calcext:value-type="float">
+      <text:p>2</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce44" office:value-type="float" office:value="2" calcext:value-type="float">
+      <text:p>2</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce50" table:formula="of:=[.A21]=[.B21]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A21])" office:value-type="string" office:string-value="=SEARCH(I21;J21)" calcext:value-type="string">
+      <text:p>=SEARCH(I21;J21)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>Excel 2016 has same result</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce45" office:value-type="string" calcext:value-type="string">
+      <text:p>BπŸ˜‚</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce45" office:value-type="string" calcext:value-type="string">
+      <text:p>abπŸ˜‚de𝔖ghπ•¬π–ˆπ–π–™π–šπ–“π–Œ!</text:p>
+     </table:table-cell>
+     <table:table-cell/>
     </table:table-row>
-    <table:table-row table:style-name="ro5" table:number-rows-repeated="4">
-     <table:table-cell table:style-name="ce14"/>
-     <table:table-cell table:style-name="ce17"/>
-     <table:table-cell table:style-name="ce36"/>
-     <table:table-cell table:style-name="ce11"/>
-     <table:table-cell table:number-columns-repeated="7"/>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell table:formula="of:=SEARCH([.I22];[.J21])" office:value-type="float" office:value="3" calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce45" office:value-type="float" office:value="3" calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce51" table:formula="of:=[.A22]=[.B22]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A22])" office:value-type="string" office:string-value="=SEARCH(I22;J21)" calcext:value-type="string">
+      <text:p>=SEARCH(I22;J21)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>Excel 2016 has same result</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce45" office:value-type="string" calcext:value-type="string">
+      <text:p>πŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce45" office:value-type="string" calcext:value-type="string">
+      <text:p>abπŸ˜‚</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro7">
+     <table:table-cell table:formula="of:=SEARCH([.I23];[.J23])" office:value-type="float" office:value="3" calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce45" office:value-type="float" office:value="3" calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce52" table:formula="of:=[.A23]=[.B23]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A23])" office:value-type="string" office:string-value="=SEARCH(I23;J23)" calcext:value-type="string">
+      <text:p>=SEARCH(I23;J23)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>Excel 2016 returns 4</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce45" office:value-type="string" calcext:value-type="string">
+      <text:p>𧀬</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce60" office:value-type="string" calcext:value-type="string"><text:p>"<text:span text:style-name="T3">π§Œ’π§€¬</text:span>"</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell table:formula="of:=SEARCH([.I24];[.J21])" office:value-type="float" office:value="8" calcext:value-type="float">
+      <text:p>8</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce45" office:value-type="float" office:value="8" calcext:value-type="float">
+      <text:p>8</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce53" table:formula="of:=[.A24]=[.B24]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A24])" office:value-type="string" office:string-value="=SEARCH(I24;J21)" calcext:value-type="string">
+      <text:p>=SEARCH(I24;J21)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>Excel 2016 returns 10</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce45" office:value-type="string" calcext:value-type="string">
+      <text:p>h</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="2"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro3">
+     <table:table-cell table:formula="of:=SEARCH([.I25];[.J25])" office:value-type="float" office:value="4" calcext:value-type="float">
+      <text:p>4</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce45" office:value-type="float" office:value="4" calcext:value-type="float">
+      <text:p>4</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce54" table:formula="of:=[.A25]=[.B25]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A25])" office:value-type="string" office:string-value="=SEARCH(I25;J25)" calcext:value-type="string">
+      <text:p>=SEARCH(I25;J25)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>Excel 2016 has same result</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce45" office:value-type="string" calcext:value-type="string">
+      <text:p>e</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce61" office:value-type="string" calcext:value-type="string">
+      <text:p>"üë"</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell table:formula="of:=SEARCH([.I26];[.J26])" office:value-type="float" office:value="3" calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce45" office:value-type="float" office:value="3" calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce55" table:formula="of:=[.A26]=[.B26]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A26])" office:value-type="string" office:string-value="=SEARCH(I26;J26)" calcext:value-type="string">
+      <text:p>=SEARCH(I26;J26)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>Excel 2016 returns 5</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce45" office:value-type="string" calcext:value-type="string">
+      <text:p>𝖍𝖙</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce62" office:value-type="string" calcext:value-type="string">
+      <text:p>π•¬π–ˆπ–π–™π–šπ–“π–Œ!</text:p>
+     </table:table-cell>
+     <table:table-cell/>
     </table:table-row>
-    <table:table-row table:style-name="ro5" table:number-rows-repeated="12">
+    <table:table-row table:style-name="ro5" table:number-rows-repeated="11">
      <table:table-cell table:style-name="ce14"/>
      <table:table-cell table:style-name="ce17"/>
      <table:table-cell table:style-name="ce36"/>
@@ -1483,4 +1615,4 @@
    </table:named-expressions>
   </office:spreadsheet>
  </office:body>
-</office:document>
\ No newline at end of file
+</office:document>
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 96d8f764a418..88b1fd43759d 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8942,7 +8942,16 @@ void ScInterpreter::ScSearch()
             if (!bBool)
                 PushNoValue();
             else
-                PushDouble((double)nPos + 1);
+            {
+                sal_Int32 nIdx = 0;
+                sal_Int32 nCnt = 0;
+                while ( nIdx <= nPos )
+                {
+                    sStr.iterateCodePoints( &nIdx );
+                    ++nCnt;
+                }
+                PushDouble( ( double )nCnt );
+            }
         }
     }
 }


More information about the Libreoffice-commits mailing list