summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2018-07-21 10:20:51 +0800
committerMark Hung <marklh9@gmail.com>2018-07-24 12:12:01 +0200
commit6a79db85be2520de3ca5d2c52eacdb58bc17fec8 (patch)
treed72a7e30bf46d018d83a508048295172baacc049
parent0bc245ede6ec5831561e950299071f57b0329da8 (diff)
tdf#118835 export animClr element. ( handle AnimateColor ).
Implement PowerPointExport::WriteAnimateColorColor to export to, from, by elements of the animClr element. Change-Id: I0fb81f8838656c127610a9a10654e3e51106bea8 Reviewed-on: https://gerrit.libreoffice.org/57820 Tested-by: Jenkins Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r--sd/qa/unit/data/odp/tdf118835.odpbin0 -> 11973 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx30
-rw-r--r--sd/source/filter/eppt/epptooxml.hxx2
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx73
4 files changed, 103 insertions, 2 deletions
diff --git a/sd/qa/unit/data/odp/tdf118835.odp b/sd/qa/unit/data/odp/tdf118835.odp
new file mode 100644
index 000000000000..c3e15a6dcac9
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf118835.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 6756f86e9ab7..e33f02f82103 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -148,6 +148,7 @@ public:
void testTdf118783();
void testTdf104789();
void testOpenDocumentAsReadOnly();
+ void testTdf118835();
void testTdf118768();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
@@ -218,6 +219,7 @@ public:
CPPUNIT_TEST(testTdf118783);
CPPUNIT_TEST(testTdf104789);
CPPUNIT_TEST(testOpenDocumentAsReadOnly);
+ CPPUNIT_TEST(testTdf118835);
CPPUNIT_TEST(testTdf118768);
CPPUNIT_TEST_SUITE_END();
@@ -1726,6 +1728,34 @@ void SdOOXMLExportTest2::testOpenDocumentAsReadOnly()
xDocShRef->DoClose();
}
+void SdOOXMLExportTest2::testTdf118835()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf118835.odp"), ODP);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+ xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDocContent, "(//p:animClr)[1]", "clrSpc", "rgb");
+ assertXPathContent(pXmlDocContent, "(//p:animClr)[1]//p:attrName", "style.color");
+ assertXPath(pXmlDocContent, "(//p:animClr)[1]//p:to/a:srgbClr", "val", "ed1c24");
+
+ assertXPath(pXmlDocContent, "(//p:animClr)[2]", "clrSpc", "rgb");
+ assertXPathContent(pXmlDocContent, "(//p:animClr)[2]//p:attrName", "stroke.color");
+ assertXPath(pXmlDocContent, "(//p:animClr)[2]//p:to/a:srgbClr", "val", "333399");
+
+ assertXPath(pXmlDocContent, "(//p:animClr)[3]", "clrSpc", "rgb");
+ assertXPathContent(pXmlDocContent, "(//p:animClr)[3]//p:attrName", "fillcolor");
+ assertXPath(pXmlDocContent, "(//p:animClr)[3]//p:to/a:srgbClr", "val", "fcd3c1");
+
+ assertXPath(pXmlDocContent, "(//p:animClr)[5]", "clrSpc", "hsl");
+ assertXPathContent(pXmlDocContent, "(//p:animClr)[5]//p:attrName", "fillcolor");
+ assertXPath(pXmlDocContent, "(//p:animClr)[5]//p:by/p:hsl", "h", "10800000");
+ assertXPath(pXmlDocContent, "(//p:animClr)[5]//p:by/p:hsl", "s", "0");
+ assertXPath(pXmlDocContent, "(//p:animClr)[5]//p:by/p:hsl", "l", "0");
+
+ xDocShRef->DoClose();
+}
+
void SdOOXMLExportTest2::testTdf118768()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf118768-brake.odp"), ODP);
diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx
index ee5520f590b5..8784ae49c18a 100644
--- a/sd/source/filter/eppt/epptooxml.hxx
+++ b/sd/source/filter/eppt/epptooxml.hxx
@@ -112,6 +112,8 @@ private:
void WriteAnimationNodeEffect( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, sal_Int32 nXmlNodeType, bool bMainSeqChild );
void WriteAnimationNodeCommand(const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, sal_Int32 nXmlNodeType, bool bMainSeqChild );
void WriteAnimationNodeCommonPropsStart( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, bool bSingle, bool bMainSeqChild );
+
+ static void WriteAnimateColorColor(const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Any& rAny, sal_Int32 nToken);
static void WriteAnimationProperty( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Any& rAny, sal_Int32 nToken = 0 );
void WriteAnimationTarget( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Any& rTarget );
bool WriteComments( sal_uInt32 nPageNum );
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 5811334ddff7..80e87fa1db0c 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -45,6 +45,7 @@
#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/AnimationColorSpace.hpp>
#include <com/sun/star/animations/Event.hpp>
#include <com/sun/star/animations/EventTrigger.hpp>
#include <com/sun/star/animations/Timing.hpp>
@@ -55,6 +56,7 @@
#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/XAnimateColor.hpp>
#include <com/sun/star/animations/XCommand.hpp>
#include <com/sun/star/animations/XTransitionFilter.hpp>
#include <com/sun/star/beans/Property.hpp>
@@ -1195,8 +1197,18 @@ void PowerPointExport::WriteAnimationNodeAnimate(const FSHelperPtr& pFS, const R
}
else if (nXmlNodeType == XML_animClr)
{
+ Reference<XAnimateColor> xColor(rXNode, UNO_QUERY);
+ const char *pColorSpace = "rgb";
+ const char *pDirection = nullptr;
+ if (xColor.is() && xColor->getColorInterpolation() == AnimationColorSpace::HSL)
+ {
+ // Note: from, to, by can still be specified in any supported format.
+ pColorSpace = "hsl";
+ pDirection = xColor->getDirection() ? "cw" : "ccw";
+ }
pFS->startElementNS(XML_p, nXmlNodeType,
- XML_clrSpc, "rgb",
+ XML_clrSpc, pColorSpace,
+ XML_dir, pDirection,
XML_calcmode, pCalcMode,
XML_valueType, pValueType,
FSEND);
@@ -1229,6 +1241,54 @@ void PowerPointExport::WriteAnimationNodeAnimate(const FSHelperPtr& pFS, const R
pFS->endElementNS(XML_p, nXmlNodeType);
}
+void PowerPointExport::WriteAnimateColorColor(const FSHelperPtr& pFS, const Any& rAny, sal_Int32 nToken)
+{
+ if (!rAny.hasValue())
+ return;
+
+ sal_Int32 nColor = 0;
+ if (rAny >>= nColor)
+ {
+ pFS->startElementNS(XML_p, nToken, FSEND);
+
+ if (nToken == XML_by)
+ {
+ // CT_TLByRgbColorTransform
+ SAL_WARN("sd.eppt", "Export p:rgb in p:by of animClr isn't implemented yet.");
+ }
+ else
+ {
+ // CT_Color
+ pFS->singleElementNS(XML_a, XML_srgbClr, XML_val, I32SHEX(nColor), FSEND);
+ }
+
+ pFS->endElementNS(XML_p, nToken);
+ }
+
+ Sequence< double > aHSL(3);
+ if (rAny >>= aHSL)
+ {
+ pFS->startElementNS(XML_p, nToken, FSEND);
+
+ if (nToken == XML_by)
+ {
+ // CT_TLByHslColorTransform
+ pFS->singleElementNS(XML_p, XML_hsl,
+ XML_h, I32S(aHSL[0] * 60000), // ST_Angel
+ XML_s, I32S(aHSL[1] * 100000),
+ XML_l, I32S(aHSL[2] * 100000),
+ FSEND);
+ }
+ else
+ {
+ // CT_Color
+ SAL_WARN("sd.eppt", "Export p:hsl in p:from or p:to of animClr isn't implemented yet.");
+ }
+
+ pFS->endElementNS(XML_p, nToken);
+ }
+}
+
void PowerPointExport::WriteAnimationNodeAnimateInside(const FSHelperPtr& pFS, const Reference< XAnimationNode >& rXNode, bool bMainSeqChild, bool bSimple, bool bWriteTo)
{
Reference< XAnimate > rXAnimate(rXNode, UNO_QUERY);
@@ -1276,7 +1336,16 @@ void PowerPointExport::WriteAnimationNodeAnimateInside(const FSHelperPtr& pFS, c
pFS->endElementNS(XML_p, XML_cBhvr);
WriteAnimateValues(pFS, rXAnimate);
- if (bWriteTo)
+
+ Reference<XAnimateColor> xColor(rXNode, UNO_QUERY);
+
+ if (xColor.is())
+ {
+ WriteAnimateColorColor(pFS, xColor->getBy(), XML_by);
+ WriteAnimateColorColor(pFS, xColor->getFrom(), XML_from);
+ WriteAnimateColorColor(pFS, xColor->getTo(), XML_to);
+ }
+ else if (bWriteTo)
WriteAnimateTo(pFS, rXAnimate->getTo(), rXAnimate->getAttributeName());
}