summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-01-28 10:03:39 -0500
committerAndras Timar <andras.timar@collabora.com>2019-03-04 15:21:46 +0100
commitb44679e47211a27f4fe22d05762d9d48c8f88935 (patch)
tree076a17f27081ac7e2af7fec1264f06bd73f5ddd0 /sd
parentd92715c797c290e16b04ebc957d908288f997439 (diff)
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 <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/CustomAnimationPreset.hxx3
-rw-r--r--sd/source/core/CustomAnimationPreset.cxx33
-rw-r--r--sd/source/ui/animations/CustomAnimationPane.cxx9
-rw-r--r--sd/source/ui/animations/CustomAnimationPane.hxx14
4 files changed, 30 insertions, 29 deletions
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;