1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_PPT_EXANIMATIONS_HXX
25 #define _SD_PPT_EXANIMATIONS_HXX
26 
27 #include <com/sun/star/animations/XTimeContainer.hpp>
28 #include <com/sun/star/drawing/XDrawPage.hpp>
29 #include <com/sun/star/animations/XAnimate.hpp>
30 #ifndef _SD_PPTANIMATIONS_HXX
31 #include "../ppt/pptanimations.hxx"
32 #endif
33 #include <pptexsoundcollection.hxx>
34 #include <filter/msfilter/escherex.hxx>
35 
36 #ifdef DBG_ANIM_LOG
37 #include <stdio.h>
38 #endif
39 
40 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
41 #include <boost/shared_ptr.hpp>
42 #endif
43 
44 #include <list>
45 
46 class DffRecordHeader;
47 class SdPage;
48 class SvStream;
49 
50 namespace ppt
51 {
52 
53 	struct AfterEffectNode
54 	{
55 		::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxNode;
56 		::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxMaster;
57 
AfterEffectNodeppt::AfterEffectNode58 		AfterEffectNode( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode,
59 						 const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xMaster )
60 						 : mxNode( xNode ), mxMaster( xMaster ) {}
61 	};
62 
63 	typedef boost::shared_ptr< AfterEffectNode > AfterEffectNodePtr;
64 
65 typedef sal_uInt32 TranslateMode;
66 #define TRANSLATE_NONE				0
67 #define TRANSLATE_VALUE				1
68 #define TRANSLATE_ATTRIBUTE			2
69 #define TRANSLATE_MEASURE			4
70 #define TRANSLATE_NUMBER_TO_STRING	8
71 
72 const int AFTEREFFECT_NONE = 0;
73 const int AFTEREFFECT_COLOR = 1;
74 const int AFTEREFFECT_SET = 2;
75 
76 class AnimationExporter
77 {
78 	::com::sun::star::uno::Any aTarget;
79 
80 	void writeZString( SvStream& rStrm, const rtl::OUString& rVal );
81 	sal_Bool getColorAny( const ::com::sun::star::uno::Any& rAny, const sal_Int16 nColorSpace, sal_Int32& rMode, sal_Int32& rA, sal_Int32& rB, sal_Int32& rC ) const;
82 	sal_Bool exportAnimProperty( SvStream& rStrm, const sal_uInt16 nPropertyId, const ::com::sun::star::uno::Any& rAny, const TranslateMode eTranslateMode );
83 	::com::sun::star::uno::Any convertAnimateValue( const ::com::sun::star::uno::Any& rSource, const rtl::OUString& rAttributeName ) const;
84 	void exportAnimPropertyString( SvStream& rStrm, const sal_uInt16 nPropertyId, const rtl::OUString& rVal, const TranslateMode eTranslateMode );
85 	void exportAnimPropertyFloat( SvStream& rStrm, const sal_uInt16 nPropertyId, const double& rVal, const TranslateMode eTranslateMode );
86 	void exportAnimPropertyuInt32( SvStream& rStrm, const sal_uInt16 nPropertyId, const sal_uInt32 nVal, const TranslateMode eTranslateMode );
87 	void exportAnimPropertyByte( SvStream& rStrm, const sal_uInt16 nPropertyId, const sal_uInt8 nVal, const TranslateMode eTranslateMode );
88 
89 	// if available exportAnimPropertySet returns the ::com::sun::star::presentation::EffectNodeType
90 	sal_Int16 exportAnimPropertySet( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
91 	void exportAnimNode( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode,
92 						const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >* pParent, const sal_Int32 nGroupLevel, const sal_Int16 nFillDefault );
93 	void exportAnimate( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
94 	void exportAnimateTarget( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode, const sal_uInt32 nForceAttributeName = 0, int nAfterEffectType = AFTEREFFECT_NONE );
95 	void exportAnimateSet( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >&  xNode, int nAfterEffectType );
96 	void exportAnimAction( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
97 	void exportAnimEvent( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode, const sal_Int32 nFlags = 0 );
98 	void exportNode( SvStream& rStrm, ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > xNode,
99 						const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >* xParent,
100 							const sal_uInt16 nContainerRecType, const sal_uInt16 nInstance, const sal_Int32 nGroupLevel, const sal_Bool bTakeBackInteractiveSequenceTiming,
101 								const sal_Int16 nFillDefault );
102 	void exportAnimateTargetElement( SvStream& rStrm, const ::com::sun::star::uno::Any aAny, const sal_Bool bCreate2b01Atom );
103 	void exportAnimateKeyPoints( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimate >& xAnimate );
104 	void exportAnimValue( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode, const sal_Bool bExportAlways );
105 	void exportTransitionFilter( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
106 	void exportAnimateMotion( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
107 	void exportAnimateTransform( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
108 	void exportAnimateColor( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode, int nAfterEffectType );
109 	void exportIterate( SvStream& rStrm, const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
110 
111 	const EscherSolverContainer& mrSolverContainer;
112 	ppt::ExSoundCollection& mrExSoundCollection;
113 	void processAfterEffectNodes( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode );
114 
115 	bool isAfterEffectNode( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) const;
116 	bool hasAfterEffectNode( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode, ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xAfterEffectNode ) const;
117 	bool isEmptyNode( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) const;
118 
119 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > createAfterEffectNodeClone( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) const;
120 
121 	std::list< AfterEffectNodePtr > maAfterEffectNodes;
122 
123 public:
124 	AnimationExporter( const EscherSolverContainer& rSolverContainer, ppt::ExSoundCollection& rExSoundCollection );
125 
126 	void doexport( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage, SvStream& rStrm );
127 
128 	sal_Int32 mnCurrentGroup;
129 };
130 
131 } // namespace ppt
132 
133 #endif
134