[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/qa sc/source

Tibor Nagy (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 1 08:50:55 UTC 2021


 sc/qa/unit/data/ods/deleteCirclesInRowAndCol.ods |binary
 sc/qa/unit/subsequent_filters-test.cxx           |   31 +++++++++++++
 sc/source/core/data/drwlayer.cxx                 |   51 ++++++++++++++---------
 3 files changed, 64 insertions(+), 18 deletions(-)

New commits:
commit 0dca9589e0051e41ec29552b3204a57fb14ccebf
Author:     Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Tue Nov 10 14:25:23 2020 +0100
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Mon Mar 1 09:50:17 2021 +0100

    tdf#41845 sc: delete row/column with validation circles
    
    Red validation circles around the cells were
    left after deleting their rows or columns, showing
    invalid data on the next valid or not-validated
    cells.
    
    Co-authored-by: Attila Szűcs (NISZ)
    
    Change-Id: I0dcef9225696b76eda78f0ee8831a83c20f53b0e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105527
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit d6d8b9c59524cff8effc170c57940700282bf625)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111585
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sc/qa/unit/data/ods/deleteCirclesInRowAndCol.ods b/sc/qa/unit/data/ods/deleteCirclesInRowAndCol.ods
new file mode 100644
index 000000000000..6b99787c4b43
Binary files /dev/null and b/sc/qa/unit/data/ods/deleteCirclesInRowAndCol.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 91aff833b4b1..6d400cb7371f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -268,6 +268,7 @@ public:
     void testTextLengthDataValidityXLSX();
     void testDeleteCircles();
     void testDrawCircleInMergeCells();
+    void testDeleteCirclesInRowAndCol();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -423,6 +424,7 @@ public:
     CPPUNIT_TEST(testTextLengthDataValidityXLSX);
     CPPUNIT_TEST(testDeleteCircles);
     CPPUNIT_TEST(testDrawCircleInMergeCells);
+    CPPUNIT_TEST(testDeleteCirclesInRowAndCol);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -4735,6 +4737,35 @@ void ScFiltersTest::testDrawCircleInMergeCells()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testDeleteCirclesInRowAndCol()
+{
+    ScDocShellRef xDocSh = loadDoc("deleteCirclesInRowAndCol.", FORMAT_ODS);
+    CPPUNIT_ASSERT_MESSAGE("Failed to load deleteCirclesInRowAndCol.ods", xDocSh.is());
+
+    ScDocument& rDoc = xDocSh->GetDocument();
+
+    ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+    SdrPage* pPage = pDrawLayer->GetPage(0);
+    CPPUNIT_ASSERT_MESSAGE("draw page for sheet 1 should exist.", pPage);
+
+    // There should be 6 circle objects!
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), pPage->GetObjCount());
+
+    // Delete first row (1023 = MAXCOLS)
+    pDrawLayer->DeleteObjectsInArea(0,0,0,1023,0,true);
+
+    // There should be 3 circle objects!
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pPage->GetObjCount());
+
+    // Delete first col (1048575 = MAXROWS)
+    pDrawLayer->DeleteObjectsInArea(0,0,0,0,1048575,true);
+
+    // There should not be a circle object!
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pPage->GetObjCount());
+
+    xDocSh->DoClose();
+}
+
 ScFiltersTest::ScFiltersTest()
       : ScBootstrapFixture( "sc/qa/unit/data" )
 {
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 76a79a00b060..2da197750608 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1372,37 +1372,53 @@ void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
     pPage->RecalcObjOrdNums();
 
     const size_t nObjCount = pPage->GetObjCount();
-    if (nObjCount)
-    {
-        size_t nDelCount = 0;
-        tools::Rectangle aDelRect = pDoc->GetMMRect( nCol1, nRow1, nCol2, nRow2, nTab );
+    if (!nObjCount)
+        return;
 
-        std::unique_ptr<SdrObject*[]> ppObj(new SdrObject*[nObjCount]);
+    size_t nDelCount = 0;
+    tools::Rectangle aDelRect = pDoc->GetMMRect( nCol1, nRow1, nCol2, nRow2, nTab );
+    tools::Rectangle aDelCircle = pDoc->GetMMRect( nCol1, nRow1, nCol2, nRow2, nTab );
+    aDelCircle.AdjustLeft(-250);
+    aDelCircle.AdjustRight(250);
+    aDelCircle.AdjustTop(-70);
+    aDelCircle.AdjustBottom(70);
 
-        SdrObjListIter aIter( pPage, SdrIterMode::Flat );
-        SdrObject* pObject = aIter.Next();
-        while (pObject)
+    std::unique_ptr<SdrObject*[]> ppObj(new SdrObject*[nObjCount]);
+
+    SdrObjListIter aIter( pPage, SdrIterMode::Flat );
+    SdrObject* pObject = aIter.Next();
+    while (pObject)
+    {
+        // do not delete note caption, they are always handled by the cell note
+        // TODO: detective objects are still deleted, is this desired?
+        if (!IsNoteCaption( pObject ))
         {
-            // do not delete note caption, they are always handled by the cell note
-            // TODO: detective objects are still deleted, is this desired?
-            if (!IsNoteCaption( pObject ))
+            tools::Rectangle aObjRect;
+            ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObject);
+            if (pObjData && pObjData->meType == ScDrawObjData::ValidationCircle)
+            {
+                aObjRect = pObject->GetLogicRect();
+                if(aDelCircle.IsInside(aObjRect))
+                   ppObj[nDelCount++] = pObject;
+            }
+            else
             {
-                tools::Rectangle aObjRect = pObject->GetCurrentBoundRect();
+                aObjRect = pObject->GetCurrentBoundRect();
                 if (aDelRect.IsInside(aObjRect))
                 {
                     if (bAnchored)
                     {
                         ScAnchorType aAnchorType = ScDrawLayer::GetAnchorType(*pObject);
-                        if(aAnchorType == SCA_CELL || aAnchorType == SCA_CELL_RESIZE)
+                        if (aAnchorType == SCA_CELL || aAnchorType == SCA_CELL_RESIZE)
                             ppObj[nDelCount++] = pObject;
                     }
-                    else
-                        ppObj[nDelCount++] = pObject;
+                   else
+                       ppObj[nDelCount++] = pObject;
                 }
             }
-
-            pObject = aIter.Next();
         }
+        pObject = aIter.Next();
+    }
 
         if (bRecording)
             for (size_t i=1; i<=nDelCount; ++i)
@@ -1410,7 +1426,6 @@ void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
 
         for (size_t i=1; i<=nDelCount; ++i)
             pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() );
-    }
 }
 
 void ScDrawLayer::DeleteObjectsInSelection( const ScMarkData& rMark )


More information about the Libreoffice-commits mailing list