[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/qa sc/source
Tibor Nagy (via logerrit)
logerrit at kemper.freedesktop.org
Fri Feb 26 08:32:01 UTC 2021
sc/qa/unit/data/xlsx/testDrawCircleInMergeCells.xlsx |binary
sc/qa/unit/subsequent_filters-test.cxx | 69 +++++++++++++++++++
sc/source/core/data/drwlayer.cxx | 10 --
sc/source/core/tool/detfunc.cxx | 2
4 files changed, 71 insertions(+), 10 deletions(-)
New commits:
commit c80dfc6592ce315700dbda4b69f3fb22c17a1429
Author: Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Tue Nov 3 11:50:59 2020 +0100
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Fri Feb 26 09:31:25 2021 +0100
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 at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit d7bcf59a51a058ba57e685cfc3e000fec623f716)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111577
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/xlsx/testDrawCircleInMergeCells.xlsx b/sc/qa/unit/data/xlsx/testDrawCircleInMergeCells.xlsx
new file mode 100644
index 000000000000..cab448a22d49
Binary files /dev/null and b/sc/qa/unit/data/xlsx/testDrawCircleInMergeCells.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index b067b8c22ba8..91aff833b4b1 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -267,6 +267,7 @@ public:
void testTextBoxBodyUpright();
void testTextLengthDataValidityXLSX();
void testDeleteCircles();
+ void testDrawCircleInMergeCells();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -421,6 +422,7 @@ public:
CPPUNIT_TEST(testTextBoxBodyUpright);
CPPUNIT_TEST(testTextLengthDataValidityXLSX);
CPPUNIT_TEST(testDeleteCircles);
+ CPPUNIT_TEST(testDrawCircleInMergeCells);
CPPUNIT_TEST_SUITE_END();
@@ -4666,6 +4668,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 48a0dacbac4a..76a79a00b060 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -820,15 +820,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 e8dfae30cb5a..b76af228830f 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 = pDoc->GetDrawLayer();
SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab));
- tools::Rectangle aRect = GetDrawRect( nCol, nRow );
+ tools::Rectangle aRect = ScDrawLayer::GetCellRect(*pDoc, ScAddress(nCol, nRow, nTab), true);
aRect.AdjustLeft( -250 );
aRect.AdjustRight(250 );
aRect.AdjustTop( -70 );
More information about the Libreoffice-commits
mailing list