Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SD_CUSTOMANIMATIONPRESET_HXX
30 : : #define _SD_CUSTOMANIMATIONPRESET_HXX
31 : :
32 : : #include <boost/shared_ptr.hpp>
33 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 : : #include <com/sun/star/animations/AnimationNodeType.hpp>
35 : :
36 : : #include <comphelper/stl_types.hxx>
37 : : #include <CustomAnimationEffect.hxx>
38 : :
39 : : #include <boost/unordered_map.hpp>
40 : :
41 : : namespace sd {
42 : :
43 : : typedef boost::unordered_map< rtl::OUString, CustomAnimationEffectPtr, rtl::OUStringHash, comphelper::UStringEqual > EffectsSubTypeMap;
44 : : typedef boost::unordered_map< rtl::OUString, rtl::OUString, rtl::OUStringHash, comphelper::UStringEqual > UStringMap;
45 : : typedef std::vector< rtl::OUString > UStringList;
46 : :
47 [ # # ]: 0 : class CustomAnimationPreset
48 : : {
49 : : friend class CustomAnimationPresets;
50 : :
51 : : public:
52 : : CustomAnimationPreset( CustomAnimationEffectPtr pEffect );
53 : :
54 : : void add( CustomAnimationEffectPtr pEffect );
55 : :
56 : : SD_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > create( const rtl::OUString& rstrSubType );
57 : :
58 : 0 : const rtl::OUString& getPresetId() const { return maPresetId; }
59 : : const rtl::OUString& getProperty() const { return maProperty; }
60 : 0 : const rtl::OUString& getLabel() const { return maLabel; }
61 : : sal_Int16 getPresetClass() const { return mnPresetClass; }
62 : 0 : double getDuration() const { return mfDuration; }
63 : :
64 : : UStringList getSubTypes();
65 : : UStringList getProperties() const;
66 : :
67 : : bool hasProperty( const rtl::OUString& rProperty ) const;
68 : 0 : bool isTextOnly() const { return mbIsTextOnly; }
69 : :
70 : : private:
71 : : rtl::OUString maPresetId;
72 : : rtl::OUString maProperty;
73 : : sal_Int16 mnPresetClass;
74 : : rtl::OUString maLabel;
75 : : rtl::OUString maDefaultSubTyp;
76 : : double mfDuration;
77 : : bool mbIsTextOnly;
78 : :
79 : : EffectsSubTypeMap maSubTypes;
80 : : };
81 : :
82 : : typedef boost::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
83 : : typedef boost::unordered_map<rtl::OUString, CustomAnimationPresetPtr, rtl::OUStringHash, comphelper::UStringEqual> EffectDescriptorMap;
84 : : typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList;
85 : :
86 : 0 : struct PresetCategory
87 : : {
88 : : rtl::OUString maLabel;
89 : : EffectDescriptorList maEffects;
90 : :
91 : 0 : PresetCategory( const rtl::OUString& rLabel, const EffectDescriptorList& rEffects )
92 [ # # ]: 0 : : maLabel( rLabel ), maEffects( rEffects ) {}
93 : : };
94 : : typedef boost::shared_ptr< PresetCategory > PresetCategoryPtr;
95 : : typedef std::vector< PresetCategoryPtr > PresetCategoryList;
96 : :
97 : : class CustomAnimationPresets
98 : : {
99 : : public:
100 : : CustomAnimationPresets();
101 : : virtual ~CustomAnimationPresets();
102 : :
103 : : void init();
104 : :
105 : : SD_DLLPUBLIC static const CustomAnimationPresets& getCustomAnimationPresets();
106 : :
107 : : ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const;
108 : :
109 : : SD_DLLPUBLIC CustomAnimationPresetPtr getEffectDescriptor( const rtl::OUString& rPresetId ) const;
110 : :
111 : : const rtl::OUString& getUINameForPresetId( const rtl::OUString& rPresetId ) const;
112 : : const rtl::OUString& getUINameForProperty( const rtl::OUString& rProperty ) const;
113 : :
114 : 0 : const PresetCategoryList& getEntrancePresets() const { return maEntrancePresets; }
115 : 0 : const PresetCategoryList& getEmphasisPresets() const { return maEmphasisPresets; }
116 : 0 : const PresetCategoryList& getExitPresets() const { return maExitPresets; }
117 : 0 : const PresetCategoryList& getMotionPathsPresets() const { return maMotionPathsPresets; }
118 : 0 : const PresetCategoryList& getMiscPresets() const { return maMiscPresets; }
119 : :
120 : : void changePresetSubType( CustomAnimationEffectPtr pEffect, const rtl::OUString& rPresetSubType ) const;
121 : :
122 : : private:
123 : : void importEffects();
124 : : void importResources();
125 : :
126 : : void importPresets( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xConfigProvider, const rtl::OUString& rNodePath, PresetCategoryList& rPresetMap );
127 : :
128 : : const rtl::OUString& translateName( const rtl::OUString& rId, const UStringMap& rNameMap ) const;
129 : :
130 : : private:
131 : : ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxRootNode;
132 : : EffectDescriptorMap maEffectDiscriptorMap;
133 : : UStringMap maEffectNameMap;
134 : : UStringMap maPropertyNameMap;
135 : :
136 : : PresetCategoryList maEntrancePresets;
137 : : PresetCategoryList maEmphasisPresets;
138 : : PresetCategoryList maExitPresets;
139 : : PresetCategoryList maMotionPathsPresets;
140 : : PresetCategoryList maMiscPresets;
141 : :
142 : : static CustomAnimationPresets* mpCustomAnimationPresets;
143 : : };
144 : :
145 : : typedef boost::shared_ptr< CustomAnimationPresets > CustomAnimationPresetsPtr;
146 : :
147 : : }
148 : :
149 : : #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX
150 : :
151 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|