summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2012-11-27 14:39:05 +0100
committerEike Rathke <erack@redhat.com>2012-11-27 14:41:39 +0100
commitd5b7bcbd263162b31780b53070f90fe8b3366786 (patch)
tree4faced78c7f3ff944dec19859166c1ff7c8d0b72 /sw/inc
parentcb5df8a899a2f6795f857c4d300b6a3cf8977d20 (diff)
avoid unnecessary LanguageTag conversions
Change-Id: Ic85bfad73814e9d2a28efc368526f3c1b5a84ad1
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/breakit.hxx39
-rw-r--r--sw/inc/swtypes.hxx3
2 files changed, 36 insertions, 6 deletions
diff --git a/sw/inc/breakit.hxx b/sw/inc/breakit.hxx
index 1ce59f76b4b8..44b855591643 100644
--- a/sw/inc/breakit.hxx
+++ b/sw/inc/breakit.hxx
@@ -35,7 +35,7 @@
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <com/sun/star/i18n/XScriptTypeDetector.hpp>
#include <com/sun/star/i18n/ForbiddenCharacters.hpp>
-#include <i18npool/lang.h>
+#include <i18npool/languagetag.hxx>
#include <swdllapi.h>
/*************************************************************************
@@ -48,13 +48,13 @@ class SW_DLLPUBLIC SwBreakIt : private ::boost::noncopyable
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
mutable com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xBreak;
- com::sun::star::lang::Locale * m_pLocale;
+ LanguageTag * m_pLanguageTag; ///< language tag of the current locale
com::sun::star::i18n::ForbiddenCharacters * m_pForbidden;
- LanguageType aLast; ///< language of the current locale
LanguageType aForbiddenLang; ///< language of the current forbiddenChar struct
void _GetLocale( const LanguageType aLang );
+ void _GetLocale( const LanguageTag& rLanguageTag );
void _GetForbidden( const LanguageType aLang );
void createBreakIterator() const;
@@ -81,9 +81,38 @@ public:
const com::sun::star::lang::Locale& GetLocale( const LanguageType aLang )
{
- if( !m_pLocale || aLast != aLang )
+ if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != aLang )
_GetLocale( aLang );
- return *m_pLocale;
+ return m_pLanguageTag->getLocale();
+ }
+
+ const com::sun::star::lang::Locale& GetLocale( const LanguageTag& rLanguageTag )
+ {
+ // Use LanguageType comparison instead of LanguageTag::operator!=()
+ // because here the LanguageTag is already a known LanguageType value
+ // assigned, so LanguageTag does not need to convert to BCP47 for
+ // comparison.
+ if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != rLanguageTag.getLanguageType() )
+ _GetLocale( rLanguageTag );
+ return m_pLanguageTag->getLocale();
+ }
+
+ const LanguageTag& GetLanguageTag( const LanguageType aLang )
+ {
+ if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != aLang )
+ _GetLocale( aLang );
+ return *m_pLanguageTag;
+ }
+
+ const LanguageTag& GetLanguageTag( const LanguageTag& rLanguageTag )
+ {
+ // Use LanguageType comparison instead of LanguageTag::operator!=()
+ // because here the LanguageTag is already a known LanguageType value
+ // assigned, so LanguageTag does not need to convert to BCP47 for
+ // comparison.
+ if( !m_pLanguageTag || m_pLanguageTag->getLanguageType() != rLanguageTag.getLanguageType() )
+ _GetLocale( rLanguageTag );
+ return *m_pLanguageTag;
}
const com::sun::star::i18n::ForbiddenCharacters& GetForbidden( const LanguageType aLang )
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index 465901240b31..34bb2572fa65 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -34,7 +34,7 @@
#include <limits.h> //For LONG_MAX.
#include <com/sun/star/uno/Reference.h>
#include "swdllapi.h"
-#include <i18npool/lang.h>
+#include <i18npool/languagetag.hxx>
namespace com { namespace sun { namespace star {
namespace linguistic2{
@@ -245,6 +245,7 @@ namespace nsSetAttrMode
// Returns the APP - CharClass instance - used for all ToUpper/ToLower/...
SW_DLLPUBLIC CharClass& GetAppCharClass();
SW_DLLPUBLIC LanguageType GetAppLanguage();
+SW_DLLPUBLIC const LanguageTag& GetAppLanguageTag();
#if 0