bump product version to 7.2.5.1
[LibreOffice.git] / sd / inc / CustomAnimationPreset.hxx
blob6894a7c7af77ba900100ff6c7245faf86cce4a35
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 #pragma once
22 #include <sal/config.h>
24 #include <vector>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include "CustomAnimationEffect.hxx"
30 #include <unordered_map>
32 namespace sd {
34 typedef std::unordered_map< OUString, CustomAnimationEffectPtr > EffectsSubTypeMap;
35 typedef std::unordered_map< OUString, OUString > UStringMap;
37 class CustomAnimationPreset
39 friend class CustomAnimationPresets;
41 public:
42 CustomAnimationPreset( const CustomAnimationEffectPtr& pEffect );
44 void add( const CustomAnimationEffectPtr& pEffect );
46 SD_DLLPUBLIC css::uno::Reference< css::animations::XAnimationNode > create( const OUString& rstrSubType );
48 const OUString& getPresetId() const { return maPresetId; }
49 const OUString& getLabel() const { return maLabel; }
50 double getDuration() const { return mfDuration; }
52 std::vector<OUString> getSubTypes();
53 std::vector<OUString> getProperties() const;
55 bool hasProperty( std::u16string_view rProperty ) const;
56 bool isTextOnly() const { return mbIsTextOnly; }
58 private:
59 OUString maPresetId;
60 OUString maProperty;
61 OUString maLabel;
62 OUString maDefaultSubTyp;
63 double mfDuration;
64 bool mbIsTextOnly;
66 EffectsSubTypeMap maSubTypes;
69 typedef std::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
70 typedef std::unordered_map<OUString, CustomAnimationPresetPtr> EffectDescriptorMap;
71 typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList;
73 struct PresetCategory
75 OUString maLabel;
76 EffectDescriptorList maEffects;
78 PresetCategory( const OUString& rLabel, const EffectDescriptorList& rEffects )
79 : maLabel( rLabel ), maEffects( rEffects ) {}
81 typedef std::shared_ptr< PresetCategory > PresetCategoryPtr;
82 typedef std::vector< PresetCategoryPtr > PresetCategoryList;
84 class SD_DLLPUBLIC CustomAnimationPresets final
86 public:
87 SAL_DLLPRIVATE CustomAnimationPresets();
88 SAL_DLLPRIVATE ~CustomAnimationPresets();
90 /** This method gets presets instance, which is localized
91 * for the current user's locale.
93 static const CustomAnimationPresets& getCustomAnimationPresets();
95 SAL_DLLPRIVATE css::uno::Reference< css::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const;
97 CustomAnimationPresetPtr getEffectDescriptor( const OUString& rPresetId ) const;
99 SAL_DLLPRIVATE const OUString& getUINameForPresetId( const OUString& rPresetId ) const;
100 SAL_DLLPRIVATE const OUString& getUINameForProperty( const OUString& rProperty ) const;
102 SAL_DLLPRIVATE const PresetCategoryList& getEntrancePresets() const { return maEntrancePresets; }
103 SAL_DLLPRIVATE const PresetCategoryList& getEmphasisPresets() const { return maEmphasisPresets; }
104 SAL_DLLPRIVATE const PresetCategoryList& getExitPresets() const { return maExitPresets; }
105 SAL_DLLPRIVATE const PresetCategoryList& getMotionPathsPresets() const { return maMotionPathsPresets; }
106 SAL_DLLPRIVATE const PresetCategoryList& getMiscPresets() const { return maMiscPresets; }
108 SAL_DLLPRIVATE void changePresetSubType( const CustomAnimationEffectPtr& pEffect, const OUString& rPresetSubType ) const;
110 private:
111 SAL_DLLPRIVATE void importEffects();
112 SAL_DLLPRIVATE void importResources();
114 SAL_DLLPRIVATE void importPresets( const css::uno::Reference< css::lang::XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, PresetCategoryList& rPresetMap );
116 SAL_DLLPRIVATE static const OUString& translateName( const OUString& rId, const UStringMap& rNameMap );
118 private:
119 css::uno::Reference< css::animations::XAnimationNode > mxRootNode;
120 EffectDescriptorMap maEffectDescriptorMap;
121 UStringMap maEffectNameMap;
122 UStringMap maPropertyNameMap;
124 PresetCategoryList maEntrancePresets;
125 PresetCategoryList maEmphasisPresets;
126 PresetCategoryList maExitPresets;
127 PresetCategoryList maMotionPathsPresets;
128 PresetCategoryList maMiscPresets;
130 //! Maps per-language the animation presets.
131 SAL_DLLPRIVATE static std::map<OUString, CustomAnimationPresets> mPresetsMap;
135 css::uno::Reference< css::animations::XAnimationNode > implImportEffects( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceFactory, const OUString& rPath );
137 void implImportLabels( const css::uno::Reference< css::lang::XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, UStringMap& rStringMap );
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */