[Libreoffice-commits] core.git: vcl/coretext vcl/inc
Tor Lillqvist
tml at collabora.com
Thu Nov 28 12:45:04 PST 2013
vcl/coretext/ctfonts.cxx | 20 +++++++++++---------
vcl/coretext/ctfonts.hxx | 25 +------------------------
vcl/coretext/ctlayout.cxx | 8 ++++----
vcl/coretext/salgdi2.cxx | 39 +++++++++++++--------------------------
vcl/inc/coretext/salgdi2.h | 33 ++++++++++++++++++---------------
vcl/inc/headless/svpgdi.hxx | 2 +-
6 files changed, 48 insertions(+), 79 deletions(-)
New commits:
commit cb17d9392b78fdce96aa8e140df8b90d7abe0d2c
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Nov 28 22:27:26 2013 +0200
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
diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index d46d19d..425fb44 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -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);
}
// -----------------------------------------------------------------------
diff --git a/vcl/coretext/ctfonts.hxx b/vcl/coretext/ctfonts.hxx
index 605a2c1..5865df5 100644
--- a/vcl/coretext/ctfonts.hxx
+++ b/vcl/coretext/ctfonts.hxx
@@ -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;
};
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index 0e9a6e0..1f8bdf8 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -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);
}
diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index 9d3bae0..cbd49f4 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -67,19 +67,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 )
: PhysicalFontFace( rSrc )
, mnFontId( rSrc.mnFontId )
@@ -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;
}
diff --git a/vcl/inc/coretext/salgdi2.h b/vcl/inc/coretext/salgdi2.h
index dc08a9e..3898aeb 100644
--- a/vcl/inc/coretext/salgdi2.h
+++ b/vcl/inc/coretext/salgdi2.h
@@ -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;
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index c36cfd3..f6281ad 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -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;
More information about the Libreoffice-commits
mailing list