ensure a correct index is assigned to a duplicated ScRangeData instance

ScRangeName::insert() assigns an index only if the passed ScRangeData
instance's index was 0. Duplicating an ScRangeData object duplicates
also the index, so effectively two instances with the same index could
be inserted to the named expressions collection, a following
ScRangeName::findByIndex() retrieved one of them by chance.

Change-Id: Ic141ffb1a683bda5907f4359167da84faf1649e1
This commit is contained in:
Eike Rathke
2016-03-16 23:03:58 +01:00
parent 2a78e3eb92
commit 336d816176

View File

@@ -468,6 +468,7 @@ void adjustRangeName(formula::FormulaToken* pToken, ScDocument& rNewDoc, const S
{
bNewGlobal = bOldGlobal;
pRangeData = new ScRangeData(*pOldRangeData, &rNewDoc);
pRangeData->SetIndex(0); // needed for insert to assign a new index
ScTokenArray* pRangeNameToken = pRangeData->GetCode();
if (rNewDoc.GetPool() != const_cast<ScDocument*>(pOldDoc)->GetPool())
{