summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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