summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-08-14 11:51:05 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-08-14 11:52:55 -0400
commit64073c45aac22696bed6b688bb34974d646f3c34 (patch)
tree4d3e4733e0438fe0117462e25e7c2491bc2647de /sc/qa
parent9a9ee66f0d9dd126ed31db096b77f9c67355411b (diff)
Do the same when inserting columns.
Change-Id: I387ef3c2c8345bb5be75909596f59af80b966443
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc_sharedformula.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index 4d9ad67f0e38..39e5176d61df 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -340,6 +340,54 @@ void Test::testSharedFormulasRefUpdate()
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow());
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength());
+ // Insert cells over A11:B11 to shift to right again.
+ m_pDoc->InsertCol(ScRange(0,10,0,1,10,0));
+ if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A10"))
+ CPPUNIT_FAIL("Wrong formula in B1");
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "C11"))
+ CPPUNIT_FAIL("Wrong formula in B2");
+ if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A12"))
+ CPPUNIT_FAIL("Wrong formula in B3");
+
+ pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
+ CPPUNIT_ASSERT_MESSAGE("B1 should be a non-shared formula cell.", pFC && !pFC->IsShared());
+ pFC = m_pDoc->GetFormulaCell(ScAddress(1,1,0));
+ CPPUNIT_ASSERT_MESSAGE("B2 should be a non-shared formula cell.", pFC && !pFC->IsShared());
+ pFC = m_pDoc->GetFormulaCell(ScAddress(1,2,0));
+ CPPUNIT_ASSERT_MESSAGE("B3 should be a non-shared formula cell.", pFC && !pFC->IsShared());
+
+ // Insert cells over A12:B12 to shift to right.
+ m_pDoc->InsertCol(ScRange(0,11,0,1,11,0));
+ if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A10"))
+ CPPUNIT_FAIL("Wrong formula in B1");
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "C11"))
+ CPPUNIT_FAIL("Wrong formula in B2");
+ if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "C12"))
+ CPPUNIT_FAIL("Wrong formula in B3");
+
+ pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
+ CPPUNIT_ASSERT_MESSAGE("B1 should be a non-shared formula cell.", pFC && !pFC->IsShared());
+ // B2 and B3 should be grouped.
+ pFC = m_pDoc->GetFormulaCell(ScAddress(1,1,0));
+ CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC && pFC->IsShared());
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow());
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength());
+
+ // Insert cells over A10:B10 to shift to right.
+ m_pDoc->InsertCol(ScRange(0,9,0,1,9,0));
+ if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "C10"))
+ CPPUNIT_FAIL("Wrong formula in B1");
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "C11"))
+ CPPUNIT_FAIL("Wrong formula in B2");
+ if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "C12"))
+ CPPUNIT_FAIL("Wrong formula in B3");
+
+ // B1:B3 should be now grouped.
+ pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
+ CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC && pFC->IsShared());
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow());
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength());
+
m_pDoc->DeleteTab(0);
}