Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _SD_CUSTOMANIMATIONPRESET_HXX
21 : #define _SD_CUSTOMANIMATIONPRESET_HXX
22 :
23 : #include <boost/shared_ptr.hpp>
24 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 : #include <com/sun/star/animations/AnimationNodeType.hpp>
26 :
27 : #include <comphelper/stl_types.hxx>
28 : #include <CustomAnimationEffect.hxx>
29 :
30 : #include <boost/unordered_map.hpp>
31 :
32 : namespace sd {
33 :
34 : typedef boost::unordered_map< rtl::OUString, CustomAnimationEffectPtr, rtl::OUStringHash, comphelper::UStringEqual > EffectsSubTypeMap;
35 : typedef boost::unordered_map< rtl::OUString, rtl::OUString, rtl::OUStringHash, comphelper::UStringEqual > UStringMap;
36 : typedef std::vector< rtl::OUString > UStringList;
37 :
38 0 : class CustomAnimationPreset
39 : {
40 : friend class CustomAnimationPresets;
41 :
42 : public:
43 : CustomAnimationPreset( CustomAnimationEffectPtr pEffect );
44 :
45 : void add( CustomAnimationEffectPtr pEffect );
46 :
47 : SD_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > create( const rtl::OUString& rstrSubType );
48 :
49 0 : const rtl::OUString& getPresetId() const { return maPresetId; }
50 : const rtl::OUString& getProperty() const { return maProperty; }
51 0 : const rtl::OUString& getLabel() const { return maLabel; }
52 : sal_Int16 getPresetClass() const { return mnPresetClass; }
53 0 : double getDuration() const { return mfDuration; }
54 :
55 : UStringList getSubTypes();
56 : UStringList getProperties() const;
57 :
58 : bool hasProperty( const rtl::OUString& rProperty ) const;
59 0 : bool isTextOnly() const { return mbIsTextOnly; }
60 :
61 : private:
62 : rtl::OUString maPresetId;
63 : rtl::OUString maProperty;
64 : sal_Int16 mnPresetClass;
65 : rtl::OUString maLabel;
66 : rtl::OUString maDefaultSubTyp;
67 : double mfDuration;
68 : bool mbIsTextOnly;
69 :
70 : EffectsSubTypeMap maSubTypes;
71 : };
72 :
73 : typedef boost::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
74 : typedef boost::unordered_map<rtl::OUString, CustomAnimationPresetPtr, rtl::OUStringHash, comphelper::UStringEqual> EffectDescriptorMap;
75 : typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList;
76 :
77 0 : struct PresetCategory
78 : {
79 : rtl::OUString maLabel;
80 : EffectDescriptorList maEffects;
81 :
82 16 : PresetCategory( const rtl::OUString& rLabel, const EffectDescriptorList& rEffects )
83 16 : : maLabel( rLabel ), maEffects( rEffects ) {}
84 : };
85 : typedef boost::shared_ptr< PresetCategory > PresetCategoryPtr;
86 : typedef std::vector< PresetCategoryPtr > PresetCategoryList;
87 :
88 : class CustomAnimationPresets
89 : {
90 : public:
91 : CustomAnimationPresets();
92 : virtual ~CustomAnimationPresets();
93 :
94 : void init();
95 :
96 : SD_DLLPUBLIC static const CustomAnimationPresets& getCustomAnimationPresets();
97 :
98 : ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const;
99 :
100 : SD_DLLPUBLIC CustomAnimationPresetPtr getEffectDescriptor( const rtl::OUString& rPresetId ) const;
101 :
102 : const rtl::OUString& getUINameForPresetId( const rtl::OUString& rPresetId ) const;
103 : const rtl::OUString& getUINameForProperty( const rtl::OUString& rProperty ) const;
104 :
105 0 : const PresetCategoryList& getEntrancePresets() const { return maEntrancePresets; }
106 0 : const PresetCategoryList& getEmphasisPresets() const { return maEmphasisPresets; }
107 0 : const PresetCategoryList& getExitPresets() const { return maExitPresets; }
108 0 : const PresetCategoryList& getMotionPathsPresets() const { return maMotionPathsPresets; }
109 0 : const PresetCategoryList& getMiscPresets() const { return maMiscPresets; }
110 :
111 : void changePresetSubType( CustomAnimationEffectPtr pEffect, const rtl::OUString& rPresetSubType ) const;
112 :
113 : private:
114 : void importEffects();
115 : void importResources();
116 :
117 : void importPresets( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xConfigProvider, const rtl::OUString& rNodePath, PresetCategoryList& rPresetMap );
118 :
119 : const rtl::OUString& translateName( const rtl::OUString& rId, const UStringMap& rNameMap ) const;
120 :
121 : private:
122 : ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > mxRootNode;
123 : EffectDescriptorMap maEffectDiscriptorMap;
124 : UStringMap maEffectNameMap;
125 : UStringMap maPropertyNameMap;
126 :
127 : PresetCategoryList maEntrancePresets;
128 : PresetCategoryList maEmphasisPresets;
129 : PresetCategoryList maExitPresets;
130 : PresetCategoryList maMotionPathsPresets;
131 : PresetCategoryList maMiscPresets;
132 :
133 : static CustomAnimationPresets* mpCustomAnimationPresets;
134 : };
135 :
136 : typedef boost::shared_ptr< CustomAnimationPresets > CustomAnimationPresetsPtr;
137 :
138 : }
139 :
140 : #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|