[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sc/qa sc/source

Winfried Donkers winfrieddonkers at libreoffice.org
Wed Nov 29 23:38:09 UTC 2017


 sc/qa/unit/data/functions/text/fods/replace.fods |  230 +++++++++++++++++++++--
 sc/source/core/tool/interpr1.cxx                 |   17 +
 2 files changed, 227 insertions(+), 20 deletions(-)

New commits:
commit 44487fee8646c0ded5c2b2ffaaa70e75a7af7e04
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Tue Nov 28 15:55:56 2017 +0100

    tdf#97198 Make Calc function REPLACE work with UniCode non-BMP-characters.
    
    Change-Id: Ie9bd27ba2c28bdad0af9d91cb270ef37d5384791
    Reviewed-on: https://gerrit.libreoffice.org/45421
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit aaba725b466950f47c4e93d790986d209e80ead3)
    Reviewed-on: https://gerrit.libreoffice.org/45495

diff --git a/sc/qa/unit/data/functions/text/fods/replace.fods b/sc/qa/unit/data/functions/text/fods/replace.fods
index 140b735e7090..1ab069f6460a 100644
--- a/sc/qa/unit/data/functions/text/fods/replace.fods
+++ b/sc/qa/unit/data/functions/text/fods/replace.fods
@@ -1141,36 +1141,230 @@
      <table:table-cell table:number-columns-repeated="7"/>
     </table:table-row>
     <table:table-row table:style-name="ro5">
-     <table:table-cell table:style-name="ce18"/>
-     <table:table-cell table:style-name="ce17"/>
-     <table:table-cell table:style-name="ce27"/>
-     <table:table-cell table:style-name="ce11"/>
+     <table:table-cell table:formula="of:=REPLACE("";5;1;"Q")" office:value-type="string" office:string-value="Q" calcext:value-type="string">
+      <text:p>Q</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string">
+      <text:p>Q</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce43" table:formula="of:=[.A10]=[.B10]" 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="ce57" table:formula="of:=FORMULA([.A10])" office:value-type="string" office:string-value="=REPLACE("";5;1;"Q")" calcext:value-type="string">
+      <text:p>=REPLACE("";5;1;"Q")</text:p>
+     </table:table-cell>
      <table:table-cell table:number-columns-repeated="4"/>
-     <table:table-cell table:style-name="ce17"/>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>BπŸ˜‚</text:p>
+     </table:table-cell>
      <table:table-cell table:number-columns-repeated="2"/>
     </table:table-row>
-    <table:table-row table:style-name="ro5" table:number-rows-repeated="6">
-     <table:table-cell table:style-name="ce14"/>
-     <table:table-cell table:style-name="ce17"/>
-     <table:table-cell table:style-name="ce27"/>
-     <table:table-cell table:style-name="ce11"/>
+    <table:table-row table:style-name="ro6">
+     <table:table-cell table:style-name="ce34" table:formula="of:=REPLACE([.I11];4;3;[.I10])" office:value-type="string" office:string-value="abπŸ˜‚BπŸ˜‚ghπ•¬π–ˆπ–π–™π–šπ–“π–Œ!" calcext:value-type="string">
+      <text:p>abπŸ˜‚BπŸ˜‚ghπ•¬π–ˆπ–π–™π–šπ–“π–Œ!</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>abπŸ˜‚BπŸ˜‚ghπ•¬π–ˆπ–π–™π–šπ–“π–Œ!</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce44" table:formula="of:=[.A11]=[.B11]" 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([.A11])" office:value-type="string" office:string-value="=REPLACE(I11;4;3;I10)" calcext:value-type="string">
+      <text:p>=REPLACE(I11;4;3;I10)</text:p>
+     </table:table-cell>
      <table:table-cell table:number-columns-repeated="4"/>
