sd/inc/CustomAnimationPreset.hxx | 3 + sd/inc/TransitionPreset.hxx | 4 +- sd/source/core/CustomAnimationPreset.cxx | 33 +++++++++++------- sd/source/core/TransitionPreset.cxx | 42 +++++++++--------------- sd/source/ui/animations/CustomAnimationPane.cxx | 9 ----- sd/source/ui/animations/CustomAnimationPane.hxx | 14 ++++---- 6 files changed, 50 insertions(+), 55 deletions(-)
New commits: commit 312346531dde33cd000a1d3c95c7b7829b656438 Author: Ashod Nakashian <[email protected]> AuthorDate: Mon Jan 28 20:39:17 2019 -0500 Commit: Andras Timar <[email protected]> CommitDate: Mon Mar 4 15:22:01 2019 +0100 sd: LOK: support localization of slide transition presets Change-Id: Ic3ea57e537e118e10d155203921574967154c234 Reviewed-on: https://gerrit.libreoffice.org/68264 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> diff --git a/sd/inc/TransitionPreset.hxx b/sd/inc/TransitionPreset.hxx index 623989f8e93a..4cbfd0e91b9f 100644 --- a/sd/inc/TransitionPreset.hxx +++ b/sd/inc/TransitionPreset.hxx @@ -44,7 +44,6 @@ class TransitionPreset { public: static const TransitionPresetList& getTransitionPresetList(); - static bool importTransitionPresetList( TransitionPresetList& rList ); sal_Int16 getTransition() const { return mnTransition; } sal_Int16 getSubtype() const { return mnSubtype; } @@ -59,6 +58,9 @@ public: private: TransitionPreset( const css::uno::Reference< css::animations::XAnimationNode >& xNode ); + static bool importTransitionPresetList(TransitionPresetList& rList); + SAL_DLLPRIVATE static std::map<OUString, TransitionPresetList> mPresetsMap; + sal_Int16 mnTransition; sal_Int16 mnSubtype; bool mbDirection; diff --git a/sd/source/core/TransitionPreset.cxx b/sd/source/core/TransitionPreset.cxx index 1d07e80e33ea..2eeb5a49eca0 100644 --- a/sd/source/core/TransitionPreset.cxx +++ b/sd/source/core/TransitionPreset.cxx @@ -30,7 +30,9 @@ #include <comphelper/getexpandeduri.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/lok.hxx> #include <unotools/pathoptions.hxx> +#include <unotools/syslocaleoptions.hxx> #include <officecfg/Office/UI/Effects.hxx> #include <tools/stream.hxx> @@ -237,34 +239,24 @@ bool TransitionPreset::importTransitionPresetList( TransitionPresetList& rList ) return bRet; } -namespace -{ - class ImportedTransitionPresetList - { - private: - sd::TransitionPresetList m_aTransitionPresetList; - public: - ImportedTransitionPresetList() - { - sd::TransitionPreset::importTransitionPresetList( - m_aTransitionPresetList); - } - const sd::TransitionPresetList& getList() const - { - return m_aTransitionPresetList; - } - }; - - class theTransitionPresetList : - public rtl::Static<ImportedTransitionPresetList, - theTransitionPresetList> - { - }; -} +std::map<OUString, TransitionPresetList> sd::TransitionPreset::mPresetsMap; const TransitionPresetList& TransitionPreset::getTransitionPresetList() { - return theTransitionPresetList::get().getList(); + // Support localization per-view. Currently not useful for Desktop + // but very much critical for LOK. The cache now is per-language. + const OUString aLang = comphelper::LibreOfficeKit::isActive() + ? comphelper::LibreOfficeKit::getLanguageTag().getLanguage() + : SvtSysLocaleOptions().GetLanguageTag().getLanguage(); + + SolarMutexGuard aGuard; + const auto it = mPresetsMap.find(aLang); + if (it != mPresetsMap.end()) + return it->second; + + TransitionPresetList& rList = mPresetsMap[aLang]; + sd::TransitionPreset::importTransitionPresetList(rList); + return rList; } } commit b44679e47211a27f4fe22d05762d9d48c8f88935 Author: Ashod Nakashian <[email protected]> AuthorDate: Mon Jan 28 10:03:39 2019 -0500 Commit: Andras Timar <[email protected]> CommitDate: Mon Mar 4 15:21:46 2019 +0100 sd: LOK: support per-user localization of CustomAnimationPreset This only fixes the caching in CustomAnimationPreset and CustomAnimationPane. Other cached labels will be done separately. Change-Id: Iaf511168d26b3a5567ca53556e242d3c071d2623 Reviewed-on: https://gerrit.libreoffice.org/68263 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> diff --git a/sd/inc/CustomAnimationPreset.hxx b/sd/inc/CustomAnimationPreset.hxx index b5d9b4d60008..790569613d82 100644 --- a/sd/inc/CustomAnimationPreset.hxx +++ b/sd/inc/CustomAnimationPreset.hxx @@ -127,7 +127,8 @@ private: PresetCategoryList maMotionPathsPresets; PresetCategoryList maMiscPresets; - SAL_DLLPRIVATE static CustomAnimationPresets* mpCustomAnimationPresets; + //! Maps per-language the animation presets. + SAL_DLLPRIVATE static std::map<OUString, CustomAnimationPresets*> mpCustomAnimationPresetsMap; }; diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx index 3754479cb46d..6d2f44ccba4c 100644 --- a/sd/source/core/CustomAnimationPreset.cxx +++ b/sd/source/core/CustomAnimationPreset.cxx @@ -36,7 +36,9 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/random.hxx> +#include <comphelper/lok.hxx> #include <unotools/pathoptions.hxx> +#include <unotools/syslocaleoptions.hxx> #include <tools/stream.hxx> #include <tools/debug.hxx> @@ -527,22 +529,27 @@ void CustomAnimationPresets::changePresetSubType( const CustomAnimationEffectPtr } } -CustomAnimationPresets* CustomAnimationPresets::mpCustomAnimationPresets = nullptr; +std::map<OUString, CustomAnimationPresets*> CustomAnimationPresets::mpCustomAnimationPresetsMap; const CustomAnimationPresets& CustomAnimationPresets::getCustomAnimationPresets() { - if( !mpCustomAnimationPresets ) - { - SolarMutexGuard aGuard; - - if( !mpCustomAnimationPresets ) - { - mpCustomAnimationPresets = new sd::CustomAnimationPresets(); - mpCustomAnimationPresets->importResources(); - } - } - - return *mpCustomAnimationPresets; + // Support localization per-view. Currently not useful for Desktop + // but very much critical for LOK. The cache now is per-language. + const OUString aLang = comphelper::LibreOfficeKit::isActive() + ? comphelper::LibreOfficeKit::getLanguageTag().getLanguage() + : SvtSysLocaleOptions().GetLanguageTag().getLanguage(); + + SolarMutexGuard aGuard; + const auto it = mpCustomAnimationPresetsMap.find(aLang); + if (it != mpCustomAnimationPresetsMap.end()) + return *it->second; + + // Note: we are invoked recursively(!), so we must set the instance pointer + // in the cache map before we importResources, lest we get in infinite loop. + sd::CustomAnimationPresets* pCustomAnimationPresets = new sd::CustomAnimationPresets(); + mpCustomAnimationPresetsMap[aLang] = pCustomAnimationPresets; + pCustomAnimationPresets->importResources(); + return *pCustomAnimationPresets; } Reference< XAnimationNode > CustomAnimationPresets::getRandomPreset( sal_Int16 nPresetClass ) const diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index b999ec95e893..59a483e9e1f7 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -128,7 +128,6 @@ CustomAnimationPane::CustomAnimationPane( Window* pParent, ViewShellBase& rBase, const css::uno::Reference<css::frame::XFrame>& rxFrame ) : PanelLayout( pParent, "CustomAnimationsPanel", "modules/simpress/ui/customanimationspanel.ui", rxFrame ), mrBase( rBase ), - mpCustomAnimationPresets(nullptr), mnPropertyType( nPropertyTypeNone ), mnMotionPathPos( 3 ), mnCurvePathPos( LISTBOX_ENTRY_NOTFOUND ), @@ -145,7 +144,6 @@ CustomAnimationPane::CustomAnimationPane( Window* pParent, ViewShellBase& rBase, bool ) : PanelLayout( pParent, "CustomAnimationsPanel", "modules/simpress/ui/customanimationspanelhorizontal.ui", rxFrame ), mrBase( rBase ), - mpCustomAnimationPresets(nullptr), mnPropertyType( nPropertyTypeNone ), mnMotionPathPos( 3 ), mnCurvePathPos( LISTBOX_ENTRY_NOTFOUND ), @@ -2432,13 +2430,6 @@ void CustomAnimationPane::preview( const Reference< XAnimationNode >& xAnimation SlideShow::StartPreview( mrBase, mxCurrentPage, xRoot ); } -const CustomAnimationPresets& CustomAnimationPane::getPresets() -{ - if (mpCustomAnimationPresets == nullptr) - mpCustomAnimationPresets = &CustomAnimationPresets::getCustomAnimationPresets(); - return *mpCustomAnimationPresets; -} - // ICustomAnimationListController void CustomAnimationPane::onSelect() { diff --git a/sd/source/ui/animations/CustomAnimationPane.hxx b/sd/source/ui/animations/CustomAnimationPane.hxx index f1aff2e25cdc..a436a98b732d 100644 --- a/sd/source/ui/animations/CustomAnimationPane.hxx +++ b/sd/source/ui/animations/CustomAnimationPane.hxx @@ -134,8 +134,6 @@ private: private: ViewShellBase& mrBase; - const CustomAnimationPresets* mpCustomAnimationPresets; - VclPtr<PushButton> mpPBAddEffect; VclPtr<PushButton> mpPBRemoveEffect; VclPtr<FixedText> mpFTEffect; @@ -178,16 +176,20 @@ private: css::uno::Reference< css::drawing::XDrawPage > mxCurrentPage; css::uno::Reference< css::drawing::XDrawView > mxView; - /** The mpCustomAnimationPresets is initialized either on demand or + /** The CustomAnimationPresets is initialized either on demand or after a short time after the construction of a new object of this class. This timer is responsible for the later. */ Timer maLateInitTimer; - /** This method initializes the mpCustomAnimationPresets on demand and - returns a reference to the list. + /** This method gets presets instance, which is localized + * for the current user's locale. */ - const CustomAnimationPresets& getPresets(); + const CustomAnimationPresets& getPresets() const + { + // CustomAnimationPresets already caches, no need for another one here. + return CustomAnimationPresets::getCustomAnimationPresets(); + } MotionPathTagVector maMotionPathTags; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
