[Libreoffice-commits] core.git: Branch 'libreoffice-5-2-0' - svl/source

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Tue Jul 12 14:05:16 UTC 2016


 svl/source/numbers/zformat.cxx |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit 0a27e1aa4b710219935f298581ccc993963a6a12
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Mon Jul 11 09:20:21 2016 +0200

    tdf#100842 Do not insert things in the middle of the number
    
    With fraction number format, if number is longer than number of digits in format
    jump to the beginning of number before inserting extras:
    strings, blank, star filling
    Do not do this for exponent of scientific format as it may contain
    unwanted 0 at beginning.
    
    Change-Id: Ide99f5cba198f76541f0e4e17b29469a99b57b9f
    Reviewed-on: https://gerrit.libreoffice.org/27097
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit 0727e6e79994b66836841978a554b7f6855449dc)
    Reviewed-on: https://gerrit.libreoffice.org/27142
    (cherry picked from commit f087e995e169fc348e2b5e0b65d45fd2836fd2d0)
    Reviewed-on: https://gerrit.libreoffice.org/27145
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 9f987f5..7f0df63 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -4296,6 +4296,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
     const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
     // no normal thousands separators if number divided by thousands
     bool bDoThousands = (rInfo.nThousand == 0);
+    bool bFoundNumber = false;
     short nType;
 
     k = sBuff.getLength(); // behind last digit
@@ -4307,12 +4308,18 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
         case NF_SYMBOLTYPE_STAR:
             if( bStarFlag )
             {
+                if ( bFoundNumber && eSymbolType != NF_SYMBOLTYPE_EXP )
+                    k = 0; // tdf#100842 jump to beginning of number before inserting something else
                 bRes = lcl_insertStarFillChar( sBuff, k, rInfo.sStrArray[j]);
             }
             break;
         case NF_SYMBOLTYPE_BLANK:
             if (rInfo.sStrArray[j].getLength() >= 2)
+            {
+                if ( bFoundNumber && eSymbolType != NF_SYMBOLTYPE_EXP )
+                    k = 0; // tdf#100842 jump to beginning of number before inserting something else
                 k = InsertBlanks(sBuff, k, rInfo.sStrArray[j][1] );
+            }
             break;
         case NF_SYMBOLTYPE_THSEP:
             // Same as in ImpNumberFillWithThousands() above, do not insert
@@ -4333,6 +4340,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
             break;
         case NF_SYMBOLTYPE_DIGIT:
         {
+            bFoundNumber = true;
             const OUString& rStr = rInfo.sStrArray[j];
             const sal_Unicode* p1 = rStr.getStr();
             const sal_Unicode* p = p1 + rStr.getLength();
@@ -4363,6 +4371,7 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
         case NF_KEY_GENERAL: // Standard in the String
         {
             OUStringBuffer sNum;
+            bFoundNumber = true;
             ImpGetOutputStandard(rNumber, sNum);
             sNum.stripStart('-');
             sBuff.insert(k, sNum.makeStringAndClear());
@@ -4372,6 +4381,8 @@ bool SvNumberformat::ImpNumberFill( OUStringBuffer& sBuff, // number string
             break;
 
         default:
+            if ( bFoundNumber && eSymbolType != NF_SYMBOLTYPE_EXP )
+                k = 0; // tdf#100842 jump to beginning of number before inserting something else
             sBuff.insert(k, rInfo.sStrArray[j]);
             break;
         } // of switch


More information about the Libreoffice-commits mailing list