sc/qa/unit/data/functions/text/fods/len.fods | 100 +++++++++++++++++++++++++-- sc/source/core/tool/interpr1.cxx | 10 ++ 2 files changed, 102 insertions(+), 8 deletions(-)
New commits: commit 47155ce8fb4302d377b374d39b501d0a0f7577c5 Author: Winfried Donkers <winfrieddonk...@libreoffice.org> Date: Mon Nov 13 15:18:52 2017 +0100 tdf#97198 Make Calc function LEN work with Unicode non-BMP characters. Change-Id: Ibfdaaf1ed313257fc5f9036a7dd1ef51033fa8cd Reviewed-on: https://gerrit.libreoffice.org/44681 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/sc/qa/unit/data/functions/text/fods/len.fods b/sc/qa/unit/data/functions/text/fods/len.fods index 2d643cef2fcd..adc36d87f379 100644 --- a/sc/qa/unit/data/functions/text/fods/len.fods +++ b/sc/qa/unit/data/functions/text/fods/len.fods @@ -1189,13 +1189,99 @@ <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:number-rows-repeated="28"> - <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="ro5"> + <table:table-cell table:style-name="ce14" table:formula="of:=LEN([.I10])" office:value-type="float" office:value="16" calcext:value-type="float"> + <text:p>16</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="16" calcext:value-type="float"> + <text:p>16</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce40" 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="ce11" table:formula="of:=FORMULA([.A10])" office:value-type="string" office:string-value="=LEN(I10)" calcext:value-type="string"> + <text:p>=LEN(I10)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns 25</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-cell table:style-name="ce17"/> + </table:table-row> + <table:table-row table:style-name="ro5"> + <table:table-cell table:style-name="ce14" table:formula="of:=LEN([.I11])" office:value-type="float" office:value="3" calcext:value-type="float"> + <text:p>3</text:p> + </table:table-cell> + <table:table-cell 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="ce41" 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="=LEN(I11)" calcext:value-type="string"> + <text:p>=LEN(I11)</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 office:value-type="string" calcext:value-type="string"> + <text:p>abð</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:=LEN([.I12])" office:value-type="float" office:value="4" calcext:value-type="float"> + <text:p>4</text:p> + </table:table-cell> + <table:table-cell 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="ce42" 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="=LEN(I12)" calcext:value-type="string"> + <text:p>=LEN(I12)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns 6</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:=LEN([.I13])" office:value-type="float" office:value="6" calcext:value-type="float"> + <text:p>6</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="6" calcext:value-type="float"> + <text:p>6</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce45" 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="=LEN(I13)" calcext:value-type="string"> + <text:p>=LEN(I13)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>Excel 2016 returns 6</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + <table:table-cell table:style-name="ce48" 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:number-rows-repeated="24"> + <table:table-cell table:style-name="ce14"/> + <table:table-cell table:style-name="ce17"/> + <table:table-cell table:style-name="ce38"/> + <table:table-cell table:style-name="ce11"/> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce17"/> <table:table-cell table:number-columns-repeated="4"/> </table:table-row> <table:table-row table:style-name="ro2" table:number-rows-repeated="39"> @@ -1232,4 +1318,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 f83040c79e39..96d8f764a418 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -3064,7 +3064,15 @@ void ScInterpreter::ScLower() void ScInterpreter::ScLen() { - PushDouble(GetString().getLength()); + OUString aStr = GetString().getString(); + sal_Int32 nIdx = 0; + sal_Int32 nCnt = 0; + while ( nIdx < aStr.getLength() ) + { + aStr.iterateCodePoints( &nIdx ); + ++nCnt; + } + PushDouble( nCnt ); } void ScInterpreter::ScT()
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits