sc/qa/unit/data/functions/text/fods/right.fods | 112 ++++++++++++++++++------- sc/source/core/tool/interpr1.cxx | 26 +++++ 2 files changed, 108 insertions(+), 30 deletions(-)
New commits: commit 09455734727daa3774158795febd910b33b1d784 Author: Winfried Donkers <[email protected]> Date: Thu Nov 16 16:40:25 2017 +0100 tdf#97198 Make Calc function RIGHT work with Unicode non-BMP characters. Change-Id: I775bc50d8e5948a2af9efb77dcea9d7cae7293d5 Reviewed-on: https://gerrit.libreoffice.org/44834 Tested-by: Jenkins <[email protected]> Reviewed-by: Eike Rathke <[email protected]> diff --git a/sc/qa/unit/data/functions/text/fods/right.fods b/sc/qa/unit/data/functions/text/fods/right.fods index 9f4b97f1f8b3..fff9ffc855cc 100644 --- a/sc/qa/unit/data/functions/text/fods/right.fods +++ b/sc/qa/unit/data/functions/text/fods/right.fods @@ -1251,9 +1251,12 @@ <table:table-cell table:style-name="ce17" office:value-type="string" calcext:value-type="string"> <text:p>un</text:p> </table:table-cell> + <table:table-cell table:style-name="ce49" 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="ce29"/> <table:table-cell table:style-name="ce11"/> - <table:table-cell table:number-columns-repeated="4"/> + <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> @@ -1282,55 +1285,110 @@ </table:table-cell> </table:table-row> <table:table-row table:style-name="ro5"> - <table:table-cell table:style-name="ce14"/> - <table:table-cell table:style-name="ce17"/> - <table:table-cell table:style-name="ce29"/> - <table:table-cell table:style-name="ce11"/> - <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce14" table:formula="of:=RIGHT("abðdeðghð¬ðððððð!";11)" office:value-type="string" office:string-value="ðghð¬ðððððð!" calcext:value-type="string"> + <text:p>ðghð¬ðððððð!</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce41" office:value-type="string" calcext:value-type="string"> + <text:p>ðghð¬ðððððð!</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="=RIGHT("abðdeðghð¬ðððððð!";11)" calcext:value-type="string"> + <text:p>=RIGHT("abðdeðghð¬ðððððð!";11)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns 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>c</text:p> </table:table-cell> <table:table-cell table:number-columns-repeated="22"/> </table:table-row> <table:table-row table:style-name="ro5"> - <table:table-cell table:style-name="ce14"/> - <table:table-cell table:style-name="ce17"/> - <table:table-cell table:style-name="ce29"/> - <table:table-cell table:style-name="ce11"/> - <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce14" table:formula="of:=RIGHT("abð";2)" office:value-type="string" office:string-value="bð" calcext:value-type="string"> + <text:p>bð</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce41" office:value-type="string" calcext:value-type="string"> + <text:p>bð</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="=RIGHT("abð";2)" calcext:value-type="string"> + <text:p>=RIGHT("abð";2)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns 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>d</text:p> </table:table-cell> <table:table-cell table:number-columns-repeated="22"/> </table:table-row> <table:table-row table:style-name="ro5"> - <table:table-cell table:style-name="ce14"/> - <table:table-cell table:style-name="ce17"/> - <table:table-cell table:style-name="ce29"/> - <table:table-cell table:style-name="ce11"/> - <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce14" table:formula="of:=RIGHT("""ð§ð§¬""";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="ce41" office:value-type="string" calcext:value-type="string"> + <text:p>ð§¬"</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="=RIGHT("""ð§ð§¬""";2)" calcext:value-type="string"> + <text:p>=RIGHT("""ð§ð§¬""";2)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns 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>E</text:p> </table:table-cell> <table:table-cell table:number-columns-repeated="22"/> </table:table-row> <table:table-row table:style-name="ro5"> - <table:table-cell table:style-name="ce14"/> - <table:table-cell table:style-name="ce17"/> - <table:table-cell table:style-name="ce29"/> - <table:table-cell table:style-name="ce11"/> - <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce14" table:formula="of:=RIGHT("""uÌeÌ""";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="ce41" office:value-type="string" calcext:value-type="string"> + <text:p>Ì"</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="=RIGHT("""uÌeÌ""";2)" calcext:value-type="string"> + <text:p>=RIGHT("""uÌeÌ""";2)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns 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>f</text:p> </table:table-cell> <table:table-cell table:number-columns-repeated="22"/> </table:table-row> <table:table-row table:style-name="ro5"> - <table:table-cell table:style-name="ce14"/> - <table:table-cell table:style-name="ce17"/> - <table:table-cell table:style-name="ce29"/> - <table:table-cell table:style-name="ce11"/> - <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce14" table:formula="of:=RIGHT("ð¬ðððððð!";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="ce41" office:value-type="string" calcext:value-type="string"> + <text:p>ððð!</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="=RIGHT("ð¬ðððððð!";4)" calcext:value-type="string"> + <text:p>=RIGHT("ð¬ðððððð!";4)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns 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>g</text:p> </table:table-cell> @@ -1488,4 +1546,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 d53c00f9fcd7..2f2955b52927 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -8867,9 +8867,29 @@ void ScInterpreter::ScRight() else n = 1; OUString aStr = GetString().getString(); - if( n < aStr.getLength() ) - aStr = aStr.copy( aStr.getLength() - n ); - PushString( aStr ); + sal_Int32 nLen = aStr.getLength(); + sal_Int32 nIdx = 0; + sal_Int32 nCnt = 0; + while ( nIdx < nLen ) + { + aStr.iterateCodePoints( &nIdx ); + ++nCnt; + } + if ( nCnt <= n ) + PushString( aStr ); + else + { + sal_Int32 nCLen = nCnt; + nIdx = 0; + nCnt = 0; + while ( nIdx < nLen && n < ( nCLen - nCnt ) ) + { + aStr.iterateCodePoints( &nIdx ); + ++nCnt; + } + aStr = aStr.copy( nIdx, nLen - nIdx ); + PushString( aStr ); + } } }
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
