summaryrefslogtreecommitdiff
path: root/include/unotools/localedatawrapper.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2021-05-01 08:30:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-02 10:00:43 +0200
commit86b345a963a64fd9b9a3cab522b3ac2e909977fd (patch)
treeb55be7134aa02c203b0b4eea6afeab3aecfd65a6 /include/unotools/localedatawrapper.hxx
parentaa38eede9d340cbb11a792ab1ebbe681521a4489 (diff)
tdf#79049 speed up OOXML workbook load (4)
Optimise LocaleDataWrapper for reads by initialising the data we in the constructor, so we don't need any kind of locking Reduces load time from 34s to 28s. Change-Id: I4bd3bddb30b70ba015fe5b1372534f9507762b74 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114960 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/unotools/localedatawrapper.hxx')
-rw-r--r--include/unotools/localedatawrapper.hxx62
1 files changed, 24 insertions, 38 deletions
diff --git a/include/unotools/localedatawrapper.hxx b/include/unotools/localedatawrapper.hxx
index 70c62ad3073b..29e9815935c2 100644
--- a/include/unotools/localedatawrapper.hxx
+++ b/include/unotools/localedatawrapper.hxx
@@ -30,7 +30,6 @@
#include <rtl/ustring.hxx>
#include <rtl/math.h>
#include <i18nlangtag/languagetag.hxx>
-#include <unotools/readwritemutexguard.hxx>
#include <unotools/unotoolsdllapi.h>
#include <memory>
#include <map>
@@ -58,6 +57,10 @@ enum class MeasurementSystem {
US
};
+/**
+ * This class can be accessed without locking because we load
+ * all of the data in the constructor.
+ */
class UNOTOOLS_DLLPUBLIC LocaleDataWrapper
{
static sal_uInt8 nLocaleDataChecking; // 0:=dontknow, 1:=yes, 2:=no
@@ -81,54 +84,44 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper
sal_uInt16 nCurrPositiveFormat;
sal_uInt16 nCurrNegativeFormat;
sal_uInt16 nCurrDigits;
- bool bLocaleDataItemValid;
- bool bReservedWordValid;
- bool bSecondaryCalendarValid;
- mutable ::utl::ReadWriteMutex aMutex;
- struct SAL_DLLPRIVATE Locale_Compare
- {
- bool operator()(const css::lang::Locale& rLocale1, const css::lang::Locale& rLocale2) const;
- };
- mutable std::map<css::lang::Locale, css::i18n::LocaleDataItem2, Locale_Compare> maDataItemCache;
-
- // whenever Locale changes
- void invalidateData();
-
- void getOneLocaleItemImpl( sal_Int16 nItem );
+
+ void loadData();
+ void loadDateAcceptancePatterns(const std::vector<OUString> & rOverrideDateAcceptancePatterns);
+
const OUString& getOneLocaleItem( sal_Int16 nItem ) const;
- void getOneReservedWordImpl( sal_Int16 nWord );
const OUString& getOneReservedWord( sal_Int16 nWord ) const;
- void getCurrSymbolsImpl();
- void getCurrFormatsImpl();
+ void loadCurrencyFormats();
void scanCurrFormatImpl( const OUString& rCode,
sal_Int32 nStart, sal_Int32& nSign,
sal_Int32& nPar, sal_Int32& nNum,
sal_Int32& nBlank, sal_Int32& nSym ) const;
- void getDateOrdersImpl();
+ void loadDateOrders();
DateOrder scanDateOrderImpl( const OUString& rCode ) const;
- void getDefaultCalendarImpl();
- void getSecondaryCalendarImpl();
-
void ImplAddFormatNum( rtl::OUStringBuffer& rBuf,
sal_Int64 nNumber, sal_uInt16 nDecimals,
bool bUseThousandSep, bool bTrailingZeros ) const;
- void getDigitGroupingImpl();
+ void loadDigitGrouping();
public:
- LocaleDataWrapper(
- const css::uno::Reference< css::uno::XComponentContext > & rxContext,
- const LanguageTag& rLanguageTag
- );
- LocaleDataWrapper(
- const LanguageTag& rLanguageTag
- );
- ~LocaleDataWrapper();
+ LocaleDataWrapper(
+ const css::uno::Reference< css::uno::XComponentContext > & rxContext,
+ const LanguageTag& rLanguageTag
+ );
+ /**
+ @param rOverrideDateAcceptancePatterns Override locale's date acceptance patterns.
+ An empty sequence resets the patterns to the locale's pattern sequence.
+ */
+ LocaleDataWrapper(
+ const LanguageTag& rLanguageTag,
+ const std::vector<OUString> & rOverrideDateAcceptancePatterns = {}
+ );
+ ~LocaleDataWrapper();
/** Get the service factory, meant to be able to create a CalendarWrapper
from a LocaleDataWrapper. Note that the service factory may be
@@ -139,9 +132,6 @@ public:
css::uno::XComponentContext > & getComponentContext()
const { return m_xContext; }
- /// set a new Locale to request
- void setLanguageTag( const LanguageTag& rLanguageTag );
-
/// get current requested Locale
const LanguageTag& getLanguageTag() const;
@@ -163,10 +153,6 @@ public:
css::uno::Sequence< css::lang::Locale > getAllInstalledLocaleNames() const;
css::uno::Sequence< OUString > getDateAcceptancePatterns() const;
- /** Override locale's date acceptance patterns.
- An empty sequence resets the patterns to the locale's pattern sequence.
- */
- void setDateAcceptancePatterns( const css::uno::Sequence< OUString > & rPatterns );
/// same as the wrapper implementation but static
static css::uno::Sequence< css::lang::Locale > getInstalledLocaleNames();