[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Fri Aug 5 22:34:47 UTC 2016


 sc/source/core/tool/interpr5.cxx |   61 +++++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 25 deletions(-)

New commits:
commit 1af2f6d038836534516f9f0423df51c51192d8f1
Author: Eike Rathke <erack at redhat.com>
Date:   Sat Aug 6 00:33:03 2016 +0200

    determine nFuncFmtType before PushDouble()
    
    ... as PushDouble() may use it to create a FormulaTypedDoubleToken for type
    inheritance.
    
    Change-Id: I9fd668802d2890185fd4e338478c1404586cda04

diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 738c10c..6cc80b3 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1327,20 +1327,24 @@ void ScInterpreter::CalculateAddSub(bool _bSub)
         else
             PushIllegalArgument();
     }
-    else if ( _bSub )
-        PushDouble( ::rtl::math::approxSub( fVal1, fVal2 ) );
     else
-        PushDouble( ::rtl::math::approxAdd( fVal1, fVal2 ) );
-    if ( nFmtCurrencyType == css::util::NumberFormat::CURRENCY )
     {
-        nFuncFmtType = nFmtCurrencyType;
-        nFuncFmtIndex = nFmtCurrencyIndex;
-    }
-    else
-    {
-        lcl_GetDiffDateTimeFmtType( nFuncFmtType, nFmt1, nFmt2 );
-        if ( nFmtPercentType == css::util::NumberFormat::PERCENT && nFuncFmtType == css::util::NumberFormat::NUMBER )
-            nFuncFmtType = css::util::NumberFormat::PERCENT;
+        // Determine nFuncFmtType type before PushDouble().
+        if ( nFmtCurrencyType == css::util::NumberFormat::CURRENCY )
+        {
+            nFuncFmtType = nFmtCurrencyType;
+            nFuncFmtIndex = nFmtCurrencyIndex;
+        }
+        else
+        {
+            lcl_GetDiffDateTimeFmtType( nFuncFmtType, nFmt1, nFmt2 );
+            if (nFmtPercentType == css::util::NumberFormat::PERCENT && nFuncFmtType == css::util::NumberFormat::NUMBER)
+                nFuncFmtType = css::util::NumberFormat::PERCENT;
+        }
+        if ( _bSub )
+            PushDouble( ::rtl::math::approxSub( fVal1, fVal2 ) );
+        else
+            PushDouble( ::rtl::math::approxAdd( fVal1, fVal2 ) );
     }
 }
 
@@ -1506,11 +1510,14 @@ void ScInterpreter::ScMul()
             PushIllegalArgument();
     }
     else
-        PushDouble(fVal1 * fVal2);
-    if ( nFmtCurrencyType == css::util::NumberFormat::CURRENCY )
     {
-        nFuncFmtType = nFmtCurrencyType;
-        nFuncFmtIndex = nFmtCurrencyIndex;
+        // Determine nFuncFmtType type before PushDouble().
+        if ( nFmtCurrencyType == css::util::NumberFormat::CURRENCY )
+        {
+            nFuncFmtType = nFmtCurrencyType;
+            nFuncFmtIndex = nFmtCurrencyIndex;
+        }
+        PushDouble(fVal1 * fVal2);
     }
 }
 
@@ -1580,13 +1587,15 @@ void ScInterpreter::ScDiv()
     }
     else
     {
+        // Determine nFuncFmtType type before PushDouble().
+        if (    nFmtCurrencyType  == css::util::NumberFormat::CURRENCY &&
+                nFmtCurrencyType2 != css::util::NumberFormat::CURRENCY)
+        {   // even USD/USD is not USD
+            nFuncFmtType = nFmtCurrencyType;
+            nFuncFmtIndex = nFmtCurrencyIndex;
+        }
         PushDouble( div( fVal1, fVal2) );
     }
-    if ( nFmtCurrencyType == css::util::NumberFormat::CURRENCY && nFmtCurrencyType2 != css::util::NumberFormat::CURRENCY )
-    {   // even USD/USD is not USD
-        nFuncFmtType = nFmtCurrencyType;
-        nFuncFmtIndex = nFmtCurrencyIndex;
-    }
 }
 
 void ScInterpreter::ScPower()
@@ -3221,15 +3230,20 @@ void ScInterpreter::ScMatRef()
             }
             else
             {
-                PushDouble(nMatVal.fVal);  // handles DoubleError
+                // Determine nFuncFmtType type before PushDouble().
                 pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr);
                 nFuncFmtType = nCurFmtType;
                 nFuncFmtIndex = nCurFmtIndex;
+                PushDouble(nMatVal.fVal);  // handles DoubleError
             }
         }
     }
     else
     {
+        // Determine nFuncFmtType type before PushDouble().
+        pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr);
+        nFuncFmtType = nCurFmtType;
+        nFuncFmtIndex = nCurFmtIndex;
         // If not a result matrix, obtain the cell value.
         sal_uInt16 nErr = aCell.mpFormula->GetErrCode();
         if (nErr)
@@ -3241,9 +3255,6 @@ void ScInterpreter::ScMatRef()
             svl::SharedString aVal = aCell.mpFormula->GetString();
             PushString( aVal );
         }
-        pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr);
-        nFuncFmtType = nCurFmtType;
-        nFuncFmtIndex = nCurFmtIndex;
     }
 }
 


More information about the Libreoffice-commits mailing list