Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sd / inc / CustomAnimationPreset.hxx
blobc262ad059531577d5c88614a55888f1f1d65dcf9
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 <utility>
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;
38 class CustomAnimationPreset
40 friend class CustomAnimationPresets;
42 public:
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( std::u16string_view rProperty ) const;
57 bool isTextOnly() const { return mbIsTextOnly; }
59 private:
60 OUString maPresetId;
61 OUString maProperty;
62 OUString maLabel;
63 OUString maDefaultSubTyp;
64 double mfDuration;
65 bool mbIsTextOnly;
67 EffectsSubTypeMap maSubTypes;
70 typedef std::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
71 typedef std::unordered_map<OUString, CustomAnimationPresetPtr> EffectDescriptorMap;
72 typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList;
74 struct PresetCategory
76 OUString maLabel;
77 EffectDescriptorList maEffects;
79 PresetCategory( OUString aLabel, EffectDescriptorList&& rEffects )
80 : maLabel(std::move( aLabel )), maEffects( std::move(rEffects) ) {}
82 typedef std::shared_ptr< PresetCategory > PresetCategoryPtr;
83 typedef std::vector< PresetCategoryPtr > PresetCategoryList;
85 class SD_DLLPUBLIC CustomAnimationPresets final
87 public:
88 SAL_DLLPRIVATE CustomAnimationPresets();
89 SAL_DLLPRIVATE ~CustomAnimationPresets();
91 /** This method gets presets instance, which is localized
92 * for the current user's locale.
94 static const CustomAnimationPresets& getCustomAnimationPresets();
96 SAL_DLLPRIVATE css::uno::Reference< css::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const;
98 CustomAnimationPresetPtr getEffectDescriptor( const OUString& rPresetId ) const;
100 SAL_DLLPRIVATE const OUString& getUINameForPresetId( const OUString& rPresetId ) const;
101 SAL_DLLPRIVATE const OUString& getUINameForProperty( const OUString& rProperty ) const;
103 SAL_DLLPRIVATE const PresetCategoryList& getEntrancePresets() const { return maEntrancePresets; }
104 SAL_DLLPRIVATE const PresetCategoryList& getEmphasisPresets() const { return maEmphasisPresets; }
105 SAL_DLLPRIVATE const PresetCategoryList& getExitPresets() const { return maExitPresets; }
106 SAL_DLLPRIVATE const PresetCategoryList& getMotionPathsPresets() const { return maMotionPathsPresets; }
107 SAL_DLLPRIVATE const PresetCategoryList& getMiscPresets() const { return maMiscPresets; }
109 SAL_DLLPRIVATE void changePresetSubType( const CustomAnimationEffectPtr& pEffect, const OUString& rPresetSubType ) const;
111 private:
112 SAL_DLLPRIVATE void importEffects();
113 SAL_DLLPRIVATE void importResources();
115 SAL_DLLPRIVATE void importPresets( const css::uno::Reference< css::lang::XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, PresetCategoryList& rPresetMap );
117 SAL_DLLPRIVATE static const OUString& translateName( const OUString& rId, const UStringMap& rNameMap );
119 private:
120 css::uno::Reference< css::animations::XAnimationNode > mxRootNode;
121 EffectDescriptorMap maEffectDescriptorMap;
122 UStringMap maEffectNameMap;
123 UStringMap maPropertyNameMap;
125 PresetCategoryList maEntrancePresets;
126 PresetCategoryList maEmphasisPresets;
127 PresetCategoryList maExitPresets;
128 PresetCategoryList maMotionPathsPresets;
129 PresetCategoryList maMiscPresets;
131 //! Maps per-language the animation presets.
132 SAL_DLLPRIVATE static std::map<OUString, CustomAnimationPresets> mPresetsMap;
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 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */