summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2020-09-17 16:49:02 +0200
committerLászló Németh <nemeth@numbertext.org>2020-10-09 09:24:18 +0200
commit20da1a5dd37c7edac620566c992d5a53b23a5f12 (patch)
treec86ca1c4d3617889469ee1cf8ddb7d3d36e07d0c /chart2
parent4777f5a0512655552c8803a7378926ad7c02da71 (diff)
tdf#134978 Chart OOXML Import: fix pie chart label custom position
Follow-up of commit dff7a46fb46d1fa2a3ad674ee493ae2d59150fe3 (tdf#130032 Chart OOXML Import: fix data label custom position). Change-Id: Iaaf4ae654ac0c1b4896a53be6034e6c027412df0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102981 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2import.cxx23
-rw-r--r--chart2/qa/extras/data/xlsx/tdf134978.xlsxbin0 -> 13746 bytes
-rw-r--r--chart2/source/tools/ChartTypeHelper.cxx3
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx7
4 files changed, 29 insertions, 4 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index dadc782c0af6..d901f879ea18 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -158,6 +158,7 @@ public:
void testTdf125444PercentageCustomLabel();
void testDataPointLabelCustomPos();
void testTdf130032();
+ void testTdf134978();
void testTdf119138MissingAutoTitleDeleted();
void testStockChartShiftedCategoryPosition();
void testTdf133376();
@@ -272,6 +273,7 @@ public:
CPPUNIT_TEST(testTdf125444PercentageCustomLabel);
CPPUNIT_TEST(testDataPointLabelCustomPos);
CPPUNIT_TEST(testTdf130032);
+ CPPUNIT_TEST(testTdf134978);
CPPUNIT_TEST(testTdf119138MissingAutoTitleDeleted);
CPPUNIT_TEST(testStockChartShiftedCategoryPosition);
CPPUNIT_TEST(testTdf133376);
@@ -1783,7 +1785,7 @@ void Chart2ImportTest::testTdf109858()
CPPUNIT_ASSERT( aAny.hasValue() );
sal_Int32 nLabelPlacement = 0;
CPPUNIT_ASSERT( aAny >>= nLabelPlacement );
- CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data point label should be placed bestFit", chart::DataLabelPlacement::AVOID_OVERLAP, nLabelPlacement );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data point label should be placed bestfit", chart::DataLabelPlacement::CUSTOM, nLabelPlacement );
// test data series label position
Reference<beans::XPropertySet> xSeriesPropSet(xChart1Doc->getDiagram()->getDataRowProperties(0), uno::UNO_SET_THROW);
@@ -2511,6 +2513,25 @@ void Chart2ImportTest::testTdf130032()
CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::RIGHT, aPlacement);
}
+void Chart2ImportTest::testTdf134978()
+{
+ // test CustomLabelPosition on Pie chart
+ load("/chart2/qa/extras/data/xlsx/", "tdf134978.xlsx");
+ uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc.is());
+ uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+ CPPUNIT_ASSERT(xDataSeries.is());
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(2),
+ uno::UNO_SET_THROW);
+ CPPUNIT_ASSERT(xPropertySet.is());
+
+ chart2::RelativePosition aCustomLabelPosition;
+ xPropertySet->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.040273622047244093, aCustomLabelPosition.Primary, 1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.25635352872557599, aCustomLabelPosition.Secondary, 1e-7);
+}
+
void Chart2ImportTest::testTdf119138MissingAutoTitleDeleted()
{
load("/chart2/qa/extras/data/xlsx/", "tdf119138-missing-autotitledeleted.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/tdf134978.xlsx b/chart2/qa/extras/data/xlsx/tdf134978.xlsx
new file mode 100644
index 000000000000..ad5522a9144d
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/tdf134978.xlsx
Binary files differ
diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx
index 236d066f77d3..a4b8059ffb19 100644
--- a/chart2/source/tools/ChartTypeHelper.cxx
+++ b/chart2/source/tools/ChartTypeHelper.cxx
@@ -252,12 +252,13 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const
if(!bDonut)
{
- aRet.realloc(4);
+ aRet.realloc(5);
sal_Int32* pSeq = aRet.getArray();
*pSeq++ = css::chart::DataLabelPlacement::AVOID_OVERLAP;
*pSeq++ = css::chart::DataLabelPlacement::OUTSIDE;
*pSeq++ = css::chart::DataLabelPlacement::INSIDE;
*pSeq++ = css::chart::DataLabelPlacement::CENTER;
+ *pSeq++ = css::chart::DataLabelPlacement::CUSTOM;
}
else
{
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 6042b0d0dbe4..55eb67037b9a 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -293,7 +293,8 @@ void PieChart::createTextLabelShape(
double nVal = rSeries.getYValue(nPointIndex);
//AVOID_OVERLAP is in fact "Best fit" in the UI.
- bool bMovementAllowed = ( nLabelPlacement == css::chart::DataLabelPlacement::AVOID_OVERLAP );
+ bool bMovementAllowed = nLabelPlacement == css::chart::DataLabelPlacement::AVOID_OVERLAP
+ || nLabelPlacement == css::chart::DataLabelPlacement::CUSTOM;
if( bMovementAllowed )
nLabelPlacement = css::chart::DataLabelPlacement::CENTER;
@@ -389,7 +390,9 @@ void PieChart::createTextLabelShape(
* First off the routine try to place the label inside the related pie slice,
* if this is not possible the label is placed outside.
*/
- if (!performLabelBestFitInnerPlacement(rParam, aPieLabelInfo))
+ if (rSeries.getLabelPlacement(nPointIndex, m_xChartTypeModel, m_pPosHelper->isSwapXAndY())
+ == css::chart::DataLabelPlacement::CUSTOM
+ || !performLabelBestFitInnerPlacement(rParam, aPieLabelInfo))
{
if (m_aAvailableOuterRect.getWidth())
{