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>
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( const CustomAnimationEffectPtr
& pEffect
);
50 SD_DLLPUBLIC
css::uno::Reference
< css::animations::XAnimationNode
> create( const OUString
& rstrSubType
);
52 const OUString
& getPresetId() const { return maPresetId
; }
53 const OUString
& getLabel() const { return maLabel
; }
54 double getDuration() const { return mfDuration
; }
56 UStringList
getSubTypes();
57 UStringList
getProperties() const;
59 bool hasProperty( const OUString
& rProperty
) const;
60 bool isTextOnly() const { return mbIsTextOnly
; }
65 sal_Int16 mnPresetClass
;
67 OUString maDefaultSubTyp
;
71 EffectsSubTypeMap maSubTypes
;
74 typedef std::shared_ptr
< CustomAnimationPreset
> CustomAnimationPresetPtr
;
75 typedef std::unordered_map
<OUString
, CustomAnimationPresetPtr
, OUStringHash
> EffectDescriptorMap
;
76 typedef std::vector
< CustomAnimationPresetPtr
> EffectDescriptorList
;
81 EffectDescriptorList maEffects
;
83 PresetCategory( const OUString
& rLabel
, const EffectDescriptorList
& rEffects
)
84 : maLabel( rLabel
), maEffects( rEffects
) {}
86 typedef std::shared_ptr
< PresetCategory
> PresetCategoryPtr
;
87 typedef std::vector
< PresetCategoryPtr
> PresetCategoryList
;
89 class SD_DLLPUBLIC CustomAnimationPresets final
92 SAL_DLLPRIVATE
CustomAnimationPresets();
93 SAL_DLLPRIVATE
~CustomAnimationPresets();
95 static const CustomAnimationPresets
& getCustomAnimationPresets();
97 SAL_DLLPRIVATE
css::uno::Reference
< css::animations::XAnimationNode
> getRandomPreset( sal_Int16 nPresetClass
) const;
99 CustomAnimationPresetPtr
getEffectDescriptor( const OUString
& rPresetId
) const;
101 SAL_DLLPRIVATE
const OUString
& getUINameForPresetId( const OUString
& rPresetId
) const;
102 SAL_DLLPRIVATE
const OUString
& getUINameForProperty( const OUString
& rProperty
) const;
104 SAL_DLLPRIVATE
const PresetCategoryList
& getEntrancePresets() const { return maEntrancePresets
; }
105 SAL_DLLPRIVATE
const PresetCategoryList
& getEmphasisPresets() const { return maEmphasisPresets
; }
106 SAL_DLLPRIVATE
const PresetCategoryList
& getExitPresets() const { return maExitPresets
; }
107 SAL_DLLPRIVATE
const PresetCategoryList
& getMotionPathsPresets() const { return maMotionPathsPresets
; }
108 SAL_DLLPRIVATE
const PresetCategoryList
& getMiscPresets() const { return maMiscPresets
; }
110 SAL_DLLPRIVATE
void changePresetSubType( const CustomAnimationEffectPtr
& pEffect
, const OUString
& rPresetSubType
) const;
113 SAL_DLLPRIVATE
void importEffects();
114 SAL_DLLPRIVATE
void importResources();
116 SAL_DLLPRIVATE
void importPresets( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, PresetCategoryList
& rPresetMap
);
118 SAL_DLLPRIVATE
static const OUString
& translateName( const OUString
& rId
, const UStringMap
& rNameMap
);
121 css::uno::Reference
< css::animations::XAnimationNode
> mxRootNode
;
122 EffectDescriptorMap maEffectDiscriptorMap
;
123 UStringMap maEffectNameMap
;
124 UStringMap maPropertyNameMap
;
126 PresetCategoryList maEntrancePresets
;
127 PresetCategoryList maEmphasisPresets
;
128 PresetCategoryList maExitPresets
;
129 PresetCategoryList maMotionPathsPresets
;
130 PresetCategoryList maMiscPresets
;
132 SAL_DLLPRIVATE
static CustomAnimationPresets
* mpCustomAnimationPresets
;
136 css::uno::Reference
< css::animations::XAnimationNode
> implImportEffects( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xServiceFactory
, const OUString
& rPath
);
138 void implImportLabels( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, UStringMap
& rStringMap
);
143 #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */