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 INCLUDED_SD_INC_CUSTOMANIMATIONPRESET_HXX
21 #define INCLUDED_SD_INC_CUSTOMANIMATIONPRESET_HXX
23 #include <sal/config.h>
27 #include <boost/shared_ptr.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/animations/AnimationNodeType.hpp>
31 #include <CustomAnimationEffect.hxx>
33 #include <unordered_map>
37 typedef std::unordered_map
< OUString
, CustomAnimationEffectPtr
, OUStringHash
> EffectsSubTypeMap
;
38 typedef std::unordered_map
< OUString
, OUString
, OUStringHash
> UStringMap
;
39 typedef std::vector
< OUString
> UStringList
;
41 class CustomAnimationPreset
43 friend class CustomAnimationPresets
;
46 CustomAnimationPreset( CustomAnimationEffectPtr pEffect
);
48 void add( CustomAnimationEffectPtr pEffect
);
50 SD_DLLPUBLIC ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> create( const OUString
& rstrSubType
);
52 const OUString
& getPresetId() const { return maPresetId
; }
53 const OUString
& getProperty() const { return maProperty
; }
54 const OUString
& getLabel() const { return maLabel
; }
55 sal_Int16
getPresetClass() const { return mnPresetClass
; }
56 double getDuration() const { return mfDuration
; }
58 UStringList
getSubTypes();
59 UStringList
getProperties() const;
61 bool hasProperty( const OUString
& rProperty
) const;
62 bool isTextOnly() const { return mbIsTextOnly
; }
67 sal_Int16 mnPresetClass
;
69 OUString maDefaultSubTyp
;
73 EffectsSubTypeMap maSubTypes
;
76 typedef boost::shared_ptr
< CustomAnimationPreset
> CustomAnimationPresetPtr
;
77 typedef std::unordered_map
<OUString
, CustomAnimationPresetPtr
, OUStringHash
> EffectDescriptorMap
;
78 typedef std::vector
< CustomAnimationPresetPtr
> EffectDescriptorList
;
83 EffectDescriptorList maEffects
;
85 PresetCategory( const OUString
& rLabel
, const EffectDescriptorList
& rEffects
)
86 : maLabel( rLabel
), maEffects( rEffects
) {}
88 typedef boost::shared_ptr
< PresetCategory
> PresetCategoryPtr
;
89 typedef std::vector
< PresetCategoryPtr
> PresetCategoryList
;
91 class SD_DLLPUBLIC CustomAnimationPresets
94 SAL_DLLPRIVATE
CustomAnimationPresets();
95 SAL_DLLPRIVATE
virtual ~CustomAnimationPresets();
97 SAL_DLLPRIVATE
void init();
99 static const CustomAnimationPresets
& getCustomAnimationPresets();
101 SAL_DLLPRIVATE ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> getRandomPreset( sal_Int16 nPresetClass
) const;
103 CustomAnimationPresetPtr
getEffectDescriptor( const OUString
& rPresetId
) const;
105 SAL_DLLPRIVATE
const OUString
& getUINameForPresetId( const OUString
& rPresetId
) const;
106 SAL_DLLPRIVATE
const OUString
& getUINameForProperty( const OUString
& rProperty
) const;
108 SAL_DLLPRIVATE
const PresetCategoryList
& getEntrancePresets() const { return maEntrancePresets
; }
109 SAL_DLLPRIVATE
const PresetCategoryList
& getEmphasisPresets() const { return maEmphasisPresets
; }
110 SAL_DLLPRIVATE
const PresetCategoryList
& getExitPresets() const { return maExitPresets
; }
111 SAL_DLLPRIVATE
const PresetCategoryList
& getMotionPathsPresets() const { return maMotionPathsPresets
; }
112 SAL_DLLPRIVATE
const PresetCategoryList
& getMiscPresets() const { return maMiscPresets
; }
114 SAL_DLLPRIVATE
void changePresetSubType( CustomAnimationEffectPtr pEffect
, const OUString
& rPresetSubType
) const;
117 SAL_DLLPRIVATE
void importEffects();
118 SAL_DLLPRIVATE
void importResources();
120 SAL_DLLPRIVATE
void importPresets( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, PresetCategoryList
& rPresetMap
);
122 SAL_DLLPRIVATE
const OUString
& translateName( const OUString
& rId
, const UStringMap
& rNameMap
) const;
125 ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
> mxRootNode
;
126 EffectDescriptorMap maEffectDiscriptorMap
;
127 UStringMap maEffectNameMap
;
128 UStringMap maPropertyNameMap
;
130 PresetCategoryList maEntrancePresets
;
131 PresetCategoryList maEmphasisPresets
;
132 PresetCategoryList maExitPresets
;
133 PresetCategoryList maMotionPathsPresets
;
134 PresetCategoryList maMiscPresets
;
136 SAL_DLLPRIVATE
static CustomAnimationPresets
* mpCustomAnimationPresets
;
140 css::uno::Reference
< css::animations::XAnimationNode
> implImportEffects( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xServiceFactory
, const OUString
& rPath
);
142 void implImportLabels( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, UStringMap
& rStringMap
);
147 #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */