sc/qa/unit/filters-test.cxx | 21 - sc/qa/unit/helper/qahelper.cxx | 29 + sc/qa/unit/helper/qahelper.hxx | 3 sc/qa/unit/helper/shared_test_impl.hxx | 3 sc/qa/unit/rangelst_test.cxx | 1 sc/qa/unit/subsequent_export-test.cxx | 42 -- sc/qa/unit/subsequent_filters-test.cxx | 54 +-- sc/qa/unit/ucalc.cxx | 21 - sc/qa/unit/ucalc_formula.cxx | 543 +++++++++++---------------------- sc/qa/unit/ucalc_sharedformula.cxx | 229 ++++--------- sc/qa/unit/ucalc_sort.cxx | 96 +---- 11 files changed, 367 insertions(+), 675 deletions(-)
New commits: commit ab9663ed187ba4776d9ff3d9c21f83eed478a268 Author: ritztro <brentritztr...@gmail.com> Date: Sat Apr 11 01:08:26 2015 -0700 tdf#90290 reduce some copy&paste code in ucalc. Change-Id: Iea8879b2ef9e4d23ce5ea0be364d1359f174e5c4 Reviewed-on: https://gerrit.libreoffice.org/15241 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index bfb2a8a..53ec5b8 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -355,28 +355,21 @@ void ScFiltersTest::testSharedFormulaXLS() ScDocument& rDoc2 = xDocSh->GetDocument(); rDoc2.CalcAll(); - if (!checkFormula(rDoc2, ScAddress(1,0,0), "A1*20")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(rDoc2, ScAddress(1,0,0), "A1*20", "Wrong formula."); - if (!checkFormula(rDoc2, ScAddress(1,1,0), "A2*20")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(rDoc2, ScAddress(1,1,0), "A2*20", "Wrong formula."); - if (!checkFormula(rDoc2, ScAddress(1,2,0), "A3*20")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(rDoc2, ScAddress(1,2,0), "A3*20", "Wrong formula."); // There is an intentional gap at row 4. - if (!checkFormula(rDoc2, ScAddress(1,4,0), "A5*20")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(rDoc2, ScAddress(1,4,0), "A5*20", "Wrong formula."); - if (!checkFormula(rDoc2, ScAddress(1,5,0), "A6*20")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(rDoc2, ScAddress(1,5,0), "A6*20", "Wrong formula."); - if (!checkFormula(rDoc2, ScAddress(1,6,0), "A7*20")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(rDoc2, ScAddress(1,6,0), "A7*20", "Wrong formula."); - if (!checkFormula(rDoc2, ScAddress(1,7,0), "A8*20")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(rDoc2, ScAddress(1,7,0), "A8*20", "Wrong formula."); // We re-group formula cells on load. Let's check that as well. diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 654df89..cf44e39 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -423,25 +423,44 @@ ScTokenArray* getTokens(ScDocument& rDoc, const ScAddress& rPos) } -bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected) +void checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected, const char * pFailMessage, bool& rPass) { + rPass = true; ScTokenArray* pCode = getTokens(rDoc, rPos); if (!pCode) { cerr << "Empty token array." << endl; - return false; + rPass = false; + CPPUNIT_FAIL(pFailMessage); } OUString aFormula = toString(rDoc, rPos, *pCode, rDoc.GetGrammar()); if (aFormula != OUString::createFromAscii(pExpected)) { - cerr << "Formula '" << pExpected << "' expected, but '" << aFormula << "' found" << endl; - return false; + CPPUNIT_ASSERT_EQUAL_MESSAGE("The expected and actual value differ.", OUString::createFromAscii(pExpected), aFormula); + CPPUNIT_FAIL(pFailMessage); + rPass = false; } +} - return true; +void checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected, const char * pFailMessage) +{ + ScTokenArray* pCode = getTokens(rDoc, rPos); + if (!pCode) + { + cerr << "Empty token array." << endl; + CPPUNIT_FAIL(pFailMessage); + } + + OUString aFormula = toString(rDoc, rPos, *pCode, rDoc.GetGrammar()); + if (aFormula != OUString::createFromAscii(pExpected)) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("The expected and actual value differ.", OUString::createFromAscii(pExpected), aFormula); + CPPUNIT_FAIL(pFailMessage); + } } + bool checkFormulaPosition(ScDocument& rDoc, const ScAddress& rPos) { OUString aStr(rPos.Format(SCA_VALID)); diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 829c127..5f4aa05 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -126,7 +126,8 @@ SCQAHELPER_DLLPUBLIC std::vector<OUString> getChartRangeRepresentations(const Sd SCQAHELPER_DLLPUBLIC ScRangeList getChartRanges(ScDocument& rDoc, const SdrOle2Obj& rChartObj); -SCQAHELPER_DLLPUBLIC bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected); +SCQAHELPER_DLLPUBLIC void checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected, const char * pFailMessage, bool& rPass); +SCQAHELPER_DLLPUBLIC void checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected, const char * pFailMessage); SCQAHELPER_DLLPUBLIC bool checkFormulaPosition(ScDocument& rDoc, const ScAddress& rPos); SCQAHELPER_DLLPUBLIC bool checkFormulaPositions( diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx index 666be99..fa31e77 100644 --- a/sc/qa/unit/helper/shared_test_impl.hxx +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -279,8 +279,7 @@ void testCeilingFloor_Impl( ScDocument& rDoc ) OUString aRef( OUString::createFromAscii( pORef)); ScAddress aPos; aPos.Parse(aRef); - if (!checkFormula( rDoc, aPos, "AND(K3:K81)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula( rDoc, aPos, "AND(K3:K81)", "Wrong formula."); CPPUNIT_ASSERT_MESSAGE( OString( OString(pORef) + " result is error.").getStr(), isFormulaWithoutError( rDoc, aPos)); CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(aPos)); diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx index 6430fef..e7cd4df 100644 --- a/sc/qa/unit/rangelst_test.cxx +++ b/sc/qa/unit/rangelst_test.cxx @@ -92,7 +92,6 @@ void Test::setUp() SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); - m_pDoc = &m_xDocShRef->GetDocument(); } diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index d54a9e5..18a4215 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -1010,8 +1010,7 @@ void ScExportTest::testFormulaRefSheetNameODS() sc::AutoCalcSwitch aACSwitch(rDoc, true); // turn on auto calc. rDoc.SetString(ScAddress(1,1,0), "='90''s Data'.B2"); CPPUNIT_ASSERT_EQUAL(1.1, rDoc.GetValue(ScAddress(1,1,0))); - if (!checkFormula(rDoc, ScAddress(1,1,0), "'90''s Data'.B2")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(rDoc, ScAddress(1,1,0), "'90''s Data'.B2", "Wrong formula"); } // Now, save and reload this document. ScDocShellRef xNewDocSh = saveAndReload(xDocSh, ODS); @@ -1020,8 +1019,7 @@ void ScExportTest::testFormulaRefSheetNameODS() ScDocument& rDoc = xNewDocSh->GetDocument(); rDoc.CalcAll(); CPPUNIT_ASSERT_EQUAL(1.1, rDoc.GetValue(ScAddress(1,1,0))); - if (!checkFormula(rDoc, ScAddress(1,1,0), "'90''s Data'.B2")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(rDoc, ScAddress(1,1,0), "'90''s Data'.B2", "Wrong formula"); xNewDocSh->DoClose(); } @@ -1071,10 +1069,8 @@ void ScExportTest::testCellValuesExportODS() CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(5,0,0)); // check formula - if (!checkFormula(rDoc, ScAddress(4,0,0), "10*C1/4")) - CPPUNIT_FAIL("Wrong formula =10*C1/4"); - if (!checkFormula(rDoc, ScAddress(7,0,0), "SUM(C1:F1)")) - CPPUNIT_FAIL("Wrong formula =SUM(C1:F1)"); + checkFormula(rDoc, ScAddress(4,0,0), "10*C1/4", "Wrong formula =10*C1/4"); + checkFormula(rDoc, ScAddress(7,0,0), "SUM(C1:F1)", "Wrong formula =SUM(C1:F1)"); CPPUNIT_ASSERT_EQUAL(16.5, rDoc.GetValue(7,0,0)); // check string @@ -1093,8 +1089,7 @@ void ScExportTest::testCellValuesExportODS() //check contiguous values CPPUNIT_ASSERT_EQUAL( 12.0, rDoc.GetValue(0,5,0) ); CPPUNIT_ASSERT_EQUAL( OUString("a string"), rDoc.GetString(0,6,0) ); - if (!checkFormula(rDoc, ScAddress(0,7,0), "$A$6")) - CPPUNIT_FAIL("Wrong formula =$A$6"); + checkFormula(rDoc, ScAddress(0,7,0), "$A$6", "Wrong formula =$A$6"); CPPUNIT_ASSERT_EQUAL( rDoc.GetValue(0,5,0), rDoc.GetValue(0,7,0) ); xNewDocSh->DoClose(); @@ -1262,29 +1257,21 @@ void ScExportTest::testFormulaReferenceXLS() ScDocument& rDoc = xDocSh->GetDocument(); - if (!checkFormula(rDoc, ScAddress(3,1,0), "$A$2+$B$2+$C$2")) - CPPUNIT_FAIL("Wrong formula in D2"); + checkFormula(rDoc, ScAddress(3,1,0), "$A$2+$B$2+$C$2", "Wrong formula in D2"); - if (!checkFormula(rDoc, ScAddress(3,2,0), "A3+B3+C3")) - CPPUNIT_FAIL("Wrong formula in D3"); + checkFormula(rDoc, ScAddress(3,2,0), "A3+B3+C3", "Wrong formula in D3"); - if (!checkFormula(rDoc, ScAddress(3,5,0), "SUM($A$6:$C$6)")) - CPPUNIT_FAIL("Wrong formula in D6"); + checkFormula(rDoc, ScAddress(3,5,0), "SUM($A$6:$C$6)", "Wrong formula in D6"); - if (!checkFormula(rDoc, ScAddress(3,6,0), "SUM(A7:C7)")) - CPPUNIT_FAIL("Wrong formula in D7"); + checkFormula(rDoc, ScAddress(3,6,0), "SUM(A7:C7)", "Wrong formula in D7"); - if (!checkFormula(rDoc, ScAddress(3,9,0), "$Two.$A$2+$Two.$B$2+$Two.$C$2")) - CPPUNIT_FAIL("Wrong formula in D10"); + checkFormula(rDoc, ScAddress(3,9,0), "$Two.$A$2+$Two.$B$2+$Two.$C$2", "Wrong formula in D10"); - if (!checkFormula(rDoc, ScAddress(3,10,0), "$Two.A3+$Two.B3+$Two.C3")) - CPPUNIT_FAIL("Wrong formula in D11"); + checkFormula(rDoc, ScAddress(3,10,0), "$Two.A3+$Two.B3+$Two.C3", "Wrong formula in D11"); - if (!checkFormula(rDoc, ScAddress(3,13,0), "MIN($Two.$A$2:$C$2)")) - CPPUNIT_FAIL("Wrong formula in D14"); + checkFormula(rDoc, ScAddress(3,13,0), "MIN($Two.$A$2:$C$2)", "Wrong formula in D14"); - if (!checkFormula(rDoc, ScAddress(3,14,0), "MAX($Two.A3:C3)")) - CPPUNIT_FAIL("Wrong formula in D15"); + checkFormula(rDoc, ScAddress(3,14,0), "MAX($Two.A3:C3)", "Wrong formula in D15"); xDocSh->DoClose(); } @@ -2441,8 +2428,7 @@ void ScExportTest::testSupBookVirtualPath() ScDocument& rDoc = xDocSh->GetDocument(); - if (!checkFormula(rDoc, ScAddress(0,0,0), "'file:///home/timar/Documents/external.xls'#$Sheet1.A1")) - CPPUNIT_FAIL("Wrong SupBook VirtualPath URL"); + checkFormula(rDoc, ScAddress(0,0,0), "'file:///home/timar/Documents/external.xls'#$Sheet1.A1", "Wrong SupBook VirtualPath URL"); xDocSh->DoClose(); } diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 33431ca..73b79d7 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -1293,40 +1293,29 @@ void ScFiltersTest::testDataTableMortgageXLS() // One-variable table - if (!checkFormula(rDoc, ScAddress(3,1,0), "PMT(B3/12,B4,-B5)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(3,1,0), "PMT(B3/12,B4,-B5)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(3,2,0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C3)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(3,2,0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C3)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(3,3,0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C4)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(3,3,0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C4)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(3,4,0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C5)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(3,4,0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C5)", "Wrong formula!"); // Two-variable table - if (!checkFormula(rDoc, ScAddress(2,7,0), "PMT(B9/12,B10,-B11)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(2,7,0), "PMT(B9/12,B10,-B11)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(3,8,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C9,$B$10,D$8)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(3,8,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C9,$B$10,D$8)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(3,9,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C10,$B$10,D$8)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(3,9,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C10,$B$10,D$8)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(3,10,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C11,$B$10,D$8)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(3,10,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C11,$B$10,D$8)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(4,8,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C9,$B$10,E$8)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(4,8,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C9,$B$10,E$8)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(4,9,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C10,$B$10,E$8)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(4,9,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C10,$B$10,E$8)", "Wrong formula!"); - if (!checkFormula(rDoc, ScAddress(4,10,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C11,$B$10,E$8)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(4,10,0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C11,$B$10,E$8)", "Wrong formula!"); xDocSh->DoClose(); } @@ -1352,26 +1341,22 @@ void ScFiltersTest::testDataTableOneVarXLSX() // B5:B11 should have multiple operations formula cells. Just check the // top and bottom cells. - if (!checkFormula(rDoc, ScAddress(1,4,0), "MULTIPLE.OPERATIONS(B$4,$A$2,$A5)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(1,4,0), "MULTIPLE.OPERATIONS(B$4,$A$2,$A5)", "Wrong formula!"); CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(1,4,0))); - if (!checkFormula(rDoc, ScAddress(1,10,0), "MULTIPLE.OPERATIONS(B$4,$A$2,$A11)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(1,10,0), "MULTIPLE.OPERATIONS(B$4,$A$2,$A11)", "Wrong formula!"); CPPUNIT_ASSERT_EQUAL(14.0, rDoc.GetValue(ScAddress(1,10,0))); // Likewise, E5:I5 should have multiple operations formula cells. Just // check the left- and right-most cells. - if (!checkFormula(rDoc, ScAddress(4,4,0), "MULTIPLE.OPERATIONS($D5,$B$2,E$4)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(4,4,0), "MULTIPLE.OPERATIONS($D5,$B$2,E$4)", "Wrong formula!"); CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(4,4,0))); - if (!checkFormula(rDoc, ScAddress(8,4,0), "MULTIPLE.OPERATIONS($D5,$B$2,I$4)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(8,4,0), "MULTIPLE.OPERATIONS($D5,$B$2,I$4)", "Wrong formula!"); CPPUNIT_ASSERT_EQUAL(50.0, rDoc.GetValue(ScAddress(8,4,0))); @@ -1399,13 +1384,11 @@ void ScFiltersTest::testDataTableMultiTableXLSX() // B4:M15 should have multiple operations formula cells. We'll just check // the top-left and bottom-right ones. - if (!checkFormula(rDoc, ScAddress(1,3,0), "MULTIPLE.OPERATIONS($A$3,$E$1,$A4,$D$1,B$3)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(1,3,0), "MULTIPLE.OPERATIONS($A$3,$E$1,$A4,$D$1,B$3)", "Wrong formula!"); CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(ScAddress(1,3,0))); - if (!checkFormula(rDoc, ScAddress(12,14,0), "MULTIPLE.OPERATIONS($A$3,$E$1,$A15,$D$1,M$3)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(rDoc, ScAddress(12,14,0), "MULTIPLE.OPERATIONS($A$3,$E$1,$A15,$D$1,M$3)", "Wrong formula!"); CPPUNIT_ASSERT_EQUAL(144.0, rDoc.GetValue(ScAddress(12,14,0))); @@ -3030,8 +3013,7 @@ void ScFiltersTest::testErrorOnExternalReferences() CPPUNIT_ASSERT(pFC); CPPUNIT_ASSERT_EQUAL(ScErrorCodes::errNoName, pFC->GetErrCode()); - if (!checkFormula(rDoc, ScAddress(0,0,0), "'file:///Path/To/FileA.ods'#$Sheet1.A1A")) - CPPUNIT_FAIL("Formula changed"); + checkFormula(rDoc, ScAddress(0,0,0), "'file:///Path/To/FileA.ods'#$Sheet1.A1A", "Formula changed"); xDocSh->DoClose(); } diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index f00e3a0..3c598f6 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -3792,19 +3792,16 @@ void Test::testCutPasteRefUndo() m_pDoc->CopyFromClip(ScAddress(2,1,0), aMark, IDF_CONTENTS, pUndoDoc, &aClipDoc, true, false); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(0,1,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "C2")) - CPPUNIT_FAIL("A2 should be referencing C2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "C2", "A2 should be referencing C2."); // At this point, the ref undo document should contain a formula cell at A2 that references B2. - if (!checkFormula(*pUndoDoc, ScAddress(0,1,0), "B2")) - CPPUNIT_FAIL("A2 in the undo document should be referencing B2."); + checkFormula(*pUndoDoc, ScAddress(0,1,0), "B2", "A2 in the undo document should be referencing B2."); ScUndoPaste aUndo(&getDocShell(), ScRange(ScAddress(2,1,0)), aMark, pUndoDoc, NULL, IDF_CONTENTS, NULL, false, NULL); aUndo.Undo(); // Now A2 should be referencing B2 once again. - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "B2")) - CPPUNIT_FAIL("A2 should be referencing B2 after undo."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "B2", "A2 should be referencing B2 after undo."); m_pDoc->DeleteTab(0); } @@ -3827,10 +3824,8 @@ void Test::testMoveRefBetweenSheets() CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0,2,0))); // These formulas should not display the sheet name. - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "A1")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM(A1:C1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,1,0), "A1", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM(A1:C1)", "Wrong formula!"); // Move Test1.A2:A3 to Test2.A2:A3. ScDocFunc& rFunc = getDocShell().GetDocFunc(); @@ -3842,10 +3837,8 @@ void Test::testMoveRefBetweenSheets() CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0,2,1))); // The reference in the pasted formula should display sheet name after the move. - if (!checkFormula(*m_pDoc, ScAddress(0,1,1), "Test1.A1")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,2,1), "SUM(Test1.A1:C1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,1,1), "Test1.A1", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,2,1), "SUM(Test1.A1:C1)", "Wrong formula!"); m_pDoc->DeleteTab(1); m_pDoc->DeleteTab(0); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 6219eaa..153106a 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -285,8 +285,7 @@ void Test::testFormulaParseReference() OUString aInput("="); aInput += OUString::createFromAscii(aChecks[i]); m_pDoc->SetString(ScAddress(0,0,0), aInput); - if (!checkFormula(*m_pDoc, ScAddress(0,0,0), aChecks[i])) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,0,0), aChecks[i], "Wrong formula"); } } @@ -881,100 +880,82 @@ void Test::testFormulaRefUpdate() m_pDoc->SetString(ScAddress(2,3,0), "=$A$1"); // C4 ScAddress aPos(2,2,0); - if (!checkFormula(*m_pDoc, aPos, "A1")) - CPPUNIT_FAIL("Wrong formula in C3."); + checkFormula(*m_pDoc, aPos, "A1", "Wrong formula in C3."); aPos = ScAddress(2,3,0); - if (!checkFormula(*m_pDoc, aPos, "$A$1")) - CPPUNIT_FAIL("Wrong formula in C4."); + checkFormula(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); // Delete row 2 to push formula cells up (to C2:C3). m_pDoc->DeleteRow(ScRange(0,1,0,MAXCOL,1,0)); aPos = ScAddress(2,1,0); - if (!checkFormula(*m_pDoc, aPos, "A1")) - CPPUNIT_FAIL("Wrong formula in C2."); + checkFormula(*m_pDoc, aPos, "A1", "Wrong formula in C2."); aPos = ScAddress(2,2,0); - if (!checkFormula(*m_pDoc, aPos, "$A$1")) - CPPUNIT_FAIL("Wrong formula in C3."); + checkFormula(*m_pDoc, aPos, "$A$1", "Wrong formula in C3."); // Insert one row at row 2 to move them back. m_pDoc->InsertRow(ScRange(0,1,0,MAXCOL,1,0)); aPos = ScAddress(2,2,0); - if (!checkFormula(*m_pDoc, aPos, "A1")) - CPPUNIT_FAIL("Wrong formula in C3."); + checkFormula(*m_pDoc, aPos, "A1", "Wrong formula in C3."); aPos = ScAddress(2,3,0); - if (!checkFormula(*m_pDoc, aPos, "$A$1")) - CPPUNIT_FAIL("Wrong formula in C4."); + checkFormula(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); // Insert 2 rows at row 1 to shift all of A1 and C3:C4 down. m_pDoc->InsertRow(ScRange(0,0,0,MAXCOL,1,0)); aPos = ScAddress(2,4,0); - if (!checkFormula(*m_pDoc, aPos, "A3")) - CPPUNIT_FAIL("Wrong formula in C5."); + checkFormula(*m_pDoc, aPos, "A3", "Wrong formula in C5."); aPos = ScAddress(2,5,0); - if (!checkFormula(*m_pDoc, aPos, "$A$3")) - CPPUNIT_FAIL("Wrong formula in C6."); + checkFormula(*m_pDoc, aPos, "$A$3", "Wrong formula in C6."); // Delete 2 rows at row 1 to shift them back. m_pDoc->DeleteRow(ScRange(0,0,0,MAXCOL,1,0)); aPos = ScAddress(2,2,0); - if (!checkFormula(*m_pDoc, aPos, "A1")) - CPPUNIT_FAIL("Wrong formula in C3."); + checkFormula(*m_pDoc, aPos, "A1", "Wrong formula in C3."); aPos = ScAddress(2,3,0); - if (!checkFormula(*m_pDoc, aPos, "$A$1")) - CPPUNIT_FAIL("Wrong formula in C4."); + checkFormula(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); // Insert 3 columns at column B. to shift C3:C4 to F3:F4. m_pDoc->InsertCol(ScRange(1,0,0,3,MAXROW,0)); aPos = ScAddress(5,2,0); - if (!checkFormula(*m_pDoc, aPos, "A1")) - CPPUNIT_FAIL("Wrong formula in F3."); + checkFormula(*m_pDoc, aPos, "A1", "Wrong formula in F3."); aPos = ScAddress(5,3,0); - if (!checkFormula(*m_pDoc, aPos, "$A$1")) - CPPUNIT_FAIL("Wrong formula in F4."); + checkFormula(*m_pDoc, aPos, "$A$1", "Wrong formula in F4."); // Delete columns B:D to shift them back. m_pDoc->DeleteCol(ScRange(1,0,0,3,MAXROW,0)); aPos = ScAddress(2,2,0); - if (!checkFormula(*m_pDoc, aPos, "A1")) - CPPUNIT_FAIL("Wrong formula in C3."); + checkFormula(*m_pDoc, aPos, "A1", "Wrong formula in C3."); aPos = ScAddress(2,3,0); - if (!checkFormula(*m_pDoc, aPos, "$A$1")) - CPPUNIT_FAIL("Wrong formula in C4."); + checkFormula(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); // Insert cells over A1:A3 to only shift A1 down to A4. m_pDoc->InsertRow(ScRange(0,0,0,0,2,0)); aPos = ScAddress(2,2,0); - if (!checkFormula(*m_pDoc, aPos, "A4")) - CPPUNIT_FAIL("Wrong formula in C3."); + checkFormula(*m_pDoc, aPos, "A4", "Wrong formula in C3."); aPos = ScAddress(2,3,0); - if (!checkFormula(*m_pDoc, aPos, "$A$4")) - CPPUNIT_FAIL("Wrong formula in C4."); + checkFormula(*m_pDoc, aPos, "$A$4", "Wrong formula in C4."); // .. and back. m_pDoc->DeleteRow(ScRange(0,0,0,0,2,0)); aPos = ScAddress(2,2,0); - if (!checkFormula(*m_pDoc, aPos, "A1")) - CPPUNIT_FAIL("Wrong formula in C3."); + checkFormula(*m_pDoc, aPos, "A1", "Wrong formula in C3."); aPos = ScAddress(2,3,0); - if (!checkFormula(*m_pDoc, aPos, "$A$1")) - CPPUNIT_FAIL("Wrong formula in C4."); + checkFormula(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); // Delete row 1 which will delete the value cell (A1). m_pDoc->DeleteRow(ScRange(0,0,0,MAXCOL,0,0)); @@ -1003,78 +984,64 @@ void Test::testFormulaRefUpdate() m_pDoc->SetString(ScAddress(0,6,0), "=SUM($B$2:$C$3)"); aPos = ScAddress(0,5,0); - if (!checkFormula(*m_pDoc, aPos, "SUM(B2:C3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A6."); aPos = ScAddress(0,6,0); - if (!checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A7."); // Insert a row at row 1. m_pDoc->InsertRow(ScRange(0,0,0,MAXCOL,0,0)); aPos = ScAddress(0,6,0); - if (!checkFormula(*m_pDoc, aPos, "SUM(B3:C4)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, aPos, "SUM(B3:C4)", "Wrong formula in A7."); aPos = ScAddress(0,7,0); - if (!checkFormula(*m_pDoc, aPos, "SUM($B$3:$C$4)")) - CPPUNIT_FAIL("Wrong formula in A8."); + checkFormula(*m_pDoc, aPos, "SUM($B$3:$C$4)", "Wrong formula in A8."); // ... and back. m_pDoc->DeleteRow(ScRange(0,0,0,MAXCOL,0,0)); aPos = ScAddress(0,5,0); - if (!checkFormula(*m_pDoc, aPos, "SUM(B2:C3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A6."); aPos = ScAddress(0,6,0); - if (!checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A7."); // Insert columns B:C to shift only the value range. m_pDoc->InsertCol(ScRange(1,0,0,2,MAXROW,0)); aPos = ScAddress(0,5,0); - if (!checkFormula(*m_pDoc, aPos, "SUM(D2:E3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, aPos, "SUM(D2:E3)", "Wrong formula in A6."); aPos = ScAddress(0,6,0); - if (!checkFormula(*m_pDoc, aPos, "SUM($D$2:$E$3)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, aPos, "SUM($D$2:$E$3)", "Wrong formula in A7."); // ... and back. m_pDoc->DeleteCol(ScRange(1,0,0,2,MAXROW,0)); aPos = ScAddress(0,5,0); - if (!checkFormula(*m_pDoc, aPos, "SUM(B2:C3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A6."); aPos = ScAddress(0,6,0); - if (!checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A7."); // Insert rows 5:6 to shift the formula cells only. m_pDoc->InsertRow(ScRange(0,4,0,MAXCOL,5,0)); aPos = ScAddress(0,7,0); - if (!checkFormula(*m_pDoc, aPos, "SUM(B2:C3)")) - CPPUNIT_FAIL("Wrong formula in A8."); + checkFormula(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A8."); aPos = ScAddress(0,8,0); - if (!checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in A9."); + checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A9."); // ... and back. m_pDoc->DeleteRow(ScRange(0,4,0,MAXCOL,5,0)); aPos = ScAddress(0,5,0); - if (!checkFormula(*m_pDoc, aPos, "SUM(B2:C3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A6."); aPos = ScAddress(0,6,0); - if (!checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A7."); // Check the values of the formula cells in A6:A7. CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,5,0))); @@ -1131,11 +1098,9 @@ void Test::testFormulaRefUpdateRange() m_pDoc->SetString(ScAddress(0,6,0), "=SUM(B2:C5)"); m_pDoc->SetString(ScAddress(0,7,0), "=SUM($B$2:$C$5)"); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM(B2:C5)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM(B2:C5)", "Wrong formula in A7."); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "SUM($B$2:$C$5)")) - CPPUNIT_FAIL("Wrong formula in A8."); + checkFormula(*m_pDoc, ScAddress(0,7,0), "SUM($B$2:$C$5)", "Wrong formula in A8."); CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(ScAddress(0,6,0))); CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(ScAddress(0,7,0))); @@ -1143,11 +1108,9 @@ void Test::testFormulaRefUpdateRange() // Delete row 3. This should shrink the range references by one row. m_pDoc->DeleteRow(ScRange(0,2,0,MAXCOL,2,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM(B2:C4)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM(B2:C4)", "Wrong formula in A6."); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM($B$2:$C$4)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM($B$2:$C$4)", "Wrong formula in A7."); CPPUNIT_ASSERT_EQUAL(28.0, m_pDoc->GetValue(ScAddress(0,5,0))); CPPUNIT_ASSERT_EQUAL(28.0, m_pDoc->GetValue(ScAddress(0,6,0))); @@ -1155,11 +1118,9 @@ void Test::testFormulaRefUpdateRange() // Delete row 4 - bottom of range m_pDoc->DeleteRow(ScRange(0,3,0,MAXCOL,3,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(B2:C3)")) - CPPUNIT_FAIL("Wrong formula in A5."); + checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(B2:C3)", "Wrong formula in A5."); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($B$2:$C$3)", "Wrong formula in A6."); CPPUNIT_ASSERT_EQUAL(16.0, m_pDoc->GetValue(ScAddress(0,4,0))); CPPUNIT_ASSERT_EQUAL(16.0, m_pDoc->GetValue(ScAddress(0,5,0))); @@ -1167,11 +1128,9 @@ void Test::testFormulaRefUpdateRange() // Delete row 2 - top of range m_pDoc->DeleteRow(ScRange(0,1,0,MAXCOL,1,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,3,0), "SUM(B2:C2)")) - CPPUNIT_FAIL("Wrong formula in A4."); + checkFormula(*m_pDoc, ScAddress(0,3,0), "SUM(B2:C2)", "Wrong formula in A4."); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM($B$2:$C$2)")) - CPPUNIT_FAIL("Wrong formula in A5."); + checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM($B$2:$C$2)", "Wrong formula in A5."); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,3,0))); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,4,0))); @@ -1193,11 +1152,9 @@ void Test::testFormulaRefUpdateRange() m_pDoc->SetString(ScAddress(0,1,0), "=SUM(C2:F3)"); m_pDoc->SetString(ScAddress(0,2,0), "=SUM($C$2:$F$3)"); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C2:F3)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C2:F3)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$F$3)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$F$3)", "Wrong formula in A3."); CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(ScAddress(0,2,0))); @@ -1205,11 +1162,9 @@ void Test::testFormulaRefUpdateRange() // Delete column D. m_pDoc->DeleteCol(ScRange(3,0,0,3,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C2:E3)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C2:E3)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$E$3)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$E$3)", "Wrong formula in A3."); CPPUNIT_ASSERT_EQUAL(28.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(28.0, m_pDoc->GetValue(ScAddress(0,2,0))); @@ -1217,11 +1172,9 @@ void Test::testFormulaRefUpdateRange() // Delete column E - the right edge of reference range. m_pDoc->DeleteCol(ScRange(4,0,0,4,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C2:D3)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C2:D3)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$D$3)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$D$3)", "Wrong formula in A3."); CPPUNIT_ASSERT_EQUAL(16.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(16.0, m_pDoc->GetValue(ScAddress(0,2,0))); @@ -1229,11 +1182,9 @@ void Test::testFormulaRefUpdateRange() // Delete column C - the left edge of reference range. m_pDoc->DeleteCol(ScRange(2,0,0,2,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C2:C3)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C2:C3)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$C$3)", "Wrong formula in A3."); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,2,0))); @@ -1254,74 +1205,58 @@ void Test::testFormulaRefUpdateRange() m_pDoc->SetString(ScAddress(0,4,0), "=SUM(C2:D3)"); m_pDoc->SetString(ScAddress(0,5,0), "=SUM($C$2:$D$3)"); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(C2:D3)")) - CPPUNIT_FAIL("Wrong formula in A5."); + checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(C2:D3)", "Wrong formula in A5."); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$D$3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$D$3)", "Wrong formula in A6."); // Insert a column at column C. This should simply shift the reference without expansion. m_pDoc->InsertCol(ScRange(2,0,0,2,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(D2:E3)")) - CPPUNIT_FAIL("Wrong formula in A5."); + checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(D2:E3)", "Wrong formula in A5."); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($D$2:$E$3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($D$2:$E$3)", "Wrong formula in A6."); // Shift it back. m_pDoc->DeleteCol(ScRange(2,0,0,2,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(C2:D3)")) - CPPUNIT_FAIL("Wrong formula in A5."); + checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(C2:D3)", "Wrong formula in A5."); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$D$3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$D$3)", "Wrong formula in A6."); // Insert at column D. This should expand the reference by one column length. m_pDoc->InsertCol(ScRange(3,0,0,3,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(C2:E3)")) - CPPUNIT_FAIL("Wrong formula in A5."); + checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(C2:E3)", "Wrong formula in A5."); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$E$3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$E$3)", "Wrong formula in A6."); // Insert at column F. No expansion should occur since the edge expansion is turned off. m_pDoc->InsertCol(ScRange(5,0,0,5,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(C2:E3)")) - CPPUNIT_FAIL("Wrong formula in A5."); + checkFormula(*m_pDoc, ScAddress(0,4,0), "SUM(C2:E3)", "Wrong formula in A5."); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$E$3)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$E$3)", "Wrong formula in A6."); // Insert at row 2. No expansion should occur with edge expansion turned off. m_pDoc->InsertRow(ScRange(0,1,0,MAXCOL,1,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM(C3:E4)")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM(C3:E4)", "Wrong formula in A6."); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM($C$3:$E$4)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM($C$3:$E$4)", "Wrong formula in A7."); // Insert at row 4 to expand the reference range. m_pDoc->InsertRow(ScRange(0,3,0,MAXCOL,3,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM(C3:E5)")) - CPPUNIT_FAIL("Wrong formula in A7."); + checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM(C3:E5)", "Wrong formula in A7."); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "SUM($C$3:$E$5)")) - CPPUNIT_FAIL("Wrong formula in A8."); + checkFormula(*m_pDoc, ScAddress(0,7,0), "SUM($C$3:$E$5)", "Wrong formula in A8."); // Insert at row 6. No expansion with edge expansion turned off. m_pDoc->InsertRow(ScRange(0,5,0,MAXCOL,5,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "SUM(C3:E5)")) - CPPUNIT_FAIL("Wrong formula in A8."); + checkFormula(*m_pDoc, ScAddress(0,7,0), "SUM(C3:E5)", "Wrong formula in A8."); - if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "SUM($C$3:$E$5)")) - CPPUNIT_FAIL("Wrong formula in A9."); + checkFormula(*m_pDoc, ScAddress(0,8,0), "SUM($C$3:$E$5)", "Wrong formula in A9."); // Clear the range and start over. clearRange(m_pDoc, ScRange(0,0,0,20,20,0)); @@ -1339,47 +1274,37 @@ void Test::testFormulaRefUpdateRange() m_pDoc->SetString(ScAddress(0,1,0), "=SUM(C6:D7)"); m_pDoc->SetString(ScAddress(0,2,0), "=SUM($C$6:$D$7)"); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:D7)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:D7)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$D$7)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$D$7)", "Wrong formula in A3."); // Insert at column E. This should expand the reference range by one column. m_pDoc->InsertCol(ScRange(4,0,0,4,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:E7)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:E7)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$E$7)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$E$7)", "Wrong formula in A3."); // Insert at column C to edge-expand the reference range. m_pDoc->InsertCol(ScRange(2,0,0,2,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F7)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F7)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$7)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$7)", "Wrong formula in A3."); // Insert at row 8 to edge-expand. m_pDoc->InsertRow(ScRange(0,7,0,MAXCOL,7,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F8)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F8)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$8)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$8)", "Wrong formula in A3."); // Insert at row 6 to edge-expand. m_pDoc->InsertRow(ScRange(0,5,0,MAXCOL,5,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F9)")) - CPPUNIT_FAIL("Wrong formula in A2."); + checkFormula(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F9)", "Wrong formula in A2."); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$9)")) - CPPUNIT_FAIL("Wrong formula in A3."); + checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$9)", "Wrong formula in A3."); m_pDoc->DeleteTab(0); } @@ -1407,11 +1332,9 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->SetString(ScAddress(1,1,1), "=SUM(Sheet1.B2:C3)"); m_pDoc->SetString(ScAddress(1,2,1), "=SUM($Sheet1.$B$2:$C$3)"); - if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Swap the sheets. m_pDoc->MoveTab(0, 1); @@ -1420,11 +1343,9 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->GetName(1, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet1"), aName); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Swap back. m_pDoc->MoveTab(0, 1); @@ -1433,11 +1354,9 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->GetName(1, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Insert a new sheet between the two. m_pDoc->InsertTab(1, "Temp"); @@ -1447,38 +1366,30 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->GetName(2, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - if (!checkFormula(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Move the last sheet (Sheet2) to the first position. m_pDoc->MoveTab(2, 0); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Move back. m_pDoc->MoveTab(0, 2); - if (!checkFormula(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Move the "Temp" sheet to the last position. m_pDoc->MoveTab(1, 2); - if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Move back. m_pDoc->MoveTab(2, 1); @@ -1489,11 +1400,9 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->GetName(1, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Insert a new sheet before the first one. m_pDoc->InsertTab(0, "Temp"); @@ -1503,20 +1412,16 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->GetName(2, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - if (!checkFormula(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Delete the temporary sheet. m_pDoc->DeleteTab(0); - if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Append a bunch of sheets. m_pDoc->InsertTab(2, "Temp1"); @@ -1527,11 +1432,9 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->MoveTab(2, 4); m_pDoc->MoveTab(3, 2); - if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); // Delete the temp sheets. m_pDoc->DeleteTab(4); @@ -1543,11 +1446,9 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->GetName(0, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(#REF!.B2:C3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B2."); + checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(#REF!.B2:C3)", "Wrong formula in Sheet2.B2."); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($#REF!.$B$2:$C$3)")) - CPPUNIT_FAIL("Wrong formula in Sheet2.B3."); + checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($#REF!.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); m_pDoc->DeleteTab(0); } @@ -1580,8 +1481,7 @@ void Test::testFormulaRefUpdateInsertRows() CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,4,0))); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(1,5,0))); - if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "SUM(B4:B6)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,6,0), "SUM(B4:B6)", "Wrong formula!"); // Clear and start over. clearSheet(m_pDoc, 0); @@ -1603,8 +1503,7 @@ void Test::testFormulaRefUpdateInsertRows() CPPUNIT_ASSERT_MESSAGE("This formula cell should not be an error.", pFC->GetErrCode() == 0); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,5,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "MAX(A7:A9)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,5,0), "MAX(A7:A9)", "Wrong formula!"); m_pDoc->DeleteTab(0); } @@ -1619,28 +1518,22 @@ void Test::testFormulaRefUpdateSheetsDelete() m_pDoc->SetString(ScAddress(4,1,0), "=SUM(Sheet2.A4:Sheet4.A4)"); m_pDoc->SetString(ScAddress(4,2,0), "=SUM($Sheet2.A4:$Sheet4.A4)"); m_pDoc->DeleteTab(1); - if (!checkFormula(*m_pDoc, ScAddress(4,1,0), "SUM(Sheet3.A4:Sheet4.A4)")) - CPPUNIT_FAIL("Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(4,2,0), "SUM($Sheet3.A4:$Sheet4.A4)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(4,1,0), "SUM(Sheet3.A4:Sheet4.A4)", "Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(4,2,0), "SUM($Sheet3.A4:$Sheet4.A4)", "Wrong Formula"); m_pDoc->InsertTab(1, "Sheet2"); m_pDoc->SetString(ScAddress(5,1,3), "=SUM(Sheet1.A5:Sheet3.A5)"); m_pDoc->SetString(ScAddress(5,2,3), "=SUM($Sheet1.A5:$Sheet3.A5)"); m_pDoc->DeleteTab(2); - if (!checkFormula(*m_pDoc, ScAddress(5,1,2), "SUM(Sheet1.A5:Sheet2.A5)")) - CPPUNIT_FAIL("Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(5,2,2), "SUM($Sheet1.A5:$Sheet2.A5)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(5,1,2), "SUM(Sheet1.A5:Sheet2.A5)", "Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(5,2,2), "SUM($Sheet1.A5:$Sheet2.A5)", "Wrong Formula"); m_pDoc->InsertTab(2, "Sheet3"); m_pDoc->SetString(ScAddress(6,1,3), "=SUM(Sheet1.A6:Sheet3.A6)"); m_pDoc->SetString(ScAddress(6,2,3), "=SUM($Sheet1.A6:$Sheet3.A6)"); m_pDoc->DeleteTabs(0,3); - if (!checkFormula(*m_pDoc, ScAddress(6,1,0), "SUM(#REF!.A6:#REF!.A6)")) - CPPUNIT_FAIL("Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(6,2,0), "SUM($#REF!.A6:$#REF!.A6)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(6,1,0), "SUM(#REF!.A6:#REF!.A6)", "Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(6,2,0), "SUM($#REF!.A6:$#REF!.A6)", "Wrong Formula"); m_pDoc->InsertTab(0, "Sheet1"); m_pDoc->InsertTab(1, "Sheet2"); m_pDoc->InsertTab(2, "Sheet3"); @@ -1655,43 +1548,31 @@ void Test::testFormulaRefUpdateSheetsDelete() m_pDoc->DeleteTab(2); - if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.A2:Sheet2.A2)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.A2:Sheet2.A2)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(2,1,1), "SUM(Sheet1.A1:Sheet2.A1)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(2,1,1), "SUM(Sheet1.A1:Sheet2.A1)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(3,1,1), "SUM(Sheet2.A3:Sheet4.A3)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(3,1,1), "SUM(Sheet2.A3:Sheet4.A3)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.A2:$Sheet2.A2)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.A2:$Sheet2.A2)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(2,2,1), "SUM($Sheet1.A1:$Sheet2.A1)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(2,2,1), "SUM($Sheet1.A1:$Sheet2.A1)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(3,2,1), "SUM($Sheet2.A3:$Sheet4.A3)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(3,2,1), "SUM($Sheet2.A3:$Sheet4.A3)", "Wrong Formula"); m_pDoc->DeleteTab(0); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet2.A2:Sheet2.A2)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet2.A2:Sheet2.A2)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "SUM(Sheet2.A1:Sheet2.A1)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(2,1,0), "SUM(Sheet2.A1:Sheet2.A1)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(3,1,0), "SUM(Sheet2.A3:Sheet4.A3)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(3,1,0), "SUM(Sheet2.A3:Sheet4.A3)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet2.A2:$Sheet2.A2)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet2.A2:$Sheet2.A2)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(2,2,0), "SUM($Sheet2.A1:$Sheet2.A1)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(2,2,0), "SUM($Sheet2.A1:$Sheet2.A1)", "Wrong Formula"); - if (!checkFormula(*m_pDoc, ScAddress(3,2,0), "SUM($Sheet2.A3:$Sheet4.A3)")) - CPPUNIT_FAIL("Wrong Formula"); + checkFormula(*m_pDoc, ScAddress(3,2,0), "SUM($Sheet2.A3:$Sheet4.A3)", "Wrong Formula"); m_pDoc->DeleteTab(0); m_pDoc->DeleteTab(0); @@ -1720,8 +1601,7 @@ void Test::testFormulaRefUpdateInsertColumns() rFunc.InsertCells(ScRange(0,0,0,1,MAXROW,0), &aMark, INS_INSCOLS_BEFORE, false, true, false); // Now, the original column B has moved to column D. - if (!checkFormula(*m_pDoc, ScAddress(3,3,0), "SUM(D1:D3)")) - CPPUNIT_FAIL("Wrong formula in D4 after column insertion."); + checkFormula(*m_pDoc, ScAddress(3,3,0), "SUM(D1:D3)", "Wrong formula in D4 after column insertion."); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(3,3,0))); @@ -1761,17 +1641,13 @@ void Test::testFormulaRefUpdateMove() CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,10,0)); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0,11,0)); - if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "SUM(D4:D6)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,8,0), "SUM(D4:D6)", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM($D$4:$D$6)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM($D$4:$D$6)", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(0,10,0), "D5")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,10,0), "D5", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(0,11,0), "$D$6")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,11,0), "$D$6", "Wrong formula."); // Move A9:A12 to B10:B13. bMoved = rFunc.MoveBlock(ScRange(0,8,0,0,11,0), ScAddress(1,9,0), true, false, false, false); @@ -1784,17 +1660,13 @@ void Test::testFormulaRefUpdateMove() CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(1,12,0)); // Displayed formulas should stay the same since the referenced range hasn't moved. - if (!checkFormula(*m_pDoc, ScAddress(1,9,0), "SUM(D4:D6)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(1,9,0), "SUM(D4:D6)", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(1,10,0), "SUM($D$4:$D$6)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(1,10,0), "SUM($D$4:$D$6)", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(1,11,0), "D5")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(1,11,0), "D5", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(1,12,0), "$D$6")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(1,12,0), "$D$6", "Wrong formula."); // The value cells are in D4:D6. Move D4:D5 to the right but leave D6 // where it is. @@ -1807,17 +1679,13 @@ void Test::testFormulaRefUpdateMove() CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1,11,0)); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(1,12,0)); - if (!checkFormula(*m_pDoc, ScAddress(1,9,0), "SUM(D4:D6)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(1,9,0), "SUM(D4:D6)", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(1,10,0), "SUM($D$4:$D$6)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(1,10,0), "SUM($D$4:$D$6)", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(1,11,0), "E5")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(1,11,0), "E5", "Wrong formula."); - if (!checkFormula(*m_pDoc, ScAddress(1,12,0), "$D$6")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(1,12,0), "$D$6", "Wrong formula."); m_pDoc->DeleteTab(0); } @@ -1837,34 +1705,28 @@ void Test::testFormulaRefUpdateMoveUndo() // Set formulas with single cell references in A6:A8. m_pDoc->SetString(ScAddress(0,5,0), "=A1"); CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,5,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "A1")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "A1", "Wrong formula."); m_pDoc->SetString(ScAddress(0,6,0), "=A1+A2+A3"); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,6,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "A1+A2+A3")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,6,0), "A1+A2+A3", "Wrong formula."); m_pDoc->SetString(ScAddress(0,7,0), "=A1+A3+A4"); CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(0,7,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "A1+A3+A4")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,7,0), "A1+A3+A4", "Wrong formula."); // Set formulas with range references in A10:A12. m_pDoc->SetString(ScAddress(0,9,0), "=SUM(A1:A2)"); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM(A1:A2)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM(A1:A2)", "Wrong formula."); m_pDoc->SetString(ScAddress(0,10,0), "=SUM(A1:A3)"); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,10,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,10,0), "SUM(A1:A3)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,10,0), "SUM(A1:A3)", "Wrong formula."); m_pDoc->SetString(ScAddress(0,11,0), "=SUM(A1:A4)"); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,11,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)", "Wrong formula."); // Move A1:A3 to C1:C3. Note that A4 remains. ScDocFunc& rFunc = getDocShell().GetDocFunc(); @@ -1872,28 +1734,22 @@ void Test::testFormulaRefUpdateMoveUndo() CPPUNIT_ASSERT(bMoved); CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,5,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "C1")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "C1", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,6,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "C1+C2+C3")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,6,0), "C1+C2+C3", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(0,7,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "C1+C3+A4")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,7,0), "C1+C3+A4", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM(C1:C2)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM(C1:C2)", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,10,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,10,0), "SUM(C1:C3)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,10,0), "SUM(C1:C3)", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,11,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)", "Wrong formula."); // Undo the move. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); @@ -1901,28 +1757,22 @@ void Test::testFormulaRefUpdateMoveUndo() pUndoMgr->Undo(); CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,5,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "A1")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "A1", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,6,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "A1+A2+A3")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,6,0), "A1+A2+A3", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(0,7,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "A1+A3+A4")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,7,0), "A1+A3+A4", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM(A1:A2)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM(A1:A2)", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,10,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,10,0), "SUM(A1:A3)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,10,0), "SUM(A1:A3)", "Wrong formula."); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,11,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)")) - CPPUNIT_FAIL("Wrong formula."); + checkFormula(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)", "Wrong formula."); // Make sure the broadcasters are still valid by changing the value of A1. m_pDoc->SetValue(ScAddress(0,0,0), 20); @@ -1951,11 +1801,9 @@ void Test::testFormulaRefUpdateMoveToSheet() m_pDoc->SetString(ScAddress(1,0,0), "=A1"); m_pDoc->SetString(ScAddress(1,1,0), "=A2"); - if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A1")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A1", "Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A2")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "A2", "Wrong formula"); CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(1,0,0))); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(1,1,0))); @@ -1965,30 +1813,24 @@ void Test::testFormulaRefUpdateMoveToSheet() bool bMoved = rFunc.MoveBlock(ScRange(0,0,0,0,1,0), ScAddress(1,2,1), true, true, false, true); CPPUNIT_ASSERT(bMoved); - if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3", "Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4", "Wrong formula"); // Undo and check again. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); pUndoMgr->Undo(); - if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A1")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A1", "Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A2")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "A2", "Wrong formula"); // Redo and check. pUndoMgr->Redo(); - if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3", "Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4", "Wrong formula"); m_pDoc->DeleteTab(1); m_pDoc->DeleteTab(0); @@ -2057,8 +1899,7 @@ void Test::testFormulaRefUpdateDeleteAndShiftLeft() aPos.IncCol(-2); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:E1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:E1)", "Wrong formula!"); // Undo and check. SfxUndoManager* pUndo = m_pDoc->GetUndoManager(); @@ -2067,8 +1908,7 @@ void Test::testFormulaRefUpdateDeleteAndShiftLeft() pUndo->Undo(); aPos.IncCol(2); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:G1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:G1)", "Wrong formula!"); // Delete columns C:D (left end of the reference). bDeleted = rFunc.DeleteCells(ScRange(2,0,0,3,MAXROW,0), &aMark, DEL_CELLSLEFT, true, true); @@ -2076,15 +1916,13 @@ void Test::testFormulaRefUpdateDeleteAndShiftLeft() aPos.IncCol(-2); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:E1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:E1)", "Wrong formula!"); // Undo and check again. pUndo->Undo(); aPos.IncCol(2); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:G1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:G1)", "Wrong formula!"); // Delete columns B:E (overlaps on the left). bDeleted = rFunc.DeleteCells(ScRange(1,0,0,4,MAXROW,0), &aMark, DEL_CELLSLEFT, true, true); @@ -2092,15 +1930,13 @@ void Test::testFormulaRefUpdateDeleteAndShiftLeft() aPos.IncCol(-4); CPPUNIT_ASSERT_EQUAL(9.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(B1:C1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(B1:C1)", "Wrong formula!"); // Undo and check again. pUndo->Undo(); aPos.IncCol(4); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:G1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:G1)", "Wrong formula!"); // Start over with a new scenario. clearSheet(m_pDoc, 0); @@ -2119,28 +1955,24 @@ void Test::testFormulaRefUpdateDeleteAndShiftLeft() CPPUNIT_ASSERT(bDeleted); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:E1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:E1)", "Wrong formula!"); // Undo and check. pUndo->Undo(); CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:H1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:H1)", "Wrong formula!"); // Delete columns G:I (overlaps on the right). bDeleted = rFunc.DeleteCells(ScRange(6,0,0,8,MAXROW,0), &aMark, DEL_CELLSLEFT, true, true); CPPUNIT_ASSERT(bDeleted); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:F1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:F1)", "Wrong formula!"); // Undo and check again. pUndo->Undo(); CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(C1:H1)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(C1:H1)", "Wrong formula!"); m_pDoc->DeleteTab(0); } @@ -2170,8 +2002,7 @@ void Test::testFormulaRefUpdateDeleteAndShiftUp() aPos.IncRow(-2); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A5)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A5)", "Wrong formula!"); // Undo and check. SfxUndoManager* pUndo = m_pDoc->GetUndoManager(); @@ -2180,8 +2011,7 @@ void Test::testFormulaRefUpdateDeleteAndShiftUp() pUndo->Undo(); aPos.IncRow(2); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A7)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A7)", "Wrong formula!"); // Delete rows 3:4 (top end of the reference). bDeleted = rFunc.DeleteCells(ScRange(0,2,0,MAXCOL,3,0), &aMark, DEL_CELLSUP, true, true); @@ -2189,15 +2019,13 @@ void Test::testFormulaRefUpdateDeleteAndShiftUp() aPos.IncRow(-2); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A5)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A5)", "Wrong formula!"); // Undo and check again. pUndo->Undo(); aPos.IncRow(2); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A7)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A7)", "Wrong formula!"); // Delete rows 2:5 (overlaps on the top). bDeleted = rFunc.DeleteCells(ScRange(0,1,0,MAXCOL,4,0), &aMark, DEL_CELLSUP, true, true); @@ -2205,15 +2033,13 @@ void Test::testFormulaRefUpdateDeleteAndShiftUp() aPos.IncRow(-4); CPPUNIT_ASSERT_EQUAL(9.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A2:A3)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A2:A3)", "Wrong formula!"); // Undo and check again. pUndo->Undo(); aPos.IncRow(4); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A7)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A7)", "Wrong formula!"); // Start over with a new scenario. clearSheet(m_pDoc, 0); @@ -2232,28 +2058,24 @@ void Test::testFormulaRefUpdateDeleteAndShiftUp() CPPUNIT_ASSERT(bDeleted); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A5)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A5)", "Wrong formula!"); // Undo and check. pUndo->Undo(); CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A8)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A8)", "Wrong formula!"); // Delete rows 7:9 (overlaps on the bottom). bDeleted = rFunc.DeleteCells(ScRange(0,6,0,MAXCOL,8,0), &aMark, DEL_CELLSUP, true, true); CPPUNIT_ASSERT(bDeleted); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A6)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A6)", "Wrong formula!"); // Undo and check again. pUndo->Undo(); CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(aPos)); - if (!checkFormula(*m_pDoc, aPos, "SUM(A3:A8)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, aPos, "SUM(A3:A8)", "Wrong formula!"); m_pDoc->DeleteTab(0); } @@ -3069,12 +2891,9 @@ void Test::testFuncROW() ScMarkData aMark; aMark.SelectOneTable(0); rFunc.InsertCells(ScRange(0,3,0,MAXCOL,3,0), &aMark, INS_INSROWS_BEFORE, false, true, false); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "ROW(A6)")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "ROW(B6)")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "ROW(B7)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,1,0), "ROW(A6)", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "ROW(B6)", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "ROW(B7)", "Wrong formula!"); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,1,0))); diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index c0772f1..5f3cedd 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -286,12 +286,9 @@ void Test::testSharedFormulasRefUpdate() insertRangeData(m_pDoc, ScAddress(1,0,0), pData, SAL_N_ELEMENTS(pData)); } - if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A10")) - CPPUNIT_FAIL("Wrong formula in B1"); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A11")) - CPPUNIT_FAIL("Wrong formula in B2"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A12")) - CPPUNIT_FAIL("Wrong formula in B3"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "A11", "Wrong formula in B2"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "A12", "Wrong formula in B3"); const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC && pFC->IsShared()); @@ -300,12 +297,9 @@ void Test::testSharedFormulasRefUpdate() // Insert cells over A11:B11 to shift to right. This should split the B1:B3 grouping into 3. 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"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "C11", "Wrong formula in B2"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "A12", "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()); @@ -317,12 +311,9 @@ void Test::testSharedFormulasRefUpdate() // Delelte cells over A11:B11 to bring it back to the previous state. m_pDoc->DeleteCol(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), "A11")) - CPPUNIT_FAIL("Wrong formula in B2"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A12")) - CPPUNIT_FAIL("Wrong formula in B3"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "A11", "Wrong formula in B2"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "A12", "Wrong formula in B3"); pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC && pFC->IsShared()); @@ -331,12 +322,9 @@ void Test::testSharedFormulasRefUpdate() // Insert cells over A11:A12 and shift down. m_pDoc->InsertRow(ScRange(0,10,0,0,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), "A13")) - CPPUNIT_FAIL("Wrong formula in B2"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A14")) - CPPUNIT_FAIL("Wrong formula in B3"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "A13", "Wrong formula in B2"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "A14", "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()); @@ -348,12 +336,9 @@ void Test::testSharedFormulasRefUpdate() // Delete A11:A12 to bring it back to the way it was. m_pDoc->DeleteRow(ScRange(0,10,0,0,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), "A11")) - CPPUNIT_FAIL("Wrong formula in B2"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A12")) - CPPUNIT_FAIL("Wrong formula in B3"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "A11", "Wrong formula in B2"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "A12", "Wrong formula in B3"); pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC && pFC->IsShared()); @@ -362,12 +347,9 @@ void Test::testSharedFormulasRefUpdate() // 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"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "C11", "Wrong formula in B2"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "A12", "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()); @@ -378,12 +360,9 @@ void Test::testSharedFormulasRefUpdate() // 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"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "C11", "Wrong formula in B2"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "C12", "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()); @@ -395,12 +374,9 @@ void Test::testSharedFormulasRefUpdate() // 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"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "C10", "Wrong formula in B1"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "C11", "Wrong formula in B2"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "C12", "Wrong formula in B3"); // B1:B3 should be now grouped. pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); @@ -451,9 +427,9 @@ void Test::testSharedFormulasRefUpdateMove() CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(1,2,0))); // The formulas should have been adjusted for the move. - CPPUNIT_ASSERT(checkFormula(*m_pDoc, ScAddress(2,1,0), "R[-1]C[-1]")); - CPPUNIT_ASSERT(checkFormula(*m_pDoc, ScAddress(2,2,0), "R[-1]C[-1]")); - CPPUNIT_ASSERT(checkFormula(*m_pDoc, ScAddress(2,3,0), "R[-1]C[-1]")); + checkFormula(*m_pDoc, ScAddress(2,1,0), "R[-1]C[-1]", "Wrong Formula!"); + checkFormula(*m_pDoc, ScAddress(2,2,0), "R[-1]C[-1]", "Wrong Formula!"); + checkFormula(*m_pDoc, ScAddress(2,3,0), "R[-1]C[-1]", "Wrong Formula!"); SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); CPPUNIT_ASSERT(pUndoMgr); @@ -465,9 +441,9 @@ void Test::testSharedFormulasRefUpdateMove() CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(1,3,0))); // And the formulas should have been re-adjusted to their original references. - CPPUNIT_ASSERT(checkFormula(*m_pDoc, ScAddress(2,1,0), "RC[-1]")); - CPPUNIT_ASSERT(checkFormula(*m_pDoc, ScAddress(2,2,0), "RC[-1]")); - CPPUNIT_ASSERT(checkFormula(*m_pDoc, ScAddress(2,3,0), "RC[-1]")); + checkFormula(*m_pDoc, ScAddress(2,1,0), "RC[-1]", "Wrong Formula!"); + checkFormula(*m_pDoc, ScAddress(2,2,0), "RC[-1]", "Wrong Formula!"); + checkFormula(*m_pDoc, ScAddress(2,3,0), "RC[-1]", "Wrong Formula!"); m_pDoc->DeleteTab(0); } @@ -564,12 +540,9 @@ void Test::testSharedFormulasRefUpdateRange() insertRangeData(m_pDoc, ScAddress(1,2,0), pData, SAL_N_ELEMENTS(pData)); } - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($A$3:$A$5)")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,3,0), "SUM($A$3:$A$5)")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "SUM($A$3:$A$5)")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($A$3:$A$5)", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,3,0), "SUM($A$3:$A$5)", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,4,0), "SUM($A$3:$A$5)", "Wrong formula"); // B3:B5 should be shared. const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,2,0)); @@ -593,12 +566,9 @@ void Test::testSharedFormulasRefUpdateRange() CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(4), pFC->GetSharedTopRow()); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength()); - if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "SUM($A$5:$A$7)")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,5,0), "SUM($A$5:$A$7)")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "SUM($A$5:$A$7)")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,4,0), "SUM($A$5:$A$7)", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,5,0), "SUM($A$5:$A$7)", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(1,6,0), "SUM($A$5:$A$7)", "Wrong formula"); m_pDoc->DeleteTab(0); } @@ -751,14 +721,10 @@ void Test::testSharedFormulasRefUpdateExternal() CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0))); // Check the formulas too. - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A1")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "'file:///extdata.fake'#$Data.A2")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "'file:///extdata.fake'#$Data.A3")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A1", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,7,0), "'file:///extdata.fake'#$Data.A2", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,8,0), "'file:///extdata.fake'#$Data.A3", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,9,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)", "Wrong formula!"); // Delete rows 1 and 2. This should not change the references in the formula cells below. ScDocFunc& rDocFunc = getDocShell().GetDocFunc(); @@ -767,38 +733,26 @@ void Test::testSharedFormulasRefUpdateExternal() rDocFunc.DeleteCells(ScRange(0,0,0,MAXCOL,1,0), &aMark, DEL_CELLSUP, true, true); // Check the shifted formula cells now in A5:A8. - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "'file:///extdata.fake'#$Data.A1")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "'file:///extdata.fake'#$Data.A2")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A3")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,4,0), "'file:///extdata.fake'#$Data.A1", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,5,0), "'file:///extdata.fake'#$Data.A2", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A3", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,7,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)", "Wrong formula!"); // Undo and check the formulas again. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); CPPUNIT_ASSERT(pUndoMgr); pUndoMgr->Undo(); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A1")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "'file:///extdata.fake'#$Data.A2")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "'file:///extdata.fake'#$Data.A3")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A1", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,7,0), "'file:///extdata.fake'#$Data.A2", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,8,0), "'file:///extdata.fake'#$Data.A3", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,9,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)", "Wrong formula!"); // Redo the row deletion and check the formulas again. pUndoMgr->Redo(); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "'file:///extdata.fake'#$Data.A1")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "'file:///extdata.fake'#$Data.A2")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A3")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,4,0), "'file:///extdata.fake'#$Data.A1", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,5,0), "'file:///extdata.fake'#$Data.A2", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A3", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(0,7,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)", "Wrong formula!"); xExtDocSh->DoClose(); @@ -815,10 +769,11 @@ void Test::testSharedFormulasInsertRow() SCROW pRows[] = { 0, 1, 3, 4 }; for (size_t i = 0, n = SAL_N_ELEMENTS(pRows); i < n; ++i) { + bool aPass; ScAddress aPos(1, pRows[i], 0); - if (!checkFormula(*pDoc, aPos, "$A$5")) + checkFormula(*pDoc, aPos, "$A$5", "Wrong Formula", aPass); + if(!aPass) { - cerr << "Wrong formula!" << endl; return false; } } @@ -846,10 +801,11 @@ void Test::testSharedFormulasInsertRow() { for (SCROW i = 0; i <= 3; ++i) { + bool aPass; ScAddress aPos(1,i,0); - if (!checkFormula(*pDoc, aPos, "$A$4")) + checkFormula(*pDoc, aPos, "$A$4", "Wrong Formula!", aPass); + if(!aPass) { - cerr << "Wrong formula!" << endl; return false; } } @@ -1133,8 +1089,7 @@ void Test::testSharedFormulasRefUpdateMoveSheets() for (SCROW i = 0; i <= 7; ++i) { CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,1))); - if (!checkFormula(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC")) - CPPUNIT_FAIL("Wrong formula expression."); + checkFormula(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC", "Wrong formula expression."); } // Insert a new sheet at the left end. @@ -1152,8 +1107,7 @@ void Test::testSharedFormulasRefUpdateMoveSheets() for (SCROW i = 0; i <= 7; ++i) { CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,2))); - if (!checkFormula(*m_pDoc, ScAddress(0,i,2), "Sheet2!RC")) - CPPUNIT_FAIL("Wrong formula expression."); + checkFormula(*m_pDoc, ScAddress(0,i,2), "Sheet2!RC", "Wrong formula expression."); } // Delete Sheet4. @@ -1170,8 +1124,7 @@ void Test::testSharedFormulasRefUpdateMoveSheets() for (SCROW i = 0; i <= 7; ++i) { CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,1))); - if (!checkFormula(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC")) - CPPUNIT_FAIL("Wrong formula expression."); + checkFormula(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC", "Wrong formula expression."); } m_pDoc->DeleteTab(2); @@ -1199,11 +1152,9 @@ void Test::testSharedFormulasRefUpdateCopySheets() // Copy Sheet1 and insert the copied sheet before the current Sheet1 position. m_pDoc->CopyTab(0, 0); - if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "$Sheet2.A1")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,0,0), "$Sheet2.A1", "Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "$Sheet2.A2")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,1,0), "$Sheet2.A2", "Wrong formula"); // Check the values on the copied sheet. CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0))); @@ -1240,35 +1191,26 @@ void Test::testSharedFormulasRefUpdateDeleteSheets() CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,2,0))); - if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "Sheet2.B2")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "Sheet2.B3")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "Sheet2.B4")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,0,0), "Sheet2.B2", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,1,0), "Sheet2.B3", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,2,0), "Sheet2.B4", "Wrong formula"); // Delete Sheet2. ScDocFunc& rFunc = getDocShell().GetDocFunc(); rFunc.DeleteTable(1, true, true); - if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "#REF!.B2")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "#REF!.B3")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "#REF!.B4")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,0,0), "#REF!.B2", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,1,0), "#REF!.B3", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,2,0), "#REF!.B4", "Wrong formula"); // Undo the deletion and make sure the formulas are back to the way they were. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); CPPUNIT_ASSERT(pUndoMgr); pUndoMgr->Undo(); - if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "Sheet2.B2")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "Sheet2.B3")) - CPPUNIT_FAIL("Wrong formula"); - if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "Sheet2.B4")) - CPPUNIT_FAIL("Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,0,0), "Sheet2.B2", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,1,0), "Sheet2.B3", "Wrong formula"); + checkFormula(*m_pDoc, ScAddress(0,2,0), "Sheet2.B4", "Wrong formula"); // TODO: We can't test redo yet as ScUndoDeleteTab::Redo() relies on // view shell to do its thing. @@ -1367,11 +1309,9 @@ void Test::testSharedFormulaInsertColumn() // Insert a single column at Column F. This used to crash before fdo#74041. m_pDoc->InsertCol(ScRange(5,0,0,5,MAXROW,0)); - if (!checkFormula(*m_pDoc, ScAddress(8,1,0), "H3*B3")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(8,1,0), "H3*B3", "Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(8,2,0), "H4*B4")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(8,2,0), "H4*B4", "Wrong formula!"); m_pDoc->DeleteTab(0); } @@ -1562,20 +1502,13 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange() rFunc.ModifyAllRangeNames(aNewNames); // Check to make sure all displayed formulas are still good. - if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "SUM(MyRange)")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(MyRange)")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM(MyRange)")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "ROW()")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "ROW()")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,7,0), "ROW()")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "AVERAGE(MyRange)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,0,0), "SUM(MyRange)", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(MyRange)", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM(MyRange)", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,4,0), "ROW()", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,6,0), "ROW()", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,7,0), "ROW()", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(2,0,0), "AVERAGE(MyRange)", "Wrong formula!"); // Check the calculation results as well. CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,0,0))); diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx index 8e183ff..9452489 100644 --- a/sc/qa/unit/ucalc_sort.cxx +++ b/sc/qa/unit/ucalc_sort.cxx @@ -182,12 +182,9 @@ void Test::testSortHorizontal() CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); } - if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "CONCATENATE(C2;\"-\";D2)")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "CONCATENATE(C3;\"-\";D3)")) - CPPUNIT_FAIL("Wrong formula!"); - if (!checkFormula(*m_pDoc, ScAddress(1,3,0), "CONCATENATE(C4;\"-\";D4)")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,1,0), "CONCATENATE(C2;\"-\";D2)", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,2,0), "CONCATENATE(C3;\"-\";D3)", "Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,3,0), "CONCATENATE(C4;\"-\";D4)", "Wrong formula!"); m_pDoc->DeleteTab(0); } @@ -763,8 +760,7 @@ void Test::testSortRefUpdate() } // C2 should now point to A4. - if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]")) - CPPUNIT_FAIL("Wrong formula in C2!"); + checkFormula(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]", "Wrong formula in C2!"); // Undo the sort. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); @@ -787,8 +783,7 @@ void Test::testSortRefUpdate() } // C2 should now point to A2. - if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "RC[-2]")) - CPPUNIT_FAIL("Wrong formula in C2!"); + checkFormula(*m_pDoc, ScAddress(2,1,0), "RC[-2]", "Wrong formula in C2!"); // Redo. pUndoMgr->Redo(); @@ -809,8 +804,7 @@ void Test::testSortRefUpdate() } // C2 should now point to A4. - if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]")) - CPPUNIT_FAIL("Wrong formula in C2!"); + checkFormula(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]", "Wrong formula in C2!"); // Undo again. pUndoMgr->Undo(); @@ -913,8 +907,7 @@ void Test::testSortRefUpdate2() // Formulas in column B should still point to their respective left neighbor cell. for (SCROW i = 1; i <= 4; ++i) { - if (!checkFormula(*m_pDoc, ScAddress(1,i,0), "RC[-1]")) - CPPUNIT_FAIL("Wrong formula!"); + checkFormula(*m_pDoc, ScAddress(1,i,0), "RC[-1]", "Wrong formula!"); } // Undo and check the result in column B. @@ -994,12 +987,9 @@ void Test::testSortRefUpdate3() CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,5,0))); // Make sure the formula cells have been adjusted correctly. - if (!checkFormula(*m_pDoc, ScAddress(0,3,0), "A2+A3")) - CPPUNIT_FAIL("Wrong formula in A4."); - if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "A2+10")) - CPPUNIT_FAIL("Wrong formula in A5."); - if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "A3+10")) - CPPUNIT_FAIL("Wrong formula in A6."); + checkFormula(*m_pDoc, ScAddress(0,3,0), "A2+A3", "Wrong formula in A4."); + checkFormula(*m_pDoc, ScAddress(0,4,0), "A2+10", "Wrong formula in A5."); + checkFormula(*m_pDoc, ScAddress(0,5,0), "A3+10", "Wrong formula in A6."); // Undo and check the result. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); @@ -1148,8 +1138,7 @@ void Test::testSortRefUpdate4_Impl() { for (SCCOL nCol=0; nCol < 4; ++nCol) { - if (!checkFormula(*m_pDoc, ScAddress(nCol,nRow+1,0), aCheck[nRow][nCol])) - CPPUNIT_FAIL(OString("Wrong formula in " + OString('A'+nCol) + OString::number(nRow+2) + ".").getStr()); + checkFormula(*m_pDoc, ScAddress(nCol,nRow+1,0), aCheck[nRow][nCol], OString("Wrong formula in " + OString('A'+nCol) + OString::number(nRow+2) + ".").getStr()); } } @@ -1220,8 +1209,7 @@ void Test::testSortRefUpdate4_Impl() { for (SCCOL nCol=0; nCol < 4; ++nCol) { - if (!checkFormula(*m_pDoc, ScAddress(nCol,nRow+1,0), aCheck[nRow][nCol])) - CPPUNIT_FAIL(OString("Wrong formula in " + OString('A'+nCol) + OString::number(nRow+2) + ".").getStr()); + checkFormula(*m_pDoc, ScAddress(nCol,nRow+1,0), aCheck[nRow][nCol], OString("Wrong formula in " + OString('A'+nCol) + OString::number(nRow+2) + ".").getStr()); } } } @@ -1314,8 +1302,7 @@ void Test::testSortRefUpdate5() }; for (SCROW nRow=0; nRow < static_cast<SCROW>(SAL_N_ELEMENTS(aFormulaCheck)); ++nRow) { - if (!checkFormula(*m_pDoc, ScAddress(1,nRow+1,0), aFormulaCheck[nRow])) - CPPUNIT_FAIL(OString("Wrong formula in B" + OString::number(nRow+2) + ".").getStr()); + checkFormula(*m_pDoc, ScAddress(1,nRow+1,0), aFormulaCheck[nRow], OString("Wrong formula in B" + OString::number(nRow+2) + ".").getStr()); } ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits