summaryrefslogtreecommitdiff
path: root/sc
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
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')
-rw-r--r--sc/qa/unit/data/xlsx/testDrawCircleInMergeCells.xlsxbin0 -> 8170 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx69
-rw-r--r--sc/source/core/data/drwlayer.cxx10
-rw-r--r--sc/source/core/tool/detfunc.cxx2
4 files changed, 71 insertions, 10 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" )
{
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 7790bf81f58e..4ef2e7d492c4 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1025,15 +1025,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
// Validation circle for detective.
rData.setShapeRect(GetDocument(), pObj->GetLogicRect());
- Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
- aPos.setX(TwipsToHmm( aPos.X() ));
- aPos.setY(TwipsToHmm( aPos.Y() ));
-
- // Calculations and values as in detfunc.cxx
-
- Size aSize( TwipsToHmm( pDoc->GetColWidth( nCol1, nTab1) ),
- TwipsToHmm( pDoc->GetRowHeight( nRow1, nTab1) ) );
- tools::Rectangle aRect( aPos, aSize );
+ tools::Rectangle aRect = GetCellRect(*GetDocument(), rData.maStart, true);
aRect.AdjustLeft( -250 );
aRect.AdjustRight(250 );
aRect.AdjustTop( -70 );
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index b008cec43e01..786b4624f9c8 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -638,7 +638,7 @@ void ScDetectiveFunc::DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData
ScDrawLayer* pModel = rDoc.GetDrawLayer();
SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab));
- tools::Rectangle aRect = GetDrawRect( nCol, nRow );
+ tools::Rectangle aRect = ScDrawLayer::GetCellRect(rDoc, ScAddress(nCol, nRow, nTab), true);
aRect.AdjustLeft( -250 );
aRect.AdjustRight(250 );
aRect.AdjustTop( -70 );