Re-factoring: Avoid pointless class derivation
No need to hide stuff from ourselves at multiple levels. Rename the CoreText-specific ImplMacTextStyle class to CoreTextStyle and unify it with its sole derived class CTTextStyle. This is all internal to vcl anyway. Change-Id: Ib9e632ccba5c273200d4e3fce79a97db305c6662
This commit is contained in:
parent
f562ec13d0
commit
cb17d9392b
@ -64,8 +64,10 @@ inline double toRadian(int nDegree)
|
||||
return nDegree * (M_PI / 1800.0);
|
||||
}
|
||||
|
||||
CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD )
|
||||
: ImplMacTextStyle( rFSD )
|
||||
CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD )
|
||||
: mpFontData( (ImplMacFontData*)rFSD.mpFontData )
|
||||
, mfFontStretch( 1.0 )
|
||||
, mfFontRotation( 0.0 )
|
||||
, mpStyleDict( NULL )
|
||||
{
|
||||
mpFontData = (CTFontData*)rFSD.mpFontData;
|
||||
@ -125,7 +127,7 @@ CTTextStyle::CTTextStyle( const FontSelectPattern& rFSD )
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
CTTextStyle::~CTTextStyle( void )
|
||||
CoreTextStyle::~CoreTextStyle( void )
|
||||
{
|
||||
if( mpStyleDict )
|
||||
CFRelease( mpStyleDict );
|
||||
@ -133,7 +135,7 @@ CTTextStyle::~CTTextStyle( void )
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void CTTextStyle::GetFontMetric( float fPixelSize, ImplFontMetricData& rMetric ) const
|
||||
void CoreTextStyle::GetFontMetric( float fPixelSize, ImplFontMetricData& rMetric ) const
|
||||
{
|
||||
// get the matching CoreText font handle
|
||||
// TODO: is it worth it to cache the CTFontRef in SetFont() and reuse it here?
|
||||
@ -155,7 +157,7 @@ void CTTextStyle::GetFontMetric( float fPixelSize, ImplFontMetricData& rMetric )
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
bool CTTextStyle::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect ) const
|
||||
bool CoreTextStyle::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect ) const
|
||||
{
|
||||
CGGlyph nCGGlyph = nGlyphId & GF_IDXMASK;
|
||||
// XXX: this is broken if the glyph came from fallback font
|
||||
@ -213,7 +215,7 @@ static void MyCGPathApplierFunc( void* pData, const CGPathElement* pElement )
|
||||
}
|
||||
}
|
||||
|
||||
bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon& rResult ) const
|
||||
bool CoreTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon& rResult ) const
|
||||
{
|
||||
rResult.clear();
|
||||
|
||||
@ -235,7 +237,7 @@ bool CTTextStyle::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void CTTextStyle::SetTextColor( const RGBAColor& rColor )
|
||||
void CoreTextStyle::SetTextColor( const RGBAColor& rColor )
|
||||
{
|
||||
CGFloat aColor[] = { rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue(), rColor.GetAlpha() };
|
||||
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
|
||||
@ -267,9 +269,9 @@ PhysicalFontFace* CTFontData::Clone( void ) const
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
ImplMacTextStyle* CTFontData::CreateMacTextStyle( const FontSelectPattern& rFSD ) const
|
||||
CoreTextStyle* CTFontData::CreateTextStyle( const FontSelectPattern& rFSD ) const
|
||||
{
|
||||
return new CTTextStyle( rFSD);
|
||||
return new CoreTextStyle( rFSD);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
@ -23,29 +23,6 @@
|
||||
#endif
|
||||
#include "sallayout.hxx"
|
||||
|
||||
class CTTextStyle
|
||||
: public ImplMacTextStyle
|
||||
{
|
||||
public:
|
||||
explicit CTTextStyle( const FontSelectPattern& );
|
||||
virtual ~CTTextStyle( void );
|
||||
|
||||
virtual SalLayout* GetTextLayout( void ) const;
|
||||
|
||||
virtual void GetFontMetric( float fDPIY, ImplFontMetricData& ) const;
|
||||
virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) const;
|
||||
virtual bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) const;
|
||||
|
||||
virtual void SetTextColor( const RGBAColor& );
|
||||
|
||||
private:
|
||||
/// CoreText text style object
|
||||
CFMutableDictionaryRef mpStyleDict;
|
||||
|
||||
friend class CTLayout;
|
||||
CFMutableDictionaryRef GetStyleDict( void ) const { return mpStyleDict; }
|
||||
};
|
||||
|
||||
// CoreText specific physically available font face
|
||||
class CTFontData
|
||||
: public ImplMacFontData
|
||||
@ -56,7 +33,7 @@ public:
|
||||
virtual ~CTFontData( void );
|
||||
virtual PhysicalFontFace* Clone( void ) const;
|
||||
|
||||
virtual ImplMacTextStyle* CreateMacTextStyle( const FontSelectPattern& ) const;
|
||||
virtual CoreTextStyle* CreateTextStyle( const FontSelectPattern& ) const;
|
||||
virtual ImplFontEntry* CreateFontInstance( /*const*/ FontSelectPattern& ) const;
|
||||
virtual int GetFontTable( const char pTagName[5], unsigned char* ) const;
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ class CTLayout
|
||||
: public SalLayout
|
||||
{
|
||||
public:
|
||||
explicit CTLayout( const CTTextStyle* );
|
||||
explicit CTLayout( const CoreTextStyle* );
|
||||
virtual ~CTLayout( void );
|
||||
|
||||
virtual bool LayoutText( ImplLayoutArgs& );
|
||||
@ -52,7 +52,7 @@ private:
|
||||
CGPoint GetTextDrawPosition(void) const;
|
||||
double GetWidth(void) const;
|
||||
|
||||
const CTTextStyle* const mpTextStyle;
|
||||
const CoreTextStyle* const mpTextStyle;
|
||||
|
||||
// CoreText specific objects
|
||||
CFAttributedStringRef mpAttrString;
|
||||
@ -69,7 +69,7 @@ private:
|
||||
mutable double mfBaseAdv;
|
||||
};
|
||||
|
||||
CTLayout::CTLayout( const CTTextStyle* pTextStyle )
|
||||
CTLayout::CTLayout( const CoreTextStyle* pTextStyle )
|
||||
: mpTextStyle( pTextStyle )
|
||||
, mpAttrString( NULL )
|
||||
, mpCTLine( NULL )
|
||||
@ -493,7 +493,7 @@ void CTLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ ) {}
|
||||
void CTLayout::DropGlyph( int /*nStart*/ ) {}
|
||||
void CTLayout::Simplify( bool /*bIsBase*/ ) {}
|
||||
|
||||
SalLayout* CTTextStyle::GetTextLayout( void ) const
|
||||
SalLayout* CoreTextStyle::GetTextLayout( void ) const
|
||||
{
|
||||
return new CTLayout( this);
|
||||
}
|
||||
|
@ -65,19 +65,6 @@ SystemFontList::~SystemFontList( void )
|
||||
{}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
|
||||
ImplMacTextStyle::ImplMacTextStyle( const FontSelectPattern& rReqFont )
|
||||
: mpFontData( (ImplMacFontData*)rReqFont.mpFontData )
|
||||
, mfFontStretch( 1.0 )
|
||||
, mfFontRotation( 0.0 )
|
||||
{}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
ImplMacTextStyle::~ImplMacTextStyle( void )
|
||||
{}
|
||||
|
||||
// =======================================================================
|
||||
|
||||
ImplMacFontData::ImplMacFontData( const ImplMacFontData& rSrc )
|
||||
@ -284,7 +271,7 @@ AquaSalGraphics::AquaSalGraphics()
|
||||
, maLineColor( COL_WHITE )
|
||||
, maFillColor( COL_BLACK )
|
||||
, mpMacFontData( NULL )
|
||||
, mpMacTextStyle( NULL )
|
||||
, mpTextStyle( NULL )
|
||||
, maTextColor( COL_BLACK )
|
||||
, mbNonAntialiasedText( false )
|
||||
, mbPrinter( false )
|
||||
@ -294,7 +281,7 @@ AquaSalGraphics::AquaSalGraphics()
|
||||
: mrContext( NULL )
|
||||
, mfFakeDPIScale( 1.0 )
|
||||
, mpMacFontData( NULL )
|
||||
, mpMacTextStyle( NULL )
|
||||
, mpTextStyle( NULL )
|
||||
, maTextColor( COL_BLACK )
|
||||
, mbNonAntialiasedText( false )
|
||||
#endif
|
||||
@ -306,7 +293,7 @@ AquaSalGraphics::~AquaSalGraphics()
|
||||
{
|
||||
#ifdef MACOSX
|
||||
CGPathRelease( mxClipPath );
|
||||
delete mpMacTextStyle;
|
||||
delete mpTextStyle;
|
||||
|
||||
if( mpXorEmulation )
|
||||
delete mpXorEmulation;
|
||||
@ -328,15 +315,15 @@ AquaSalGraphics::~AquaSalGraphics()
|
||||
void AquaSalGraphics::SetTextColor( SalColor nSalColor )
|
||||
{
|
||||
maTextColor = RGBAColor( nSalColor );
|
||||
if( mpMacTextStyle)
|
||||
mpMacTextStyle->SetTextColor( maTextColor );
|
||||
if( mpTextStyle)
|
||||
mpTextStyle->SetTextColor( maTextColor );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void AquaSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int /*nFallbackLevel*/ )
|
||||
{
|
||||
mpMacTextStyle->GetFontMetric( mfFakeDPIScale, *pMetric );
|
||||
mpTextStyle->GetFontMetric( mfFakeDPIScale, *pMetric );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@ -435,7 +422,7 @@ bool AquaSalGraphics::AddTempDevFont( ImplDevFontList*,
|
||||
|
||||
sal_Bool AquaSalGraphics::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPolyPolygon& rPolyPoly )
|
||||
{
|
||||
const bool bRC = mpMacTextStyle->GetGlyphOutline( nGlyphId, rPolyPoly );
|
||||
const bool bRC = mpTextStyle->GetGlyphOutline( nGlyphId, rPolyPoly );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
@ -443,7 +430,7 @@ sal_Bool AquaSalGraphics::GetGlyphOutline( sal_GlyphId nGlyphId, basegfx::B2DPol
|
||||
|
||||
sal_Bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId nGlyphId, Rectangle& rRect )
|
||||
{
|
||||
const bool bRC = mpMacTextStyle->GetGlyphBoundRect( nGlyphId, rRect );
|
||||
const bool bRC = mpTextStyle->GetGlyphBoundRect( nGlyphId, rRect );
|
||||
return bRC;
|
||||
}
|
||||
|
||||
@ -465,8 +452,8 @@ void AquaSalGraphics::DrawServerFontLayout( const ServerFontLayout& )
|
||||
sal_uInt16 AquaSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbackLevel*/ )
|
||||
{
|
||||
// release the text style
|
||||
delete mpMacTextStyle;
|
||||
mpMacTextStyle = NULL;
|
||||
delete mpTextStyle;
|
||||
mpTextStyle = NULL;
|
||||
|
||||
// handle NULL request meaning: release-font-resources request
|
||||
if( !pReqFont )
|
||||
@ -477,8 +464,8 @@ sal_uInt16 AquaSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbac
|
||||
|
||||
// update the text style
|
||||
mpMacFontData = static_cast<const ImplMacFontData*>( pReqFont->mpFontData );
|
||||
mpMacTextStyle = mpMacFontData->CreateMacTextStyle( *pReqFont );
|
||||
mpMacTextStyle->SetTextColor( maTextColor );
|
||||
mpTextStyle = mpMacFontData->CreateTextStyle( *pReqFont );
|
||||
mpTextStyle->SetTextColor( maTextColor );
|
||||
|
||||
SAL_INFO("vcl.coretext",
|
||||
"SetFont"
|
||||
@ -500,7 +487,7 @@ sal_uInt16 AquaSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbac
|
||||
|
||||
SalLayout* AquaSalGraphics::GetTextLayout( ImplLayoutArgs& /*rArgs*/, int /*nFallbackLevel*/ )
|
||||
{
|
||||
SalLayout* pSalLayout = mpMacTextStyle->GetTextLayout();
|
||||
SalLayout* pSalLayout = mpTextStyle->GetTextLayout();
|
||||
return pSalLayout;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
class AquaSalFrame;
|
||||
class ImplDevFontAttributes;
|
||||
class ImplMacTextStyle;
|
||||
class CoreTextStyle;
|
||||
|
||||
typedef sal_uInt32 sal_GlyphId;
|
||||
typedef std::vector<unsigned char> ByteVector;
|
||||
@ -61,7 +61,7 @@ public:
|
||||
virtual ImplFontEntry* CreateFontInstance( FontSelectPattern& ) const;
|
||||
virtual sal_IntPtr GetFontId() const;
|
||||
|
||||
virtual ImplMacTextStyle* CreateMacTextStyle( const FontSelectPattern& ) const = 0;
|
||||
virtual CoreTextStyle* CreateTextStyle( const FontSelectPattern& ) const = 0;
|
||||
virtual int GetFontTable( const char pTagName[5], unsigned char* ) const = 0;
|
||||
|
||||
const ImplFontCharMap* GetImplFontCharMap() const;
|
||||
@ -83,29 +83,32 @@ private:
|
||||
mutable bool mbFontCapabilitiesRead;
|
||||
};
|
||||
|
||||
// --------------------
|
||||
// - ImplMacTextStyle -
|
||||
// --------------------
|
||||
class ImplMacTextStyle
|
||||
class CoreTextStyle
|
||||
{
|
||||
public:
|
||||
explicit ImplMacTextStyle( const FontSelectPattern& );
|
||||
virtual ~ImplMacTextStyle( void );
|
||||
CoreTextStyle( const FontSelectPattern& );
|
||||
~CoreTextStyle( void );
|
||||
|
||||
virtual SalLayout* GetTextLayout( void ) const = 0;
|
||||
SalLayout* GetTextLayout( void ) const;
|
||||
|
||||
virtual void GetFontMetric( float fPDIY, ImplFontMetricData& ) const = 0;
|
||||
virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) const = 0;
|
||||
virtual bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) const = 0;
|
||||
void GetFontMetric( float fPDIY, ImplFontMetricData& ) const;
|
||||
bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) const;
|
||||
bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) const;
|
||||
|
||||
virtual void SetTextColor( const RGBAColor& ) = 0;
|
||||
void SetTextColor( const RGBAColor& );
|
||||
|
||||
//###protected:
|
||||
const ImplMacFontData* mpFontData;
|
||||
/// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
|
||||
float mfFontStretch;
|
||||
/// text rotation in radian
|
||||
float mfFontRotation;
|
||||
|
||||
private:
|
||||
/// CoreText text style object
|
||||
CFMutableDictionaryRef mpStyleDict;
|
||||
|
||||
friend class CTLayout;
|
||||
CFMutableDictionaryRef GetStyleDict( void ) const { return mpStyleDict; }
|
||||
};
|
||||
|
||||
// ------------------
|
||||
@ -158,7 +161,7 @@ protected:
|
||||
|
||||
// Device Font settings
|
||||
const ImplMacFontData* mpMacFontData;
|
||||
ImplMacTextStyle* mpMacTextStyle;
|
||||
CoreTextStyle* mpTextStyle;
|
||||
RGBAColor maTextColor;
|
||||
/// allows text to be rendered without antialiasing
|
||||
bool mbNonAntialiasedText;
|
||||
|
@ -90,7 +90,7 @@ protected:
|
||||
|
||||
// Device Font settings
|
||||
const ImplMacFontData* mpMacFontData;
|
||||
ImplMacTextStyle* mpMacTextStyle;
|
||||
CoreTextStyle* mpTextStyle;
|
||||
RGBAColor maTextColor;
|
||||
/// allows text to be rendered without antialiasing
|
||||
bool mbNonAntialiasedText;
|
||||
|
Loading…
x
Reference in New Issue
Block a user