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

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.
üst 5260bf5e
......@@ -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; }
......
......@@ -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,
......
......@@ -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 &&
......
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