summaryrefslogtreecommitdiff
path: root/sw
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
parentcb5df8a899a2f6795f857c4d300b6a3cf8977d20 (diff)
avoid unnecessary LanguageTag conversions
Change-Id: Ic85bfad73814e9d2a28efc368526f3c1b5a84ad1
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/breakit.hxx39
-rw-r--r--sw/inc/swtypes.hxx3
-rw-r--r--sw/source/core/bastyp/breakit.cxx22
-rw-r--r--sw/source/core/bastyp/init.cxx13
-rw-r--r--sw/source/core/doc/docsort.cxx2
-rw-r--r--sw/source/core/doc/tblafmt.cxx8
-rw-r--r--sw/source/core/edit/acorrect.cxx4
-rw-r--r--sw/source/core/fields/authfld.cxx2
-rw-r--r--sw/source/core/text/txtfrm.cxx2
-rw-r--r--sw/source/core/tox/tox.cxx2
-rw-r--r--sw/source/core/unocore/unosrch.cxx2
-rw-r--r--sw/source/filter/html/wrthtml.cxx3
-rw-r--r--sw/source/ui/dbui/dbinsdlg.cxx2
-rw-r--r--sw/source/ui/index/swuiidxmrk.cxx2
-rw-r--r--sw/source/ui/misc/outline.cxx2
-rw-r--r--sw/source/ui/shells/textsh1.cxx2
-rw-r--r--sw/source/ui/smartmenu/stmenu.cxx4
-rw-r--r--sw/source/ui/uiview/srcview.cxx3
-rw-r--r--sw/source/ui/uiview/viewsrch.cxx2
-rw-r--r--sw/source/ui/utlui/attrdesc.cxx2
20 files changed, 80 insertions, 41 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
diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx
index f56cd5d84f17..275385ccc9e2 100644
--- a/sw/source/core/bastyp/breakit.cxx
+++ b/sw/source/core/bastyp/breakit.cxx
@@ -60,9 +60,8 @@ SwBreakIt * SwBreakIt::Get()
SwBreakIt::SwBreakIt( const uno::Reference<uno::XComponentContext> & rxContext )
: m_xContext( rxContext ),
- m_pLocale( NULL ),
+ m_pLanguageTag( NULL ),
m_pForbidden( NULL ),
- aLast( LANGUAGE_DONTKNOW ),
aForbiddenLang( LANGUAGE_DONTKNOW )
{
OSL_ENSURE( m_xContext.is(), "SwBreakIt: no MultiServiceFactory" );
@@ -70,7 +69,7 @@ SwBreakIt::SwBreakIt( const uno::Reference<uno::XComponentContext> & rxContext )
SwBreakIt::~SwBreakIt()
{
- delete m_pLocale;
+ delete m_pLanguageTag;
delete m_pForbidden;
}
@@ -82,14 +81,23 @@ void SwBreakIt::createBreakIterator() const
void SwBreakIt::_GetLocale( const LanguageType aLang )
{
- aLast = aLang;
- delete m_pLocale;
- m_pLocale = new lang::Locale( LanguageTag( aLast ).getLocale() );
+ if (m_pLanguageTag)
+ m_pLanguageTag->reset( aLang );
+ else
+ m_pLanguageTag = new LanguageTag( aLang );
+}
+
+void SwBreakIt::_GetLocale( const LanguageTag& rLanguageTag )
+{
+ if (m_pLanguageTag)
+ *m_pLanguageTag = rLanguageTag;
+ else
+ m_pLanguageTag = new LanguageTag( rLanguageTag );
}
void SwBreakIt::_GetForbidden( const LanguageType aLang )
{
- LocaleDataWrapper aWrap( m_xContext, LanguageTag( GetLocale( aLang )) );
+ LocaleDataWrapper aWrap( m_xContext, GetLanguageTag( aLang ) );
aForbiddenLang = aLang;
delete m_pForbidden;
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index dcbf6a7ff135..cbf22b974e86 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -810,7 +810,7 @@ CharClass& GetAppCharClass()
{
pAppCharClass = new CharClass(
::comphelper::getProcessComponentContext(),
- LanguageTag( SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() )));
+ SwBreakIt::Get()->GetLanguageTag( GetAppLanguageTag() ));
}
return *pAppCharClass;
}
@@ -827,12 +827,16 @@ LanguageType GetAppLanguage()
return Application::GetSettings().GetLanguageTag().getLanguageType();
}
+const LanguageTag& GetAppLanguageTag()
+{
+ return Application::GetSettings().GetLanguageTag();
+}
+
CollatorWrapper& GetAppCollator()
{
if( !pCollator )
{
- const lang::Locale& rLcl = pBreakIt->GetLocale(
- (LanguageType)GetAppLanguage() );
+ const lang::Locale& rLcl = pBreakIt->GetLocale( GetAppLanguage() );
uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
pCollator = new CollatorWrapper( xMSF );
@@ -844,8 +848,7 @@ CollatorWrapper& GetAppCaseCollator()
{
if( !pCaseCollator )
{
- const lang::Locale& rLcl = pBreakIt->GetLocale(
- (LanguageType)GetAppLanguage() );
+ const lang::Locale& rLcl = pBreakIt->GetLocale( GetAppLanguage() );
uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
pCaseCollator = new CollatorWrapper( xMSF );
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index dd4bf7952725..2753b5366277 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -90,7 +90,7 @@ void SwSortElement::Init( SwDoc* pD, const SwSortOptions& rOpt,
{
case LANGUAGE_NONE:
case LANGUAGE_DONTKNOW:
- nLang = (LanguageType)GetAppLanguage();
+ nLang = GetAppLanguage();
break;
}
pLocale = new lang::Locale( LanguageTag( nLang ).getLocale() );
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index a861adc8a9a4..103bf9c5edaa 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -308,7 +308,7 @@ SwBoxAutoFmt::SwBoxAutoFmt()
// aBLTR( RES_... ),
aRotateMode( SVX_ROTATE_MODE_STANDARD, 0 )
{
- eSysLanguage = eNumFmtLanguage = static_cast<LanguageType>(::GetAppLanguage());
+ eSysLanguage = eNumFmtLanguage = ::GetAppLanguage();
aBox.SetDistance( 55 );
}
@@ -492,7 +492,7 @@ sal_Bool SwBoxAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, s
eSysLanguage = (LanguageType) eSys;
eNumFmtLanguage = (LanguageType) eLge;
if ( eSysLanguage == LANGUAGE_SYSTEM ) // from old versions (Calc)
- eSysLanguage = static_cast<LanguageType>(::GetAppLanguage());
+ eSysLanguage = ::GetAppLanguage();
}
aStacked.SetValue( aOrientation.IsStacked() );
@@ -759,12 +759,12 @@ void SwTableAutoFmt::UpdateFromSet( sal_uInt8 nPos,
0 != (pNumFormat = pNFmtr->GetEntry( pNumFmtItem->GetValue() )) )
pFmt->SetValueFormat( ((SvNumberformat*)pNumFormat)->GetFormatstring(),
pNumFormat->GetLanguage(),
- static_cast<LanguageType>(::GetAppLanguage()));
+ ::GetAppLanguage());
else
{
// default
pFmt->SetValueFormat( aEmptyStr, LANGUAGE_SYSTEM,
- static_cast<LanguageType>(::GetAppLanguage() ));
+ ::GetAppLanguage() );
}
}
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 8a985ce004a2..d252dbda6c7d 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -329,7 +329,7 @@ sal_Bool SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPo
LanguageType eLang = GetLanguage(nEndPos, sal_False);
if(LANGUAGE_SYSTEM == eLang)
- eLang = (LanguageType)GetAppLanguage();
+ eLang = GetAppLanguage();
//JP 22.04.99: Bug 63883 - Sonderbehandlung fuer Punkte.
bool bLastCharIsPoint = nEndPos < pTxtNd->GetTxt().Len() &&
@@ -439,7 +439,7 @@ LanguageType SwAutoCorrDoc::GetLanguage( xub_StrLen nPos, sal_Bool bPrevPara ) c
if( pNd )
eRet = pNd->GetLang( nPos, 0 );
if(LANGUAGE_SYSTEM == eRet)
- eRet = (LanguageType)GetAppLanguage();
+ eRet = GetAppLanguage();
return eRet;
}
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx
index 0e31c09b561c..b65390f411ca 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -79,7 +79,7 @@ SwAuthorityFieldType::SwAuthorityFieldType(SwDoc* pDoc)
m_cSuffix(']'),
m_bIsSequence(sal_False),
m_bSortByDocument(sal_True),
- m_eLanguage((LanguageType)::GetAppLanguage())
+ m_eLanguage(::GetAppLanguage())
{
}
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 27b034b1bf8b..de795f9674c3 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -329,7 +329,7 @@ SwDigitModeModifier::SwDigitModeModifier( const OutputDevice& rOutp, LanguageTyp
else if ( SvtCTLOptions::NUMERALS_ARABIC == nTextNumerals )
eLang = LANGUAGE_ENGLISH;
else if ( SvtCTLOptions::NUMERALS_SYSTEM == nTextNumerals )
- eLang = (LanguageType)::GetAppLanguage();
+ eLang = ::GetAppLanguage();
((OutputDevice&)rOut).SetDigitLanguage( eLang );
}
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 54463665e947..ff711ab7989f 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -517,7 +517,7 @@ SwTOXBase::SwTOXBase(const SwTOXType* pTyp, const SwForm& rForm,
: SwClient((SwModify*)pTyp),
aForm(rForm),
aTitle(rTitle),
- eLanguage((LanguageType)::GetAppLanguage()),
+ eLanguage(::GetAppLanguage()),
nCreateType(nCreaType),
nOLEOptions(0),
eCaptionDisplay(CAPTION_COMPLETE),
diff --git a/sw/source/core/unocore/unosrch.cxx b/sw/source/core/unocore/unosrch.cxx
index a738f4902b6a..d8971536ce14 100644
--- a/sw/source/core/unocore/unosrch.cxx
+++ b/sw/source/core/unocore/unosrch.cxx
@@ -730,7 +730,7 @@ void SwXTextSearch::FillSearchOptions( util::SearchOptions& rSearchOpt ) const
else
rSearchOpt.algorithmType = util::SearchAlgorithms_ABSOLUTE;
- rSearchOpt.Locale = LanguageTag( GetAppLanguage() ).getLocale();
+ rSearchOpt.Locale = GetAppLanguageTag().getLocale();
rSearchOpt.searchString = sSearchText;
rSearchOpt.replaceString = sReplaceText;
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 67c6a568e5a7..3fb52dc4d496 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -266,8 +266,7 @@ sal_uLong SwHTMLWriter::WriteStream()
nHeaderFooterSpace = 0;
nTxtAttrsToIgnore = 0;
nCSS1OutMode = 0;
- sal_uInt16 nScript = SvtLanguageOptions::GetScriptTypeOfLanguage(
- static_cast< LanguageType >( GetAppLanguage() ) );
+ sal_uInt16 nScript = SvtLanguageOptions::GetScriptTypeOfLanguage( GetAppLanguage() );
switch( nScript )
{
case SCRIPTTYPE_ASIAN:
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index e4e6a6d8c4d2..076a8dd9421d 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -1673,7 +1673,7 @@ void SwInsertDBColAutoPilot::Commit()
else
{
pSubValues[4].Value <<= rtl::OUString(sTmp);
- eLang = (LanguageType)GetAppLanguage();
+ eLang = GetAppLanguage();
}
if( eLang != ePrevLang )
diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx
index 22b186108a77..5e08dc6f33f0 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -450,7 +450,7 @@ static void lcl_SelectSameStrings(SwWrtShell& rSh, sal_Bool bWordOnly, sal_Bool
SearchAlgorithms_ABSOLUTE,
( bWordOnly ? SearchFlags::NORM_WORD_ONLY : 0 ),
rSh.GetSelTxt(), OUString(),
- LanguageTag( GetAppLanguage() ).getLocale(),
+ GetAppLanguageTag().getLocale(),
0, 0, 0,
(bCaseSensitive
? 0
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index 222da29e46e1..04e40b267074 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -953,7 +953,7 @@ void NumberingPreview::Paint( const Rectangle& /*rRect*/ )
sal_uInt16 nYStart = 4;
sal_uInt16 nYStep = sal_uInt16((aSize.Height() - 6)/ MAXLEVEL);
aStdFont = OutputDevice::GetDefaultFont(
- DEFAULTFONT_UI_SANS, (LanguageType)GetAppLanguage(),
+ DEFAULTFONT_UI_SANS, GetAppLanguage(),
DEFAULTFONT_FLAGS_ONLYONE, this );
// #101524# OJ
aStdFont.SetColor( SwViewOption::GetFontColor() );
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index e2faab997e8b..1b521cb5f419 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -1605,7 +1605,7 @@ void SwTextShell::GetState( SfxItemSet &rSet )
aActionIndicesSequence );
uno::Reference <frame::XController> xController = GetView().GetController();
- const lang::Locale aLocale( SW_BREAKITER()->GetLocale( (LanguageType)GetAppLanguage() ) );
+ const lang::Locale aLocale( SW_BREAKITER()->GetLocale( GetAppLanguageTag() ) );
const rtl::OUString aApplicationName( rSmartTagMgr.GetApplicationName() );
const rtl::OUString aRangeText = xRange->getString();
diff --git a/sw/source/ui/smartmenu/stmenu.cxx b/sw/source/ui/smartmenu/stmenu.cxx
index 211a107122a5..64d1cce16a6d 100644
--- a/sw/source/ui/smartmenu/stmenu.cxx
+++ b/sw/source/ui/smartmenu/stmenu.cxx
@@ -42,7 +42,7 @@ SwSmartTagPopup::SwSmartTagPopup( SwView* pSwView,
mxTextRange( xTextRange )
{
Reference <frame::XController> xController = mpSwView->GetController();
- const lang::Locale aLocale( SW_BREAKITER()->GetLocale( (LanguageType)GetAppLanguage() ) );
+ const lang::Locale aLocale( SW_BREAKITER()->GetLocale( GetAppLanguageTag() ) );
sal_uInt16 nMenuPos = 0;
sal_uInt16 nSubMenuPos = 0;
@@ -160,7 +160,7 @@ sal_uInt16 SwSmartTagPopup::Execute( const Rectangle& rWordPos, Window* pWin )
maInvokeActions[ nId ].mxSmartTagProperties,
mxTextRange->getString(),
rtl::OUString(),
- SW_BREAKITER()->GetLocale( (LanguageType)GetAppLanguage() ) );
+ SW_BREAKITER()->GetLocale( GetAppLanguageTag() ) );
}
}
diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx
index ff7d51da0cdc..2d077b08a01e 100644
--- a/sw/source/ui/uiview/srcview.cxx
+++ b/sw/source/ui/uiview/srcview.cxx
@@ -585,8 +585,7 @@ sal_uInt16 SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem,
}
util::SearchOptions aSearchOpt( rSearchItem.GetSearchOptions() );
- aSearchOpt.Locale = LanguageTag(
- static_cast< LanguageType >( GetAppLanguage() ) ).getLocale();
+ aSearchOpt.Locale = GetAppLanguageTag().getLocale();
sal_uInt16 nFound;
sal_Bool bAll = sal_False;
diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx
index 37d9757bee8a..6e515d3b6fd3 100644
--- a/sw/source/ui/uiview/viewsrch.cxx
+++ b/sw/source/ui/uiview/viewsrch.cxx
@@ -731,7 +731,7 @@ sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions )
// build SearchOptions to be used
//
SearchOptions aSearchOpt( pSrchItem->GetSearchOptions() );
- aSearchOpt.Locale = LanguageTag( (sal_uInt16)GetAppLanguage() ).getLocale();
+ aSearchOpt.Locale = GetAppLanguageTag().getLocale();
if( !bDoReplace )
aSearchOpt.replaceString = aEmptyStr;
diff --git a/sw/source/ui/utlui/attrdesc.cxx b/sw/source/ui/utlui/attrdesc.cxx
index ef379077073e..71af93043048 100644
--- a/sw/source/ui/utlui/attrdesc.cxx
+++ b/sw/source/ui/utlui/attrdesc.cxx
@@ -83,7 +83,7 @@ void SwAttrSet::GetPresentation(
{
SfxItemIter aIter( *this );
const IntlWrapper rInt( ::comphelper::getProcessServiceFactory(),
- LanguageTag( GetAppLanguage()) );
+ GetAppLanguageTag() );
while( sal_True )
{
aIter.GetCurItem()->GetPresentation( ePres, eCoreMetric,