[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Dec 6 20:39:13 PST 2011


 sc/inc/drwlayer.hxx              |    1 +
 sc/source/core/data/documen9.cxx |    1 +
 sc/source/core/data/drwlayer.cxx |   37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+)

New commits:
commit 3e68dba79d630fd9516bfa1314ebc0fd48d969bd
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Dec 6 23:34:44 2011 -0500

    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.

diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 6f4f71d..f879e74 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 b8cca4c..e4dec4f 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 327f65a..2e2d00a 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 &&


More information about the Libreoffice-commits mailing list