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
;
38 class CustomAnimationPreset
40 friend class CustomAnimationPresets
;
43 CustomAnimationPreset( const CustomAnimationEffectPtr
& pEffect
);
45 void add( const CustomAnimationEffectPtr
& pEffect
);
47 SD_DLLPUBLIC
css::uno::Reference
< css::animations::XAnimationNode
> create( const OUString
& rstrSubType
);
49 const OUString
& getPresetId() const { return maPresetId
; }
50 const OUString
& getLabel() const { return maLabel
; }
51 double getDuration() const { return mfDuration
; }
53 std::vector
<OUString
> getSubTypes();
54 std::vector
<OUString
> getProperties() const;
56 bool hasProperty( const OUString
& rProperty
) const;
57 bool isTextOnly() const { return mbIsTextOnly
; }
63 OUString maDefaultSubTyp
;
67 EffectsSubTypeMap maSubTypes
;
70 typedef std::shared_ptr
< CustomAnimationPreset
> CustomAnimationPresetPtr
;
71 typedef std::unordered_map
<OUString
, CustomAnimationPresetPtr
> EffectDescriptorMap
;
72 typedef std::vector
< CustomAnimationPresetPtr
> EffectDescriptorList
;
76 OUString
const maLabel
;
77 EffectDescriptorList maEffects
;
79 PresetCategory( const OUString
& rLabel
, const EffectDescriptorList
& rEffects
)
80 : maLabel( rLabel
), maEffects( rEffects
) {}
82 typedef std::shared_ptr
< PresetCategory
> PresetCategoryPtr
;
83 typedef std::vector
< PresetCategoryPtr
> PresetCategoryList
;
85 class SD_DLLPUBLIC CustomAnimationPresets final
88 SAL_DLLPRIVATE
CustomAnimationPresets();
89 SAL_DLLPRIVATE
~CustomAnimationPresets();
91 static const CustomAnimationPresets
& getCustomAnimationPresets();
93 SAL_DLLPRIVATE
css::uno::Reference
< css::animations::XAnimationNode
> getRandomPreset( sal_Int16 nPresetClass
) const;
95 CustomAnimationPresetPtr
getEffectDescriptor( const OUString
& rPresetId
) const;
97 SAL_DLLPRIVATE
const OUString
& getUINameForPresetId( const OUString
& rPresetId
) const;
98 SAL_DLLPRIVATE
const OUString
& getUINameForProperty( const OUString
& rProperty
) const;
100 SAL_DLLPRIVATE
const PresetCategoryList
& getEntrancePresets() const { return maEntrancePresets
; }
101 SAL_DLLPRIVATE
const PresetCategoryList
& getEmphasisPresets() const { return maEmphasisPresets
; }
102 SAL_DLLPRIVATE
const PresetCategoryList
& getExitPresets() const { return maExitPresets
; }
103 SAL_DLLPRIVATE
const PresetCategoryList
& getMotionPathsPresets() const { return maMotionPathsPresets
; }
104 SAL_DLLPRIVATE
const PresetCategoryList
& getMiscPresets() const { return maMiscPresets
; }
106 SAL_DLLPRIVATE
void changePresetSubType( const CustomAnimationEffectPtr
& pEffect
, const OUString
& rPresetSubType
) const;
109 SAL_DLLPRIVATE
void importEffects();
110 SAL_DLLPRIVATE
void importResources();
112 SAL_DLLPRIVATE
void importPresets( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, PresetCategoryList
& rPresetMap
);
114 SAL_DLLPRIVATE
static const OUString
& translateName( const OUString
& rId
, const UStringMap
& rNameMap
);
117 css::uno::Reference
< css::animations::XAnimationNode
> mxRootNode
;
118 EffectDescriptorMap maEffectDiscriptorMap
;
119 UStringMap maEffectNameMap
;
120 UStringMap maPropertyNameMap
;
122 PresetCategoryList maEntrancePresets
;
123 PresetCategoryList maEmphasisPresets
;
124 PresetCategoryList maExitPresets
;
125 PresetCategoryList maMotionPathsPresets
;
126 PresetCategoryList maMiscPresets
;
128 SAL_DLLPRIVATE
static CustomAnimationPresets
* mpCustomAnimationPresets
;
132 css::uno::Reference
< css::animations::XAnimationNode
> implImportEffects( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xServiceFactory
, const OUString
& rPath
);
134 void implImportLabels( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xConfigProvider
, const OUString
& rNodePath
, UStringMap
& rStringMap
);
139 #endif // _SD_CUSTOMANIMATIONEFFECTS_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */