From 1f61b9bca25c4a1ce03f88e4408f2716865a8f86 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Wed, 14 Mar 2018 18:59:49 +0100 Subject: tdf#90627 Don't save empty conditions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5a953c1b0fff7bf41a59360a8f52596264ddf266 Reviewed-on: https://gerrit.libreoffice.org/51293 Tested-by: Jenkins Reviewed-by: Szymon Kłos Reviewed-on: https://gerrit.libreoffice.org/51455 Reviewed-by: Andras Timar Tested-by: Andras Timar (cherry picked from commit a21204ec1cf0b5f311f581ecce437785005d0456) --- sd/qa/unit/data/odp/tdf90627.odp | Bin 0 -> 38499 bytes sd/qa/unit/export-tests-ooxml2.cxx | 15 ++++++++ sd/source/filter/eppt/epptooxml.hxx | 4 +- sd/source/filter/eppt/pptx-epptooxml.cxx | 63 +++++++++++++++---------------- 4 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 sd/qa/unit/data/odp/tdf90627.odp diff --git a/sd/qa/unit/data/odp/tdf90627.odp b/sd/qa/unit/data/odp/tdf90627.odp new file mode 100644 index 000000000000..dfa28c9b09a3 Binary files /dev/null and b/sd/qa/unit/data/odp/tdf90627.odp differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 9818801662aa..ed1076fe1f0e 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -130,6 +130,7 @@ public: void testTdf115394Zero(); /// SmartArt animated elements void testTdf104792(); + void testTdf90627(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -180,6 +181,7 @@ public: CPPUNIT_TEST(testTdf115394); CPPUNIT_TEST(testTdf115394Zero); CPPUNIT_TEST(testTdf104792); + CPPUNIT_TEST(testTdf90627); CPPUNIT_TEST_SUITE_END(); @@ -1215,6 +1217,19 @@ void SdOOXMLExportTest2::testTdf104792() xDocShRef->DoClose(); } +void SdOOXMLExportTest2::testTdf90627() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf90627.odp"), ODP); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + + xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); + // Don't export empty conditions + assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst[1]/p:seq/p:cTn/p:childTnLst[1]/p:par[2]/p:cTn/p:childTnLst[1]/p:par/p:cTn/p:childTnLst[1]/p:par/p:cTn/p:endCondLst", 0); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/source/filter/eppt/epptooxml.hxx b/sd/source/filter/eppt/epptooxml.hxx index 7c4ab7a9580a..fb8617491936 100644 --- a/sd/source/filter/eppt/epptooxml.hxx +++ b/sd/source/filter/eppt/epptooxml.hxx @@ -103,8 +103,8 @@ protected: static void WriteAnimateTo( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Any& rValue, const OUString& rAttributeName ); static void WriteAnimateValues( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimate >& rXAnimate ); - static void WriteAnimationCondition( const ::sax_fastparser::FSHelperPtr& pFS, css::uno::Any& rAny, bool bWriteEvent, bool bMainSeqChild ); - static void WriteAnimationCondition( const ::sax_fastparser::FSHelperPtr& pFS, const char* pDelay, const char* pEvent, double fDelay, bool bHasFDelay ); + static void WriteAnimationCondition( const ::sax_fastparser::FSHelperPtr& pFS, css::uno::Any const & rAny, bool bWriteEvent, bool bMainSeqChild, sal_Int32 nToken ); + static void WriteAnimationCondition( const ::sax_fastparser::FSHelperPtr& pFS, const char* pDelay, const char* pEvent, double fDelay, bool bHasFDelay, sal_Int32 nToken ); void WriteAnimations( const ::sax_fastparser::FSHelperPtr& pFS ); static void WriteAnimationAttributeName( const ::sax_fastparser::FSHelperPtr& pFS, const OUString& rAttributeName ); void WriteAnimationNode( const ::sax_fastparser::FSHelperPtr& pFS, const css::uno::Reference< css::animations::XAnimationNode >& rXNode, bool bMainSeqChild ); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 9d6f3066b7e9..a661fda0dd80 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -1250,29 +1250,35 @@ void PowerPointExport::WriteAnimationNodeAnimateInside( const FSHelperPtr& pFS, WriteAnimateTo( pFS, rXAnimate->getTo(), rXAnimate->getAttributeName() ); } -void PowerPointExport::WriteAnimationCondition( const FSHelperPtr& pFS, const char* pDelay, const char* pEvent, double fDelay, bool bHasFDelay ) +void PowerPointExport::WriteAnimationCondition(const FSHelperPtr& pFS, const char* pDelay, const char* pEvent, double fDelay, bool bHasFDelay, sal_Int32 nToken) { - if( bHasFDelay || pDelay || pEvent ) { - if( !pEvent ) - pFS->singleElementNS( XML_p, XML_cond, - XML_delay, bHasFDelay ? I64S( (sal_uInt32) (fDelay*1000.0) ) : pDelay, - FSEND ); - else { - pFS->startElementNS( XML_p, XML_cond, - XML_delay, bHasFDelay ? I64S( (sal_uInt32) (fDelay*1000.0) ) : pDelay, - XML_evt, pEvent, - FSEND ); + if (bHasFDelay || pDelay || pEvent) + { + pFS->startElementNS(XML_p, nToken, FSEND); + + if (!pEvent) + pFS->singleElementNS(XML_p, XML_cond, + XML_delay, bHasFDelay ? I64S(static_cast(fDelay*1000.0)) : pDelay, + FSEND); + else + { + pFS->startElementNS(XML_p, XML_cond, + XML_delay, bHasFDelay ? I64S(static_cast(fDelay*1000.0)) : pDelay, + XML_evt, pEvent, + FSEND); - pFS->startElementNS( XML_p, XML_tgtEl, FSEND ); - pFS->singleElementNS( XML_p, XML_sldTgt, FSEND ); - pFS->endElementNS( XML_p, XML_tgtEl ); + pFS->startElementNS( XML_p, XML_tgtEl, FSEND ); + pFS->singleElementNS( XML_p, XML_sldTgt, FSEND ); + pFS->endElementNS( XML_p, XML_tgtEl ); - pFS->endElementNS( XML_p, XML_cond ); - } + pFS->endElementNS(XML_p, XML_cond); + } + + pFS->endElementNS(XML_p, nToken); } } -void PowerPointExport::WriteAnimationCondition( const FSHelperPtr& pFS, Any& rAny, bool bWriteEvent, bool bMainSeqChild ) +void PowerPointExport::WriteAnimationCondition(const FSHelperPtr& pFS, Any const& rAny, bool bWriteEvent, bool bMainSeqChild, sal_Int32 nToken) { bool bHasFDelay = false; double fDelay = 0; @@ -1355,7 +1361,7 @@ void PowerPointExport::WriteAnimationCondition( const FSHelperPtr& pFS, Any& rAn } } - WriteAnimationCondition( pFS, pDelay, pEvent, fDelay, bHasFDelay ); + WriteAnimationCondition(pFS, pDelay, pEvent, fDelay, bHasFDelay, nToken); } void PowerPointExport::WriteAnimationNodeCommonPropsStart( const FSHelperPtr& pFS, const Reference< XAnimationNode >& rXNode, bool bSingle, bool bMainSeqChild ) @@ -1501,26 +1507,22 @@ void PowerPointExport::WriteAnimationNodeCommonPropsStart( const FSHelperPtr& pF if( aAny.hasValue() ) { Sequence< Any > aCondSeq; - pFS->startElementNS( XML_p, XML_stCondLst, FSEND ); if( aAny >>= aCondSeq ) { for( int i = 0; i < aCondSeq.getLength(); i ++ ) - WriteAnimationCondition( pFS, aCondSeq[ i ], false, bMainSeqChild ); + WriteAnimationCondition( pFS, aCondSeq[ i ], false, bMainSeqChild, XML_stCondLst ); } else - WriteAnimationCondition( pFS, aAny, false, bMainSeqChild ); - pFS->endElementNS( XML_p, XML_stCondLst ); + WriteAnimationCondition( pFS, aAny, false, bMainSeqChild, XML_stCondLst ); } aAny = rXNode->getEnd(); if( aAny.hasValue() ) { Sequence< Any > aCondSeq; - pFS->startElementNS( XML_p, XML_endCondLst, FSEND ); if( aAny >>= aCondSeq ) { for( int i = 0; i < aCondSeq.getLength(); i ++ ) - WriteAnimationCondition( pFS, aCondSeq[ i ], false, bMainSeqChild ); + WriteAnimationCondition( pFS, aCondSeq[ i ], false, bMainSeqChild, XML_endCondLst ); } else - WriteAnimationCondition( pFS, aAny, false, bMainSeqChild ); - pFS->endElementNS( XML_p, XML_endCondLst ); + WriteAnimationCondition( pFS, aAny, false, bMainSeqChild, XML_endCondLst ); } Reference< XEnumerationAccess > xEnumerationAccess( rXNode, UNO_QUERY ); @@ -1556,13 +1558,8 @@ void PowerPointExport::WriteAnimationNodeSeq( const FSHelperPtr& pFS, const Refe WriteAnimationNodeCommonPropsStart( pFS, rXNode, true, bMainSeqChild ); - pFS->startElementNS( XML_p, XML_prevCondLst, FSEND ); - WriteAnimationCondition( pFS, nullptr, "onPrev", 0, true ); - pFS->endElementNS( XML_p, XML_prevCondLst ); - - pFS->startElementNS( XML_p, XML_nextCondLst, FSEND ); - WriteAnimationCondition( pFS, nullptr, "onNext", 0, true ); - pFS->endElementNS( XML_p, XML_nextCondLst ); + WriteAnimationCondition(pFS, nullptr, "onPrev", 0, true, XML_prevCondLst); + WriteAnimationCondition(pFS, nullptr, "onNext", 0, true, XML_nextCondLst); pFS->endElementNS( XML_p, XML_seq ); } -- cgit