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

Kohei Yoshida kohei.yoshida at collabora.com
Mon Apr 28 08:59:00 PDT 2014


 sc/qa/unit/ucalc.hxx             |    2 ++
 sc/qa/unit/ucalc_formula.cxx     |   33 +++++++++++++++++++++++++++++++++
 sc/source/core/tool/scmatrix.cxx |    2 +-
 3 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 5fab47ddbe332a150fb2005e941a2c19bd38ce7f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Apr 28 11:55:23 2014 -0400

    fdo#75397: Return an empty string for empty element.
    
    This is the behavior as of 3.6.  It had changed in 4.0 and onward by
    accident, and caused the bug as reported in fdo#75397.
    
    Change-Id: Id96fea354604b3c13cbbf2d9a73223b7725c7d66

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index b71da72..32da95a 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -579,7 +579,7 @@ svl::SharedString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE
         {
             if (!maMatFlag.get<bool>(nR, nC))
                 // not an empty path.
-                break;
+                return svl::SharedString::getEmptyString();
 
             // result of empty FALSE jump path
             sal_uLong nKey = rFormatter.GetStandardFormat( NUMBERFORMAT_LOGICAL,
commit 18fa4733f46c2dae40bad7cdea9d3f98e24495dd
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Apr 28 11:16:29 2014 -0400

    fdo#75397: Write unit test for this.
    
    Change-Id: Id261aebd427eb032463668c2654ce837139b4a05

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2939ac5..71b33a7 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -133,6 +133,7 @@ public:
     void testFuncN();
     void testFuncCOUNTIF();
     void testFuncNUMBERVALUE();
+    void testFuncLEN();
     void testFuncLOOKUP();
     void testFuncVLOOKUP();
     void testFuncMATCH();
@@ -383,6 +384,7 @@ public:
     CPPUNIT_TEST(testFuncN);
     CPPUNIT_TEST(testFuncCOUNTIF);
     CPPUNIT_TEST(testFuncNUMBERVALUE);
+    CPPUNIT_TEST(testFuncLEN);
     CPPUNIT_TEST(testFuncLOOKUP);
     CPPUNIT_TEST(testFuncVLOOKUP);
     CPPUNIT_TEST(testFuncMATCH);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 9776715..b2caf22 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2635,6 +2635,39 @@ void Test::testFuncNUMBERVALUE()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testFuncLEN()
+{
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+    m_pDoc->InsertTab(0, "Formula");
+
+    // Leave A1:A3 empty, and insert an array of LEN in B1:B3 that references
+    // these empty cells.
+
+    ScMarkData aMark;
+    aMark.SelectOneTable(0);
+    m_pDoc->InsertMatrixFormula(1, 0, 1, 2, aMark, "=LEN(A1:A3)", NULL);
+
+    ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
+    CPPUNIT_ASSERT(pFC);
+    CPPUNIT_ASSERT_MESSAGE("This formulashould be a matrix origin.",
+                           pFC->GetMatrixFlag() == MM_FORMULA);
+
+    // This should be a 1x3 matrix.
+    SCCOL nCols = -1;
+    SCROW nRows = -1;
+    pFC->GetMatColsRows(nCols, nRows);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCols);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), nRows);
+
+    // LEN value should be 0 for an empty cell.
+    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(0.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testFuncLOOKUP()
 {
     FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);


More information about the Libreoffice-commits mailing list