[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-5-2+backports' - sc/inc sc/source

Ilhan Yesil (via logerrit) logerrit at kemper.freedesktop.org
Wed May 22 11:48:19 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  |   26 ++++++++++++++++++++++----
 sc/source/ui/docshell/docfunc.cxx |   17 +++++++++++++++++
 sc/source/ui/view/viewfunc.cxx    |   11 +++++++++--
 6 files changed, 52 insertions(+), 10 deletions(-)

New commits:
commit cd0d6b6190759eb5f14e081e1c5ca789b1ca471f
Author:     Ilhan Yesil <ilhanyesil at gmx.de>
AuthorDate: Mon Mar 18 15:29:11 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed May 22 13:47:44 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.
    
    Reviewed-on: https://gerrit.libreoffice.org/69390
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit d2fa9c0d657877c967e41fdd0091f81d1b7ca048)
    
    Change-Id: I91f24bf92ab5329aba1d053b3cf5fba77bf16e4f
    Reviewed-on: https://gerrit.libreoffice.org/72665
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 690bab10710d..aa98d27e5240 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1381,7 +1381,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(
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 091d8f1da471..261459968c25 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -146,7 +146,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 Rectangle& rRange );
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index 984f21eeb311..b1f5745edb90 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -269,7 +269,7 @@ void ScDocument::DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
 }
 
 void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                        const ScMarkData& rMark )
+                        const ScMarkData& rMark, bool bAnchored)
 {
     if (!pDrawLayer)
         return;
@@ -278,7 +278,7 @@ void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR
     ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
     for (; itr != itrEnd && *itr < nTabCount; ++itr)
         if (maTabs[*itr])
-            pDrawLayer->DeleteObjectsInArea( *itr, nCol1, nRow1, nCol2, nRow2 );
+            pDrawLayer->DeleteObjectsInArea( *itr, nCol1, nRow1, nCol2, nRow2, bAnchored);
 }
 
 void ScDocument::DeleteObjectsInSelection( const ScMarkData& rMark )
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 8bccca95b0ec..eb471d300b07 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1373,7 +1373,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 )
@@ -1403,8 +1403,17 @@ void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
             if (!IsNoteCaption( pObject ))
             {
                 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();
@@ -1460,7 +1469,16 @@ void ScDrawLayer::DeleteObjectsInSelection( const ScMarkData& rMark )
                     if (!IsNoteCaption( pObject ))
                     {
                         Rectangle aObjRect = pObject->GetCurrentBoundRect();
-                        if ( aMarkBound.IsInside( aObjRect ) )
+                        ScRange aRange = pDoc->GetRange(nTab, aObjRect);
+                        bool bObjectInMarkArea =
+                            aMarkBound.IsInside(aObjRect) && rMark.IsAllMarked(aRange);
+                        const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObject);
+                        ScAnchorType aAnchorType = ScDrawLayer::GetAnchorType(*pObject);
+                        bool bObjectAnchoredToMarkedCell
+                            = ((aAnchorType == SCA_CELL || aAnchorType == SCA_CELL_RESIZE)
+                               && rMark.IsCellMarked(pObjData->maStart.Col(),
+                                                     pObjData->maStart.Row()));
+                        if (bObjectInMarkArea || bObjectAnchoredToMarkedCell)
                         {
                             ScRange aRange = pDoc->GetRange( nTab, aObjRect );
                             if (rMark.IsAllMarked(aRange))
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index a00ec537c14b..a19da56d872a 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2421,6 +2421,23 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
         rDocShell.UpdatePaintExt( nExtFlags, nStartCol, nStartRow, *itr, nEndCol, nEndRow, *itr );
     }
 
+    switch (eCmd)
+    {
+    case DelCellCmd::DEL_CELLSUP:
+    case DelCellCmd::DEL_CELLSLEFT:
+        rDoc.DeleteObjectsInArea(nStartCol, nStartRow, nEndCol, nEndRow, aMark, true);
+        break;
+    case DelCellCmd::DEL_DELROWS:
+        rDoc.DeleteObjectsInArea(0, nStartRow, MAXCOL, nEndRow, aMark, true);
+        break;
+    case DelCellCmd::DEL_DELCOLS:
+        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 ad5741df3fdf..b9e0743d11f3 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1671,15 +1671,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