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 INCLUDED_SLIDESHOW_ANIMATIONFACTORY_HXX
25 #define INCLUDED_SLIDESHOW_ANIMATIONFACTORY_HXX
26 
27 
28 #include "numberanimation.hxx"
29 #include "enumanimation.hxx"
30 #include "coloranimation.hxx"
31 #include "stringanimation.hxx"
32 #include "boolanimation.hxx"
33 #include "pairanimation.hxx"
34 
35 #include "shape.hxx"
36 #include "shapeattributelayer.hxx"
37 #include "shapemanager.hxx"
38 
39 #include <boost/noncopyable.hpp>
40 
41 
42 namespace rtl
43 {
44     class OUString;
45 }
46 
47 
48 /* Definition of AnimationFactory class */
49 
50 namespace slideshow
51 {
52     namespace internal
53     {
54 
55         /** Factory for Animation objects
56 
57         	Given a SMIL XAnimate node, this factory generates the
58         	appropriate Animation object from that, which will modify
59         	the attribute as specified.
60          */
61         class AnimationFactory : private boost::noncopyable
62         {
63         public:
64             /** Classifies the attribute name.
65 
66 				This enum maps names to appropriate factory methods.
67              */
68             enum AttributeClass
69             {
70                 /// Unknown, prolly invalid name
71                 CLASS_UNKNOWN_PROPERTY,
72                 /// Use createNumberPropertyAnimation
73                 CLASS_NUMBER_PROPERTY,
74                 /// Use createEnumPropertyAnimation
75                 CLASS_ENUM_PROPERTY,
76                 /// Use createColorPropertyAnimation
77                 CLASS_COLOR_PROPERTY,
78                 /// Use createStringPropertyAnimation
79                 CLASS_STRING_PROPERTY,
80                 /// Use createBoolPropertyAnimation
81                 CLASS_BOOL_PROPERTY
82             };
83 
84             static AttributeClass classifyAttributeName( const ::rtl::OUString& rAttrName );
85 
86             /// Collection of flags common to all factory methods
87             enum FactoryFlags
88             {
89                 /** Don't call enter/leaveAnimation for the Shape.
90 
91 					This is useful for set effects
92                  */
93                 FLAG_NO_SPRITE = 1
94             };
95 
96             static NumberAnimationSharedPtr createNumberPropertyAnimation( const ::rtl::OUString&				rAttrName,
97                                                                            const AnimatableShapeSharedPtr&		rShape,
98                                                                            const ShapeManagerSharedPtr&			rShapeManager,
99                                                                            const ::basegfx::B2DVector&          rSlideSize,
100                                                                            int									nFlags=0 );
101 
102             static EnumAnimationSharedPtr createEnumPropertyAnimation( const ::rtl::OUString&					rAttrName,
103                                                                        const AnimatableShapeSharedPtr&			rShape,
104                                                                        const ShapeManagerSharedPtr&				rShapeManager,
105                                                                        const ::basegfx::B2DVector&              rSlideSize,
106                                                                        int										nFlags=0 );
107 
108             static ColorAnimationSharedPtr 	createColorPropertyAnimation( const ::rtl::OUString&				rAttrName,
109                                                                           const AnimatableShapeSharedPtr&		rShape,
110                                                                           const ShapeManagerSharedPtr&			rShapeManager,
111                                                                           const ::basegfx::B2DVector&           rSlideSize,
112                                                                           int									nFlags=0 );
113 
114             /** Create scale or move animation
115 
116             	@param nTransformType
117                 Must be one of
118                 animations::AnimationTransformType::TRANSLATE or
119                 animations::AnimationTransformType::SCALE.
120              */
121             static PairAnimationSharedPtr 	createPairPropertyAnimation( const AnimatableShapeSharedPtr&		rShape,
122                                                                          const ShapeManagerSharedPtr&			rShapeManager,
123                                                                          const ::basegfx::B2DVector&            rSlideSize,
124                                                                          sal_Int16								nTransformType,
125                                                                          int									nFlags=0 );
126 
127             static StringAnimationSharedPtr createStringPropertyAnimation( const ::rtl::OUString&				rAttrName,
128                                                                            const AnimatableShapeSharedPtr&		rShape,
129                                                                            const ShapeManagerSharedPtr&			rShapeManager,
130                                                                            const ::basegfx::B2DVector&          rSlideSize,
131                                                                            int									nFlags=0 );
132 
133             static BoolAnimationSharedPtr 	createBoolPropertyAnimation( const ::rtl::OUString&					rAttrName,
134                                                                          const AnimatableShapeSharedPtr&		rShape,
135                                                                          const ShapeManagerSharedPtr&			rShapeManager,
136                                                                          const ::basegfx::B2DVector&            rSlideSize,
137                                                                          int									nFlags=0 );
138 
139             static NumberAnimationSharedPtr	createPathMotionAnimation( const ::rtl::OUString&					rSVGDPath,
140 																	   sal_Int16								nAdditive,
141                                                                        const AnimatableShapeSharedPtr&			rShape,
142                                                                        const ShapeManagerSharedPtr&				rShapeManager,
143                                                                        const ::basegfx::B2DVector&              rSlideSize,
144                                                                        int										nFlags=0);
145         private:
146             // default: constructor/destructor disabed
147             AnimationFactory();
148             ~AnimationFactory();
149         };
150     }
151 }
152 
153 #endif /* INCLUDED_SLIDESHOW_ANIMATIONFACTORY_HXX */
154