summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-06-23 15:02:59 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-09-15 15:54:18 +0200
commita2d2822bb55c9ff5c48898062a0e66f9251631d3 (patch)
tree6bb82cdf183d94d6d8a48a784a23496dbc4382be
parentbfb8ea0b77fb3e34b9604e4f6e25a0d3ac4169db (diff)
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 <nemeth@numbertext.org> (cherry picked from commit 57fedb272cfcad3436142dbe9eac2870e3c3e3d2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100054 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--chart2/qa/extras/chart2import.cxx26
-rw-r--r--chart2/qa/extras/data/xlsx/tdf134225.xlsxbin0 -> 13956 bytes
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx14
3 files changed, 27 insertions, 13 deletions
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
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/tdf134225.xlsx
Binary files 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