Kaydet (Commit) eaed8fe3 authored tarafından Eike Rathke's avatar Eike Rathke

unit test for sticky end col/row anchors, tdf#92779

Change-Id: I78584e37e5944327db9cc5b6472a9e7ea972b37e
(cherry picked from commit fe445df1)
üst be39e7ea
...@@ -1541,6 +1541,190 @@ void Test::testFormulaRefUpdateRange() ...@@ -1541,6 +1541,190 @@ void Test::testFormulaRefUpdateRange()
if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$9)")) if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$9)"))
CPPUNIT_FAIL("Wrong formula in A3."); CPPUNIT_FAIL("Wrong formula in A3.");
m_pDoc->InsertTab(1, "StickyRange");
// A3:A18 all possible combinations of relative and absolute addressing,
// leaving one row above and below unreferenced.
ScAddress aPos(0,2,1);
m_pDoc->SetString( aPos, "=B2:B1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=B2:B$1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=B2:$B1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=B2:$B$1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=B$2:B1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=B$2:B$1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=B$2:$B1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=B$2:$B$1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=$B2:B1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=$B2:B$1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=$B2:$B1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=$B2:$B$1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=$B$2:B1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=$B$2:B$1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=$B$2:$B1048575");
aPos.IncRow();
m_pDoc->SetString( aPos, "=$B$2:$B$1048575");
aPos.IncRow();
// A19 reference to two cells on one row.
m_pDoc->SetString( aPos, "=B1048575:C1048575");
aPos.IncRow();
// Insert 2 rows in the middle to shift bottom reference down and make it
// sticky.
m_pDoc->InsertRow( ScRange( aPos, ScAddress(MAXCOL,aPos.Row()+1,1)));
// A3:A18 must not result in #REF! anywhere.
bool bCheck = true;
aPos.Set(0,2,1);
bCheck &= checkFormula(*m_pDoc, aPos, "B2:B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B2:B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B2:$B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B2:$B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B$2:B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B$2:B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B$2:$B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B$2:$B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B2:B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B2:B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B2:$B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B2:$B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B$2:B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B$2:B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B$2:$B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B$2:$B$1048576");
aPos.IncRow();
if (!bCheck)
CPPUNIT_FAIL("Wrong reference in A3:A18 after insertion.");
// A19 reference to one row shifted out should be #REF!
bCheck &= checkFormula(*m_pDoc, aPos, "B#REF!:C#REF!");
if (!bCheck)
CPPUNIT_FAIL("Wrong reference in A19 after insertion.");
// A19 enter reference to last row.
m_pDoc->SetString( aPos, "=B1048576:C1048576");
aPos.IncRow();
// Delete row 1 to shift top reference up, bottom reference stays sticky.
m_pDoc->DeleteRow(ScRange(0,0,1,MAXCOL,0,1));
// Check sticky bottom references and display of entire column references,
// now in A2:A17.
bCheck = true;
aPos.Set(0,1,1);
bCheck &= checkFormula(*m_pDoc, aPos, "B:B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B1:B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B:$B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B1:$B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B$1:B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B:B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B$1:$B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B:$B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B:B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B1:B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B:$B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B1:$B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B$1:B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B:B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B$1:$B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B:$B");
aPos.IncRow();
if (!bCheck)
CPPUNIT_FAIL("Wrong reference in A2:A17 after deletion.");
// A18 reference to one last row should be shifted up.
bCheck &= checkFormula(*m_pDoc, aPos, "B1048575:C1048575");
if (!bCheck)
CPPUNIT_FAIL("Wrong reference in A18 after deletion.");
aPos.IncRow();
// Insert 4 rows in the middle.
m_pDoc->InsertRow( ScRange( aPos, ScAddress(MAXCOL,aPos.Row()+3,1)));
// Delete 2 rows in the middle.
m_pDoc->DeleteRow( ScRange( aPos, ScAddress(MAXCOL,aPos.Row()+1,1)));
// References in A2:A17 must still be the same.
bCheck = true;
aPos.Set(0,1,1);
bCheck &= checkFormula(*m_pDoc, aPos, "B:B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B1:B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B:$B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B1:$B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B$1:B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B:B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B$1:$B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "B:$B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B:B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B1:B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B:$B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B1:$B$1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B$1:B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B:B");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B$1:$B1048576");
aPos.IncRow();
bCheck &= checkFormula(*m_pDoc, aPos, "$B:$B");
aPos.IncRow();
if (!bCheck)
CPPUNIT_FAIL("Wrong reference in A2:A17 after deletion.");
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0); m_pDoc->DeleteTab(0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment