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

Kohei Yoshida kohei.yoshida at collabora.com
Thu Oct 16 17:51:15 PDT 2014


 sc/qa/unit/ucalc_formula.cxx     |   21 ++++++++++++++
 sc/source/core/tool/interpr1.cxx |   55 +++++++++++++++++++++++----------------
 2 files changed, 54 insertions(+), 22 deletions(-)

New commits:
commit 51b215902d8e1f415b5fef49fc50c7167f0c7787
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Oct 16 20:49:42 2014 -0400

    fdo#73080: Fix the single cell reference cases as well.
    
    Change-Id: Ib9a8ae04733c5bcb982ef4d337112eb8249d0ee0

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 44c3ea6..d5dcb8e 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4510,12 +4510,39 @@ void ScInterpreter::ScMatch()
     }
 }
 
+namespace {
+
+bool isCellContentEmpty( const ScRefCellValue& rCell )
+{
+    switch (rCell.meType)
+    {
+        case CELLTYPE_VALUE:
+        case CELLTYPE_STRING:
+        case CELLTYPE_EDIT:
+            return false;
+        case CELLTYPE_FORMULA:
+        {
+            sc::FormulaResultValue aRes = rCell.mpFormula->GetResult();
+            if (aRes.meType != sc::FormulaResultValue::String)
+                return false;
+            if (!aRes.maString.isEmpty())
+                return false;
+        }
+        break;
+        default:
+            ;
+    }
+
+    return true;
+}
+
+}
+
 void ScInterpreter::ScCountEmptyCells()
 {
     if ( MustHaveParamCount( GetByte(), 1 ) )
     {
         sal_uLong nMaxCount = 0, nCount = 0;
-        CellType eCellType;
         switch (GetStackType())
         {
             case svSingleRef :
@@ -4523,8 +4550,9 @@ void ScInterpreter::ScCountEmptyCells()
                 nMaxCount = 1;
                 ScAddress aAdr;
                 PopSingleRef( aAdr );
-                eCellType = pDok->GetCellType(aAdr);
-                if (eCellType != CELLTYPE_NONE)
+                ScRefCellValue aCell;
+                aCell.assign(*pDok, aAdr);
+                if (!isCellContentEmpty(aCell))
                     nCount = 1;
             }
             break;
@@ -4546,25 +4574,8 @@ void ScInterpreter::ScCountEmptyCells()
                     for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
                     {
                         const ScRefCellValue& rCell = aIter.getRefCellValue();
-                        switch (rCell.meType)
-                        {
-                            case CELLTYPE_VALUE:
-                            case CELLTYPE_STRING:
-                            case CELLTYPE_EDIT:
-                                ++nCount;
-                            break;
-                            case CELLTYPE_FORMULA:
-                            {
-                                sc::FormulaResultValue aRes = rCell.mpFormula->GetResult();
-                                if (aRes.meType != sc::FormulaResultValue::String)
-                                    ++nCount;
-                                else if (!aRes.maString.isEmpty())
-                                    ++nCount;
-                            }
-                            break;
-                            default:
-                                ;
-                        }
+                        if (!isCellContentEmpty(rCell))
+                            ++nCount;
                     }
                 }
             }
commit 9d8f1795836f58cb275eae19818eb25ee80901a0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Oct 16 20:49:07 2014 -0400

    fdo#73080: Write another test case for single cell reference cases.
    
    Change-Id: I8dff6850c7088b483d1ad669867da6cef454d9a2

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 5c5d6b0..afa1261 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2538,6 +2538,27 @@ void Test::testFuncCOUNTBLANK()
     CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,5,0)));
     CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(3,5,0)));
 
+    // Test single cell reference cases.
+
+    clearSheet(m_pDoc, 0);
+
+    const char* aData2[][2] = {
+        { "1",     "=COUNTBLANK(A1)" },
+        { "A",     "=COUNTBLANK(A2)" },
+        {   0,     "=COUNTBLANK(A3)" },
+        { "=\"\"", "=COUNTBLANK(A4)" },
+        { "=A4"  , "=COUNTBLANK(A5)" },
+    };
+
+    aRange = insertRangeData(m_pDoc, aPos, aData2, SAL_N_ELEMENTS(aData2));
+    CPPUNIT_ASSERT(aRange.aStart == aPos);
+
+    CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+    CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,3,0)));
+    CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,4,0)));
+
     m_pDoc->DeleteTab(0);
 }
 


More information about the Libreoffice-commits mailing list