diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-06-10 05:17:49 +0000 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2012-06-15 16:02:59 +0200 |
commit | 27e869767c1d0745cdfefcf1cf0c2f76fc74c942 (patch) | |
tree | c2d2ff00e4e267d60116bbd2415d42a8e74c83f3 | |
parent | 9fe8948942b8006a4089fbcce90456f68aec677c (diff) |
correctly copy the cond formats, fdo#50679
Change-Id: I52d645a8a7662016ced8c1eb6b320c4a14807353
Signed-off-by: Jan Holesovsky <kendy@suse.cz>
-rw-r--r-- | sc/source/core/data/table2.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index a554c20a9e76..18dfda4d258a 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -632,6 +632,8 @@ void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if ( IsProtected() ) for (i = nCol1; i <= nCol2; i++) pTable->aCol[i].RemoveProtected(nRow1, nRow2); + + pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->pDocument, *mpCondFormatList)); } } @@ -666,8 +668,16 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO { ScConditionalFormat* pFormat = pOldCondFormatList->GetFormat(nId); ScConditionalFormat* pNewFormat = pFormat->Clone(pDocument); - pNewFormat->SetKey(mpCondFormatList->size()+1); + pNewFormat->SetKey(0); //not in list => create entries in both maps and new format + sal_uLong nMax = 0; + for(ScConditionalFormatList::const_iterator itr = mpCondFormatList->begin(); + itr != mpCondFormatList->end(); ++itr) + { + if(itr->GetKey() > nMax) + nMax = itr->GetKey(); + } + pNewFormat->SetKey(nMax + 1); mpCondFormatList->InsertNew(pNewFormat); sal_Int32 nNewId = pNewFormat->GetKey(); aOldIdToNewId.insert( std::pair<sal_Int32, sal_Int32>( nId, nNewId ) ); @@ -683,6 +693,9 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO { sal_uInt32 nNewKey = aOldIdToNewId.find(itr->first)->second; ScConditionalFormat* pFormat = mpCondFormatList->GetFormat( nNewKey ); + if(!pFormat) + continue; + pFormat->UpdateReference(URM_MOVE, ScRange(nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, nRow2 - nDy, pTable->nTab), nDx, nDy, pTable->nTab - nTab); pFormat->AddRange(itr->second); |