[Libreoffice-commits] core.git: sc/qa sc/source
Winfried Donkers
winfrieddonkers at libreoffice.org
Fri Nov 24 20:11:25 UTC 2017
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 <winfrieddonkers at libreoffice.org>
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 <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
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 );
+ }
}
}
More information about the Libreoffice-commits
mailing list