-     <table:table-cell table:style-name="ce17"/>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>abπŸ˜‚de𝔖ghπ•¬π–ˆπ–π–™π–šπ–“π–Œ!</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="2"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro6">
+     <table:table-cell table:style-name="ce34" table:formula="of:=REPLACE([.I12];3;1;"xXx")" office:value-type="string" office:string-value="BπŸ˜‚xXxπŸ˜‚d" calcext:value-type="string">
+      <text:p>BπŸ˜‚xXxπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>BπŸ˜‚xXxπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce45" table:formula="of:=[.A12]=[.B12]" 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([.A12])" office:value-type="string" office:string-value="=REPLACE(I12;3;1;"xXx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;3;1;"xXx")</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string">
+      <text:p>BπŸ˜‚cπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="2"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell table:style-name="ce37" table:formula="of:=REPLACE([.I12];2;1;"xXx")" office:value-type="string" office:string-value="BxXxcπŸ˜‚d" calcext:value-type="string">
+      <text:p>BxXxcπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>BxXxcπŸ˜‚d</text:p>
+      </table:table-cell>
+     <table:table-cell table:style-name="ce46" table:formula="of:=[.A13]=[.B13]" 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([.A13])" office:value-type="string" office:string-value="=REPLACE(I12;2;1;"xXx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;2;1;"xXx")</text:p>
+      </table:table-cell>
+      <table:table-cell table:number-columns-repeated="7"/>
+     </table:table-row>
+     <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce37" table:formula="of:=REPLACE([.I12];3;1;"𝖍𝖙")" office:value-type="string" office:string-value="BπŸ˜‚π–π–™πŸ˜‚d" calcext:value-type="string">
+      <text:p>BπŸ˜‚π–π–™πŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>BπŸ˜‚π–π–™πŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce47" table:formula="of:=[.A14]=[.B14]" 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([.A14])" office:value-type="string" office:string-value="=REPLACE(I12;3;1;"𝖍𝖙")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;3;1;"𝖍𝖙")</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+      <table:table-cell table:style-name="ce17"/>
      <table:table-cell table:number-columns-repeated="2"/>
     </table:table-row>
     <table:table-row table:style-name="ro5">
-     <table:table-cell/>
+     <table:table-cell table:style-name="ce37" table:formula="of:=REPLACE([.I12];2;1;"x𝖍𝖙x")" office:value-type="string" office:string-value="Bx𝖍𝖙xcπŸ˜‚d" calcext:value-type="string">
+      <text:p>Bx𝖍𝖙xcπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>Bx𝖍𝖙xcπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce48" table:formula="of:=[.A15]=[.B15]" 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([.A15])" office:value-type="string" office:string-value="=REPLACE(I12;2;1;"x𝖍𝖙x")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;2;1;"x𝖍𝖙x")</text:p>
+     </table:table-cell>
+      <table:table-cell table:number-columns-repeated="4"/>
+      <table:table-cell table:style-name="ce17"/>
+      <table:table-cell table:number-columns-repeated="2"/>
+     </table:table-row>
+    <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce37" table:formula="of:=REPLACE([.I12];2;0;"xXx")" office:value-type="string" office:string-value="BxXxπŸ˜‚cπŸ˜‚d" calcext:value-type="string">
+      <text:p>BxXxπŸ˜‚cπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>BxXxπŸ˜‚cπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce49" table:formula="of:=[.A16]=[.B16]" 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([.A16])" office:value-type="string" office:string-value="=REPLACE(I12;2;0;"xXx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;2;0;"xXx")</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+      <table:table-cell table:style-name="ce17"/>
+     <table:table-cell table:number-columns-repeated="2"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce37" table:formula="of:=REPLACE([.I12];3;0;"xXx")" office:value-type="string" office:string-value="BπŸ˜‚xXxcπŸ˜‚d" calcext:value-type="string">
+      <text:p>BπŸ˜‚xXxcπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce37" office:value-type="string" calcext:value-type="string">
+      <text:p>BπŸ˜‚xXxcπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce50" table:formula="of:=[.A17]=[.B17]" 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([.A17])" office:value-type="string" office:string-value="=REPLACE(I12;3;0;"xXx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;3;0;"xXx")</text:p>
+     </table:table-cell>
+      <table:table-cell table:number-columns-repeated="4"/>
+      <table:table-cell table:style-name="ce17"/>
+      <table:table-cell table:number-columns-repeated="2"/>
+     </table:table-row>
+     <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce14" table:formula="of:=REPLACE([.I12];1;0;"xYx")" office:value-type="string" office:string-value="xYxBπŸ˜‚cπŸ˜‚d" calcext:value-type="string">
+      <text:p>xYxBπŸ˜‚cπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string">
+      <text:p>xYxBπŸ˜‚cπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce51" table:formula="of:=[.A18]=[.B18]" 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([.A18])" office:value-type="string" office:string-value="=REPLACE(I12;1;0;"xYx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;1;0;"xYx")</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="7"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce14" table:formula="of:=REPLACE([.I12];1;1;"xYx")" office:value-type="string" office:string-value="xYxπŸ˜‚cπŸ˜‚d" calcext:value-type="string">
+      <text:p>xYxπŸ˜‚cπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string">
+      <text:p>xYxπŸ˜‚cπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce52" table:formula="of:=[.A19]=[.B19]" 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([.A19])" office:value-type="string" office:string-value="=REPLACE(I12;1;1;"xYx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;1;1;"xYx")</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+      <table:table-cell table:style-name="ce17"/>
+     <table:table-cell table:number-columns-repeated="2"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce14" table:formula="of:=REPLACE([.I12];1;2;"xYx")" office:value-type="string" office:string-value="xYxcπŸ˜‚d" calcext:value-type="string">
+      <text:p>xYxcπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string">
+      <text:p>xYxcπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce53" table:formula="of:=[.A20]=[.B20]" 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([.A20])" office:value-type="string" office:string-value="=REPLACE(I12;1;2;"xYx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;1;2;"xYx")</text:p>
+     </table:table-cell>
+      <table:table-cell table:number-columns-repeated="4"/>
+      <table:table-cell table:style-name="ce17"/>
+      <table:table-cell table:number-columns-repeated="2"/>
+     </table:table-row>
+    <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce14" table:formula="of:=REPLACE([.I12];1;3;"xYx")" office:value-type="string" office:string-value="xYxπŸ˜‚d" calcext:value-type="string">
+      <text:p>xYxπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string">
+      <text:p>xYxπŸ˜‚d</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce54" 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="=REPLACE(I12;1;3;"xYx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;1;3;"xYx")</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
      <table:table-cell table:style-name="ce17"/>
-     <table:table-cell table:style-name="ce27"/>
-     <table:table-cell table:style-name="ce11"/>
+     <table:table-cell table:number-columns-repeated="2"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce14" table:formula="of:=REPLACE([.I12];1;4;"xYx")" office:value-type="string" office:string-value="xYxd" calcext:value-type="string">
+      <text:p>xYxd</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string">
+      <text:p>xYxd</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce55" 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="=REPLACE(I12;1;4;"xYx")" calcext:value-type="string">
+      <text:p>=REPLACE(I12;1;4;"xYx")</text:p>
+     </table:table-cell>
      <table:table-cell table:number-columns-repeated="4"/>
      <table:table-cell table:style-name="ce17"/>
      <table:table-cell table:number-columns-repeated="2"/>
     </table:table-row>
-    <table:table-row table:style-name="ro5" table:number-rows-repeated="20">
-     <table:table-cell table:style-name="ce14"/>
+    <table:table-row table:style-name="ro5" table:number-rows-repeated="15">
      <table:table-cell table:style-name="ce17"/>
-     <table:table-cell table:style-name="ce27"/>
      <table:table-cell table:style-name="ce11"/>
      <table:table-cell table:number-columns-repeated="4"/>
      <table:table-cell table:style-name="ce17"/>
@@ -1210,4 +1404,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 2895c93f2a2e..164c1185e1b8 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8451,9 +8451,22 @@ void ScInterpreter::ScReplace()
                 nPos = nLen + 1;
             if (nCount > nLen - nPos + 1)
                 nCount = nLen - nPos + 1;
-            aOldStr = aOldStr.replaceAt( nPos-1, nCount, "" );
+            sal_Int32 nIdx = 0;
+            sal_Int32 nCnt = 0;
+            while ( nIdx < nLen && nPos > nCnt + 1 )
+            {
+                aOldStr.iterateCodePoints( &nIdx );
+                ++nCnt;
+            }
+            sal_Int32 nStart = nIdx;
+            while ( nIdx < nLen && nPos + nCount - 1 > nCnt )
+            {
+                aOldStr.iterateCodePoints( &nIdx );
+                ++nCnt;
+            }
+            aOldStr = aOldStr.replaceAt( nStart, nIdx - nStart, "" );
             if ( CheckStringResultLen( aOldStr, aNewStr ) )
-                aOldStr = aOldStr.replaceAt( nPos-1, 0, aNewStr );
+                aOldStr = aOldStr.replaceAt( nStart, 0, aNewStr );
             PushString( aOldStr );
         }
     }


More information about the Libreoffice-commits mailing list