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

Henry Castro hcvcastro at gmail.com
Mon Mar 9 02:54:16 PDT 2015


 sc/qa/unit/ucalc.cxx            |   68 +++++++++++++++++++++++++++++++++++++++-
 sc/qa/unit/ucalc.hxx            |    4 ++
 sc/source/core/data/column4.cxx |    2 -
 3 files changed, 72 insertions(+), 2 deletions(-)

New commits:
commit 319042492ffcdf9ab5fb78c6c46c4f381a02cfa7
Author: Henry Castro <hcvcastro at gmail.com>
Date:   Fri Mar 6 13:51:25 2015 -0400

    Resolves tdf#80137 Paste array formula into range pastes as non-array formula
    
    Reviewed-on: https://gerrit.libreoffice.org/14770
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    (cherry picked from commit 097a16b59884c777f724cec6c5d42734974ed44b)
    Signed-off-by: Andras Timar <andras.timar at collabora.com>
    
    Conflicts:
    	sc/qa/unit/ucalc.cxx
    	sc/qa/unit/ucalc.hxx
    
    Change-Id: I500008b32e5af07702b76afb901a3ec270453462

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ce5efc2..db306e7 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
  * This file is part of the LibreOffice project.
  *
@@ -6203,6 +6202,73 @@ void Test::testMixData()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testCopyPasteMatrixFormula()
+{
+    m_pDoc->InsertTab(0, "hcv");
+
+    // Set Values to B1, C1, D1
+    m_pDoc->SetValue(ScAddress(1,0,0), 2.0);    // B1
+    m_pDoc->SetValue(ScAddress(2,0,0), 5.0);    // C1
+    m_pDoc->SetValue(ScAddress(3,0,0), 3.0);    // D1
+
+    // Set Values to B2, C2
+    m_pDoc->SetString(ScAddress(1,1,0), "B2");  // B2
+    //m_pDoc->SetString(ScAddress(2,1,0), "C2");  // C2
+    m_pDoc->SetString(ScAddress(3,1,0), "D2");  // D2
+
+    // Set Vallues to D3
+    //m_pDoc->SetValue(ScAddress(1,2,0), 9.0);    // B3
+    //m_pDoc->SetString(ScAddress(2,2,0), "C3");  // C3
+    m_pDoc->SetValue(ScAddress(3,2,0), 11.0);   // D3
+
+    // Insert matrix formula to A1
+    ScMarkData aMark;
+    aMark.SelectOneTable(0);
+    m_pDoc->InsertMatrixFormula(0, 0, 0, 0, aMark, "=COUNTIF(ISBLANK(B1:D1);TRUE())");
+    m_pDoc->CalcAll();
+    // A1 should containg 0
+    CPPUNIT_ASSERT_EQUAL( 0.0, m_pDoc->GetValue(ScAddress(0,0,0)) ); // A1
+
+    // Copy cell A1 to clipboard.
+    ScAddress aPos(0,0,0);  // A1
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    ScClipParam aParam(aPos, false);
+    m_pDoc->CopyToClip(aParam, &aClipDoc, &aMark);
+    // Formula string should be equal.
+    CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(aPos), aClipDoc.GetString(aPos));
+
+    // First try single range.
+    // Paste matrix formula to A2
+    pasteFromClip(m_pDoc, ScRange(0,1,0,0,1,0), &aClipDoc); // A2
+    // A2 Cell value should contain 1.0
+    CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+
+    // Paste matrix formula to A3
+    pasteFromClip(m_pDoc, ScRange(0,2,0,0,2,0), &aClipDoc); // A3
+    // A3 Cell value should contain 2.0
+    CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+
+    // Paste matrix formula to A4
+    pasteFromClip(m_pDoc, ScRange(0,3,0,0,3,0), &aClipDoc); // A4
+    // A4 Cell value should contain 3.0
+    CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc->GetValue(ScAddress(0,3,0)));
+
+    // Clear cell A2:A4
+    clearRange(m_pDoc, ScRange(0,1,0,0,3,0));
+
+    // Paste matrix formula to range A2:A4
+    pasteFromClip(m_pDoc, ScRange(0,1,0,0,3,0), &aClipDoc); // A2:A4
+
+    // A2 Cell value should contain 1.0
+    CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+    // A3 Cell value should contain 2.0
+    CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+    // A4 Cell value should contain 3.0
+    CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc->GetValue(ScAddress(0,3,0)));
+
+    m_pDoc->DeleteTab(0);
+}
+
 ScDocShell* Test::findLoadedDocShellByName(const OUString& rName)
 {
     TypeId aType(TYPE(ScDocShell));
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 28e0e01..794482a 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -418,6 +418,9 @@ public:
 
     void testColumnFindEditCells();
 
+    // tdf#80137
+    void testCopyPasteMatrixFormula();
+
     CPPUNIT_TEST_SUITE(Test);
 #if CALC_TEST_PERF
     CPPUNIT_TEST(testPerf);
@@ -615,6 +618,7 @@ public:
     CPPUNIT_TEST(testFormulaToValue);
     CPPUNIT_TEST(testFormulaToValue2);
     CPPUNIT_TEST(testColumnFindEditCells);
+    CPPUNIT_TEST(testCopyPasteMatrixFormula);
     CPPUNIT_TEST_SUITE_END();
 
 private:
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 19e3b14..63534c3 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -516,7 +516,7 @@ void ScColumn::CloneFormulaCell(
             xGroup->compileCode(*pDocument, aPos, pDocument->GetGrammar());
             for (size_t i = 0; i < nLen; ++i, aPos.IncRow())
             {
-                ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, xGroup);
+                ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, xGroup, pDocument->GetGrammar(), rSrc.GetMatrixFlag());
                 if (i == 0)
                 {
                     xGroup->mpTopCell = pCell;


More information about the Libreoffice-commits mailing list