From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- sd/inc/CustomAnimationPreset.hxx | 142 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 sd/inc/CustomAnimationPreset.hxx (limited to 'sd/inc/CustomAnimationPreset.hxx') diff --git a/sd/inc/CustomAnimationPreset.hxx b/sd/inc/CustomAnimationPreset.hxx new file mode 100644 index 000000000..b746b20b7 --- /dev/null +++ b/sd/inc/CustomAnimationPreset.hxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include + +#include + +#include + +#include "CustomAnimationEffect.hxx" + +#include + +namespace sd { + +typedef std::unordered_map< OUString, CustomAnimationEffectPtr > EffectsSubTypeMap; +typedef std::unordered_map< OUString, OUString > UStringMap; + +class CustomAnimationPreset +{ + friend class CustomAnimationPresets; + +public: + CustomAnimationPreset( const CustomAnimationEffectPtr& pEffect ); + + void add( const CustomAnimationEffectPtr& pEffect ); + + SD_DLLPUBLIC css::uno::Reference< css::animations::XAnimationNode > create( const OUString& rstrSubType ); + + const OUString& getPresetId() const { return maPresetId; } + const OUString& getLabel() const { return maLabel; } + double getDuration() const { return mfDuration; } + + std::vector getSubTypes(); + std::vector getProperties() const; + + bool hasProperty( std::u16string_view rProperty ) const; + bool isTextOnly() const { return mbIsTextOnly; } + +private: + OUString maPresetId; + OUString maProperty; + OUString maLabel; + OUString maDefaultSubTyp; + double mfDuration; + bool mbIsTextOnly; + + EffectsSubTypeMap maSubTypes; +}; + +typedef std::shared_ptr< CustomAnimationPreset > CustomAnimationPresetPtr; +typedef std::unordered_map EffectDescriptorMap; +typedef std::vector< CustomAnimationPresetPtr > EffectDescriptorList; + +struct PresetCategory +{ + OUString maLabel; + EffectDescriptorList maEffects; + + PresetCategory( const OUString& rLabel, EffectDescriptorList&& rEffects ) + : maLabel( rLabel ), maEffects( std::move(rEffects) ) {} +}; +typedef std::shared_ptr< PresetCategory > PresetCategoryPtr; +typedef std::vector< PresetCategoryPtr > PresetCategoryList; + +class SD_DLLPUBLIC CustomAnimationPresets final +{ +public: + SAL_DLLPRIVATE CustomAnimationPresets(); + SAL_DLLPRIVATE ~CustomAnimationPresets(); + + /** This method gets presets instance, which is localized + * for the current user's locale. + */ + static const CustomAnimationPresets& getCustomAnimationPresets(); + + SAL_DLLPRIVATE css::uno::Reference< css::animations::XAnimationNode > getRandomPreset( sal_Int16 nPresetClass ) const; + + CustomAnimationPresetPtr getEffectDescriptor( const OUString& rPresetId ) const; + + SAL_DLLPRIVATE const OUString& getUINameForPresetId( const OUString& rPresetId ) const; + SAL_DLLPRIVATE const OUString& getUINameForProperty( const OUString& rProperty ) const; + + SAL_DLLPRIVATE const PresetCategoryList& getEntrancePresets() const { return maEntrancePresets; } + SAL_DLLPRIVATE const PresetCategoryList& getEmphasisPresets() const { return maEmphasisPresets; } + SAL_DLLPRIVATE const PresetCategoryList& getExitPresets() const { return maExitPresets; } + SAL_DLLPRIVATE const PresetCategoryList& getMotionPathsPresets() const { return maMotionPathsPresets; } + SAL_DLLPRIVATE const PresetCategoryList& getMiscPresets() const { return maMiscPresets; } + + SAL_DLLPRIVATE void changePresetSubType( const CustomAnimationEffectPtr& pEffect, const OUString& rPresetSubType ) const; + +private: + SAL_DLLPRIVATE void importEffects(); + SAL_DLLPRIVATE void importResources(); + + SAL_DLLPRIVATE void importPresets( const css::uno::Reference< css::lang::XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, PresetCategoryList& rPresetMap ); + + SAL_DLLPRIVATE static const OUString& translateName( const OUString& rId, const UStringMap& rNameMap ); + +private: + css::uno::Reference< css::animations::XAnimationNode > mxRootNode; + EffectDescriptorMap maEffectDescriptorMap; + UStringMap maEffectNameMap; + UStringMap maPropertyNameMap; + + PresetCategoryList maEntrancePresets; + PresetCategoryList maEmphasisPresets; + PresetCategoryList maExitPresets; + PresetCategoryList maMotionPathsPresets; + PresetCategoryList maMiscPresets; + + //! Maps per-language the animation presets. + SAL_DLLPRIVATE static std::map mPresetsMap; +}; + + +css::uno::Reference< css::animations::XAnimationNode > implImportEffects( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceFactory, const OUString& rPath ); + +void implImportLabels( const css::uno::Reference< css::lang::XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, UStringMap& rStringMap ); + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3