sc/inc/rangenam.hxx | 5 +++++ sc/qa/unit/ucalc_formula.cxx | 13 +++++++++++-- sc/source/core/tool/rangenam.cxx | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-)
New commits: commit b3fd5efef2ade574d33cc1ac39e832ccca14a569 Author: Kohei Yoshida <[email protected]> Date: Fri Nov 1 13:28:00 2013 -0400 We need to update sheet positions of range names when modifying sheets. And add Dump() to ScRangeData for debugging convenience and re-enable previously failed test cases. Change-Id: I9d8f41a8be4c9c301254ef300c7b7f0c1ea7f393 diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx index 65fae47..6113709 100644 --- a/sc/inc/rangenam.hxx +++ b/sc/inc/rangenam.hxx @@ -24,6 +24,7 @@ #include "address.hxx" #include "formula/grammar.hxx" #include "scdllapi.h" +#include "calcmacros.hxx" #include <map> #include <vector> @@ -151,6 +152,10 @@ public: SCCOL GetMaxCol() const; void CompileUnresolvedXML(); + +#if DEBUG_FORMULA_COMPILER + void Dump() const; +#endif }; inline bool ScRangeData::HasType( RangeType nType ) const diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index ce9ce2e..361c015 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -1262,20 +1262,29 @@ void Test::testFormulaRefUpdateNamedExpression() m_pDoc->SetValue(ScAddress(3,9,0), 20); CPPUNIT_ASSERT_EQUAL(43.0, m_pDoc->GetValue(ScAddress(2,7,0))); -#if 0 // Insert a new sheet before the current. m_pDoc->InsertTab(0, "New"); OUString aName; m_pDoc->GetName(1, aName); CPPUNIT_ASSERT_EQUAL(OUString("Formula"), aName); + + pName = pGlobalNames->findByUpperName("MYRANGE"); + CPPUNIT_ASSERT_MESSAGE("Failed to find named expression 'MyRange' in the global scope.", pName); + m_pDoc->SetValue(ScAddress(3,9,1), 10); CPPUNIT_ASSERT_EQUAL(33.0, m_pDoc->GetValue(ScAddress(2,7,1))); m_pDoc->DeleteTab(0); + aName = OUString(); + m_pDoc->GetName(0, aName); + CPPUNIT_ASSERT_EQUAL(OUString("Formula"), aName); + + pName = pGlobalNames->findByUpperName("MYRANGE"); + CPPUNIT_ASSERT_MESSAGE("Failed to find named expression 'MyRange' in the global scope.", pName); + m_pDoc->SetValue(ScAddress(3,9,0), 11); CPPUNIT_ASSERT_EQUAL(34.0, m_pDoc->GetValue(ScAddress(2,7,0))); -#endif // Clear all and start over. clearRange(m_pDoc, ScRange(0,0,0,100,100,0)); diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index b963eab..4389a4b 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -196,6 +196,18 @@ void ScRangeData::CompileUnresolvedXML() } } +#if DEBUG_FORMULA_COMPILER +void ScRangeData::Dump() const +{ + cout << "-- ScRangeData" << endl; + cout << " name: " << aName << endl; + cout << " ref position: (col=" << aPos.Col() << ", row=" << aPos.Row() << ", sheet=" << aPos.Tab() << ")" << endl; + + if (pCode) + pCode->Dump(); +} +#endif + void ScRangeData::GuessPosition() { // set a position that allows "absoluting" of all relative references @@ -392,6 +404,9 @@ void ScRangeData::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt, SCTAB nL sc::RefUpdateResult aRes = pCode->AdjustReferenceOnInsertedTab(rCxt, aPos); if (aRes.mbReferenceModified) rCxt.maUpdatedNames.setUpdatedName(nLocalTab, nIndex); + + if (rCxt.mnInsertPos <= aPos.Tab()) + aPos.IncTab(rCxt.mnSheets); } void ScRangeData::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt, SCTAB nLocalTab ) @@ -399,6 +414,9 @@ void ScRangeData::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt, SCTAB nL sc::RefUpdateResult aRes = pCode->AdjustReferenceOnDeletedTab(rCxt, aPos); if (aRes.mbReferenceModified) rCxt.maUpdatedNames.setUpdatedName(nLocalTab, nIndex); + + if (rCxt.mnDeletePos <= aPos.Tab()) + aPos.IncTab(-rCxt.mnSheets); } void ScRangeData::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nLocalTab ) @@ -406,6 +424,8 @@ void ScRangeData::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nLocal sc::RefUpdateResult aRes = pCode->AdjustReferenceOnMovedTab(rCxt, aPos); if (aRes.mbReferenceModified) rCxt.maUpdatedNames.setUpdatedName(nLocalTab, nIndex); + + aPos.SetTab(rCxt.getNewTab(aPos.Tab())); } void ScRangeData::MakeValidName( OUString& rName ) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
