summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2020-11-03 11:50:59 +0100
committerLászló Németh <nemeth@numbertext.org>2020-11-06 11:51:58 +0100
commitd7bcf59a51a058ba57e685cfc3e000fec623f716 (patch)
treefa14958eff1539cad590d0aee06dd4f646eba482 /sc/qa
parent27926e61dfe8f86ba4aeef0d04b705b16eadbfe1 (diff)
tdf#137614 sc: fix data circle shape size on merged cells
When we are marked invalid data using Tools->Detective-> Mark Invalid Data, only top left cell of the merged cells is circled instead of all the merged range. Note: ScDrawLayer::RecalcPos change is for resizing the circled merged cell. Co-authored-by: Regina Henschel Change-Id: Ia03c506c92ec6e1c81ef3039c20e8e7ba9e9181d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105241 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/data/xlsx/testDrawCircleInMergeCells.xlsxbin0 -> 8170 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx69
2 files changed, 69 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/testDrawCircleInMergeCells.xlsx b/sc/qa/unit/data/xlsx/testDrawCircleInMergeCells.xlsx
new file mode 100644
index 000000000000..cab448a22d49
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/testDrawCircleInMergeCells.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 335ce70d51fa..891cc326b907 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -287,6 +287,7 @@ public:
void testTextBoxBodyUpright();
void testTextLengthDataValidityXLSX();
void testDeleteCircles();
+ void testDrawCircleInMergeCells();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -461,6 +462,7 @@ public:
CPPUNIT_TEST(testTextBoxBodyUpright);
CPPUNIT_TEST(testTextLengthDataValidityXLSX);
CPPUNIT_TEST(testDeleteCircles);
+ CPPUNIT_TEST(testDrawCircleInMergeCells);
CPPUNIT_TEST_SUITE_END();
@@ -5080,6 +5082,73 @@ void ScFiltersTest::testDeleteCircles()
xDocSh->DoClose();
}
+void ScFiltersTest::testDrawCircleInMergeCells()
+{
+ ScDocShellRef xDocSh = loadDoc("testDrawCircleInMergeCells.", FORMAT_XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load testDrawCircleInMergeCells.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);
+
+ // A1:B2 is merged.
+ ScRange aMergedRange(0,0,0);
+ rDoc.ExtendTotalMerge(aMergedRange);
+ CPPUNIT_ASSERT_EQUAL(ScRange(0,0,0,1,1,0), aMergedRange);
+
+ // Mark invalid value
+ bool bOverflow;
+ bool bMarkInvalid = ScDetectiveFunc(rDoc, 0).MarkInvalid(bOverflow);
+ CPPUNIT_ASSERT_EQUAL(true, bMarkInvalid);
+
+ // There should be a circle object!
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount());
+
+ SdrObject* pObj = pPage->GetObj(0);
+ tools::Rectangle aRect(pObj->GetLogicRect());
+ Point aStartCircle = aRect.TopLeft();
+ Point aEndCircle = aRect.BottomRight();
+
+ tools::Rectangle aCellRect = rDoc.GetMMRect(0,0,1,1,0);
+ aCellRect.AdjustLeft( -250 );
+ aCellRect.AdjustRight(250 );
+ aCellRect.AdjustTop( -70 );
+ aCellRect.AdjustBottom(70 );
+ Point aStartCell = aCellRect.TopLeft();
+ Point aEndCell = aCellRect.BottomRight();
+
+ CPPUNIT_ASSERT_EQUAL(aStartCell.X(), aStartCircle.X());
+ CPPUNIT_ASSERT_EQUAL(aEndCell.X(), aEndCircle.X());
+ CPPUNIT_ASSERT_EQUAL(aStartCell.Y(), aStartCircle.Y());
+ CPPUNIT_ASSERT_EQUAL(aEndCell.Y(), aEndCircle.Y());
+
+ // Change the height of the first row. (556 ~ 1cm)
+ rDoc.SetRowHeight(0, 0, 556);
+ ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj);
+ pDrawLayer->RecalcPos(pObj,*pData,false,false);
+
+ tools::Rectangle aRecalcRect(pObj->GetLogicRect());
+ Point aStartRecalcCircle = aRecalcRect.TopLeft();
+ Point aEndRecalcCircle = aRecalcRect.BottomRight();
+
+ tools::Rectangle aRecalcCellRect = rDoc.GetMMRect(0,0,1,1,0);
+ aRecalcCellRect.AdjustLeft( -250 );
+ aRecalcCellRect.AdjustRight(250 );
+ aRecalcCellRect.AdjustTop( -70 );
+ aRecalcCellRect.AdjustBottom(70 );
+ Point aStartRecalcCell = aRecalcCellRect.TopLeft();
+ Point aEndRecalcCell1 = aRecalcCellRect.BottomRight();
+
+ CPPUNIT_ASSERT_EQUAL(aStartRecalcCell.X(), aStartRecalcCircle.X());
+ CPPUNIT_ASSERT_EQUAL(aEndRecalcCell1.X(), aEndRecalcCircle.X());
+ CPPUNIT_ASSERT_EQUAL(aStartRecalcCell.Y(), aStartRecalcCircle.Y());
+ CPPUNIT_ASSERT_EQUAL(aEndRecalcCell1.Y(), aEndRecalcCircle.Y());
+
+ xDocSh->DoClose();
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "sc/qa/unit/data" )
{