Kaydet (Commit) 21394b08 authored tarafından Eike Rathke's avatar Eike Rathke

Defer also loading of the English CalendarWrapper, tdf#109045 follow-up

Always constructing the en-US CalendarWrapper defeats the original intention
that not for every construction of SvNumberFormatter a calendar is needed, plus
if no en-US is requested constructing such calendar is just wasted.

Since

	commit 2a226965
	Date:   Mon Jul 10 15:56:32 2017 +0200

		tdf#109045: store en calendar separately in OnDemandCalendarWrapper

Change-Id: I06e13754f03fc1fe4fbf48b76ccb82c917606480
üst 9af8964d
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
const LocaleDataWrapper& operator*() const { return *get(); } const LocaleDataWrapper& operator*() const { return *get(); }
}; };
/** Load a calendar only if it's needed. Keep calendar for "en" locale /** Load a calendar only if it's needed. Keep calendar for "en-US" locale
separately, as there can be alternation between locale dependent and separately, as there can be alternation between locale dependent and
locale independent formats. locale independent formats.
SvNumberformatter uses it upon switching locales. SvNumberformatter uses it upon switching locales.
...@@ -143,7 +143,7 @@ class OnDemandCalendarWrapper ...@@ -143,7 +143,7 @@ class OnDemandCalendarWrapper
css::lang::Locale aEnglishLocale; css::lang::Locale aEnglishLocale;
css::lang::Locale aLocale; css::lang::Locale aLocale;
mutable css::lang::Locale aLastAnyLocale; mutable css::lang::Locale aLastAnyLocale;
std::unique_ptr<CalendarWrapper> pEnglishPtr; mutable std::unique_ptr<CalendarWrapper> pEnglishPtr;
mutable std::unique_ptr<CalendarWrapper> pAnyPtr; mutable std::unique_ptr<CalendarWrapper> pAnyPtr;
public: public:
...@@ -161,8 +161,7 @@ public: ...@@ -161,8 +161,7 @@ public:
{ {
m_xContext = rxContext; m_xContext = rxContext;
changeLocale( rLocale ); changeLocale( rLocale );
pEnglishPtr.reset(new CalendarWrapper( m_xContext )); pEnglishPtr.reset();
pEnglishPtr->loadDefaultCalendar( aEnglishLocale );
pAnyPtr.reset(); pAnyPtr.reset();
} }
...@@ -176,6 +175,11 @@ public: ...@@ -176,6 +175,11 @@ public:
CalendarWrapper* pPtr; CalendarWrapper* pPtr;
if ( aLocale == aEnglishLocale ) if ( aLocale == aEnglishLocale )
{ {
if (!pEnglishPtr)
{
pEnglishPtr.reset( new CalendarWrapper( m_xContext ));
pEnglishPtr->loadDefaultCalendar( aEnglishLocale );
}
pPtr = pEnglishPtr.get(); pPtr = pEnglishPtr.get();
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment