LibreOffice Module sd (master) 1
CustomAnimationPreset.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <utility>
25#include <vector>
26
27#include <com/sun/star/lang/XMultiServiceFactory.hpp>
28
30
31#include <unordered_map>
32
33namespace sd {
34
35typedef std::unordered_map< OUString, CustomAnimationEffectPtr > EffectsSubTypeMap;
36typedef std::unordered_map< OUString, OUString > UStringMap;
37
39{
41
42public:
44
45 void add( const CustomAnimationEffectPtr& pEffect );
46
47 SD_DLLPUBLIC css::uno::Reference< css::animations::XAnimationNode > create( const OUString& rstrSubType );
48
49 const OUString& getPresetId() const { return maPresetId; }
50 const OUString& getLabel() const { return maLabel; }
51 double getDuration() const { return mfDuration; }
52
53 std::vector<OUString> getSubTypes();
54 std::vector<OUString> getProperties() const;
55
56 bool hasProperty( std::u16string_view rProperty ) const;
57 bool isTextOnly() const { return mbIsTextOnly; }
58
59private:
60 OUString maPresetId;
61 OUString maProperty;
62 OUString maLabel;
64 double mfDuration;
66
68};
69
70typedef std::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr;
71typedef std::unordered_map<OUString, CustomAnimationPresetPtr> EffectDescriptorMap;
72typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList;
73
75{
76 OUString maLabel;
78
79 PresetCategory( OUString aLabel, EffectDescriptorList&& rEffects )
80 : maLabel(std::move( aLabel )), maEffects( std::move(rEffects) ) {}
81};
82typedef std::shared_ptr< PresetCategory > PresetCategoryPtr;
83typedef std::vector< PresetCategoryPtr > PresetCategoryList;
84
86{
87public:
88 SAL_DLLPRIVATE CustomAnimationPresets();
89 SAL_DLLPRIVATE ~CustomAnimationPresets();
90
94 static const CustomAnimationPresets& getCustomAnimationPresets();
95
96 SAL_DLLPRIVATE css::uno::Reference< css::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const;
97
98 CustomAnimationPresetPtr getEffectDescriptor( const OUString& rPresetId ) const;
99
100 SAL_DLLPRIVATE const OUString& getUINameForPresetId( const OUString& rPresetId ) const;
101 SAL_DLLPRIVATE const OUString& getUINameForProperty( const OUString& rProperty ) const;
102
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; }
108
109 SAL_DLLPRIVATE void changePresetSubType( const CustomAnimationEffectPtr& pEffect, const OUString& rPresetSubType ) const;
110
111private:
112 SAL_DLLPRIVATE void importEffects();
113 SAL_DLLPRIVATE void importResources();
114
115 SAL_DLLPRIVATE void importPresets( const css::uno::Reference< css::lang::XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, PresetCategoryList& rPresetMap );
116
117 SAL_DLLPRIVATE static const OUString& translateName( const OUString& rId, const UStringMap& rNameMap );
118
119private:
120 css::uno::Reference< css::animations::XAnimationNode > mxRootNode;
124
130
132 SAL_DLLPRIVATE static std::map<OUString, CustomAnimationPresets> mPresetsMap;
133};
134
135
136css::uno::Reference< css::animations::XAnimationNode > implImportEffects( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceFactory, const OUString& rPath );
137
138void implImportLabels( const css::uno::Reference< css::lang::XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, UStringMap& rStringMap );
139
140}
141
142
143/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< OUString > getSubTypes()
CustomAnimationPreset(const CustomAnimationEffectPtr &pEffect)
std::vector< OUString > getProperties() const
const OUString & getPresetId() const
SD_DLLPUBLIC css::uno::Reference< css::animations::XAnimationNode > create(const OUString &rstrSubType)
bool hasProperty(std::u16string_view rProperty) const
const OUString & getLabel() const
void add(const CustomAnimationEffectPtr &pEffect)
SAL_DLLPRIVATE const PresetCategoryList & getEmphasisPresets() const
static SAL_DLLPRIVATE std::map< OUString, CustomAnimationPresets > mPresetsMap
Maps per-language the animation presets.
SAL_DLLPRIVATE const PresetCategoryList & getMotionPathsPresets() const
css::uno::Reference< css::animations::XAnimationNode > mxRootNode
SAL_DLLPRIVATE const PresetCategoryList & getExitPresets() const
EffectDescriptorMap maEffectDescriptorMap
SAL_DLLPRIVATE const PresetCategoryList & getMiscPresets() const
SAL_DLLPRIVATE const PresetCategoryList & getEntrancePresets() const
void implImportLabels(const Reference< XMultiServiceFactory > &xConfigProvider, const OUString &rNodePath, UStringMap &rStringMap)
std::vector< PresetCategoryPtr > PresetCategoryList
std::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr
std::unordered_map< OUString, CustomAnimationEffectPtr > EffectsSubTypeMap
Reference< XAnimationNode > implImportEffects(const Reference< XMultiServiceFactory > &xServiceFactory, const OUString &rPath)
std::unordered_map< OUString, CustomAnimationPresetPtr > EffectDescriptorMap
std::unordered_map< OUString, OUString > UStringMap
std::shared_ptr< CustomAnimationEffect > CustomAnimationEffectPtr
std::shared_ptr< PresetCategory > PresetCategoryPtr
std::vector< CustomAnimationPresetPtr > EffectDescriptorList
#define SD_DLLPUBLIC
Definition: sddllapi.h:27
PresetCategory(OUString aLabel, EffectDescriptorList &&rEffects)
EffectDescriptorList maEffects
OUString aLabel