diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-12-06 23:34:44 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-12-06 23:38:09 -0500 |
commit | e2621785569969374cc3bc39fae0341d8b848612 (patch) | |
tree | f888b45373beef9cb0702d2c45a13ec983cec842 /sc | |
parent | 5260bf5ea7271cca4767f596592091dcdfd895fe (diff) |
bnc#733864: Make sure to adjust the sheet index of drawing objects.
For cell-anchored drawing objects. Failing to do so would result in
either one of
1) write error during file save,
2) drawing object disappearing upon reload, or
3) drawing object relocated to a wrong sheet, with wrong position
and size upon reload.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/drwlayer.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/documen9.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/drwlayer.cxx | 37 |
3 files changed, 39 insertions, 0 deletions
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx index 6f4f71dd6902..f879e7475774 100644 --- a/sc/inc/drwlayer.hxx +++ b/sc/inc/drwlayer.hxx @@ -126,6 +126,7 @@ public: void ScMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ); // incl. content, bAlloc=FALSE -> only content void ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, sal_Bool bAlloc ); + void ResetTab( SCTAB nStart, SCTAB nEnd ); ScDocument* GetDocument() const { return pDoc; } diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx index b8cca4c9f52e..e4dec4ff2301 100644 --- a/sc/source/core/data/documen9.cxx +++ b/sc/source/core/data/documen9.cxx @@ -257,6 +257,7 @@ void ScDocument::DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ) { // angelegt wird die Page schon im ScTable ctor pDrawLayer->ScCopyPage( nOldPos, nNewPos, false ); + pDrawLayer->ResetTab(static_cast<SCTAB>(nNewPos), static_cast<SCTAB>(maTabs.size())); } void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 327f65a15e17..2e2d00a4e606 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -435,16 +435,32 @@ void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, sal_Bool b if (pOldPage && pNewPage) { + SCTAB nOldTab = static_cast<SCTAB>(nOldPos); + SCTAB nNewTab = static_cast<SCTAB>(nNewPos); + SdrObjListIter aIter( *pOldPage, IM_FLAT ); SdrObject* pOldObject = aIter.Next(); while (pOldObject) { + ScDrawObjData* pOldData = GetObjData(pOldObject); + if (pOldData) + { + pOldData->maStart.SetTab(nOldTab); + pOldData->maEnd.SetTab(nOldTab); + } SdrObject* pNewObject = pOldObject->Clone(); pNewObject->SetModel(this); pNewObject->SetPage(pNewPage); pNewObject->NbcMove(Size(0,0)); pNewPage->InsertObject( pNewObject ); + ScDrawObjData* pNewData = GetObjData(pNewObject); + if (pNewData) + { + pNewData->maStart.SetTab(nNewTab); + pNewData->maEnd.SetTab(nNewTab); + } + if (bRecording) AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) ); @@ -456,6 +472,27 @@ void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos, sal_Bool b InsertPage(pNewPage, nNewPos); } +void ScDrawLayer::ResetTab( SCTAB nStart, SCTAB nEnd ) +{ + for (SCTAB i = nStart; i <= nEnd; ++i) + { + SdrPage* pPage = GetPage(static_cast<sal_uInt16>(i)); + if (!pPage) + continue; + + SdrObjListIter aIter(*pPage, IM_FLAT); + for (SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next()) + { + ScDrawObjData* pData = GetObjData(pObj); + if (!pData) + continue; + + pData->maStart.SetTab(i); + pData->maEnd.SetTab(i); + } + } +} + inline sal_Bool IsInBlock( const ScAddress& rPos, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2 ) { return rPos.Col() >= nCol1 && rPos.Col() <= nCol2 && |