Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / sd / inc / CustomAnimationPreset.hxx
blob2685dd2be4d3a62c94d055b86e92e49e95487d23
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
25 #include <vector>
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include "CustomAnimationEffect.hxx"
31 #include <unordered_map>
33 namespace sd {
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;
43 public:
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; }
60 private:
61 OUString maPresetId;
62 OUString maProperty;
63 OUString maLabel;
64 OUString maDefaultSubTyp;
65 double mfDuration;
66 bool mbIsTextOnly;
68 EffectsSubTypeMap maSubTypes;
71 typedef std::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
72 typedef std::unordered_map<OUString, CustomAnimationPresetPtr> EffectDescriptorMap;
73 typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList;
75 struct PresetCategory
77 OUString maLabel;
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
88 public:
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;
109 private:
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 );
117 private:
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: */