diff options
author | Eike Rathke <erack@redhat.com> | 2017-12-13 21:56:36 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-12-14 11:10:31 +0100 |
commit | 52274384a3de2d0a0c9023c62ed9159df965fbd0 (patch) | |
tree | d9114561fb1e31ed609622512962ec9810aa1892 /svl | |
parent | 9b26a2ea8e7968d344ae8da12b314464e282c009 (diff) |
Move GetKeywords() and related from SvNumberformat to SvNumberFormatter
... as especially the keywords are controlled by the current state (locale) of
the ImpSvNumberformatScan instance and *not* a property of SvNumberformat. Add
a clarifying descriptive comment as well, and outline it's only for the unit
tests anyway..
Change-Id: I732918026bf9ffc25db11033d5f10bc2f51e3505
Reviewed-on: https://gerrit.libreoffice.org/46426
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/svl.cxx | 15 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 26 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 20 | ||||
-rw-r--r-- | svl/source/numbers/zforscan.hxx | 4 |
4 files changed, 35 insertions, 30 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index defc53df056d..be9310db0af9 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1393,9 +1393,8 @@ void Test::testUserDefinedNumberFormats() void Test::testNfEnglishKeywordsIntegrity() { SvNumberFormatter aFormatter(m_xContext, LANGUAGE_ENGLISH_US); - const SvNumberformat* pNumberFormat = aFormatter.GetEntry(0); - const NfKeywordTable& sKeywords = pNumberFormat->GetKeywords(); - const ::std::vector<OUString> & sEnglishKeywords = pNumberFormat->GetEnglishKeywords(); + const ::std::vector<OUString> & sEnglishKeywords = aFormatter.GetEnglishKeywords(); + const NfKeywordTable& sKeywords = aFormatter.GetKeywords(0); CPPUNIT_ASSERT_EQUAL( size_t(NF_KEYWORD_ENTRIES_COUNT), sEnglishKeywords.size() ); for (size_t i = 0; i < size_t(NF_KEYWORD_ENTRIES_COUNT); ++i) { @@ -1459,9 +1458,8 @@ void Test::testNfEnglishKeywordsIntegrity() void Test::testStandardColorIntegrity() { SvNumberFormatter aFormatter(m_xContext, LANGUAGE_ENGLISH_US); - const SvNumberformat* pNumberFormat = aFormatter.GetEntry(0); - const ::std::vector<Color> & aStandardColors = pNumberFormat->GetStandardColor(); - const size_t nMaxDefaultColors = pNumberFormat->GetMaxDefaultColors(); + const ::std::vector<Color> & aStandardColors = aFormatter.GetStandardColors(); + const size_t nMaxDefaultColors = aFormatter.GetMaxDefaultColors(); CPPUNIT_ASSERT_EQUAL( nMaxDefaultColors, size_t(NF_KEY_LASTCOLOR) - size_t(NF_KEY_FIRSTCOLOR) + 1 ); CPPUNIT_ASSERT_EQUAL( nMaxDefaultColors, aStandardColors.size() ); // Colors must follow same order as in sEnglishKeyword @@ -1480,9 +1478,8 @@ void Test::testStandardColorIntegrity() void Test::testColorNamesConversion() { SvNumberFormatter aFormatter(m_xContext, LANGUAGE_GERMAN); - const SvNumberformat* pNumberFormat = aFormatter.GetEntry(0); - const ::std::vector<OUString> & rEnglishKeywords = pNumberFormat->GetEnglishKeywords(); - const NfKeywordTable& rKeywords = pNumberFormat->GetKeywords(); + const ::std::vector<OUString> & rEnglishKeywords = aFormatter.GetEnglishKeywords(); + const NfKeywordTable& rKeywords = aFormatter.GetKeywords(0); // Holding a reference to the NfKeywordTable doesn't help if we switch // locales internally, so copy the relevant parts in advance. diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index ec99b5caaefc..89c938a9e17a 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -4617,4 +4617,30 @@ sal_uInt16 NfCurrencyEntry::GetEffectiveNegativeFormat( sal_uInt16 nIntlFormat, return nIntlFormat; } +const NfKeywordTable & SvNumberFormatter::GetKeywords( sal_uInt32 nKey ) +{ + osl::MutexGuard aGuard( GetInstanceMutex() ); + const SvNumberformat* pFormat = GetFormatEntry( nKey); + if (pFormat) + ChangeIntl( pFormat->GetLanguage()); + else + ChangeIntl( IniLnge); + return pFormatScanner->GetKeywords(); +} + +const std::vector<OUString> & SvNumberFormatter::GetEnglishKeywords() const +{ + return ImpSvNumberformatScan::GetEnglishKeywords(); +} + +const std::vector<Color> & SvNumberFormatter::GetStandardColors() const +{ + return ImpSvNumberformatScan::GetStandardColors(); +} + +size_t SvNumberFormatter::GetMaxDefaultColors() const +{ + return ImpSvNumberformatScan::GetMaxDefaultColors(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index c4c26e19df3b..d9368ea7ea35 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -5527,24 +5527,4 @@ const SvNumberFormatter& SvNumberformat::GetFormatter() const return *rScan.GetNumberformatter(); } -const NfKeywordTable & SvNumberformat::GetKeywords() const -{ - return rScan.GetKeywords(); -} - -const ::std::vector<OUString> & SvNumberformat::GetEnglishKeywords() const -{ - return ImpSvNumberformatScan::GetEnglishKeywords(); -} - -const ::std::vector<Color> & SvNumberformat::GetStandardColor() const -{ - return ImpSvNumberformatScan::GetStandardColor(); -} - -size_t SvNumberformat::GetMaxDefaultColors() const -{ - return ImpSvNumberformatScan::GetMaxDefaultColors(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/source/numbers/zforscan.hxx b/svl/source/numbers/zforscan.hxx index 2ed23617b235..6282481c669a 100644 --- a/svl/source/numbers/zforscan.hxx +++ b/svl/source/numbers/zforscan.hxx @@ -73,10 +73,12 @@ public: } return sKeyword; } + static const ::std::vector<OUString> & GetEnglishKeywords() { return sEnglishKeyword; } + // Keywords used in output like true and false const OUString& GetSpecialKeyword( NfKeywordIndex eIdx ) const { @@ -91,7 +93,7 @@ public: const OUString& GetRedString() const { return GetKeywords()[NF_KEY_RED]; } const OUString& GetBooleanString() const { return GetKeywords()[NF_KEY_BOOLEAN]; } static const OUString& GetErrorString() { return sErrStr; } - static const ::std::vector<Color> & GetStandardColor() + static const ::std::vector<Color> & GetStandardColors() { return StandardColor; } |