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 <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include "CustomAnimationEffect.hxx"
31 #include <unordered_map>
35 typedef std::unordered_map
< OUString
, CustomAnimationEffectPtr
> EffectsSubTypeMap
;
36 typedef std::unordered_map
< OUString
, OUString
> UStringMap
;
37 typedef std::vector
< OUString
> UStringList
;
39 class CustomAnimationPreset
41 friend class CustomAnimationPresets
;
44 CustomAnimationPreset( const CustomAnimationEffectPtr
& pEffect
);
46 void add( const CustomAnimationEffectPtr
& pEffect
);
48 SD_DLLPUBLIC
css::uno::Reference
< css::animations::XAnimationNode
> create( const OUString
& rstrSubType
);
50 const OUString
& getPresetId() const { return maPresetId
; }
51 const OUString
& getLabel() const { return maLabel
; }
52 double getDuration() const { return mfDuration
; }
54 UStringList
getSubTypes();
55 UStringList
getProperties() const;
57 bool hasProperty( const OUString
& rProperty
) const;
58 bool isTextOnly() const { return mbIsTextOnly
; }
64 OUString maDefaultSubTyp
;
68 EffectsSubTypeMap maSubTypes
;
71 typedef std::shared_ptr
< CustomAnimationPreset
> CustomAnimationPresetPtr
;
72 typedef std::unordered_map
<OUString
, CustomAnimationPresetPtr
> EffectDescriptorMap
;
73 typedef std::vector
< CustomAnimationPresetPtr
> EffectDescriptorList
;
78 EffectDescriptorList maEffects
;
80 PresetCategory( const OUString
& rLabel
, const EffectDescriptorList
& rEffects
)
81 : maLabel( rLabel
), maEffects( rEffects
) {}
83 typedef std::shared_ptr
< PresetCategory
> PresetCategoryPtr
;
84 typedef std::vector
< PresetCategoryPtr
> PresetCategoryList
;
86 class SD_DLLPUBLIC CustomAnimationPresets final
89 SAL_DLLPRIVATE
CustomAnimationPresets();
90 SAL_DLLPRIVATE
~CustomAnimationPresets();
92 static const CustomAnimationPresets
& getCustomAnimationPresets();
94 SAL_DLLPRIVATE
css::uno::Reference
< css::animations::XAnimationNode
> getRandomPreset( sal_Int16 nPresetClass
) const;
96 CustomAnimationPresetPtr
getEffectDescriptor( const OUString
& rPresetId
) const;
98 SAL_DLLPRIVATE
const OUString
& getUINameForPresetId( const OUString
& rPresetId
) const;
99 SAL_DLLPRIVATE
const OUString
& getUINameForProperty( const OUString
& rProperty
) const;
101 SAL_DLLPRIVATE
const PresetCategoryList
& getEntrancePresets() const { return maEntrancePresets
; }
102 SAL_DLLPRIVATE
const PresetCategoryList
& getEmphasisPresets() const { return maEmphasisPresets
; }
103 SAL_DLLPRIVATE
const PresetCategoryList
& getExitPresets() const { return maExitPresets
; }
104 SAL_DLLPRIVATE
const PresetCategoryList
& getMotionPathsPresets() const { return maMotionPathsPresets
; }
105 SAL_DLLPRIVATE
const PresetCategoryList
& getMiscPresets() const { return maMiscPresets
; }
107 SAL_DLLPRIVATE
void changePresetSubType( const CustomAnimationEffectPtr
& pEffect
, const OUString
& rPresetSubType
) const;
110 SAL_DLLPRIVATE
void importEffects();
111 SAL_DLLPRIVATE
void importResources();
113 SAL_DLLPRIVATE
void importPresets( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, PresetCategoryList
& rPresetMap
);
115 SAL_DLLPRIVATE
static const OUString
& translateName( const OUString
& rId
, const UStringMap
& rNameMap
);
118 css::uno::Reference
< css::animations::XAnimationNode
> mxRootNode
;
119 EffectDescriptorMap maEffectDiscriptorMap
;
120 UStringMap maEffectNameMap
;
121 UStringMap maPropertyNameMap
;
123 PresetCategoryList maEntrancePresets
;
124 PresetCategoryList maEmphasisPresets
;
125 PresetCategoryList maExitPresets
;
126 PresetCategoryList maMotionPathsPresets
;
127 PresetCategoryList maMiscPresets
;
129 SAL_DLLPRIVATE
static CustomAnimationPresets
* mpCustomAnimationPresets
;
133 css::uno::Reference
< css::animations::XAnimationNode
> implImportEffects( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xServiceFactory
, const OUString
& rPath
);
135 void implImportLabels( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, UStringMap
& rStringMap
);
140 #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */