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