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

Eike Rathke erack at redhat.com
Mon Apr 10 13:47:59 UTC 2017


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

New commits:
commit 2864c32733df6b0e9975ed5ee03a747cd2932472
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Feb 20 20:27:52 2017 +0100

    don't obtain the underlying SvNumberformat thrice, tdf#105657 follow-up
    
    ... which all GetFormatTable()->...(nFormat) do.
    Also introduce SvNumberformat::GetMaskedType() for convenience.
    
    Change-Id: I9495d71b99116e74e8b877ffc9cd21bd36cc7b7f
    (cherry picked from commit 820cb1f86f3fd177877b8719315fc03534e2049c)
    Reviewed-on: https://gerrit.libreoffice.org/36366
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx
index f798d4090638..dbfa04858c28 100644
--- a/include/svl/zformat.hxx
+++ b/include/svl/zformat.hxx
@@ -169,6 +169,9 @@ public:
     /// Get type of format, may include css::util::NumberFormat::DEFINED bit
     short GetType() const                       { return eType; }
 
+    /// Get type of format, does not include css::util::NumberFormat::DEFINED
+    short GetMaskedType() const                 { return eType & ~css::util::NumberFormat::DEFINED; }
+
     void SetType(const short eSetType)          { eType = eSetType; }
     // Standard means the I18N defined standard format of this type
     void SetStandard()                          { bStandard = true; }
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 09b7c543e7e8..fed6c0d043f0 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -19,6 +19,7 @@
 
 #include <svl/intitem.hxx>
 #include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
 #include <formula/token.hxx>
 
 #include "document.hxx"
@@ -651,14 +652,15 @@ bool ScDocument::GetSelectionFunction( ScSubTotalFunc eFunc,
 
 double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const
 {
+    const SvNumberformat* pFormat = GetFormatTable()->GetEntry( nFormat );
     short nType;
-    if ( (nType = GetFormatTable()->GetType( nFormat )) != css::util::NumberFormat::DATE
-      && nType != css::util::NumberFormat::TIME && nType != css::util::NumberFormat::DATETIME )
+    if (pFormat && (nType = pFormat->GetMaskedType()) != css::util::NumberFormat::DATE
+            && nType != css::util::NumberFormat::TIME && nType != css::util::NumberFormat::DATETIME )
     {
         short nPrecision;
         if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0)
         {
-            nPrecision = (short)GetFormatTable()->GetFormatPrecision( nFormat );
+            nPrecision = (short)pFormat->GetFormatPrecision();
             switch ( nType )
             {
                 case css::util::NumberFormat::PERCENT:      // 0.41% == 0.0041
@@ -674,7 +676,7 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const
                 }
                 case css::util::NumberFormat::FRACTION:     // get value of fraction representation
                 {
-                    return GetFormatTable()->GetRoundFractionValue( nFormat, fVal );
+                    return pFormat->GetRoundFractionValue( fVal );
                 }
             }
         }


More information about the Libreoffice-commits mailing list