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

Ilhan Yesil (via logerrit) logerrit at kemper.freedesktop.org
Mon May 27 15:59:00 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 f10f83bde06b0303a0d56dac120ecb53349250f2
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: Mon May 27 17:58:08 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/72800
    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 dff46dffd699..be7630b13461 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1469,7 +1469,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 48741497ac0e..1713d3b94120 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 5433142df41a..179b54eae0f3 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -260,7 +260,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;
@@ -269,7 +269,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])
-            mpDrawLayer->DeleteObjectsInArea( *itr, nCol1, nRow1, nCol2, nRow2 );
+            mpDrawLayer->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 8739d3b195c0..7dc7c6a4e62c 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1359,7 +1359,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 )
@@ -1389,8 +1389,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();
@@ -1447,8 +1456,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 518410f25f47..76bdf089c85d 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2487,6 +2487,23 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
         rDocShell.UpdatePaintExt( nExtFlags, nStartCol, nStartRow, *itr, nEndCol, nEndRow, *itr );
     }
 
+    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 6fdad679cb30..50fd5ed32d87 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1840,15 +1840,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