summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-01-30 23:58:57 +0100
committerLászló Németh <nemeth@numbertext.org>2020-01-31 10:43:22 +0100
commitdff7a46fb46d1fa2a3ad674ee493ae2d59150fe3 (patch)
treea20c2913d75c8173ed24064c877bb14568359700 /chart2
parent84b396a235671ea77f1a9fa0d131cb56d7662737 (diff)
tdf#130032 Chart OOXML Import: fix data label custom position
in case of all chart types except pie chart. Clean up commit 4223ff2be69f03e571464b0b09ad0d278918631b (tdf#48436 Chart: add CustomLabelPosition UNO API property). Note: use the correct default OOXML label placement in case of radar charts. Change-Id: I9a8f509304b3c70d879c8c6a95bc91d15ac28521 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87759 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2import.cxx25
-rw-r--r--chart2/qa/extras/data/xlsx/testTdf130032.xlsxbin0 -> 14208 bytes
-rw-r--r--chart2/source/view/main/VDataSeries.cxx12
3 files changed, 33 insertions, 4 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 47b2e0354d51..054b04209db2 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -153,6 +153,7 @@ public:
void testTdf123206CustomLabelField();
void testTdf125444PercentageCustomLabel();
void testDataPointLabelCustomPos();
+ void testTdf130032();
CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083);
@@ -254,6 +255,7 @@ public:
CPPUNIT_TEST(testTdf123206CustomLabelField);
CPPUNIT_TEST(testTdf125444PercentageCustomLabel);
CPPUNIT_TEST(testDataPointLabelCustomPos);
+ CPPUNIT_TEST(testTdf130032);
CPPUNIT_TEST_SUITE_END();
@@ -2353,6 +2355,7 @@ void Chart2ImportTest::testTdf125444PercentageCustomLabel()
void Chart2ImportTest::testDataPointLabelCustomPos()
{
+ // test CustomLabelPosition on Bar chart
load("/chart2/qa/extras/data/xlsx/", "testDataPointLabelCustomPos.xlsx");
uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent);
CPPUNIT_ASSERT(xChartDoc.is());
@@ -2372,6 +2375,28 @@ void Chart2ImportTest::testDataPointLabelCustomPos()
CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::OUTSIDE, aPlacement);
}
+void Chart2ImportTest::testTdf130032()
+{
+ // test CustomLabelPosition on Line chart
+ load("/chart2/qa/extras/data/xlsx/", "testTdf130032.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(1), uno::UNO_SET_THROW);
+ CPPUNIT_ASSERT(xPropertySet.is());
+
+ chart2::RelativePosition aCustomLabelPosition;
+ xPropertySet->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Primary, -0.0438333333333334, 1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Secondary, 0.086794050743657, 1e-7);
+
+ sal_Int32 aPlacement;
+ xPropertySet->getPropertyValue("LabelPlacement") >>= aPlacement;
+ CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::RIGHT, aPlacement);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/xlsx/testTdf130032.xlsx b/chart2/qa/extras/data/xlsx/testTdf130032.xlsx
new file mode 100644
index 000000000000..03a3dbf403c3
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/testTdf130032.xlsx
Binary files differ
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index 33bf9bee481d..f64cb151a2d8 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -641,8 +641,10 @@ awt::Point VDataSeries::getLabelPosition( awt::Point aTextShapePos, sal_Int32 nP
aPos.Y = static_cast<sal_Int32>(aCustomLabelPosition.Secondary * m_aReferenceSize.Height) + aTextShapePos.Y;
}
}
- catch (const uno::Exception&) {}
-
+ catch (const uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "");
+ }
return aPos;
}
@@ -659,8 +661,10 @@ bool VDataSeries::isLabelCustomPos(sal_Int32 nPointIndex) const
bCustom = true;
}
}
- catch (const uno::Exception&) {}
-
+ catch (const uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "");
+ }
return bCustom;
}