sd/inc/CustomAnimationPreset.hxx | 6 +++- sd/source/core/CustomAnimationPreset.cxx | 34 ++++++++++++++---------- sd/source/ui/animations/CustomAnimationPane.cxx | 20 ++++---------- sd/source/ui/animations/CustomAnimationPane.hxx | 12 +------- 4 files changed, 34 insertions(+), 38 deletions(-)
New commits: commit 3b55741586883d4fbb7f3e4c5368b5382c3ce5f8 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> AuthorDate: Mon Jan 28 10:03:39 2019 -0500 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Jul 24 21:01:51 2019 +0200 sd: LOK: support per-user localization of CustomAnimationPreset This only fixes the caching in CustomAnimationPreset and CustomAnimationPane. Other cached labels will be done separately. Reviewed-on: https://gerrit.libreoffice.org/68263 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> (cherry picked from commit b44679e47211a27f4fe22d05762d9d48c8f88935) Change-Id: Iaf511168d26b3a5567ca53556e242d3c071d2623 Reviewed-on: https://gerrit.libreoffice.org/76241 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sd/inc/CustomAnimationPreset.hxx b/sd/inc/CustomAnimationPreset.hxx index eeeeac55ad77..57669734014b 100644 --- a/sd/inc/CustomAnimationPreset.hxx +++ b/sd/inc/CustomAnimationPreset.hxx @@ -88,6 +88,9 @@ 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; @@ -125,7 +128,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 1f2066e6af9c..4c02acc25d6c 100644 --- a/sd/source/core/CustomAnimationPreset.cxx +++ b/sd/source/core/CustomAnimationPreset.cxx @@ -35,6 +35,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> @@ -521,22 +524,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 6971328837e8..ee1807187fbd 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -124,7 +124,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 ), mnCurvePathPos( LISTBOX_ENTRY_NOTFOUND ), mnPolygonPathPos( LISTBOX_ENTRY_NOTFOUND ), @@ -532,7 +531,7 @@ void CustomAnimationPane::updateControls() { CustomAnimationEffectPtr pEffect = maListSelection.front(); - OUString aUIName( getPresets().getUINameForPresetId( pEffect->getPresetId() ) ); + OUString aUIName( CustomAnimationPresets::getCustomAnimationPresets().getUINameForPresetId( pEffect->getPresetId() ) ); OUString aTemp( maStrModify ); @@ -542,7 +541,7 @@ void CustomAnimationPane::updateControls() mpFTEffect->SetText( aTemp ); } - CustomAnimationPresetPtr pDescriptor = getPresets().getEffectDescriptor( pEffect->getPresetId() ); + CustomAnimationPresetPtr pDescriptor = CustomAnimationPresets::getCustomAnimationPresets().getEffectDescriptor( pEffect->getPresetId() ); if( pDescriptor.get() ) { PropertySubControl* pSubControl = nullptr; @@ -994,7 +993,7 @@ bool CustomAnimationPane::setProperty1Value( sal_Int32 nType, const CustomAnimat rValue >>= aPresetSubType; if( aPresetSubType != pEffect->getPresetSubType() ) { - getPresets().changePresetSubType( pEffect, aPresetSubType ); + CustomAnimationPresets::getCustomAnimationPresets().changePresetSubType( pEffect, aPresetSubType ); bEffectChanged = true; } } @@ -1091,7 +1090,7 @@ std::unique_ptr<STLPropertySet> CustomAnimationPane::createSelectionSet() sal_Int32 nMaxParaDepth = 0; // get options from selected effects - const CustomAnimationPresets& rPresets (getPresets()); + const CustomAnimationPresets& rPresets (CustomAnimationPresets::getCustomAnimationPresets()); for( CustomAnimationEffectPtr& pEffect : maListSelection ) { EffectSequenceHelper* pEffectSequence = pEffect->getEffectSequence(); @@ -2157,7 +2156,7 @@ sal_uInt32 CustomAnimationPane::fillAnimationLB( bool bHasText ) { PresetCategoryList rCategoryList; sal_uInt16 nPosition = mpLBCategory->GetSelectedEntryPos(); - const CustomAnimationPresets& rPresets (getPresets()); + const CustomAnimationPresets& rPresets (CustomAnimationPresets::getCustomAnimationPresets()); switch(nPosition) { case 0:rCategoryList = rPresets.getEntrancePresets();break; @@ -2244,7 +2243,7 @@ IMPL_LINK_NOARG(CustomAnimationPane, lateInitCallback, Timer *, void) { // Call getPresets() to initiate the (expensive) construction of the // presets list. - getPresets(); + CustomAnimationPresets::getCustomAnimationPresets(); // update selection and control states onSelectionChanged(); @@ -2389,13 +2388,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 8df9d2511377..17642516f3df 100644 --- a/sd/source/ui/animations/CustomAnimationPane.hxx +++ b/sd/source/ui/animations/CustomAnimationPane.hxx @@ -34,7 +34,6 @@ namespace com { namespace sun { namespace star { namespace drawing { class XDrawPage; } } } } namespace com { namespace sun { namespace star { namespace drawing { class XDrawView; } } } } -namespace sd { class CustomAnimationPresets; } namespace weld { class ComboBox; } @@ -109,7 +108,7 @@ private: void changeSelection( STLPropertySet const * pResultSet, STLPropertySet const * pOldSet ); static css::uno::Any getProperty1Value( sal_Int32 nType, const CustomAnimationEffectPtr& pEffect ); - bool setProperty1Value( sal_Int32 nType, const CustomAnimationEffectPtr& pEffect, const css::uno::Any& rValue ); + static bool setProperty1Value( sal_Int32 nType, const CustomAnimationEffectPtr& pEffect, const css::uno::Any& rValue ); void UpdateLook(); sal_uInt32 fillAnimationLB( bool bHasText ); PathKind getCreatePathKind() const; @@ -130,8 +129,6 @@ private: private: ViewShellBase& mrBase; - const CustomAnimationPresets* mpCustomAnimationPresets; - // UI Elements VclPtr<FixedText> mpFTAnimation; VclPtr<CustomAnimationList> mpCustomAnimationList; @@ -173,17 +170,12 @@ 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. - */ - const CustomAnimationPresets& getPresets(); - MotionPathTagVector maMotionPathTags; ScopeLock maSelectionLock; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits