1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_SLIDESHOW_ANIMATIONFACTORY_HXX
29 #define INCLUDED_SLIDESHOW_ANIMATIONFACTORY_HXX
30 
31 
32 #include "numberanimation.hxx"
33 #include "enumanimation.hxx"
34 #include "coloranimation.hxx"
35 #include "stringanimation.hxx"
36 #include "boolanimation.hxx"
37 #include "pairanimation.hxx"
38 
39 #include "shape.hxx"
40 #include "shapeattributelayer.hxx"
41 #include "shapemanager.hxx"
42 
43 #include <boost/noncopyable.hpp>
44 
45 
46 namespace rtl
47 {
48     class OUString;
49 }
50 
51 
52 /* Definition of AnimationFactory class */
53 
54 namespace slideshow
55 {
56     namespace internal
57     {
58 
59         /** Factory for Animation objects
60 
61         	Given a SMIL XAnimate node, this factory generates the
62         	appropriate Animation object from that, which will modify
63         	the attribute as specified.
64          */
65         class AnimationFactory : private boost::noncopyable
66         {
67         public:
68             /** Classifies the attribute name.
69 
70 				This enum maps names to appropriate factory methods.
71              */
72             enum AttributeClass
73             {
74                 /// Unknown, prolly invalid name
75                 CLASS_UNKNOWN_PROPERTY,
76                 /// Use createNumberPropertyAnimation
77                 CLASS_NUMBER_PROPERTY,
78                 /// Use createEnumPropertyAnimation
79                 CLASS_ENUM_PROPERTY,
80                 /// Use createColorPropertyAnimation
81                 CLASS_COLOR_PROPERTY,
82                 /// Use createStringPropertyAnimation
83                 CLASS_STRING_PROPERTY,
84                 /// Use createBoolPropertyAnimation
85                 CLASS_BOOL_PROPERTY
86             };
87 
88             static AttributeClass classifyAttributeName( const ::rtl::OUString& rAttrName );
89 
90             /// Collection of flags common to all factory methods
91             enum FactoryFlags
92             {
93                 /** Don't call enter/leaveAnimation for the Shape.
94 
95 					This is useful for set effects
96                  */
97                 FLAG_NO_SPRITE = 1
98             };
99 
100             static NumberAnimationSharedPtr createNumberPropertyAnimation( const ::rtl::OUString&				rAttrName,
101                                                                            const AnimatableShapeSharedPtr&		rShape,
102                                                                            const ShapeManagerSharedPtr&			rShapeManager,
103                                                                            const ::basegfx::B2DVector&          rSlideSize,
104                                                                            int									nFlags=0 );
105 
106             static EnumAnimationSharedPtr createEnumPropertyAnimation( const ::rtl::OUString&					rAttrName,
107                                                                        const AnimatableShapeSharedPtr&			rShape,
108                                                                        const ShapeManagerSharedPtr&				rShapeManager,
109                                                                        const ::basegfx::B2DVector&              rSlideSize,
110                                                                        int										nFlags=0 );
111 
112             static ColorAnimationSharedPtr 	createColorPropertyAnimation( const ::rtl::OUString&				rAttrName,
113                                                                           const AnimatableShapeSharedPtr&		rShape,
114                                                                           const ShapeManagerSharedPtr&			rShapeManager,
115                                                                           const ::basegfx::B2DVector&           rSlideSize,
116                                                                           int									nFlags=0 );
117 
118             /** Create scale or move animation
119 
120             	@param nTransformType
121                 Must be one of
122                 animations::AnimationTransformType::TRANSLATE or
123                 animations::AnimationTransformType::SCALE.
124              */
125             static PairAnimationSharedPtr 	createPairPropertyAnimation( const AnimatableShapeSharedPtr&		rShape,
126                                                                          const ShapeManagerSharedPtr&			rShapeManager,
127                                                                          const ::basegfx::B2DVector&            rSlideSize,
128                                                                          sal_Int16								nTransformType,
129                                                                          int									nFlags=0 );
130 
131             static StringAnimationSharedPtr createStringPropertyAnimation( const ::rtl::OUString&				rAttrName,
132                                                                            const AnimatableShapeSharedPtr&		rShape,
133                                                                            const ShapeManagerSharedPtr&			rShapeManager,
134                                                                            const ::basegfx::B2DVector&          rSlideSize,
135                                                                            int									nFlags=0 );
136 
137             static BoolAnimationSharedPtr 	createBoolPropertyAnimation( const ::rtl::OUString&					rAttrName,
138                                                                          const AnimatableShapeSharedPtr&		rShape,
139                                                                          const ShapeManagerSharedPtr&			rShapeManager,
140                                                                          const ::basegfx::B2DVector&            rSlideSize,
141                                                                          int									nFlags=0 );
142 
143             static NumberAnimationSharedPtr	createPathMotionAnimation( const ::rtl::OUString&					rSVGDPath,
144 																	   sal_Int16								nAdditive,
145                                                                        const AnimatableShapeSharedPtr&			rShape,
146                                                                        const ShapeManagerSharedPtr&				rShapeManager,
147                                                                        const ::basegfx::B2DVector&              rSlideSize,
148                                                                        int										nFlags=0);
149         private:
150             // default: constructor/destructor disabed
151             AnimationFactory();
152             ~AnimationFactory();
153         };
154     }
155 }
156 
157 #endif /* INCLUDED_SLIDESHOW_ANIMATIONFACTORY_HXX */
158