diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-10-06 16:04:25 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-10-31 08:57:48 +0100 |
commit | 54293c1fae0c774c72a8564a25844aecf6d40f7f (patch) | |
tree | ed710710101110dff795e55a8951a1643f36c9ed | |
parent | e7a0948db44f049b1cf03a6e6fcaca7e63e88ac2 (diff) |
SmartArt: export text rotation in the PPTX
Change-Id: I74bfc172fe7434d14de468ecfd3412636e53780c
Reviewed-on: https://gerrit.libreoffice.org/43202
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/44080
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | include/oox/drawingml/drawingmltypes.hxx | 15 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 22 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 4 | ||||
-rwxr-xr-x | sd/qa/unit/data/pptx/smartart-rotation2.pptx | bin | 0 -> 43658 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 13 |
5 files changed, 32 insertions, 22 deletions
diff --git a/include/oox/drawingml/drawingmltypes.hxx b/include/oox/drawingml/drawingmltypes.hxx index 2aac13c669a7..aaed34b11ab9 100644 --- a/include/oox/drawingml/drawingmltypes.hxx +++ b/include/oox/drawingml/drawingmltypes.hxx @@ -150,6 +150,21 @@ struct IndexRange { /** retrieve the content of CT_IndexRange */ IndexRange GetIndexRange( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes ); +/** +* nRotation is a 100th of a degree and the return value is +* in a 60,000th of a degree +* +* Also rotation is in opposite directions so multiply with -1 +*/ +inline OString calcRotationValue(sal_Int32 nRotation) +{ + if (nRotation > 18000) // 180 degree + { + nRotation -= 36000; + } + nRotation *= -600; + return OString::number(nRotation); +} const sal_Int32 EMU_PER_HMM = 360; /// 360 EMUs per 1/100 mm. diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 41faecacdbdb..e2c386194d0b 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1038,26 +1038,6 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x pFS->endElement( FSNS( XML_c, XML_legend ) ); } -namespace { - -/** - * nRotation is a 100th of a degree and the return value is - * in a 60,000th of a degree - * - * Also rotation is in opposite directions so multiply with -1 - */ -OString calcRotationValue(sal_Int32 nRotation) -{ - if (nRotation > 18000) // 180 degree - { - nRotation -= 36000; - } - nRotation *= -600; - return OString::number(nRotation); -} - -} - void ChartExport::exportTitle( const Reference< XShape >& xShape ) { OUString sText; @@ -1090,7 +1070,7 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape ) pFS->singleElement( FSNS( XML_a, XML_bodyPr ), XML_vert, sWritingMode, - XML_rot, calcRotationValue(nRotation).getStr(), + XML_rot, oox::drawingml::calcRotationValue(nRotation).getStr(), FSEND ); // TODO: lstStyle pFS->singleElement( FSNS( XML_a, XML_lstStyle ), diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 4f1aa7223ee1..14f7c363ec4b 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2079,6 +2079,8 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin if( !xXText.is() ) return; + sal_Int32 nTextRotateAngle = 0; + #define DEFLRINS 254 #define DEFTBINS 127 sal_Int32 nLeft, nRight, nTop, nBottom; @@ -2118,7 +2120,6 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin { for ( sal_Int32 i = 0, nElems = aProps.getLength(); i < nElems; ++i ) { - sal_Int32 nTextRotateAngle = 0; if ( aProps[ i ].Name == "TextPreRotateAngle" && ( aProps[ i ].Value >>= nTextRotateAngle ) ) { if ( nTextRotateAngle == -90 ) @@ -2175,6 +2176,7 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin XML_anchor, sVerticalAlignment, XML_anchorCtr, bHorizontalCenter ? "1" : nullptr, XML_vert, sWritingMode, + XML_rot, (nTextRotateAngle != 0) ? oox::drawingml::calcRotationValue( nTextRotateAngle * 100 ).getStr() : nullptr, FSEND ); if( !presetWarp.isEmpty()) { diff --git a/sd/qa/unit/data/pptx/smartart-rotation2.pptx b/sd/qa/unit/data/pptx/smartart-rotation2.pptx Binary files differnew file mode 100755 index 000000000000..e1c4493a7407 --- /dev/null +++ b/sd/qa/unit/data/pptx/smartart-rotation2.pptx diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 4b467568921b..12cdd1580806 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -108,6 +108,7 @@ public: void testTdf105739(); void testTdf112552(); void testTdf112647(); + void testSmartartRotation2(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -137,6 +138,7 @@ public: CPPUNIT_TEST(testTdf105739); CPPUNIT_TEST(testTdf112552); CPPUNIT_TEST(testTdf112647); + CPPUNIT_TEST(testSmartartRotation2); CPPUNIT_TEST_SUITE_END(); @@ -827,6 +829,17 @@ void SdOOXMLExportTest2::testTdf112647() xDocShRef->DoClose(); } +void SdOOXMLExportTest2::testSmartartRotation2() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rotation2.pptx"), PPTX); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + + xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:txBody/a:bodyPr", "rot", "10800000"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); |