Kaydet (Commit) 13b69492 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst 07b66cd3
......@@ -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
......
......@@ -1296,20 +1296,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));
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment