From 74d020fb1344dd904681b612739727351f183b78 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Wed, 20 May 2020 21:10:41 +0200 Subject: tdf#133190 tdf#133191 Chart OOXML export: fix text wrap and rotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit of data point labels. Change-Id: Ic61d9ee149e838c000b5dc9ac0411bbe0f07219a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94598 Tested-by: László Németh Reviewed-by: László Németh --- oox/source/export/chartexport.cxx | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'oox') 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& xPropSet) pFS->startElement(FSNS(XML_c, XML_txPr)); sal_Int32 nRotation = 0; + const char* textWordWrap = nullptr; + if (auto xServiceInfo = uno::Reference(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& 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& 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)); -- cgit