Kaydet (Commit) 379990b9 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

tdf#112280: Export spin animation in PPTX.

Contains also:

tdf#112280: Unit test.

Change-Id: I9f13bbc2bd3a3de582491ea5b2ad16535589420a
Reviewed-on: https://gerrit.libreoffice.org/42077Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
Tested-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst 649b14eb
......@@ -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();
......
......@@ -41,12 +41,14 @@
#include <com/sun/star/animations/AnimationFill.hpp>
#include <com/sun/star/animations/AnimationNodeType.hpp>
#include <com/sun/star/animations/AnimationRestart.hpp>
#include <com/sun/star/animations/AnimationTransformType.hpp>
#include <com/sun/star/animations/AnimationValueType.hpp>
#include <com/sun/star/animations/Event.hpp>
#include <com/sun/star/animations/EventTrigger.hpp>
#include <com/sun/star/animations/Timing.hpp>
#include <com/sun/star/animations/ValuePair.hpp>
#include <com/sun/star/animations/XAnimateMotion.hpp>
#include <com/sun/star/animations/XAnimateTransform.hpp>
#include <com/sun/star/animations/XAnimationNode.hpp>
#include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
#include <com/sun/star/animations/XCommand.hpp>
......@@ -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<XAnimateMotion> rMotion(rXNode, UNO_QUERY);
if (rMotion.is())
rMotion->getPath() >>= aPath;
}
OUString aPath;
Reference<XAnimateMotion> 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<XAnimateTransform> xTransform(rXNode, UNO_QUERY);
if (xTransform.is())
{
double value;
if (xTransform->getBy() >>= value)
{
aBy = OString::number(static_cast<int>(value * PER_DEGREE));
pBy = aBy.getStr();
}
if (xTransform->getFrom() >>= value)
{
aFrom = OString::number(static_cast<int>(value * PER_DEGREE));
pFrom = aFrom.getStr();
}
if (xTransform->getTo() >>= value)
{
aTo = OString::number(static_cast<int>(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<XAnimateTransform> 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;
}
......
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