xref: /trunk/main/sd/inc/CustomAnimationPreset.hxx (revision 67e470da)
1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c45d927aSAndrew Rist  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c45d927aSAndrew Rist  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19*c45d927aSAndrew Rist  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SD_CUSTOMANIMATIONPRESET_HXX
25cdf0e10cSrcweir #define _SD_CUSTOMANIMATIONPRESET_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
28cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31cdf0e10cSrcweir #include <com/sun/star/animations/AnimationNodeType.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #ifndef _UTL_STLTYPES_HXX_
34cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <CustomAnimationEffect.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <hash_map>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace sd {
41cdf0e10cSrcweir 
42cdf0e10cSrcweir typedef std::hash_map< rtl::OUString, CustomAnimationEffectPtr, comphelper::UStringHash, comphelper::UStringEqual > EffectsSubTypeMap;
43cdf0e10cSrcweir typedef std::hash_map< rtl::OUString, rtl::OUString, comphelper::UStringHash, comphelper::UStringEqual > UStringMap;
44cdf0e10cSrcweir typedef std::vector< rtl::OUString > UStringList;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir class CustomAnimationPreset
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 	friend class CustomAnimationPresets;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir public:
51cdf0e10cSrcweir 	CustomAnimationPreset( CustomAnimationEffectPtr pEffect );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	void add( CustomAnimationEffectPtr pEffect );
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 	SD_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > create( const rtl::OUString& rstrSubType );
56cdf0e10cSrcweir 
getPresetId() const57cdf0e10cSrcweir 	const rtl::OUString& getPresetId() const { return maPresetId; }
getProperty() const58cdf0e10cSrcweir 	const rtl::OUString& getProperty() const { return maProperty; }
getLabel() const59cdf0e10cSrcweir 	const rtl::OUString& getLabel() const { return maLabel; }
getPresetClass() const60cdf0e10cSrcweir 	sal_Int16 getPresetClass() const { return mnPresetClass; }
getDuration() const61cdf0e10cSrcweir 	double getDuration() const { return mfDuration; }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	UStringList getSubTypes();
64cdf0e10cSrcweir 	UStringList getProperties() const;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	bool hasProperty( const rtl::OUString& rProperty ) const;
isTextOnly() const67cdf0e10cSrcweir 	bool isTextOnly() const { return mbIsTextOnly; }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir private:
70cdf0e10cSrcweir 	rtl::OUString maPresetId;
71cdf0e10cSrcweir 	rtl::OUString maProperty;
72cdf0e10cSrcweir 	sal_Int16 mnPresetClass;
73cdf0e10cSrcweir 	rtl::OUString maLabel;
74cdf0e10cSrcweir 	rtl::OUString maDefaultSubTyp;
75cdf0e10cSrcweir 	double mfDuration;
76cdf0e10cSrcweir 	bool mbIsTextOnly;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	EffectsSubTypeMap maSubTypes;
79cdf0e10cSrcweir };
80cdf0e10cSrcweir 
81cdf0e10cSrcweir typedef boost::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
82cdf0e10cSrcweir typedef std::hash_map<rtl::OUString, CustomAnimationPresetPtr, comphelper::UStringHash, comphelper::UStringEqual> EffectDescriptorMap;
83cdf0e10cSrcweir typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir struct PresetCategory
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	rtl::OUString maLabel;
88cdf0e10cSrcweir 	EffectDescriptorList maEffects;
89cdf0e10cSrcweir 
PresetCategorysd::PresetCategory90cdf0e10cSrcweir 	PresetCategory( const rtl::OUString& rLabel, const EffectDescriptorList& rEffects )
91cdf0e10cSrcweir 		: maLabel( rLabel ), maEffects( rEffects ) {}
92cdf0e10cSrcweir };
93cdf0e10cSrcweir typedef boost::shared_ptr< PresetCategory > PresetCategoryPtr;
94cdf0e10cSrcweir typedef std::vector< PresetCategoryPtr > PresetCategoryList;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir class CustomAnimationPresets
97cdf0e10cSrcweir {
98cdf0e10cSrcweir public:
99cdf0e10cSrcweir 	CustomAnimationPresets();
100cdf0e10cSrcweir 	virtual ~CustomAnimationPresets();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	void init();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	SD_DLLPUBLIC static const CustomAnimationPresets& getCustomAnimationPresets();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	SD_DLLPUBLIC CustomAnimationPresetPtr getEffectDescriptor( const rtl::OUString& rPresetId ) const;
109cdf0e10cSrcweir //	const AnimationEffect* getEffect( const rtl::OUString& rPresetId ) const;
110cdf0e10cSrcweir //	const AnimationEffect* getEffect( const rtl::OUString& rPresetId, const rtl::OUString& rPresetSubType ) const;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	const rtl::OUString& getUINameForPresetId( const rtl::OUString& rPresetId ) const;
113cdf0e10cSrcweir 	const rtl::OUString& getUINameForProperty( const rtl::OUString& rProperty ) const;
114cdf0e10cSrcweir 
getEntrancePresets() const115cdf0e10cSrcweir 	const PresetCategoryList& getEntrancePresets() const { return maEntrancePresets; }
getEmphasisPresets() const116cdf0e10cSrcweir 	const PresetCategoryList& getEmphasisPresets() const { return maEmphasisPresets; }
getExitPresets() const117cdf0e10cSrcweir 	const PresetCategoryList& getExitPresets() const { return maExitPresets; }
getMotionPathsPresets() const118cdf0e10cSrcweir 	const PresetCategoryList& getMotionPathsPresets() const { return maMotionPathsPresets; }
getMiscPresets() const119cdf0e10cSrcweir 	const PresetCategoryList& getMiscPresets() const { return maMiscPresets; }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	void changePresetSubType( CustomAnimationEffectPtr pEffect, const rtl::OUString& rPresetSubType ) const;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir private:
124cdf0e10cSrcweir 	void importEffects();
125cdf0e10cSrcweir 	void importResources();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	void importPresets( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xConfigProvider, const rtl::OUString& rNodePath, PresetCategoryList& rPresetMap  );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	const rtl::OUString& translateName( const rtl::OUString& rId, const UStringMap& rNameMap ) const;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir private:
132cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxRootNode;
133cdf0e10cSrcweir 	EffectDescriptorMap maEffectDiscriptorMap;
134cdf0e10cSrcweir 	UStringMap maEffectNameMap;
135cdf0e10cSrcweir 	UStringMap maPropertyNameMap;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	PresetCategoryList maEntrancePresets;
138cdf0e10cSrcweir 	PresetCategoryList maEmphasisPresets;
139cdf0e10cSrcweir 	PresetCategoryList maExitPresets;
140cdf0e10cSrcweir 	PresetCategoryList maMotionPathsPresets;
141cdf0e10cSrcweir 	PresetCategoryList maMiscPresets;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	static CustomAnimationPresets*	mpCustomAnimationPresets;
144cdf0e10cSrcweir };
145cdf0e10cSrcweir 
146cdf0e10cSrcweir typedef boost::shared_ptr< CustomAnimationPresets > CustomAnimationPresetsPtr;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX
151cdf0e10cSrcweir 
152