From 379990b93958d6c49d716f097d94f5b8894e811e Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Thu, 7 Sep 2017 19:26:07 +0200 Subject: tdf#112280: Export spin animation in PPTX. Contains also: tdf#112280: Unit test. Change-Id: I9f13bbc2bd3a3de582491ea5b2ad16535589420a Reviewed-on: https://gerrit.libreoffice.org/42077 Reviewed-by: Jan Holesovsky Tested-by: Jan Holesovsky --- sd/qa/unit/data/pptx/tdf112280.pptx | Bin 0 -> 30309 bytes sd/qa/unit/export-tests-ooxml2.cxx | 15 ++++++ sd/source/filter/eppt/pptx-epptooxml.cxx | 84 +++++++++++++++++++++++++++---- 3 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 sd/qa/unit/data/pptx/tdf112280.pptx diff --git a/sd/qa/unit/data/pptx/tdf112280.pptx b/sd/qa/unit/data/pptx/tdf112280.pptx new file mode 100644 index 000000000000..39c2aa4cb1b8 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf112280.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 5586564a33e5..531f97b153c9 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -106,6 +106,7 @@ public: void testTdf105739(); void testTdf111518(); void testTdf106867(); + void testTdf112280(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -135,6 +136,7 @@ public: CPPUNIT_TEST(testTdf105739); CPPUNIT_TEST(testTdf111518); CPPUNIT_TEST(testTdf106867); + CPPUNIT_TEST(testTdf112280); CPPUNIT_TEST_SUITE_END(); @@ -840,6 +842,19 @@ void SdOOXMLExportTest2::testTdf106867() "spid", "42"); } +void SdOOXMLExportTest2::testTdf112280() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf112280.pptx"), PPTX); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + + // check the animRot value + xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:animRot", + "by", "21600000"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 4c18981fe169..e04b6f950f75 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -41,12 +41,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -908,6 +910,16 @@ void PowerPointExport::WriteAnimationAttributeName( const FSHelperPtr& pFS, cons pFS->writeEscaped("ppt_y"); pFS->endElementNS(XML_p, XML_attrName); } + else if (rAttributeName == "Rotate") + { + pFS->startElementNS(XML_p, XML_attrName, FSEND); + pFS->writeEscaped("r"); + pFS->endElementNS(XML_p, XML_attrName); + } + else + { + SAL_INFO("sd.eppt", "unhandled animation attribute name: " << rAttributeName); + } pFS->endElementNS( XML_p, XML_attrNameLst ); } @@ -969,27 +981,62 @@ void PowerPointExport::WriteAnimationNodeAnimate( const FSHelperPtr& pFS, const } } - OUString aPath; if (nXmlNodeType == XML_animMotion) { - Reference rMotion(rXNode, UNO_QUERY); - if (rMotion.is()) - rMotion->getPath() >>= aPath; - } + OUString aPath; + Reference xMotion(rXNode, UNO_QUERY); + if (xMotion.is()) + xMotion->getPath() >>= aPath; - if (aPath.isEmpty()) + pFS->startElementNS(XML_p, nXmlNodeType, + XML_path, OUStringToOString(aPath, RTL_TEXTENCODING_UTF8), + FSEND); + } + else if (nXmlNodeType == XML_animRot) { + // when const char* is nullptr, the attribute is completely omitted in the output + const char* pBy = nullptr; + const char* pFrom = nullptr; + const char* pTo = nullptr; + OString aBy, aFrom, aTo; + + Reference xTransform(rXNode, UNO_QUERY); + if (xTransform.is()) + { + double value; + if (xTransform->getBy() >>= value) + { + aBy = OString::number(static_cast(value * PER_DEGREE)); + pBy = aBy.getStr(); + } + + if (xTransform->getFrom() >>= value) + { + aFrom = OString::number(static_cast(value * PER_DEGREE)); + pFrom = aFrom.getStr(); + } + + if (xTransform->getTo() >>= value) + { + aTo = OString::number(static_cast(value * PER_DEGREE)); + pTo = aTo.getStr(); + } + } + pFS->startElementNS(XML_p, nXmlNodeType, - XML_calcmode, pCalcMode, - XML_valueType, pValueType, + XML_by, pBy, + XML_from, pFrom, + XML_to, pTo, FSEND); } else { pFS->startElementNS(XML_p, nXmlNodeType, - XML_path, OUStringToOString(aPath, RTL_TEXTENCODING_UTF8), + XML_calcmode, pCalcMode, + XML_valueType, pValueType, FSEND); } + WriteAnimationNodeAnimateInside(pFS, rXNode, bMainSeqChild, bSimple); pFS->endElementNS(XML_p, nXmlNodeType); } @@ -1425,6 +1472,23 @@ void PowerPointExport::WriteAnimationNode( const FSHelperPtr& pFS, const Referen xmlNodeType = XML_animMotion; pMethod = &PowerPointExport::WriteAnimationNodeAnimate; break; + case AnimationNodeType::ANIMATETRANSFORM: + { + Reference xTransform(rXNode, UNO_QUERY); + if (xTransform.is()) + { + if (xTransform->getTransformType() == AnimationTransformType::SCALE) + { + SAL_WARN("sd.eppt", "SCALE transform type not handled"); + } + else if (xTransform->getTransformType() == AnimationTransformType::ROTATE) + { + xmlNodeType = XML_animRot; + pMethod = &PowerPointExport::WriteAnimationNodeAnimate; + } + } + } + break; case AnimationNodeType::SET: xmlNodeType = XML_set; pMethod = &PowerPointExport::WriteAnimationNodeAnimate; @@ -1438,7 +1502,7 @@ void PowerPointExport::WriteAnimationNode( const FSHelperPtr& pFS, const Referen pMethod = &PowerPointExport::WriteAnimationNodeCommand; break; default: - SAL_WARN("sd.eppt", "unhandled: " << rXNode->getType()); + SAL_WARN("sd.eppt", "unhandled animation node: " << rXNode->getType()); break; } -- cgit