From 51d0b4037b36a4a74c9181b95edb18017542ab79 Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Wed, 9 Mar 2016 15:23:11 +0100 Subject: tdf#84938 Change defines to typed_flags Put defines into an enum class and use typed_flags template from o3tl to give them flag operators. There were some shift operations to apply flags from start references to end references, these went into a helper in address.hxx to hide them. A marco with shift operations in address.cxx was rewritten in two helpers without shifts. One shift remained in ScRange::Format with a comment. The other flag untypical operator was a minus 1 in a helper for ScRefFinder::ToggleRel, which iteratates through all possible combinations for absolute references. This is used to make referecnces absolute via SHIFT+F4. A replacement would be too complex. Change-Id: I4850f1623e01e56c60ac2260b95fc5cad8b6fd71 Signed-off-by: Jochen Nitschke Reviewed-on: https://gerrit.libreoffice.org/22840 Tested-by: Jenkins Reviewed-by: Eike Rathke Tested-by: Eike Rathke --- sc/qa/unit/copy_paste_test.cxx | 4 +- sc/qa/unit/helper/qahelper.cxx | 14 ++-- sc/qa/unit/ucalc.cxx | 2 +- sc/qa/unit/ucalc_formula.cxx | 164 +++++++++++++++++++++------------------- sc/qa/unit/ucalc_pivottable.cxx | 6 +- sc/qa/unit/ucalc_sort.cxx | 2 +- 6 files changed, 101 insertions(+), 91 deletions(-) (limited to 'sc/qa') diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx index e0bd40279639..44a24d625227 100644 --- a/sc/qa/unit/copy_paste_test.cxx +++ b/sc/qa/unit/copy_paste_test.cxx @@ -77,8 +77,8 @@ void ScCopyPasteTest::testCopyPasteXLS() // 2. Highlight B2:C5 ScRange aSrcRange; - sal_uInt16 nRes = aSrcRange.Parse("B2:C5", &rDoc, rDoc.GetAddressConvention()); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + ScRefFlags nRes = aSrcRange.Parse("B2:C5", &rDoc, rDoc.GetAddressConvention()); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); ScMarkData aMark; aMark.SetMarkArea(aSrcRange); diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index ad32a2077c7d..96dbf5c75f12 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -392,8 +392,8 @@ ScRangeList getChartRanges(ScDocument& rDoc, const SdrOle2Obj& rChartObj) for (size_t i = 0, n = aRangeReps.size(); i < n; ++i) { ScRange aRange; - sal_uInt16 nRes = aRange.Parse(aRangeReps[i], &rDoc, rDoc.GetAddressConvention()); - if (nRes & SCA_VALID) + ScRefFlags nRes = aRange.Parse(aRangeReps[i], &rDoc, rDoc.GetAddressConvention()); + if (nRes & ScRefFlags::VALID) // This is a range address. aRanges.Append(aRange); else @@ -401,7 +401,7 @@ ScRangeList getChartRanges(ScDocument& rDoc, const SdrOle2Obj& rChartObj) // Parse it as a single cell address. ScAddress aAddr; nRes = aAddr.Parse(aRangeReps[i], &rDoc, rDoc.GetAddressConvention()); - CPPUNIT_ASSERT_MESSAGE("Failed to parse a range representation.", (nRes & SCA_VALID)); + CPPUNIT_ASSERT_MESSAGE("Failed to parse a range representation.", (nRes & ScRefFlags::VALID)); aRanges.Append(aAddr); } } @@ -416,7 +416,7 @@ ScTokenArray* getTokens(ScDocument& rDoc, const ScAddress& rPos) ScFormulaCell* pCell = rDoc.GetFormulaCell(rPos); if (!pCell) { - OUString aStr = rPos.Format(SCA_VALID); + OUString aStr = rPos.Format(ScRefFlags::VALID); cerr << aStr << " is not a formula cell." << endl; return nullptr; } @@ -447,7 +447,7 @@ bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected bool checkFormulaPosition(ScDocument& rDoc, const ScAddress& rPos) { - OUString aStr(rPos.Format(SCA_VALID)); + OUString aStr(rPos.Format(ScRefFlags::VALID)); const ScFormulaCell* pFC = rDoc.GetFormulaCell(rPos); if (!pFC) { @@ -457,7 +457,7 @@ bool checkFormulaPosition(ScDocument& rDoc, const ScAddress& rPos) if (pFC->aPos != rPos) { - OUString aStr2(pFC->aPos.Format(SCA_VALID)); + OUString aStr2(pFC->aPos.Format(ScRefFlags::VALID)); cerr << "Formula cell at " << aStr << " has incorrect position of " << aStr2 << endl; return false; } @@ -476,7 +476,7 @@ bool checkFormulaPositions( if (!checkFormulaPosition(rDoc, aPos)) { - OUString aStr(aPos.Format(SCA_VALID)); + OUString aStr(aPos.Format(ScRefFlags::VALID)); cerr << "Formula cell position failed at " << aStr << "." << endl; return false; } diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 37181312cc46..c78f321878c0 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -3543,7 +3543,7 @@ void Test::testCopyPasteSkipEmpty() bool checkRange( const ScAddress& rPos, const Check* p, const Check* pEnd ) { ScAddress aPos(rPos); - OUString aPosStr = aPos.Format(SCA_VALID); + OUString aPosStr = aPos.Format(ScRefFlags::VALID); for (; p != pEnd; ++p, aPos.IncRow()) { if (!mpDoc->GetString(aPos).equalsAscii(p->mpStr)) diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index f93f9dd91429..1d54d79dc2fa 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -298,29 +298,29 @@ void Test::testFormulaParseReference() ScAddress aPos; ScAddress::ExternalInfo aExtInfo; - sal_uInt16 nRes = aPos.Parse("'90''s Music'.D10", m_pDoc, formula::FormulaGrammar::CONV_OOO, &aExtInfo); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + ScRefFlags nRes = aPos.Parse("'90''s Music'.D10", m_pDoc, formula::FormulaGrammar::CONV_OOO, &aExtInfo); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(1), aPos.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(3), aPos.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(9), aPos.Row()); CPPUNIT_ASSERT_MESSAGE("This is not an external address.", !aExtInfo.mbExternal); nRes = aPos.Parse("'90''s and 70''s'.C100", m_pDoc, formula::FormulaGrammar::CONV_OOO, &aExtInfo); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(2), aPos.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(2), aPos.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(99), aPos.Row()); CPPUNIT_ASSERT_MESSAGE("This is not an external address.", !aExtInfo.mbExternal); nRes = aPos.Parse("'All Others'.B3", m_pDoc, formula::FormulaGrammar::CONV_OOO, &aExtInfo); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(3), aPos.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aPos.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(2), aPos.Row()); CPPUNIT_ASSERT_MESSAGE("This is not an external address.", !aExtInfo.mbExternal); nRes = aPos.Parse("NoQuote.E13", m_pDoc, formula::FormulaGrammar::CONV_OOO, &aExtInfo); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(4), aPos.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(4), aPos.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(12), aPos.Row()); @@ -330,120 +330,130 @@ void Test::testFormulaParseReference() aRange.aStart.SetTab(0); nRes = aRange.Parse(":B", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse("B:", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse(":B2", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse("B2:", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse(":2", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse("2:", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse(":2B", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse("2B:", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse("abc_foo:abc_bar", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); aRange.aStart.SetTab(0); nRes = aRange.Parse("B:B", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aStart.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Row()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aEnd.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aEnd.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(MAXROW), aRange.aEnd.Row()); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2), - (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2)); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE), 0); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE), (SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)) == + (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS)) == + ScRefFlags::ZERO); + CPPUNIT_ASSERT((nRes & (ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS)) == + (ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS)); aRange.aStart.SetTab(0); nRes = aRange.Parse("2:2", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aStart.Row()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aEnd.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(MAXCOL), aRange.aEnd.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aEnd.Row()); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2), - (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2)); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE), 0); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE), (SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)) == + (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS)) == + ScRefFlags::ZERO); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS)) == + (ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS)); nRes = aRange.Parse("NoQuote.B:C", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(4), aRange.aStart.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aStart.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Row()); CPPUNIT_ASSERT_EQUAL(static_cast(4), aRange.aEnd.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(2), aRange.aEnd.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(MAXROW), aRange.aEnd.Row()); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2), - (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2)); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE), 0); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE), (SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)) == + (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS)) == + ScRefFlags::ZERO); + CPPUNIT_ASSERT((nRes & (ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS)) == + (ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS)); // Both rows at sheet bounds and relative => convert to absolute => entire column reference. aRange.aStart.SetTab(0); nRes = aRange.Parse("B1:B1048576", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aStart.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Row()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aEnd.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aEnd.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(MAXROW), aRange.aEnd.Row()); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2), - (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2)); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE), 0); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE), (SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)) == + (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS)) == + ScRefFlags::ZERO); + CPPUNIT_ASSERT((nRes & (ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS)) == + (ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS)); // Both columns at sheet bounds and relative => convert to absolute => entire row reference. aRange.aStart.SetTab(0); nRes = aRange.Parse("A2:AMJ2", m_pDoc, formula::FormulaGrammar::CONV_OOO); - CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0); + CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & ScRefFlags::VALID)); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aStart.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aStart.Row()); CPPUNIT_ASSERT_EQUAL(static_cast(0), aRange.aEnd.Tab()); CPPUNIT_ASSERT_EQUAL(static_cast(MAXCOL), aRange.aEnd.Col()); CPPUNIT_ASSERT_EQUAL(static_cast(1), aRange.aEnd.Row()); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2), - (SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | - SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2)); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE), 0); - CPPUNIT_ASSERT_EQUAL(nRes & (SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE), (SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)) == + (ScRefFlags::COL_VALID | ScRefFlags::ROW_VALID | ScRefFlags::TAB_VALID | + ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID)); + CPPUNIT_ASSERT((nRes & (ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS)) == + ScRefFlags::ZERO); + CPPUNIT_ASSERT((nRes & (ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS)) == + (ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS)); // Check for reference input conversion to and display string of entire column/row. { @@ -5883,7 +5893,7 @@ void Test::testFuncTableRef() ScAddress aPos(3+i,1,0); m_pDoc->SetString( aPos, aFormula); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aNames[i].pCounta), aPrefix + m_pDoc->GetString( aPos)); } @@ -5895,7 +5905,7 @@ void Test::testFuncTableRef() ScAddress aPos(3+i,2,0); m_pDoc->SetString( aPos, aFormula); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aNames[i].pSum3), aPrefix + m_pDoc->GetString( aPos)); } @@ -5907,7 +5917,7 @@ void Test::testFuncTableRef() ScAddress aPos(3+i,3,0); m_pDoc->SetString( aPos, aFormula); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aNames[i].pSum4), aPrefix + m_pDoc->GetString( aPos)); } @@ -5919,7 +5929,7 @@ void Test::testFuncTableRef() ScAddress aPos(3+i,4,0); m_pDoc->SetString( aPos, aFormula); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aNames[i].pSumX), aPrefix + m_pDoc->GetString( aPos)); } @@ -5936,7 +5946,7 @@ void Test::testFuncTableRef() OUString aFormula( "=SUM(" + OUString::createFromAscii( aNames[i].pName) + ")"); ScAddress aPos(4+i,3,0); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aNames[i].pSum4), aPrefix + m_pDoc->GetString( aPos)); } @@ -5964,7 +5974,7 @@ void Test::testFuncTableRef() { OUString aFormula( OUString::createFromAscii( pColumn2Formula)); ScAddress aPos(1,5,0); - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( OUString(aPrefix + "448"), OUString(aPrefix + m_pDoc->GetString(aPos))); } @@ -6060,7 +6070,7 @@ void Test::testFuncTableRef() ScAddress aPos(7+i,9,0); m_pDoc->SetString( aPos, aFormula); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aHlNames[i].pCounta), aPrefix + m_pDoc->GetString( aPos)); } @@ -6072,7 +6082,7 @@ void Test::testFuncTableRef() ScAddress aPos(7+i,10,0); m_pDoc->SetString( aPos, aFormula); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aHlNames[i].pSum3), aPrefix + m_pDoc->GetString( aPos)); } @@ -6084,7 +6094,7 @@ void Test::testFuncTableRef() ScAddress aPos(7+i,11,0); m_pDoc->SetString( aPos, aFormula); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aHlNames[i].pSum4), aPrefix + m_pDoc->GetString( aPos)); } @@ -6096,7 +6106,7 @@ void Test::testFuncTableRef() ScAddress aPos(7+i,12,0); m_pDoc->SetString( aPos, aFormula); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aHlNames[i].pSumX), aPrefix + m_pDoc->GetString( aPos)); } @@ -6113,7 +6123,7 @@ void Test::testFuncTableRef() OUString aFormula( "=SUM(" + OUString::createFromAscii( aHlNames[i].pName) + ")"); ScAddress aPos(8+i,11,0); // For easier "debugability" have position and formula in assertion. - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( aPrefix + OUString::createFromAscii( aHlNames[i].pSum4), aPrefix + m_pDoc->GetString( aPos)); } @@ -6140,7 +6150,7 @@ void Test::testFuncTableRef() { OUString aFormula( OUString::createFromAscii( pColumn3Formula)); ScAddress aPos(5,13,0); - OUString aPrefix( aPos.Format(SCA_VALID) + " " + aFormula + " : "); + OUString aPrefix( aPos.Format(ScRefFlags::VALID) + " " + aFormula + " : "); CPPUNIT_ASSERT_EQUAL( OUString(aPrefix + "448"), OUString(aPrefix + m_pDoc->GetString(aPos))); } @@ -6912,57 +6922,57 @@ void Test::testFormulaErrorPropagation() aPos.IncRow(); // C2 m_pDoc->SetString( aPos, "=ISERROR(A1:B1+3)"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); aPos.IncRow(); // C3 m_pDoc->SetString( aPos, "=ISERROR(A1:B1+{3})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); aPos.IncRow(); // C4 aPos2 = aPos; aPos2.IncCol(); // D4 m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR(A1:B1+{3})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2)); aPos.IncRow(); // C5 m_pDoc->SetString( aPos, "=ISERROR({1;\"x\"}+{3;4})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); aPos.IncRow(); // C6 aPos2 = aPos; aPos2.IncCol(); // D6 m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR({1;\"x\"}+{3;4})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos2)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos2)); aPos.IncRow(); // C7 m_pDoc->SetString( aPos, "=ISERROR({\"x\";2}+{3;4})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); aPos.IncRow(); // C8 aPos2 = aPos; aPos2.IncCol(); // D8 m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR({\"x\";2}+{3;4})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2)); aPos.IncRow(); // C9 m_pDoc->SetString( aPos, "=ISERROR(({1;\"x\"}+{3;4})-{5;6})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); aPos.IncRow(); // C10 aPos2 = aPos; aPos2.IncCol(); // D10 m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR(({1;\"x\"}+{3;4})-{5;6})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos2)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos2)); aPos.IncRow(); // C11 m_pDoc->SetString( aPos, "=ISERROR(({\"x\";2}+{3;4})-{5;6})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); aPos.IncRow(); // C12 aPos2 = aPos; aPos2.IncCol(); // D12 m_pDoc->InsertMatrixFormula(aPos.Col(), aPos.Row(), aPos2.Col(), aPos2.Row(), aMark, "=ISERROR(({\"x\";2}+{3;4})-{5;6})"); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(SCA_VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); - CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(SCA_VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2)); m_pDoc->DeleteTab(0); } diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx index ef143ffd7bbd..3ec7bd1d8b24 100644 --- a/sc/qa/unit/ucalc_pivottable.cxx +++ b/sc/qa/unit/ucalc_pivottable.cxx @@ -680,7 +680,7 @@ void Test::testPivotTableNamedSource() // Insert the raw data. ScRange aSrcRange = insertDPSourceData(m_pDoc, aFields, nFieldCount, aData, nDataCount); - OUString aRangeStr(aSrcRange.Format(SCR_ABS_3D, m_pDoc)); + OUString aRangeStr(aSrcRange.Format(ScRefFlags::RANGE_ABS_3D, m_pDoc)); // Name this range. OUString aRangeName("MyData"); @@ -2126,7 +2126,7 @@ void Test::testFuncGETPIVOTDATA() aPos = aOutRange.aEnd; aPos.IncRow(2); // Move 2 rows down from the table output. - OUString aPivotPosStr(aOutRange.aStart.Format(SCA_ABS)); + OUString aPivotPosStr(aOutRange.aStart.Format(ScRefFlags::ADDR_ABS)); sc::AutoCalcSwitch aSwitch(*m_pDoc, true); // turn autocalc on. @@ -2188,7 +2188,7 @@ void Test::testFuncGETPIVOTDATA() aPos = aOutRange.aEnd; aPos.IncRow(2); // move 2 rows down from the output. - aPivotPosStr = aOutRange.aStart.Format(SCA_ABS); + aPivotPosStr = aOutRange.aStart.Format(ScRefFlags::ADDR_ABS); // First, get the grand totals. aFormula = ("=GETPIVOTDATA(\"Sum - Value\";") + aPivotPosStr + ")"; diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx index e692ec8fa5af..b47b3a3f1c03 100644 --- a/sc/qa/unit/ucalc_sort.cxx +++ b/sc/qa/unit/ucalc_sort.cxx @@ -141,7 +141,7 @@ void Test::testSortHorizontal() // Insert raw data into A1:D4. ScRange aDataRange = insertRangeData(m_pDoc, ScAddress(0,0,0), aData, SAL_N_ELEMENTS(aData)); - CPPUNIT_ASSERT_EQUAL(OUString("A1:D4"), aDataRange.Format(SCA_VALID)); + CPPUNIT_ASSERT_EQUAL(OUString("A1:D4"), aDataRange.Format(ScRefFlags::VALID)); // Check the formula values. CPPUNIT_ASSERT_EQUAL(OUString("Yes-No"), m_pDoc->GetString(ScAddress(3,1,0))); -- cgit