sc/qa/unit/data/functions/text/fods/left.fods | 88 +++++++++++++++++++++++++- sc/source/core/tool/interpr1.cxx | 7 +- 2 files changed, 92 insertions(+), 3 deletions(-)
New commits: commit 4e3530b4f870e0470c23ae89cdb8b9a09af54d59 Author: Winfried Donkers <winfrieddonk...@libreoffice.org> Date: Mon Nov 13 15:43:00 2017 +0100 tdf#97198 Make Calc function LEFT work with Unicode non-BMP characters Change-Id: I66d24dd962f824079fd0aea2827bd5b975ffe698 Reviewed-on: https://gerrit.libreoffice.org/44684 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/sc/qa/unit/data/functions/text/fods/left.fods b/sc/qa/unit/data/functions/text/fods/left.fods index 535eff455432..45d659aab04e 100644 --- a/sc/qa/unit/data/functions/text/fods/left.fods +++ b/sc/qa/unit/data/functions/text/fods/left.fods @@ -1152,6 +1152,92 @@ <table:table-cell table:style-name="ce17"/> <table:table-cell table:number-columns-repeated="4"/> </table:table-row> + <table:table-row table:style-name="ro5"> + <table:table-cell table:style-name="ce14" table:formula="of:=LEFT([.I11];4)" office:value-type="string" office:string-value="abðd" calcext:value-type="string"> + <text:p>abðd</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string"> + <text:p>abðd</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" table:formula="of:=[.A11]=[.B11]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A11])" office:value-type="string" office:string-value="=LEFT(I11;4)" calcext:value-type="string"> + <text:p>=LEFT(I11;4)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns the same result</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>ab<text:span text:style-name="T1">ðdeðghð¬ðððððð!</text:span></text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + </table:table-row> + <table:table-row table:style-name="ro6"> + <table:table-cell table:style-name="ce14" table:formula="of:=LEFT([.I12];2)" office:value-type="string" office:string-value=""ð§" calcext:value-type="string"> + <text:p>"ð§</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string"> + <text:p>"ð§</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce39" table:formula="of:=[.A12]=[.B12]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A12])" office:value-type="string" office:string-value="=LEFT(I12;2)" calcext:value-type="string"> + <text:p>=LEFT(I12;2)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns the same result</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell table:style-name="ce44" office:value-type="string" calcext:value-type="string"><text:p><text:span text:style-name="T2">"</text:span><text:span text:style-name="T3">ð§ð§¬</text:span><text:span text:style-name="T4">"</text:span></text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + </table:table-row> + <table:table-row table:style-name="ro3"> + <table:table-cell table:style-name="ce14" table:formula="of:=LEFT([.I13];2)" office:value-type="string" office:string-value=""u" calcext:value-type="string"> + <text:p>"u</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string"> + <text:p>"u</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce40" table:formula="of:=[.A13]=[.B13]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A13])" office:value-type="string" office:string-value="=LEFT(I13;2)" calcext:value-type="string"> + <text:p>=LEFT(I13;2)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns the 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>"uÌeÌ"</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + </table:table-row> + <table:table-row table:style-name="ro5"> + <table:table-cell table:style-name="ce14" table:formula="of:=LEFT([.I14];4)" office:value-type="string" office:string-value="ð¬ððð" calcext:value-type="string"> + <text:p>ð¬ððð</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string"> + <text:p>ð¬ððð</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce41" table:formula="of:=[.A14]=[.B14]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A14])" office:value-type="string" office:string-value="=LEFT(I14;4)" calcext:value-type="string"> + <text:p>=LEFT(I14;4)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns the same result</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell table:style-name="ce46" office:value-type="string" calcext:value-type="string"> + <text:p>ð¬ðððððð!</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + </table:table-row> <table:table-row table:style-name="ro5" table:number-rows-repeated="27"> <table:table-cell table:style-name="ce14"/> <table:table-cell table:style-name="ce17"/> @@ -1195,4 +1281,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 88b1fd43759d..2895c93f2a2e 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -8579,8 +8579,11 @@ void ScInterpreter::ScLeft() else n = 1; OUString aStr = GetString().getString(); - n = std::min(n, aStr.getLength()); - aStr = aStr.copy( 0, n ); + sal_Int32 nIdx = 0; + sal_Int32 nCnt = 0; + while ( nIdx < aStr.getLength() && n > nCnt++ ) + aStr.iterateCodePoints( &nIdx ); + aStr = aStr.copy( 0, nIdx ); PushString( aStr ); } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits