summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/qa/extras/chart2export.cxx25
-rw-r--r--chart2/qa/extras/data/xlsx/tdf133190_tdf133191.xlsxbin0 -> 12142 bytes
-rw-r--r--oox/source/export/chartexport.cxx28
3 files changed, 44 insertions, 9 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 08086d8ae2ab..429ea41c5a5a 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -168,6 +168,8 @@ public:
void testTdf131979();
void testTdf132076();
void testTdf125812();
+ void testTdf133190();
+ void testTdf133191();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(testErrorBarXLSX);
@@ -299,6 +301,8 @@ public:
CPPUNIT_TEST(testTdf131979);
CPPUNIT_TEST(testTdf132076);
CPPUNIT_TEST(testTdf125812);
+ CPPUNIT_TEST(testTdf133190);
+ CPPUNIT_TEST(testTdf133191);
CPPUNIT_TEST_SUITE_END();
@@ -2766,6 +2770,27 @@ void Chart2ExportTest::testTdf125812()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "b", "51000");
}
+void Chart2ExportTest::testTdf133190()
+{
+ load("/chart2/qa/extras/data/xlsx/", "tdf133190_tdf133191.xlsx");
+ xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // Test word wrap of data point label
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:txPr/a:bodyPr", "wrap", "none");
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:txPr/a:bodyPr", "wrap", "square");
+}
+
+void Chart2ExportTest::testTdf133191()
+{
+ load("/chart2/qa/extras/data/xlsx/", "tdf133190_tdf133191.xlsx");
+ xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // Test rotation of data point label
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[3]/c:txPr/a:bodyPr", "rot", "-4500000");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/xlsx/tdf133190_tdf133191.xlsx b/chart2/qa/extras/data/xlsx/tdf133190_tdf133191.xlsx
new file mode 100644
index 000000000000..f8cad0e8cfec
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/tdf133190_tdf133191.xlsx
Binary files differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 211b5b456438..6511cfaac48c 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2573,9 +2573,11 @@ void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet)
pFS->startElement(FSNS(XML_c, XML_txPr));
sal_Int32 nRotation = 0;
+ const char* textWordWrap = nullptr;
+
if (auto xServiceInfo = uno::Reference<lang::XServiceInfo>(xPropSet, uno::UNO_QUERY))
{
- double fMultiplier = 0;
+ double fMultiplier = 0.0;
// We have at least two possible units of returned value: degrees (e.g., for data labels),
// and 100ths of degree (e.g., for axes labels). The latter is returned as an Any wrapping
// a sal_Int32 value (see WrappedTextRotationProperty::convertInnerToOuterValue), while
@@ -2583,8 +2585,15 @@ void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet)
// use. But testing the service info should be more robust.
if (xServiceInfo->supportsService("com.sun.star.chart.ChartAxis"))
fMultiplier = -600.0;
- else if (xServiceInfo->supportsService("com.sun.star.chart2.DataSeries"))
+ else if (xServiceInfo->supportsService("com.sun.star.chart2.DataSeries") || xServiceInfo->supportsService("com.sun.star.chart2.DataPointProperties"))
+ {
fMultiplier = -60000.0;
+ bool bTextWordWrap = false;
+ if ((xPropSet->getPropertyValue("TextWordWrap") >>= bTextWordWrap) && bTextWordWrap)
+ textWordWrap = "square";
+ else
+ textWordWrap = "none";
+ }
if (fMultiplier)
{
@@ -2592,25 +2601,26 @@ void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet)
uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
if (aAny.hasValue() && (aAny >>= fTextRotation))
{
+ fTextRotation *= fMultiplier;
// The MS Office UI allows values only in range of [-90,90].
- if (fTextRotation > 9000.0 && fTextRotation < 27000.0)
+ if (fTextRotation < -5400000.0 && fTextRotation > -16200000.0)
{
// Reflect the angle if the value is between 90° and 270°
- fTextRotation -= 18000.0;
+ fTextRotation += 10800000.0;
}
- else if (fTextRotation >=27000.0)
+ else if (fTextRotation <= -16200000.0)
{
- fTextRotation -= 36000.0;
+ fTextRotation += 21600000.0;
}
- nRotation = std::round(fTextRotation * fMultiplier);
+ nRotation = std::round(fTextRotation);
}
}
}
if (nRotation)
- pFS->singleElement(FSNS(XML_a, XML_bodyPr), XML_rot, OString::number(nRotation));
+ pFS->singleElement(FSNS(XML_a, XML_bodyPr), XML_rot, OString::number(nRotation), XML_wrap, textWordWrap);
else
- pFS->singleElement(FSNS(XML_a, XML_bodyPr));
+ pFS->singleElement(FSNS(XML_a, XML_bodyPr), XML_wrap, textWordWrap);
pFS->singleElement(FSNS(XML_a, XML_lstStyle));