[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Sat May 10 00:37:49 PDT 2014


 sc/source/core/data/column3.cxx |   43 ++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 17 deletions(-)

New commits:
commit 1b9f4a686c5f397db3bd996acf53e0ad2b5d9ded
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri May 9 22:19:15 2014 -0400

    fdo#77056: Treat empty cells as if they have a value of 0.0.
    
    Change-Id: Ibe64cf7177a5298c1878e0014c049dc9c82b1344
    (cherry picked from commit 83a88b942134314e86ac612d0ef70a8e4919e4af)
    Reviewed-on: https://gerrit.libreoffice.org/9298
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 6f5e4e2..cbb38d7 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1166,6 +1166,23 @@ class MixDataHandler
 
     bool mbSkipEmpty;
 
+    void doFunction( size_t nDestRow, double fVal1, double fVal2 )
+    {
+        bool bOk = lcl_DoFunction(fVal1, fVal2, mnFunction);
+
+        if (bOk)
+            miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, fVal1);
+        else
+        {
+            ScAddress aPos(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab());
+
+            ScFormulaCell* pFC = new ScFormulaCell(&mrDestColumn.GetDoc(), aPos);
+            pFC->SetErrCode(errNoValue);
+
+            miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, pFC);
+        }
+    }
+
 public:
     MixDataHandler(
         sc::ColumnBlockPosition& rBlockPos,
@@ -1188,22 +1205,15 @@ public:
         mrBlockPos.miCellPos = aPos.first;
         switch (aPos.first->type)
         {
+            case sc::element_type_empty:
             case sc::element_type_numeric:
             {
-                // Both src and dest are of numeric type.
-                bool bOk = lcl_DoFunction(f, sc::numeric_block::at(*aPos.first->data, aPos.second), mnFunction);
-
-                if (bOk)
-                    miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, f);
-                else
-                {
-                    ScFormulaCell* pFC =
-                        new ScFormulaCell(
-                            &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()));
+                double fSrcVal = 0.0;
+                if (aPos.first->type == sc::element_type_numeric)
+                    fSrcVal = sc::numeric_block::at(*aPos.first->data, aPos.second);
 
-                    pFC->SetErrCode(errNoValue);
-                    miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, pFC);
-                }
+                // Both src and dest are of numeric type.
+                doFunction(nRow, f, fSrcVal);
             }
             break;
             case sc::element_type_formula:
@@ -1237,7 +1247,6 @@ public:
             break;
             case sc::element_type_string:
             case sc::element_type_edittext:
-            case sc::element_type_empty:
             {
                 // Destination cell is not a number. Just take the source cell.
                 miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, f);
@@ -1354,9 +1363,9 @@ public:
             {
                 case sc::element_type_numeric:
                 {
-                    double fVal = sc::numeric_block::at(*aPos.first->data, aPos.second);
-                    miNewCellsPos = maNewCells.set(
-                            miNewCellsPos, nDestRow-mnRowOffset, fVal);
+                    double fVal1 = 0.0;
+                    double fVal2 = sc::numeric_block::at(*aPos.first->data, aPos.second);
+                    doFunction(nDestRow, fVal1, fVal2);
                 }
                 break;
                 case sc::element_type_string:


More information about the Libreoffice-commits mailing list