Update ooo320-m1
[ooovba.git] / sd / inc / CustomAnimationPreset.hxx
blob5230de9117e599860f96d59cf053477322dfa7c7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CustomAnimationPreset.hxx,v $
10 * $Revision: 1.6.72.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SD_CUSTOMANIMATIONPRESET_HXX
32 #define _SD_CUSTOMANIMATIONPRESET_HXX
34 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
35 #include <boost/shared_ptr.hpp>
36 #endif
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/animations/AnimationNodeType.hpp>
40 #ifndef _UTL_STLTYPES_HXX_
41 #include <comphelper/stl_types.hxx>
42 #endif
43 #include <CustomAnimationEffect.hxx>
45 #include <hash_map>
47 namespace sd {
49 typedef std::hash_map< rtl::OUString, CustomAnimationEffectPtr, comphelper::UStringHash, comphelper::UStringEqual > EffectsSubTypeMap;
50 typedef std::hash_map< rtl::OUString, rtl::OUString, comphelper::UStringHash, comphelper::UStringEqual > UStringMap;
51 typedef std::vector< rtl::OUString > UStringList;
53 class CustomAnimationPreset
55 friend class CustomAnimationPresets;
57 public:
58 CustomAnimationPreset( CustomAnimationEffectPtr pEffect );
60 void add( CustomAnimationEffectPtr pEffect );
62 SD_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > create( const rtl::OUString& rstrSubType );
64 const rtl::OUString& getPresetId() const { return maPresetId; }
65 const rtl::OUString& getProperty() const { return maProperty; }
66 const rtl::OUString& getLabel() const { return maLabel; }
67 sal_Int16 getPresetClass() const { return mnPresetClass; }
68 double getDuration() const { return mfDuration; }
70 UStringList getSubTypes();
71 UStringList getProperties() const;
73 bool hasProperty( const rtl::OUString& rProperty ) const;
74 bool isTextOnly() const { return mbIsTextOnly; }
76 private:
77 rtl::OUString maPresetId;
78 rtl::OUString maProperty;
79 sal_Int16 mnPresetClass;
80 rtl::OUString maLabel;
81 rtl::OUString maDefaultSubTyp;
82 double mfDuration;
83 bool mbIsTextOnly;
85 EffectsSubTypeMap maSubTypes;
88 typedef boost::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
89 typedef std::hash_map<rtl::OUString, CustomAnimationPresetPtr, comphelper::UStringHash, comphelper::UStringEqual> EffectDescriptorMap;
90 typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList;
92 struct PresetCategory
94 rtl::OUString maLabel;
95 EffectDescriptorList maEffects;
97 PresetCategory( const rtl::OUString& rLabel, const EffectDescriptorList& rEffects )
98 : maLabel( rLabel ), maEffects( rEffects ) {}
100 typedef boost::shared_ptr< PresetCategory > PresetCategoryPtr;
101 typedef std::vector< PresetCategoryPtr > PresetCategoryList;
103 class CustomAnimationPresets
105 public:
106 CustomAnimationPresets();
107 virtual ~CustomAnimationPresets();
109 void init();
111 SD_DLLPUBLIC static const CustomAnimationPresets& getCustomAnimationPresets();
113 ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const;
115 SD_DLLPUBLIC CustomAnimationPresetPtr getEffectDescriptor( const rtl::OUString& rPresetId ) const;
116 // const AnimationEffect* getEffect( const rtl::OUString& rPresetId ) const;
117 // const AnimationEffect* getEffect( const rtl::OUString& rPresetId, const rtl::OUString& rPresetSubType ) const;
119 const rtl::OUString& getUINameForPresetId( const rtl::OUString& rPresetId ) const;
120 const rtl::OUString& getUINameForProperty( const rtl::OUString& rProperty ) const;
122 const PresetCategoryList& getEntrancePresets() const { return maEntrancePresets; }
123 const PresetCategoryList& getEmphasisPresets() const { return maEmphasisPresets; }
124 const PresetCategoryList& getExitPresets() const { return maExitPresets; }
125 const PresetCategoryList& getMotionPathsPresets() const { return maMotionPathsPresets; }
126 const PresetCategoryList& getMiscPresets() const { return maMiscPresets; }
128 void changePresetSubType( CustomAnimationEffectPtr pEffect, const rtl::OUString& rPresetSubType ) const;
130 private:
131 void importEffects();
132 void importResources();
134 void importPresets( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xConfigProvider, const rtl::OUString& rNodePath, PresetCategoryList& rPresetMap );
136 const rtl::OUString& translateName( const rtl::OUString& rId, const UStringMap& rNameMap ) const;
138 private:
139 ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxRootNode;
140 EffectDescriptorMap maEffectDiscriptorMap;
141 UStringMap maEffectNameMap;
142 UStringMap maPropertyNameMap;
144 PresetCategoryList maEntrancePresets;
145 PresetCategoryList maEmphasisPresets;
146 PresetCategoryList maExitPresets;
147 PresetCategoryList maMotionPathsPresets;
148 PresetCategoryList maMiscPresets;
150 static CustomAnimationPresets* mpCustomAnimationPresets;
153 typedef boost::shared_ptr< CustomAnimationPresets > CustomAnimationPresetsPtr;
157 #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX