diff options
author | Marco Cecchetti <mrcekets@gmail.com> | 2011-07-22 12:30:11 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-08-26 18:25:20 +0200 |
commit | 964e60b0847186b8aee2218b97c1cc2bc9141761 (patch) | |
tree | 6dd94d12c6c997ced9750751b081b96e9bd9ab30 | |
parent | 2ba4caca79923ffe6db3a07a59ba84886b43f84a (diff) |
a new method for exporting animations has been implemented.
This routine invokes the same animations exporter used for exporting
animation in odp format. To prevent the SVGExport object from
destruction when passed to the AnimationsExporter constructor, a
variable named xSVGExport of type Reference<XInterface> acquires the
object pointed by mpSVGExport.
-rw-r--r-- | filter/source/svg/svgexport.cxx | 83 | ||||
-rw-r--r-- | filter/source/svg/svgfilter.hxx | 20 |
2 files changed, 95 insertions, 8 deletions
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index 09d09343b6f2..0f5d890fbeec 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -52,6 +52,7 @@ #include <i18npool/lang.h> #include <svl/zforlist.hxx> #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> +#include <xmloff/animationexport.hxx> #include <boost/preprocessor/repetition/repeat.hpp> @@ -601,6 +602,10 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) if( mpSVGExport != NULL ) { + // xSVGExport is set up only to manage the life-time of the object pointed by mpSVGExport, + // and in order to prevent that it is destroyed when passed to AnimationExporter. + Reference< XInterface > xSVGExport = static_cast< ::com::sun::star::document::XFilter* >( mpSVGExport ); + // create an id for each draw page for( sal_Int32 i = 0; i < mSelectedPages.getLength(); ++i ) implRegisterInterface( mSelectedPages[i] ); @@ -643,7 +648,7 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) mpSdrModel->GetDrawOutliner( NULL ).SetCalcFieldValueHdl( maOldFieldHdl ); delete mpSVGWriter, mpSVGWriter = NULL; - delete mpSVGExport, mpSVGExport = NULL; + mpSVGExport = NULL; // pointed object is released by xSVGExport dtor at the end of this scope delete mpSVGFontExport, mpSVGFontExport = NULL; delete mpObjects, mpObjects = NULL; mbPresentation = sal_False; @@ -801,6 +806,11 @@ sal_Bool SVGFilter::implExportDocument() mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns", B2UCONST( "http://www.w3.org/2000/svg" ) ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:xlink", B2UCONST( "http://www.w3.org/1999/xlink" ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:draw", B2UCONST( "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:presentation", B2UCONST( "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:smil", B2UCONST( "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:anim", B2UCONST( "urn:oasis:names:tc:opendocument:xmlns:animation:1.0" ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xml:space", B2UCONST( "preserve" ) ); mpSVGDoc = new SvXMLElementExport( *mpSVGExport, XML_NAMESPACE_NONE, "svg", sal_True, sal_True ); @@ -827,6 +837,7 @@ sal_Bool SVGFilter::implExportDocument() if( !mbSinglePage ) { implGenerateMetaData(); + implExportAnimations(); } else { @@ -913,6 +924,9 @@ sal_Bool SVGFilter::implGenerateMetaData() sal_Int32 nCount = mSelectedPages.getLength(); if( nCount != 0 ) { + // we wrap all meta presentation info into a svg:defs element + SvXMLElementExport aDefsElem( *mpSVGExport, XML_NAMESPACE_NONE, "defs", sal_True, sal_True ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", B2UCONST( aOOOElemMetaSlides ) ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrNumberOfSlides, OUString::valueOf( nCount ) ); @@ -1118,6 +1132,73 @@ sal_Bool SVGFilter::implGenerateMetaData() // ----------------------------------------------------------------------------- +sal_Bool SVGFilter::implExportAnimations() +{ + sal_Bool bRet = sal_False; + + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", B2UCONST( "presentation-animations" ) ); + SvXMLElementExport aDefsContainerElem( *mpSVGExport, XML_NAMESPACE_NONE, "defs", sal_True, sal_True ); + + for( sal_Int32 i = 0; i < mSelectedPages.getLength(); ++i ) + { + Reference< XPropertySet > xProps( mSelectedPages[i], UNO_QUERY ); + + if( xProps.is() ) + { + sal_Int16 nTransition = 0; + xProps->getPropertyValue( B2UCONST( "TransitionType" ) ) >>= nTransition; + // we have a slide transition ? + sal_Bool bHasEffects = ( nTransition != 0 ); + + Reference< XAnimationNodeSupplier > xAnimNodeSupplier( mSelectedPages[i], UNO_QUERY ); + if( xAnimNodeSupplier.is() ) + { + Reference< XAnimationNode > xRootNode = xAnimNodeSupplier->getAnimationNode(); + if( xRootNode.is() ) + { + if( !bHasEffects ) + { + // first check if there are no animations + Reference< XEnumerationAccess > xEnumerationAccess( xRootNode, UNO_QUERY_THROW ); + Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW ); + if( xEnumeration->hasMoreElements() ) + { + // first child node may be an empty main sequence, check this + Reference< XAnimationNode > xMainNode( xEnumeration->nextElement(), UNO_QUERY_THROW ); + Reference< XEnumerationAccess > xMainEnumerationAccess( xMainNode, UNO_QUERY_THROW ); + Reference< XEnumeration > xMainEnumeration( xMainEnumerationAccess->createEnumeration(), UNO_QUERY_THROW ); + + // only export if the main sequence is not empty or if there are additional + // trigger sequences + bHasEffects = xMainEnumeration->hasMoreElements() || xEnumeration->hasMoreElements(); + } + } + if( bHasEffects ) + { + OUString sId = implGetValidIDFromInterface( mSelectedPages[i] ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlide, sId ); + sId += B2UCONST( "-animations" ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sId ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "Animations" ) ); + SvXMLElementExport aDefsElem( *mpSVGExport, XML_NAMESPACE_NONE, "defs", sal_True, sal_True ); + + UniReference< xmloff::AnimationsExporter > xAnimationsExporter; + xAnimationsExporter = new xmloff::AnimationsExporter( *mpSVGExport, xProps ); + xAnimationsExporter->prepare( xRootNode ); + xAnimationsExporter->exportAnimations( xRootNode ); + } + } + } + } + } + + bRet = sal_True; + return bRet; +} + + +// ----------------------------------------------------------------------------- + #define SVGFILTER_EXPORT_SVGSCRIPT( z, n, aFragment ) \ xExtDocHandler->unknown( OUString::createFromAscii( aFragment ## n ) ); diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx index 924cdfbd0196..2dcfa01685c0 100644 --- a/filter/source/svg/svgfilter.hxx +++ b/filter/source/svg/svgfilter.hxx @@ -32,9 +32,11 @@ #ifndef SVGFILTER_HXX #define SVGFILTER_HXX +#include <com/sun/star/animations/XAnimationNodeSupplier.hpp> #include <com/sun/star/drawing/XMasterPageTarget.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/container/XNamed.hpp> + #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> #include <com/sun/star/presentation/XPresentationSupplier.hpp> @@ -91,18 +93,21 @@ #include <cstdio> -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; + +using namespace ::com::sun::star::animations; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::java; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::document; using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::java; +using namespace ::com::sun::star::lang; using namespace ::com::sun::star::presentation; -using namespace ::com::sun::star::document; -using namespace ::com::sun::star::text; using namespace ::com::sun::star::style; -using namespace ::com::sun::star::io; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; + using namespace ::std; // ----------- @@ -309,6 +314,7 @@ private: sal_Bool implGenerateScript(); sal_Bool implExportDocument(); + sal_Bool implExportAnimations(); sal_Bool implExportPages( const XDrawPageSequence& rxPages, sal_Int32 nFirstPage, sal_Int32 nLastPage, |