[Libreoffice-commits] core.git: sc/inc sc/source

Ilhan Yesil (via logerrit) logerrit at kemper.freedesktop.org
Tue May 14 22:08:29 UTC 2019


 sc/inc/document.hxx               |    2 +-
 sc/inc/drwlayer.hxx               |    2 +-
 sc/source/core/data/documen9.cxx  |    4 ++--
 sc/source/core/data/drwlayer.cxx  |   19 ++++++++++++++-----
 sc/source/ui/docshell/docfunc.cxx |   17 +++++++++++++++++
 sc/source/ui/view/viewfunc.cxx    |   11 +++++++++--
 6 files changed, 44 insertions(+), 11 deletions(-)

New commits:
commit d2fa9c0d657877c967e41fdd0091f81d1b7ca048
Author:     Ilhan Yesil <ilhanyesil at gmx.de>
AuthorDate: Mon Mar 18 15:29:11 2019 +0100
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Wed May 15 00:07:11 2019 +0200

    tdf#123762 Cell anchored object is deleted if cell is deleted
    
    If an object is anchored to a cell, then it is expected that
    this object belongs to this cell and it's survive after a
    deletion of the cell makes no sense. So the anchored object
    will be deleted together with the cell. Objects anchored to
    the page are not affected.
    
    Change-Id: I91f24bf92ab5329aba1d053b3cf5fba77bf16e4f
    Reviewed-on: https://gerrit.libreoffice.org/69390
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index d36db2e6fef4..dd59a74c44e4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1512,7 +1512,7 @@ public:
     bool                         HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = nullptr );
 
     void                         DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                                                      const ScMarkData& rMark );
+                                                      const ScMarkData& rMark, bool bAnchored = false );
     void                         DeleteObjectsInSelection( const ScMarkData& rMark );
 
     void                         DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark,
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 143868c0e6ce..9f8268be03b8 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -143,7 +143,7 @@ public:
     bool            HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow );
 
     void            DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
-                                            SCCOL nCol2,SCROW nRow2 );
+                                            SCCOL nCol2,SCROW nRow2, bool bAnchored = false );
     void            DeleteObjectsInSelection( const ScMarkData& rMark );
 
     void            CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rectangle& rRange );
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index d5146ed509ad..d873b820c31f 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -248,7 +248,7 @@ bool ScDocument::DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer )
 }
 
 void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                        const ScMarkData& rMark )
+                        const ScMarkData& rMark, bool bAnchored)
 {
     if (!mpDrawLayer)
         return;
@@ -259,7 +259,7 @@ void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR
         if (rTab >= nTabCount)
             break;
         if (maTabs[rTab])
-            mpDrawLayer->DeleteObjectsInArea( rTab, nCol1, nRow1, nCol2, nRow2 );
+            mpDrawLayer->DeleteObjectsInArea( rTab, nCol1, nRow1, nCol2, nRow2, bAnchored);
     }
 }
 
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 90f92296534c..f27af11fc71a 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1360,7 +1360,7 @@ bool ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow )
 }
 
 void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
-                                            SCCOL nCol2,SCROW nRow2 )
+                                            SCCOL nCol2,SCROW nRow2, bool bAnchored )
 {
     OSL_ENSURE( pDoc, "ScDrawLayer::DeleteObjectsInArea without document" );
     if ( !pDoc )
@@ -1390,8 +1390,17 @@ void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
             if (!IsNoteCaption( pObject ))
             {
                 tools::Rectangle aObjRect = pObject->GetCurrentBoundRect();
-                if ( aDelRect.IsInside( aObjRect ) )
-                    ppObj[nDelCount++] = pObject;
+                if (aDelRect.IsInside(aObjRect))
+                {
+                    if (bAnchored)
+                    {
+                        ScAnchorType aAnchorType = ScDrawLayer::GetAnchorType(*pObject);
+                        if(aAnchorType == SCA_CELL || aAnchorType == SCA_CELL_RESIZE)
+                            ppObj[nDelCount++] = pObject;
+                    }
+                    else
+                        ppObj[nDelCount++] = pObject;
+                }
             }
 
             pObject = aIter.Next();
@@ -1449,8 +1458,8 @@ void ScDrawLayer::DeleteObjectsInSelection( const ScMarkData& rMark )
                     {
                         tools::Rectangle aObjRect = pObject->GetCurrentBoundRect();
                         ScRange aRange = pDoc->GetRange(nTab, aObjRect);
-                        bool bObjectInMarkArea
-                            = aMarkBound.IsInside(aObjRect) && rMark.IsAllMarked(aRange);
+                        bool bObjectInMarkArea =
+                            aMarkBound.IsInside(aObjRect) && rMark.IsAllMarked(aRange);
                         const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObject);
                         ScAnchorType aAnchorType = ScDrawLayer::GetAnchorType(*pObject);
                         bool bObjectAnchoredToMarkedCell
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index d8c475bc2bc0..1df41fa5903c 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2492,6 +2492,23 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
         rDocShell.UpdatePaintExt( nExtFlags, nStartCol, nStartRow, rTab, nEndCol, nEndRow, rTab );
     }
 
+    switch (eCmd)
+    {
+    case DelCellCmd::CellsUp:
+    case DelCellCmd::CellsLeft:
+        rDoc.DeleteObjectsInArea(nStartCol, nStartRow, nEndCol, nEndRow, aMark, true);
+        break;
+    case DelCellCmd::Rows:
+        rDoc.DeleteObjectsInArea(0, nStartRow, MAXCOL, nEndRow, aMark, true);
+        break;
+    case DelCellCmd::Cols:
+        rDoc.DeleteObjectsInArea(nStartCol, 0, nEndCol, MAXROW, aMark, true);
+        break;
+    default:
+        break;
+    }
+
+
     bool bUndoOutline = false;
     switch (eCmd)
     {
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 991e3637480f..ec73df529d72 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1838,15 +1838,22 @@ void ScViewFunc::DeleteMulti( bool bRows )
     }
 
     std::vector<sc::ColRowSpan>::const_reverse_iterator ri = aSpans.rbegin(), riEnd = aSpans.rend();
+    aFuncMark.SelectOneTable(nTab);
     for (; ri != riEnd; ++ri)
     {
         SCCOLROW nEnd = ri->mnEnd;
         SCCOLROW nStart = ri->mnStart;
 
         if (bRows)
-            rDoc.DeleteRow( 0,nTab, MAXCOL,nTab, nStart, static_cast<SCSIZE>(nEnd-nStart+1) );
+        {
+            rDoc.DeleteObjectsInArea(0, nStart, MAXCOL, nEnd, aFuncMark, true);
+            rDoc.DeleteRow(0, nTab, MAXCOL, nTab, nStart, static_cast<SCSIZE>(nEnd - nStart + 1));
+        }
         else
-            rDoc.DeleteCol( 0,nTab, MAXROW,nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd-nStart+1) );
+        {
+            rDoc.DeleteObjectsInArea(nStart, 0, nEnd, MAXROW, aFuncMark, true);
+            rDoc.DeleteCol(0, nTab, MAXROW, nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd - nStart + 1));
+        }
     }
 
     if (bNeedRefresh)


More information about the Libreoffice-commits mailing list