Font and ImplLayoutArgs with LanguageTag
Avoid the gazillion temporary conversions / Impl searches. Change-Id: I5232589f1e31d1cbb6becc198b12daabf1038f31
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include <sal/types.h>
|
||||
#include <vcl/dllapi.h>
|
||||
#include <tools/string.hxx>
|
||||
#include <i18nlangtag/lang.h>
|
||||
#include <i18nlangtag/languagetag.hxx>
|
||||
#include <tools/color.hxx>
|
||||
#include <vcl/vclenum.hxx>
|
||||
#include <vcl/fntstyle.hxx>
|
||||
@@ -79,6 +79,11 @@ public:
|
||||
FontFamily GetFamily() const;
|
||||
void SetCharSet( rtl_TextEncoding );
|
||||
rtl_TextEncoding GetCharSet() const;
|
||||
// Prefer LanguageTag over LanguageType
|
||||
void SetLanguageTag( const LanguageTag & );
|
||||
const LanguageTag& GetLanguageTag() const;
|
||||
void SetCJKContextLanguageTag( const LanguageTag& );
|
||||
const LanguageTag& GetCJKContextLanguageTag() const;
|
||||
void SetLanguage( LanguageType );
|
||||
LanguageType GetLanguage() const;
|
||||
void SetCJKContextLanguage( LanguageType );
|
||||
|
@@ -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();
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <tools/gen.hxx>
|
||||
#include <tools/string.hxx>
|
||||
#include <i18nlangtag/lang.h>
|
||||
#include <i18nlangtag/languagetag.hxx>
|
||||
#include <tools/color.hxx>
|
||||
#include <vcl/dllapi.h>
|
||||
#include <vcl/vclenum.hxx>
|
||||
@@ -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;
|
||||
|
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <tools/gen.hxx>
|
||||
#include <basegfx/polygon/b2dpolypolygon.hxx>
|
||||
#include <i18nlangtag/languagetag.hxx>
|
||||
|
||||
#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; }
|
||||
|
@@ -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; }
|
||||
|
||||
LanguageType Font::GetCJKContextLanguage() const { return mpImplFont->meCJKLanguage; }
|
||||
const LanguageTag& Font::GetCJKContextLanguageTag() const { return mpImplFont->maCJKLanguageTag; }
|
||||
|
||||
LanguageType Font::GetLanguage() const { return mpImplFont->maLanguageTag.getLanguageType( false); }
|
||||
|
||||
LanguageType Font::GetCJKContextLanguage() const { return mpImplFont->maCJKLanguageTag.getLanguageType( false); }
|
||||
|
||||
short Font::GetOrientation() const { return mpImplFont->mnOrientation; }
|
||||
|
||||
|
@@ -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 );
|
||||
|
@@ -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 ),
|
||||
|
Reference in New Issue
Block a user