From f51e79aaa8cef49421c875c2a876d8570e8b064f Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Fri, 20 Sep 2013 20:15:05 +0200 Subject: Font and ImplLayoutArgs with LanguageTag Avoid the gazillion temporary conversions / Impl searches. Change-Id: I5232589f1e31d1cbb6becc198b12daabf1038f31 --- vcl/generic/glyphs/gcach_layout.cxx | 6 ++-- vcl/inc/impfont.hxx | 6 ++-- vcl/inc/sallayout.hxx | 5 +-- vcl/source/gdi/font.cxx | 70 +++++++++++++++++++++++++------------ vcl/source/gdi/outdev3.cxx | 2 +- vcl/source/gdi/sallayout.cxx | 4 +-- 6 files changed, 59 insertions(+), 34 deletions(-) (limited to 'vcl') diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx index fd3ca3607223..01d0904e3d97 100644 --- a/vcl/generic/glyphs/gcach_layout.cxx +++ b/vcl/generic/glyphs/gcach_layout.cxx @@ -102,8 +102,7 @@ void ServerFontLayout::setNeedFallback(ImplLayoutArgs& rArgs, sal_Int32 nCharPos "com.sun.star.i18n.BreakIterator"), uno::UNO_QUERY); } - LanguageTag aLangTag(rArgs.meLanguage); - lang::Locale aLocale(aLangTag.getLocale()); + lang::Locale aLocale(rArgs.maLanguageTag.getLocale()); //if position nCharPos is missing in the font, grab the entire grapheme and //mark all glyphs as missing so the whole thing is rendered with the same @@ -417,8 +416,7 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) meScriptCode = eScriptCode; - LanguageTag aLangTag(rArgs.meLanguage); - OString sLanguage = OUStringToOString(aLangTag.getLanguage(), RTL_TEXTENCODING_UTF8); + OString sLanguage = OUStringToOString(rArgs.maLanguageTag.getLanguage(), RTL_TEXTENCODING_UTF8); if (pHbUnicodeFuncs == NULL) pHbUnicodeFuncs = getUnicodeFuncs(); diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx index 4270e9d31d6c..e849fa5a07fb 100644 --- a/vcl/inc/impfont.hxx +++ b/vcl/inc/impfont.hxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -60,8 +60,8 @@ private: Color maColor; // compatibility, now on output device Color maFillColor; // compatibility, now on output device rtl_TextEncoding meCharSet; - LanguageType meLanguage; - LanguageType meCJKLanguage; + LanguageTag maLanguageTag; + LanguageTag maCJKLanguageTag; FontFamily meFamily; FontPitch mePitch; TextAlign meAlign; diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 491db056cee6..3bfab2ce06e4 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -24,6 +24,7 @@ #include #include +#include #ifndef _TOOLS_LANG_HXX typedef unsigned short LanguageType; @@ -83,7 +84,7 @@ class ImplLayoutArgs { public: // string related inputs - LanguageType meLanguage; + LanguageTag maLanguageTag; int mnFlags; int mnLength; int mnMinCharPos; @@ -101,7 +102,7 @@ public: public: ImplLayoutArgs( const sal_Unicode* pStr, int nLength, - int nMinCharPos, int nEndCharPos, int nFlags, LanguageType eLanguage ); + int nMinCharPos, int nEndCharPos, int nFlags, const LanguageTag& rLanguageTag ); void SetLayoutWidth( long nWidth ) { mnLayoutWidth = nWidth; } void SetDXArray( const sal_Int32* pDXArray ) { mpDXArray = pDXArray; } diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx index 5bbab2a32c42..f22c199f28b6 100644 --- a/vcl/source/gdi/font.cxx +++ b/vcl/source/gdi/font.cxx @@ -41,12 +41,12 @@ DBG_NAME( Font ) Impl_Font::Impl_Font() : maColor( COL_TRANSPARENT ), - maFillColor( COL_TRANSPARENT ) + maFillColor( COL_TRANSPARENT ), + maLanguageTag( LANGUAGE_DONTKNOW ), + maCJKLanguageTag( LANGUAGE_DONTKNOW ) { mnRefCount = 1; meCharSet = RTL_TEXTENCODING_DONTKNOW; - meLanguage = LANGUAGE_DONTKNOW; - meCJKLanguage = LANGUAGE_DONTKNOW; meFamily = FAMILY_DONTKNOW; mePitch = PITCH_DONTKNOW; meAlign = ALIGN_TOP; @@ -73,12 +73,12 @@ Impl_Font::Impl_Font( const Impl_Font& rImplFont ) maStyleName( rImplFont.maStyleName ), maSize( rImplFont.maSize ), maColor( rImplFont.maColor ), - maFillColor( rImplFont.maFillColor ) + maFillColor( rImplFont.maFillColor ), + maLanguageTag( rImplFont.maLanguageTag ), + maCJKLanguageTag( rImplFont.maCJKLanguageTag ) { mnRefCount = 1; meCharSet = rImplFont.meCharSet; - meLanguage = rImplFont.meLanguage; - meCJKLanguage = rImplFont.meCJKLanguage; meFamily = rImplFont.meFamily; mePitch = rImplFont.mePitch; meAlign = rImplFont.meAlign; @@ -109,10 +109,10 @@ bool Impl_Font::operator==( const Impl_Font& rOther ) const || (mePitch != rOther.mePitch) ) return false; - if( (meCharSet != rOther.meCharSet) - || (meLanguage != rOther.meLanguage) - || (meCJKLanguage != rOther.meCJKLanguage) - || (meAlign != rOther.meAlign) ) + if( (meCharSet != rOther.meCharSet) + || (maLanguageTag != rOther.maLanguageTag) + || (maCJKLanguageTag != rOther.maCJKLanguageTag) + || (meAlign != rOther.meAlign) ) return false; if( (maSize != rOther.maSize) @@ -384,14 +384,36 @@ void Font::SetCharSet( rtl_TextEncoding eCharSet ) } } +void Font::SetLanguageTag( const LanguageTag& rLanguageTag ) +{ + DBG_CHKTHIS( Font, NULL ); + + if( mpImplFont->maLanguageTag != rLanguageTag ) + { + MakeUnique(); + mpImplFont->maLanguageTag = rLanguageTag; + } +} + +void Font::SetCJKContextLanguageTag( const LanguageTag& rLanguageTag ) +{ + DBG_CHKTHIS( Font, NULL ); + + if( mpImplFont->maCJKLanguageTag != rLanguageTag ) + { + MakeUnique(); + mpImplFont->maCJKLanguageTag = rLanguageTag; + } +} + void Font::SetLanguage( LanguageType eLanguage ) { DBG_CHKTHIS( Font, NULL ); - if( mpImplFont->meLanguage != eLanguage ) + if( mpImplFont->maLanguageTag.getLanguageType( false) != eLanguage ) { MakeUnique(); - mpImplFont->meLanguage = eLanguage; + mpImplFont->maLanguageTag.reset( eLanguage); } } @@ -399,10 +421,10 @@ void Font::SetCJKContextLanguage( LanguageType eLanguage ) { DBG_CHKTHIS( Font, NULL ); - if( mpImplFont->meCJKLanguage != eLanguage ) + if( mpImplFont->maCJKLanguageTag.getLanguageType( false) != eLanguage ) { MakeUnique(); - mpImplFont->meCJKLanguage = eLanguage; + mpImplFont->maCJKLanguageTag.reset( eLanguage); } } @@ -623,8 +645,8 @@ void Font::Merge( const Font& rFont ) SetName( rFont.GetName() ); SetStyleName( rFont.GetStyleName() ); SetCharSet( GetCharSet() ); - SetLanguage( rFont.GetLanguage() ); - SetCJKContextLanguage( rFont.GetCJKContextLanguage() ); + SetLanguageTag( rFont.GetLanguageTag() ); + SetCJKContextLanguageTag( rFont.GetCJKContextLanguageTag() ); // don't use access methods here, might lead to AskConfig(), if DONTKNOW SetFamily( rFont.mpImplFont->meFamily ); SetPitch( rFont.mpImplFont->mePitch ); @@ -697,7 +719,7 @@ SvStream& operator>>( SvStream& rIStm, Impl_Font& rImpl_Font ) rIStm >> nTmp16; rImpl_Font.meUnderline = (FontUnderline) nTmp16; rIStm >> nTmp16; rImpl_Font.meStrikeout = (FontStrikeout) nTmp16; rIStm >> nTmp16; rImpl_Font.meItalic = (FontItalic) nTmp16; - rIStm >> nTmp16; rImpl_Font.meLanguage = (LanguageType) nTmp16; + rIStm >> nTmp16; rImpl_Font.maLanguageTag.reset( (LanguageType) nTmp16); rIStm >> nTmp16; rImpl_Font.meWidthType = (FontWidth) nTmp16; rIStm >> rImpl_Font.mnOrientation; @@ -710,7 +732,7 @@ SvStream& operator>>( SvStream& rIStm, Impl_Font& rImpl_Font ) if( aCompat.GetVersion() >= 2 ) { rIStm >> nTmp8; rImpl_Font.meRelief = (FontRelief)nTmp8; - rIStm >> nTmp16; rImpl_Font.meCJKLanguage = (LanguageType)nTmp16; + rIStm >> nTmp16; rImpl_Font.maCJKLanguageTag.reset( (LanguageType)nTmp16); rIStm >> bTmp; rImpl_Font.mbVertical = bTmp; rIStm >> nTmp16; rImpl_Font.meEmphasisMark = (FontEmphasisMark)nTmp16; } @@ -738,7 +760,7 @@ SvStream& operator<<( SvStream& rOStm, const Impl_Font& rImpl_Font ) rOStm << (sal_uInt16) rImpl_Font.meUnderline; rOStm << (sal_uInt16) rImpl_Font.meStrikeout; rOStm << (sal_uInt16) rImpl_Font.meItalic; - rOStm << (sal_uInt16) rImpl_Font.meLanguage; + rOStm << (sal_uInt16) rImpl_Font.maLanguageTag.getLanguageType( false); rOStm << (sal_uInt16) rImpl_Font.meWidthType; rOStm << rImpl_Font.mnOrientation; @@ -750,7 +772,7 @@ SvStream& operator<<( SvStream& rOStm, const Impl_Font& rImpl_Font ) // new in version 2 rOStm << (sal_uInt8) rImpl_Font.meRelief; - rOStm << (sal_uInt16) rImpl_Font.meCJKLanguage; + rOStm << (sal_uInt16) rImpl_Font.maCJKLanguageTag.getLanguageType( false); rOStm << (sal_Bool) rImpl_Font.mbVertical; rOStm << (sal_uInt16) rImpl_Font.meEmphasisMark; @@ -1004,9 +1026,13 @@ long Font::GetWidth() const { return mpImplFont->maSize.Width(); } rtl_TextEncoding Font::GetCharSet() const { return mpImplFont->meCharSet; } -LanguageType Font::GetLanguage() const { return mpImplFont->meLanguage; } +const LanguageTag& Font::GetLanguageTag() const { return mpImplFont->maLanguageTag; } + +const LanguageTag& Font::GetCJKContextLanguageTag() const { return mpImplFont->maCJKLanguageTag; } + +LanguageType Font::GetLanguage() const { return mpImplFont->maLanguageTag.getLanguageType( false); } -LanguageType Font::GetCJKContextLanguage() const { return mpImplFont->meCJKLanguage; } +LanguageType Font::GetCJKContextLanguage() const { return mpImplFont->maCJKLanguageTag.getLanguageType( false); } short Font::GetOrientation() const { return mpImplFont->mnOrientation; } diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 2a0a3b6bfed7..2a0eb1113fb9 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -5744,7 +5744,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, nLayoutFlags |= SAL_LAYOUT_RIGHT_ALIGN; // set layout options - ImplLayoutArgs aLayoutArgs( rStr.getStr(), rStr.getLength(), nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguage() ); + ImplLayoutArgs aLayoutArgs( rStr.getStr(), rStr.getLength(), nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguageTag() ); int nOrientation = mpFontEntry ? mpFontEntry->mnOrientation : 0; aLayoutArgs.SetOrientation( nOrientation ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 4abdc264fdd3..fe01037931b8 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -506,9 +506,9 @@ bool ImplLayoutRuns::GetRun( int* nMinRunPos, int* nEndRunPos, bool* bRightToLef // ======================================================================= ImplLayoutArgs::ImplLayoutArgs( const sal_Unicode* pStr, int nLen, - int nMinCharPos, int nEndCharPos, int nFlags, LanguageType eLanguage ) + int nMinCharPos, int nEndCharPos, int nFlags, const LanguageTag& rLanguageTag ) : - meLanguage( eLanguage ), + maLanguageTag( rLanguageTag ), mnFlags( nFlags ), mnLength( nLen ), mnMinCharPos( nMinCharPos ), -- cgit