sc/qa/unit/ucalc.cxx             |   27 +++++++++++++++++++++++++++
 sc/source/core/tool/interpr5.cxx |    6 +++---
 2 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit 70ec826eeb8f0b311095869e23be1db95fc9d109
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Thu Nov 8 19:50:02 2012 -0500

    New unit test to ensure correct matrix creation.
    
    See fdo#56829 for what inspired this test case.
    
    Change-Id: Iee15d85a35ae96769d21ce7061b352860a5b587b

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 5b48f25..0606562 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -125,6 +125,7 @@ public:
     void testNamedRange();
     void testCSV();
     void testMatrix();
+    void testEnterMixedMatrix();
 
     /**
      * Basic test for pivot tables.
@@ -250,6 +251,7 @@ public:
     CPPUNIT_TEST(testNamedRange);
     CPPUNIT_TEST(testCSV);
     CPPUNIT_TEST(testMatrix);
+    CPPUNIT_TEST(testEnterMixedMatrix);
     CPPUNIT_TEST(testPivotTable);
     CPPUNIT_TEST(testPivotTableLabels);
     CPPUNIT_TEST(testPivotTableDateLabels);
@@ -1513,6 +1515,31 @@ void Test::testMatrix()
     checkMatrixElements<PartiallyFilledEmptyMatrix>(*pMat);
 }
 
+void Test::testEnterMixedMatrix()
+{
+    m_pDoc->InsertTab(0, "foo");
+
+    // Insert the source values in A1:B2.
+    m_pDoc->SetString(0, 0, 0, "A");
+    m_pDoc->SetString(1, 0, 0, "B");
+    double val = 1.0;
+    m_pDoc->SetValue(0, 1, 0, val);
+    val = 2.0;
+    m_pDoc->SetValue(1, 1, 0, val);
+
+    // Create a matrix range in A4:B5 referencing A1:B2.
+    ScMarkData aMark;
+    aMark.SelectOneTable(0);
+    m_pDoc->InsertMatrixFormula(0, 3, 1, 4, aMark, "=A1:B2", NULL);
+
+    CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,0,0), m_pDoc->GetString(0,3,0));
+    CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(1,0,0), m_pDoc->GetString(1,3,0));
+    CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(0,1,0), m_pDoc->GetValue(0,4,0));
+    CPPUNIT_ASSERT_EQUAL(m_pDoc->GetValue(1,1,0), m_pDoc->GetValue(1,4,0));
+
+    m_pDoc->DeleteTab(0);
+}
+
 namespace {
 
 struct DPFieldDef
commit 78bf3c9abd4a8cd939e7ba4399ae4aab9f3b2982
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Thu Nov 8 19:49:10 2012 -0500

    fdo#56829: Correctly pass element values to matrix.
    
    Change-Id: I20045ae0ddcec228b153c4005855dca9c4ddbfca

diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 46fd6fc..faa0db5 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -453,7 +453,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const 
FormulaToken* pToken
                     nGlobalError = 0;
                 }
 
-                if (nThisRow == nPrevRow + 1)
+                if (!aBucket.maNumVals.empty() && nThisRow == nPrevRow + 1)
                 {
                     // Secondary numbers.
                     aBucket.maNumVals.push_back(fVal);
@@ -475,7 +475,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const 
FormulaToken* pToken
                 double fVal = CreateDoubleError( nGlobalError);
                 nGlobalError = 0;
 
-                if (nThisRow == nPrevRow + 1)
+                if (!aBucket.maNumVals.empty() && nThisRow == nPrevRow + 1)
                 {
                     // Secondary numbers.
                     aBucket.maNumVals.push_back(fVal);
@@ -490,7 +490,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const 
FormulaToken* pToken
             }
             else
             {
-                if (nThisRow == nPrevRow + 1)
+                if (!aBucket.maStrVals.empty() && nThisRow == nPrevRow + 1)
                 {
                     // Secondary numbers.
                     aBucket.maStrVals.push_back(aStr);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to