1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _SD_CUSTOMANIMATIONPRESET_HXX
21 #define _SD_CUSTOMANIMATIONPRESET_HXX
23 #include <boost/shared_ptr.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/animations/AnimationNodeType.hpp>
27 #include <comphelper/stl_types.hxx>
28 #include <CustomAnimationEffect.hxx>
30 #include <boost/unordered_map.hpp>
34 typedef boost::unordered_map
< OUString
, CustomAnimationEffectPtr
, OUStringHash
, comphelper::UStringEqual
> EffectsSubTypeMap
;
35 typedef boost::unordered_map
< OUString
, OUString
, OUStringHash
, comphelper::UStringEqual
> UStringMap
;
36 typedef std::vector
< OUString
> UStringList
;
38 class CustomAnimationPreset
40 friend class CustomAnimationPresets
;
43 CustomAnimationPreset( CustomAnimationEffectPtr pEffect
);
45 void add( CustomAnimationEffectPtr pEffect
);
47 SD_DLLPUBLIC ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> create( const OUString
& rstrSubType
);
49 const OUString
& getPresetId() const { return maPresetId
; }
50 const OUString
& getProperty() const { return maProperty
; }
51 const OUString
& getLabel() const { return maLabel
; }
52 sal_Int16
getPresetClass() const { return mnPresetClass
; }
53 double getDuration() const { return mfDuration
; }
55 UStringList
getSubTypes();
56 UStringList
getProperties() const;
58 bool hasProperty( const OUString
& rProperty
) const;
59 bool isTextOnly() const { return mbIsTextOnly
; }
64 sal_Int16 mnPresetClass
;
66 OUString maDefaultSubTyp
;
70 EffectsSubTypeMap maSubTypes
;
73 typedef boost::shared_ptr
< CustomAnimationPreset
> CustomAnimationPresetPtr
;
74 typedef boost::unordered_map
<OUString
, CustomAnimationPresetPtr
, OUStringHash
, comphelper::UStringEqual
> EffectDescriptorMap
;
75 typedef std::vector
< CustomAnimationPresetPtr
> EffectDescriptorList
;
80 EffectDescriptorList maEffects
;
82 PresetCategory( const OUString
& rLabel
, const EffectDescriptorList
& rEffects
)
83 : maLabel( rLabel
), maEffects( rEffects
) {}
85 typedef boost::shared_ptr
< PresetCategory
> PresetCategoryPtr
;
86 typedef std::vector
< PresetCategoryPtr
> PresetCategoryList
;
88 class CustomAnimationPresets
91 CustomAnimationPresets();
92 virtual ~CustomAnimationPresets();
96 SD_DLLPUBLIC
static const CustomAnimationPresets
& getCustomAnimationPresets();
98 ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> getRandomPreset( sal_Int16 nPresetClass
) const;
100 SD_DLLPUBLIC CustomAnimationPresetPtr
getEffectDescriptor( const OUString
& rPresetId
) const;
102 const OUString
& getUINameForPresetId( const OUString
& rPresetId
) const;
103 const OUString
& getUINameForProperty( const OUString
& rProperty
) const;
105 const PresetCategoryList
& getEntrancePresets() const { return maEntrancePresets
; }
106 const PresetCategoryList
& getEmphasisPresets() const { return maEmphasisPresets
; }
107 const PresetCategoryList
& getExitPresets() const { return maExitPresets
; }
108 const PresetCategoryList
& getMotionPathsPresets() const { return maMotionPathsPresets
; }
109 const PresetCategoryList
& getMiscPresets() const { return maMiscPresets
; }
111 void changePresetSubType( CustomAnimationEffectPtr pEffect
, const OUString
& rPresetSubType
) const;
114 void importEffects();
115 void importResources();
117 void importPresets( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, PresetCategoryList
& rPresetMap
);
119 const OUString
& translateName( const OUString
& rId
, const UStringMap
& rNameMap
) const;
122 ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> mxRootNode
;
123 EffectDescriptorMap maEffectDiscriptorMap
;
124 UStringMap maEffectNameMap
;
125 UStringMap maPropertyNameMap
;
127 PresetCategoryList maEntrancePresets
;
128 PresetCategoryList maEmphasisPresets
;
129 PresetCategoryList maExitPresets
;
130 PresetCategoryList maMotionPathsPresets
;
131 PresetCategoryList maMiscPresets
;
133 static CustomAnimationPresets
* mpCustomAnimationPresets
;
136 typedef boost::shared_ptr
< CustomAnimationPresets
> CustomAnimationPresetsPtr
;
140 #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */