summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2020-11-10 14:25:23 +0100
committerLászló Németh <nemeth@numbertext.org>2020-11-20 15:21:16 +0100
commitd6d8b9c59524cff8effc170c57940700282bf625 (patch)
tree20a06d5fb8e99e477653914f11baea7221da32f8 /sc
parentbf5b90e035f2a3107833b3533eab027424093770 (diff)
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@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/ods/deleteCirclesInRowAndCol.odsbin0 -> 9109 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx31
-rw-r--r--sc/source/core/data/drwlayer.cxx30
3 files changed, 54 insertions, 7 deletions
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
--- /dev/null
+++ b/sc/qa/unit/data/ods/deleteCirclesInRowAndCol.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 695163908da8..af64711856a6 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -289,6 +289,7 @@ public:
void testTextLengthDataValidityXLSX();
void testDeleteCircles();
void testDrawCircleInMergeCells();
+ void testDeleteCirclesInRowAndCol();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -465,6 +466,7 @@ public:
CPPUNIT_TEST(testTextLengthDataValidityXLSX);
CPPUNIT_TEST(testDeleteCircles);
CPPUNIT_TEST(testDrawCircleInMergeCells);
+ CPPUNIT_TEST(testDeleteCirclesInRowAndCol);
CPPUNIT_TEST_SUITE_END();
@@ -5163,6 +5165,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 5e7f367d6445..3901434df913 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1522,6 +1522,11 @@ void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
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);
std::unique_ptr<SdrObject*[]> ppObj(new SdrObject*[nObjCount]);
@@ -1533,17 +1538,28 @@ void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
// TODO: detective objects are still deleted, is this desired?
if (!IsNoteCaption( pObject ))
{
- tools::Rectangle aObjRect = pObject->GetCurrentBoundRect();
- if (aDelRect.IsInside(aObjRect))
+ 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
{
- if (bAnchored)
+ aObjRect = pObject->GetCurrentBoundRect();
+ if (aDelRect.IsInside(aObjRect))
{
- ScAnchorType aAnchorType = ScDrawLayer::GetAnchorType(*pObject);
- if(aAnchorType == SCA_CELL || aAnchorType == SCA_CELL_RESIZE)
+ if (bAnchored)
+ {
+ ScAnchorType aAnchorType = ScDrawLayer::GetAnchorType(*pObject);
+ if (aAnchorType == SCA_CELL || aAnchorType == SCA_CELL_RESIZE)
+ ppObj[nDelCount++] = pObject;
+ }
+ else
ppObj[nDelCount++] = pObject;
}
- else
- ppObj[nDelCount++] = pObject;
}
}