[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - include/svl sc/source svl/source

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Mon Apr 10 13:48:25 UTC 2017


 include/svl/zforlist.hxx         |    3 +++
 include/svl/zformat.hxx          |    3 ++-
 sc/source/core/data/documen4.cxx |    2 +-
 svl/source/numbers/zforlist.cxx  |   12 ++++++++++++
 4 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 09478b2211bbc9ec34d8de8452e30cf1254a250c
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Thu Feb 16 22:15:37 2017 +0100

    tdf#106052 Treat SubFormat for "Precision as shown"
    
    Get precision from the correct subformat
    
    Change-Id: I458e5b3d1fb515864f19499ac9ac529e1d68a267
    Reviewed-on: https://gerrit.libreoffice.org/34505
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit e7f769bc67d3f132b477b3c253f8065243b9b8ac)
    Reviewed-on: https://gerrit.libreoffice.org/36367

diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index 36e468726a64..f03a79e0aa45 100644
--- a/include/svl/zforlist.hxx
+++ b/include/svl/zforlist.hxx
@@ -517,6 +517,9 @@ public:
     /// Count of decimals
     sal_uInt16 GetFormatPrecision( sal_uInt32 nFormat ) const;
 
+    /// Count of decimals with correct subformat according to fValue
+    sal_uInt16 GetFormatPrecision( sal_uInt32 nFormat, double fValue ) const;
+
     /// Count of integer digits
     sal_uInt16 GetFormatIntegerDigits( sal_uInt32 nFormat ) const;
 
diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index dbfa04858c28..34525acad43e 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -219,7 +219,8 @@ public:
     sal_uInt16 GetSubformatIndex( double fNumber ) const;
 
     /// Count of decimal precision
-    sal_uInt16 GetFormatPrecision() const   { return NumFor[0].Info().nCntPost; }
+    sal_uInt16 GetFormatPrecision( sal_uInt16 nIx = 0 ) const
+        { return NumFor[nIx].Info().nCntPost; }
 
     /// Count of integer digits
     sal_uInt16 GetFormatIntegerDigits() const { return NumFor[0].Info().nCntPre; }
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index fed6c0d043f0..6a1110b6cd80 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -660,7 +660,7 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const
         short nPrecision;
         if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0)
         {
-            nPrecision = (short)pFormat->GetFormatPrecision();
+            nPrecision = (short)GetFormatTable()->GetFormatPrecision( nFormat, fVal );
             switch ( nType )
             {
                 case css::util::NumberFormat::PERCENT:      // 0.41% == 0.0041
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 659e1b5b340d..108babe2da50 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1981,6 +1981,18 @@ sal_uInt16 SvNumberFormatter::GetFormatPrecision( sal_uInt32 nFormat ) const
         return pFormatScanner->GetStandardPrec();
 }
 
+sal_uInt16 SvNumberFormatter::GetFormatPrecision( sal_uInt32 nFormat, double fValue ) const
+{
+    const SvNumberformat* pFormat = GetFormatEntry( nFormat );
+    if ( pFormat )
+    {
+        sal_uInt16 nIx = pFormat->GetSubformatIndex( fValue );
+        return pFormat->GetFormatPrecision( nIx );
+    }
+    else
+        return pFormatScanner->GetStandardPrec();
+}
+
 sal_uInt16 SvNumberFormatter::GetFormatIntegerDigits( sal_uInt32 nFormat ) const
 {
     const SvNumberformat* pFormat = GetFormatEntry( nFormat );


More information about the Libreoffice-commits mailing list