Kaydet (Commit) 1bb4c8cc authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Andras Timar

tdf#119029: also export rotation for data series

Reviewed-on: https://gerrit.libreoffice.org/58401
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 8f904928)

Change-Id: I6a9895145e0c54d35bf404f209721a0c718e4446
Reviewed-on: https://gerrit.libreoffice.org/58470Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 77419fec
...@@ -107,6 +107,7 @@ public: ...@@ -107,6 +107,7 @@ public:
void testTdf116163(); void testTdf116163();
void testCustomDataLabel(); void testCustomDataLabel();
void testCustomDataLabelMultipleSeries(); void testCustomDataLabelMultipleSeries();
void testTdf119029();
CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(testErrorBarXLSX); CPPUNIT_TEST(testErrorBarXLSX);
...@@ -176,6 +177,7 @@ public: ...@@ -176,6 +177,7 @@ public:
CPPUNIT_TEST(testTdf116163); CPPUNIT_TEST(testTdf116163);
CPPUNIT_TEST(testCustomDataLabel); CPPUNIT_TEST(testCustomDataLabel);
CPPUNIT_TEST(testCustomDataLabelMultipleSeries); CPPUNIT_TEST(testCustomDataLabelMultipleSeries);
CPPUNIT_TEST(testTdf119029);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
protected: protected:
...@@ -1744,6 +1746,18 @@ void Chart2ExportTest::testCustomDataLabelMultipleSeries() ...@@ -1744,6 +1746,18 @@ void Chart2ExportTest::testCustomDataLabelMultipleSeries()
} }
void Chart2ExportTest::testTdf119029()
{
load("/chart2/qa/extras/data/odp/", "tdf119029.odp");
// Only use "chart", without number, because the number depends on the previous tests
xmlDocPtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
CPPUNIT_ASSERT(pXmlDoc);
assertXPath(pXmlDoc,
"/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:txPr/a:bodyPr", "rot",
"-5400000");
}
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -172,7 +172,7 @@ private: ...@@ -172,7 +172,7 @@ private:
void exportSeriesValues( void exportSeriesValues(
const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val ); const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val );
void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet, bool bAxis = false); void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet);
void exportDataPoints( void exportDataPoints(
const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties, const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties,
sal_Int32 nSeriesLength, sal_Int32 eChartType ); sal_Int32 nSeriesLength, sal_Int32 eChartType );
......
...@@ -2282,18 +2282,32 @@ void ChartExport::exportShapeProps( const Reference< XPropertySet >& xPropSet ) ...@@ -2282,18 +2282,32 @@ void ChartExport::exportShapeProps( const Reference< XPropertySet >& xPropSet )
pFS->endElement( FSNS( XML_c, XML_spPr ) ); pFS->endElement( FSNS( XML_c, XML_spPr ) );
} }
void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet, bool bAxis) void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet)
{ {
FSHelperPtr pFS = GetFS(); FSHelperPtr pFS = GetFS();
pFS->startElement(FSNS(XML_c, XML_txPr), FSEND); pFS->startElement(FSNS(XML_c, XML_txPr), FSEND);
sal_Int32 nRotation = 0; sal_Int32 nRotation = 0;
if (bAxis) if (auto xServiceInfo = uno::Reference<lang::XServiceInfo>(xPropSet, uno::UNO_QUERY))
{ {
double fTextRotation = 0; double fMultiplier = 0;
uno::Any aAny = xPropSet->getPropertyValue("TextRotation"); // We have at least two possible units of returned value: degrees (e.g., for data labels),
if (aAny.hasValue() && (aAny >>= fTextRotation)) // and 100ths of degree (e.g., for axes labels). The latter is returned as an Any wrapping
nRotation = fTextRotation * -600.0; // a sal_Int32 value (see WrappedTextRotationProperty::convertInnerToOuterValue), while
// the former is double. So we could test the contained type to decide which multiplier to
// 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"))
fMultiplier = -60000.0;
if (fMultiplier)
{
double fTextRotation = 0;
uno::Any aAny = xPropSet->getPropertyValue("TextRotation");
if (aAny.hasValue() && (aAny >>= fTextRotation))
nRotation = std::round(fTextRotation * fMultiplier);
}
} }
if (nRotation) if (nRotation)
...@@ -2707,7 +2721,7 @@ void ChartExport::_exportAxis( ...@@ -2707,7 +2721,7 @@ void ChartExport::_exportAxis(
// shape properties // shape properties
exportShapeProps( xAxisProp ); exportShapeProps( xAxisProp );
exportTextProps(xAxisProp, true); exportTextProps(xAxisProp);
pFS->singleElement( FSNS( XML_c, XML_crossAx ), pFS->singleElement( FSNS( XML_c, XML_crossAx ),
XML_val, I32S( rAxisIdPair.nCrossAx ), XML_val, I32S( rAxisIdPair.nCrossAx ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment