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_CUSTOMANIMATIONPRESET_HXX 25 #define _SD_CUSTOMANIMATIONPRESET_HXX 26 27 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED 28 #include <boost/shared_ptr.hpp> 29 #endif 30 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31 #include <com/sun/star/animations/AnimationNodeType.hpp> 32 33 #ifndef _UTL_STLTYPES_HXX_ 34 #include <comphelper/stl_types.hxx> 35 #endif 36 #include <CustomAnimationEffect.hxx> 37 38 #include <hash_map> 39 40 namespace sd { 41 42 typedef std::hash_map< rtl::OUString, CustomAnimationEffectPtr, comphelper::UStringHash, comphelper::UStringEqual > EffectsSubTypeMap; 43 typedef std::hash_map< rtl::OUString, rtl::OUString, comphelper::UStringHash, comphelper::UStringEqual > UStringMap; 44 typedef std::vector< rtl::OUString > UStringList; 45 46 class CustomAnimationPreset 47 { 48 friend class CustomAnimationPresets; 49 50 public: 51 CustomAnimationPreset( CustomAnimationEffectPtr pEffect ); 52 53 void add( CustomAnimationEffectPtr pEffect ); 54 55 SD_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > create( const rtl::OUString& rstrSubType ); 56 getPresetId() const57 const rtl::OUString& getPresetId() const { return maPresetId; } getProperty() const58 const rtl::OUString& getProperty() const { return maProperty; } getLabel() const59 const rtl::OUString& getLabel() const { return maLabel; } getPresetClass() const60 sal_Int16 getPresetClass() const { return mnPresetClass; } getDuration() const61 double getDuration() const { return mfDuration; } 62 63 UStringList getSubTypes(); 64 UStringList getProperties() const; 65 66 bool hasProperty( const rtl::OUString& rProperty ) const; isTextOnly() const67 bool isTextOnly() const { return mbIsTextOnly; } 68 69 private: 70 rtl::OUString maPresetId; 71 rtl::OUString maProperty; 72 sal_Int16 mnPresetClass; 73 rtl::OUString maLabel; 74 rtl::OUString maDefaultSubTyp; 75 double mfDuration; 76 bool mbIsTextOnly; 77 78 EffectsSubTypeMap maSubTypes; 79 }; 80 81 typedef boost::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr; 82 typedef std::hash_map<rtl::OUString, CustomAnimationPresetPtr, comphelper::UStringHash, comphelper::UStringEqual> EffectDescriptorMap; 83 typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList; 84 85 struct PresetCategory 86 { 87 rtl::OUString maLabel; 88 EffectDescriptorList maEffects; 89 PresetCategorysd::PresetCategory90 PresetCategory( const rtl::OUString& rLabel, const EffectDescriptorList& rEffects ) 91 : maLabel( rLabel ), maEffects( rEffects ) {} 92 }; 93 typedef boost::shared_ptr< PresetCategory > PresetCategoryPtr; 94 typedef std::vector< PresetCategoryPtr > PresetCategoryList; 95 96 class CustomAnimationPresets 97 { 98 public: 99 CustomAnimationPresets(); 100 virtual ~CustomAnimationPresets(); 101 102 void init(); 103 104 SD_DLLPUBLIC static const CustomAnimationPresets& getCustomAnimationPresets(); 105 106 ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const; 107 108 SD_DLLPUBLIC CustomAnimationPresetPtr getEffectDescriptor( const rtl::OUString& rPresetId ) const; 109 // const AnimationEffect* getEffect( const rtl::OUString& rPresetId ) const; 110 // const AnimationEffect* getEffect( const rtl::OUString& rPresetId, const rtl::OUString& rPresetSubType ) const; 111 112 const rtl::OUString& getUINameForPresetId( const rtl::OUString& rPresetId ) const; 113 const rtl::OUString& getUINameForProperty( const rtl::OUString& rProperty ) const; 114 getEntrancePresets() const115 const PresetCategoryList& getEntrancePresets() const { return maEntrancePresets; } getEmphasisPresets() const116 const PresetCategoryList& getEmphasisPresets() const { return maEmphasisPresets; } getExitPresets() const117 const PresetCategoryList& getExitPresets() const { return maExitPresets; } getMotionPathsPresets() const118 const PresetCategoryList& getMotionPathsPresets() const { return maMotionPathsPresets; } getMiscPresets() const119 const PresetCategoryList& getMiscPresets() const { return maMiscPresets; } 120 121 void changePresetSubType( CustomAnimationEffectPtr pEffect, const rtl::OUString& rPresetSubType ) const; 122 123 private: 124 void importEffects(); 125 void importResources(); 126 127 void importPresets( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xConfigProvider, const rtl::OUString& rNodePath, PresetCategoryList& rPresetMap ); 128 129 const rtl::OUString& translateName( const rtl::OUString& rId, const UStringMap& rNameMap ) const; 130 131 private: 132 ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxRootNode; 133 EffectDescriptorMap maEffectDiscriptorMap; 134 UStringMap maEffectNameMap; 135 UStringMap maPropertyNameMap; 136 137 PresetCategoryList maEntrancePresets; 138 PresetCategoryList maEmphasisPresets; 139 PresetCategoryList maExitPresets; 140 PresetCategoryList maMotionPathsPresets; 141 PresetCategoryList maMiscPresets; 142 143 static CustomAnimationPresets* mpCustomAnimationPresets; 144 }; 145 146 typedef boost::shared_ptr< CustomAnimationPresets > CustomAnimationPresetsPtr; 147 148 } 149 150 #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX 151 152