chart2/qa/extras/chart2import.cxx | 26 ++++++++++++++++++++++++++ chart2/qa/extras/data/xlsx/tdf134225.xlsx |binary chart2/source/view/charttypes/PieChart.cxx | 14 +------------- 3 files changed, 27 insertions(+), 13 deletions(-)
New commits: commit a2d2822bb55c9ff5c48898062a0e66f9251631d3 Author: Balazs Varga <balazs.varga...@gmail.com> AuthorDate: Tue Jun 23 15:02:59 2020 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Sep 15 15:54:18 2020 +0200 tdf#134225 Chart view: fix moved date label outside from pie chart. Do not need to check the sector size of a pie slice, before best fit algorithm, so we can use the CENTER position as a start position of BEST_FIT. Completion of c66cb6d6e4a843dc7c7d06e1c2c0723a6ff85fc5 (tdf#134029 Chart view: enable to move data label) Change-Id: Ie1a53784e7df2887282155113bf8bb607cdb09e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96945 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 57fedb272cfcad3436142dbe9eac2870e3c3e3d2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100054 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 3e0704c876ae..5a896f89a18d 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -161,6 +161,7 @@ public: void testTdf119138MissingAutoTitleDeleted(); void testStockChartShiftedCategoryPosition(); void testTdf133376(); + void testTdf134225(); void testTdf91250(); CPPUNIT_TEST_SUITE(Chart2ImportTest); @@ -271,6 +272,7 @@ public: CPPUNIT_TEST(testTdf119138MissingAutoTitleDeleted); CPPUNIT_TEST(testStockChartShiftedCategoryPosition); CPPUNIT_TEST(testTdf133376); + CPPUNIT_TEST(testTdf134225); CPPUNIT_TEST(testTdf91250); CPPUNIT_TEST_SUITE_END(); @@ -2527,6 +2529,30 @@ void Chart2ImportTest::testTdf133376() CPPUNIT_ASSERT_DOUBLES_EQUAL(5269, aLabelPosition.Y, 30); } +void Chart2ImportTest::testTdf134225() +{ + load("/chart2/qa/extras/data/xlsx/", "tdf134225.xlsx"); + Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + + Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference<drawing::XShape> xDataPointLabel1(getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), UNO_SET_THROW); + CPPUNIT_ASSERT(xDataPointLabel1.is()); + awt::Point aLabelPosition1 = xDataPointLabel1->getPosition(); + + Reference<drawing::XShape> xDataPointLabel2(getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=1"), UNO_SET_THROW); + CPPUNIT_ASSERT(xDataPointLabel2.is()); + awt::Point aLabelPosition2 = xDataPointLabel2->getPosition(); + + // Check the distance between the position of the 1st data point label and the second one + CPPUNIT_ASSERT_DOUBLES_EQUAL(1800, sal_Int32(aLabelPosition2.X - aLabelPosition1.X), 200); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2123, sal_Int32(aLabelPosition2.Y - aLabelPosition1.Y), 200); +} + void Chart2ImportTest::testTdf91250() { load("/chart2/qa/extras/data/docx/", "tdf91250.docx"); diff --git a/chart2/qa/extras/data/xlsx/tdf134225.xlsx b/chart2/qa/extras/data/xlsx/tdf134225.xlsx new file mode 100644 index 000000000000..ae7bdc66e302 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/tdf134225.xlsx differ diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 9032b40977f1..5ab60729cf93 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -294,19 +294,7 @@ void PieChart::createTextLabelShape( //AVOID_OVERLAP is in fact "Best fit" in the UI. bool bMovementAllowed = ( nLabelPlacement == css::chart::DataLabelPlacement::AVOID_OVERLAP ); if( bMovementAllowed ) - { - // Use center for "Best fit" for now. In the future we - // may want to implement a real best fit algorithm. - // But center is good enough, and close to what Excel - // does. - - // Place the label outside if the sector is too small - // The threshold is set to 2%, but can be improved by making it a function of - // label width and radius too ? - double fFrac = fabs( nVal / rParam.mfLogicYSum ); - nLabelPlacement = ( fFrac <= 0.02 ) ? css::chart::DataLabelPlacement::OUTSIDE : - css::chart::DataLabelPlacement::CENTER; - } + nLabelPlacement = css::chart::DataLabelPlacement::CENTER; ///for `OUTSIDE` (`INSIDE`) label placements an offset of 150 (-150), in the ///radius direction, is added to the final screen position of the label _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits