summaryrefslogtreecommitdiff
path: root/vcl/source/outdev
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2016-01-15 03:06:18 +1100
committerChris Sherlock <chris.sherlock79@gmail.com>2016-01-14 18:09:47 +0000
commit659db7d705835b8676065fb4fe3babe39d938977 (patch)
treef426e3f089449a855f51ac589865212eaef241ba /vcl/source/outdev
parentc5c47412d16b5bbdc79886ae9bf93d0158405d14 (diff)
vcl: change ImplFontMetricData to be reference counted via intrusive_ptr
Change-Id: Ie9f5fbd21a6223520cbea3af6436beb407d7a88c Reviewed-on: https://gerrit.libreoffice.org/21477 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r--vcl/source/outdev/font.cxx77
-rw-r--r--vcl/source/outdev/text.cxx8
-rw-r--r--vcl/source/outdev/textline.cxx62
3 files changed, 72 insertions, 75 deletions
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index f85fcc89d8ee..ce87da9b6244 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -189,43 +189,45 @@ FontMetric OutputDevice::GetFontMetric() const
return aMetric;
LogicalFontInstance* pFontInstance = mpFontInstance;
- ImplFontMetricData* pFontMetric = &(pFontInstance->maFontMetric);
+ ImplFontMetricDataPtr xFontMetric = pFontInstance->mxFontMetric;
// prepare metric
aMetric.Font::operator=( maFont );
// set aMetric with info from font
aMetric.SetName( maFont.GetName() );
- aMetric.SetStyleName( pFontMetric->GetStyleName() );
- aMetric.SetSize( PixelToLogic( Size( pFontMetric->GetWidth(), pFontMetric->GetAscent() + pFontMetric->GetDescent() - pFontMetric->GetInternalLeading() ) ) );
- aMetric.SetCharSet( pFontMetric->IsSymbolFont() ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE );
- aMetric.SetFamily( pFontMetric->GetFamilyType() );
- aMetric.SetPitch( pFontMetric->GetPitch() );
- aMetric.SetWeight( pFontMetric->GetWeight() );
- aMetric.SetItalic( pFontMetric->GetSlantType() );
- aMetric.SetWidthType( pFontMetric->GetWidthType() );
+ aMetric.SetStyleName( xFontMetric->GetStyleName() );
+ aMetric.SetSize( PixelToLogic( Size( xFontMetric->GetWidth(), xFontMetric->GetAscent() + xFontMetric->GetDescent() - xFontMetric->GetInternalLeading() ) ) );
+ aMetric.SetCharSet( xFontMetric->IsSymbolFont() ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE );
+ aMetric.SetFamily( xFontMetric->GetFamilyType() );
+ aMetric.SetPitch( xFontMetric->GetPitch() );
+ aMetric.SetWeight( xFontMetric->GetWeight() );
+ aMetric.SetItalic( xFontMetric->GetSlantType() );
+ aMetric.SetWidthType( xFontMetric->GetWidthType() );
if ( pFontInstance->mnOwnOrientation )
aMetric.SetOrientation( pFontInstance->mnOwnOrientation );
else
- aMetric.SetOrientation( pFontMetric->GetOrientation() );
- if( !pFontInstance->maFontMetric.IsKernable() )
+ aMetric.SetOrientation( xFontMetric->GetOrientation() );
+ if( !pFontInstance->mxFontMetric->IsKernable() )
aMetric.SetKerning( maFont.GetKerning() & ~FontKerning::FontSpecific );
// set remaining metric fields
- aMetric.SetBuiltInFontFlag( pFontMetric->IsBuiltInFont() );
- aMetric.SetScalableFlag( pFontMetric->IsScalable() );
- aMetric.SetFullstopCenteredFlag( pFontMetric->IsFullstopCentered() );
- aMetric.SetBulletOffset( pFontMetric->GetBulletOffset() );
- aMetric.SetAscent( ImplDevicePixelToLogicHeight( pFontMetric->GetAscent() + mnEmphasisAscent ) );
- aMetric.SetDescent( ImplDevicePixelToLogicHeight( pFontMetric->GetDescent() + mnEmphasisDescent ) );
- aMetric.SetInternalLeading( ImplDevicePixelToLogicHeight( pFontMetric->GetInternalLeading() + mnEmphasisAscent ) );
+ aMetric.SetBuiltInFontFlag( xFontMetric->IsBuiltInFont() );
+ aMetric.SetScalableFlag( xFontMetric->IsScalable() );
+ aMetric.SetFullstopCenteredFlag( xFontMetric->IsFullstopCentered() );
+ aMetric.SetBulletOffset( xFontMetric->GetBulletOffset() );
+ aMetric.SetAscent( ImplDevicePixelToLogicHeight( xFontMetric->GetAscent() + mnEmphasisAscent ) );
+ aMetric.SetDescent( ImplDevicePixelToLogicHeight( xFontMetric->GetDescent() + mnEmphasisDescent ) );
+ aMetric.SetInternalLeading( ImplDevicePixelToLogicHeight( xFontMetric->GetInternalLeading() + mnEmphasisAscent ) );
// OutputDevice has its own external leading function due to #i60945#
aMetric.SetExternalLeading( ImplDevicePixelToLogicHeight( GetFontExtLeading() ) );
- aMetric.SetLineHeight( ImplDevicePixelToLogicHeight( pFontMetric->GetAscent() + pFontMetric->GetDescent() + mnEmphasisAscent + mnEmphasisDescent ) );
- aMetric.SetSlant( ImplDevicePixelToLogicHeight( pFontMetric->GetSlant() ) );
+ aMetric.SetLineHeight( ImplDevicePixelToLogicHeight( xFontMetric->GetAscent() + xFontMetric->GetDescent() + mnEmphasisAscent + mnEmphasisDescent ) );
+ aMetric.SetSlant( ImplDevicePixelToLogicHeight( xFontMetric->GetSlant() ) );
SAL_INFO("vcl.gdi.fontmetric", "OutputDevice::GetFontMetric:" << aMetric);
+ xFontMetric = nullptr;
+
return aMetric;
}
@@ -481,10 +483,7 @@ FontEmphasisMark OutputDevice::ImplGetEmphasisMarkStyle( const vcl::Font& rFont
long OutputDevice::GetFontExtLeading() const
{
- LogicalFontInstance* pFontInstance = mpFontInstance;
- ImplFontMetricData* pFontMetric = &(pFontInstance->maFontMetric);
-
- return pFontMetric->GetExternalLeading();
+ return mpFontInstance->mxFontMetric->GetExternalLeading();
}
void OutputDevice::ImplClearFontData( const bool bNewFontLists )
@@ -1099,13 +1098,13 @@ bool OutputDevice::ImplNewFont() const
{
pFontInstance->mbInit = true;
- pFontInstance->maFontMetric.SetOrientation( sal::static_int_cast<short>(pFontInstance->maFontSelData.mnOrientation) );
- pGraphics->GetFontMetric( &(pFontInstance->maFontMetric) );
+ pFontInstance->mxFontMetric->SetOrientation( sal::static_int_cast<short>(pFontInstance->maFontSelData.mnOrientation) );
+ pGraphics->GetFontMetric( pFontInstance->mxFontMetric );
- pFontInstance->maFontMetric.ImplInitTextLineSize( this );
- pFontInstance->maFontMetric.ImplInitAboveTextLineSize();
+ pFontInstance->mxFontMetric->ImplInitTextLineSize( this );
+ pFontInstance->mxFontMetric->ImplInitAboveTextLineSize();
- pFontInstance->mnLineHeight = pFontInstance->maFontMetric.GetAscent() + pFontInstance->maFontMetric.GetDescent();
+ pFontInstance->mnLineHeight = pFontInstance->mxFontMetric->GetAscent() + pFontInstance->mxFontMetric->GetDescent();
SetFontOrientation( pFontInstance );
}
@@ -1115,7 +1114,7 @@ bool OutputDevice::ImplNewFont() const
if ( maFont.GetKerning() & FontKerning::FontSpecific )
{
// TODO: test if physical font supports kerning and disable if not
- if( pFontInstance->maFontMetric.IsKernable() )
+ if( pFontInstance->mxFontMetric->IsKernable() )
mbKerning = true;
}
else
@@ -1151,7 +1150,7 @@ bool OutputDevice::ImplNewFont() const
else if ( eAlign == ALIGN_TOP )
{
mnTextOffX = 0;
- mnTextOffY = +pFontInstance->maFontMetric.GetAscent() + mnEmphasisAscent;
+ mnTextOffY = +pFontInstance->mxFontMetric->GetAscent() + mnEmphasisAscent;
if ( pFontInstance->mnOrientation )
{
Point aOriginPt(0, 0);
@@ -1161,7 +1160,7 @@ bool OutputDevice::ImplNewFont() const
else // eAlign == ALIGN_BOTTOM
{
mnTextOffX = 0;
- mnTextOffY = -pFontInstance->maFontMetric.GetDescent() + mnEmphasisDescent;
+ mnTextOffY = -pFontInstance->mxFontMetric->GetDescent() + mnEmphasisDescent;
if ( pFontInstance->mnOrientation )
{
Point aOriginPt(0, 0);
@@ -1179,7 +1178,7 @@ bool OutputDevice::ImplNewFont() const
// #95414# fix for OLE objects which use scale factors very creatively
if( mbMap && !aSize.Width() )
{
- int nOrigWidth = pFontInstance->maFontMetric.GetWidth();
+ int nOrigWidth = pFontInstance->mxFontMetric->GetWidth();
float fStretch = (float)maMapRes.mnMapScNumX * maMapRes.mnMapScDenomY;
fStretch /= (float)maMapRes.mnMapScNumY * maMapRes.mnMapScDenomX;
int nNewWidth = (int)(nOrigWidth * fStretch + 0.5);
@@ -1200,14 +1199,14 @@ bool OutputDevice::ImplNewFont() const
void OutputDevice::SetFontOrientation( LogicalFontInstance* const pFontInstance ) const
{
- if( pFontInstance->maFontSelData.mnOrientation && !pFontInstance->maFontMetric.GetOrientation() )
+ if( pFontInstance->maFontSelData.mnOrientation && !pFontInstance->mxFontMetric->GetOrientation() )
{
pFontInstance->mnOwnOrientation = sal::static_int_cast<short>(pFontInstance->maFontSelData.mnOrientation);
pFontInstance->mnOrientation = pFontInstance->mnOwnOrientation;
}
else
{
- pFontInstance->mnOrientation = pFontInstance->maFontMetric.GetOrientation();
+ pFontInstance->mnOrientation = pFontInstance->mxFontMetric->GetOrientation();
}
}
@@ -1297,9 +1296,9 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
Point aOffset = Point(0,0);
if ( nEmphasisMark & EMPHASISMARK_POS_BELOW )
- aOffset.Y() += mpFontInstance->maFontMetric.GetDescent() + nEmphasisYOff;
+ aOffset.Y() += mpFontInstance->mxFontMetric->GetDescent() + nEmphasisYOff;
else
- aOffset.Y() -= mpFontInstance->maFontMetric.GetAscent() + nEmphasisYOff;
+ aOffset.Y() -= mpFontInstance->mxFontMetric->GetAscent() + nEmphasisYOff;
long nEmphasisWidth2 = nEmphasisWidth / 2;
long nEmphasisHeight2 = nEmphasisHeight / 2;
@@ -1460,9 +1459,7 @@ long OutputDevice::GetMinKashida() const
if( mbNewFont && !ImplNewFont() )
return 0;
- LogicalFontInstance* pFontInstance = mpFontInstance;
- ImplFontMetricData* pFontMetric = &(pFontInstance->maFontMetric);
- return ImplDevicePixelToLogicWidth( pFontMetric->GetMinKashida() );
+ return ImplDevicePixelToLogicWidth( mpFontInstance->mxFontMetric->GetMinKashida() );
}
sal_Int32 OutputDevice::ValidateKashidas ( const OUString& rTxt,
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 912249a0eee8..1696ae2c3033 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -177,7 +177,7 @@ void OutputDevice::ImplDrawTextBackground( const SalLayout& rSalLayout )
mpGraphics->SetFillColor( ImplColorToSal( GetTextFillColor() ) );
mbInitFillColor = true;
- ImplDrawTextRect( nX, nY, 0, -(mpFontInstance->maFontMetric.GetAscent() + mnEmphasisAscent),
+ ImplDrawTextRect( nX, nY, 0, -(mpFontInstance->mxFontMetric->GetAscent() + mnEmphasisAscent),
nWidth,
mpFontInstance->mnLineHeight+mnEmphasisAscent+mnEmphasisDescent );
}
@@ -191,7 +191,7 @@ Rectangle OutputDevice::ImplGetTextBoundRect( const SalLayout& rSalLayout )
long nWidth = rSalLayout.GetTextWidth();
long nHeight = mpFontInstance->mnLineHeight + mnEmphasisAscent + mnEmphasisDescent;
- nY -= mpFontInstance->maFontMetric.GetAscent() + mnEmphasisAscent;
+ nY -= mpFontInstance->mxFontMetric->GetAscent() + mnEmphasisAscent;
if ( mpFontInstance->mnOrientation )
{
@@ -232,7 +232,7 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout )
{
// guess vertical text extents if GetBoundRect failed
int nRight = rSalLayout.GetTextWidth();
- int nTop = mpFontInstance->maFontMetric.GetAscent() + mnEmphasisAscent;
+ int nTop = mpFontInstance->mxFontMetric->GetAscent() + mnEmphasisAscent;
long nHeight = mpFontInstance->mnLineHeight + mnEmphasisAscent + mnEmphasisDescent;
aBoundRect = Rectangle( 0, -nTop, nRight, nHeight - nTop );
}
@@ -2621,7 +2621,7 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect,
Point aTopLeft( nLeft, nTop );
aTopLeft -= aOffset;
// adjust to text alignment
- aTopLeft.Y()+= mnTextOffY - (mpFontInstance->maFontMetric.GetAscent() + mnEmphasisAscent);
+ aTopLeft.Y()+= mnTextOffY - (mpFontInstance->mxFontMetric->GetAscent() + mnEmphasisAscent);
// convert to logical coordinates
aSize = PixelToLogic( aSize );
aTopLeft.X() = ImplDevicePixelToLogicWidth( aTopLeft.X() );
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx
index 7e147d85e134..556004447776 100644
--- a/vcl/source/outdev/textline.cxx
+++ b/vcl/source/outdev/textline.cxx
@@ -56,12 +56,12 @@ bool OutputDevice::ImplIsUnderlineAbove( const vcl::Font& rFont )
void OutputDevice::ImplInitTextLineSize()
{
- mpFontInstance->maFontMetric.ImplInitTextLineSize( this );
+ mpFontInstance->mxFontMetric->ImplInitTextLineSize( this );
}
void OutputDevice::ImplInitAboveTextLineSize()
{
- mpFontInstance->maFontMetric.ImplInitAboveTextLineSize();
+ mpFontInstance->mxFontMetric->ImplInitAboveTextLineSize();
}
void OutputDevice::ImplDrawWavePixel( long nOriginX, long nOriginY,
@@ -221,13 +221,13 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY,
if ( bIsAbove )
{
- nLineHeight = pFontInstance->maFontMetric.GetAboveWavelineUnderlineSize();
- nLinePos = pFontInstance->maFontMetric.GetAboveWavelineUnderlineOffset();
+ nLineHeight = pFontInstance->mxFontMetric->GetAboveWavelineUnderlineSize();
+ nLinePos = pFontInstance->mxFontMetric->GetAboveWavelineUnderlineOffset();
}
else
{
- nLineHeight = pFontInstance->maFontMetric.GetWavelineUnderlineSize();
- nLinePos = pFontInstance->maFontMetric.GetWavelineUnderlineOffset();
+ nLineHeight = pFontInstance->mxFontMetric->GetWavelineUnderlineSize();
+ nLinePos = pFontInstance->mxFontMetric->GetWavelineUnderlineOffset();
}
if ( (eTextLine == UNDERLINE_SMALLWAVE) && (nLineHeight > 3) )
nLineHeight = 3;
@@ -303,13 +303,13 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY,
case UNDERLINE_DASHDOTDOT:
if ( bIsAbove )
{
- nLineHeight = pFontInstance->maFontMetric.GetAboveUnderlineSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetAboveUnderlineOffset();
+ nLineHeight = pFontInstance->mxFontMetric->GetAboveUnderlineSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetAboveUnderlineOffset();
}
else
{
- nLineHeight = pFontInstance->maFontMetric.GetUnderlineSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetUnderlineOffset();
+ nLineHeight = pFontInstance->mxFontMetric->GetUnderlineSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetUnderlineOffset();
}
break;
case UNDERLINE_BOLD:
@@ -320,27 +320,27 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY,
case UNDERLINE_BOLDDASHDOTDOT:
if ( bIsAbove )
{
- nLineHeight = pFontInstance->maFontMetric.GetAboveBoldUnderlineSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetAboveBoldUnderlineOffset();
+ nLineHeight = pFontInstance->mxFontMetric->GetAboveBoldUnderlineSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetAboveBoldUnderlineOffset();
}
else
{
- nLineHeight = pFontInstance->maFontMetric.GetBoldUnderlineSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetBoldUnderlineOffset();
+ nLineHeight = pFontInstance->mxFontMetric->GetBoldUnderlineSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetBoldUnderlineOffset();
}
break;
case UNDERLINE_DOUBLE:
if ( bIsAbove )
{
- nLineHeight = pFontInstance->maFontMetric.GetAboveDoubleUnderlineSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetAboveDoubleUnderlineOffset1();
- nLinePos2 = nY + pFontInstance->maFontMetric.GetAboveDoubleUnderlineOffset2();
+ nLineHeight = pFontInstance->mxFontMetric->GetAboveDoubleUnderlineSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetAboveDoubleUnderlineOffset1();
+ nLinePos2 = nY + pFontInstance->mxFontMetric->GetAboveDoubleUnderlineOffset2();
}
else
{
- nLineHeight = pFontInstance->maFontMetric.GetDoubleUnderlineSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetDoubleUnderlineOffset1();
- nLinePos2 = nY + pFontInstance->maFontMetric.GetDoubleUnderlineOffset2();
+ nLineHeight = pFontInstance->mxFontMetric->GetDoubleUnderlineSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetDoubleUnderlineOffset1();
+ nLinePos2 = nY + pFontInstance->mxFontMetric->GetDoubleUnderlineOffset2();
}
break;
default:
@@ -538,17 +538,17 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY,
switch ( eStrikeout )
{
case STRIKEOUT_SINGLE:
- nLineHeight = pFontInstance->maFontMetric.GetStrikeoutSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetStrikeoutOffset();
+ nLineHeight = pFontInstance->mxFontMetric->GetStrikeoutSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetStrikeoutOffset();
break;
case STRIKEOUT_BOLD:
- nLineHeight = pFontInstance->maFontMetric.GetBoldStrikeoutSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetBoldStrikeoutOffset();
+ nLineHeight = pFontInstance->mxFontMetric->GetBoldStrikeoutSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetBoldStrikeoutOffset();
break;
case STRIKEOUT_DOUBLE:
- nLineHeight = pFontInstance->maFontMetric.GetDoubleStrikeoutSize();
- nLinePos = nY + pFontInstance->maFontMetric.GetDoubleStrikeoutOffset1();
- nLinePos2 = nY + pFontInstance->maFontMetric.GetDoubleStrikeoutOffset2();
+ nLineHeight = pFontInstance->mxFontMetric->GetDoubleStrikeoutSize();
+ nLinePos = nY + pFontInstance->mxFontMetric->GetDoubleStrikeoutOffset1();
+ nLinePos2 = nY + pFontInstance->mxFontMetric->GetDoubleStrikeoutOffset2();
break;
default:
break;
@@ -652,8 +652,8 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY,
Rectangle aPixelRect;
aPixelRect.Left() = nBaseX+mnTextOffX;
aPixelRect.Right() = aPixelRect.Left()+nWidth;
- aPixelRect.Bottom() = nBaseY+mpFontInstance->maFontMetric.GetDescent();
- aPixelRect.Top() = nBaseY-mpFontInstance->maFontMetric.GetAscent();
+ aPixelRect.Bottom() = nBaseY+mpFontInstance->mxFontMetric->GetDescent();
+ aPixelRect.Top() = nBaseY-mpFontInstance->mxFontMetric->GetAscent();
if (mpFontInstance->mnOrientation)
{
@@ -1043,9 +1043,9 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos )
// #109280# make sure the waveline does not exceed the descent to avoid paint problems
LogicalFontInstance* pFontInstance = mpFontInstance;
- if( nWaveHeight > pFontInstance->maFontMetric.GetWavelineUnderlineSize() )
+ if( nWaveHeight > pFontInstance->mxFontMetric->GetWavelineUnderlineSize() )
{
- nWaveHeight = pFontInstance->maFontMetric.GetWavelineUnderlineSize();
+ nWaveHeight = pFontInstance->mxFontMetric->GetWavelineUnderlineSize();
}
ImplDrawWaveLine(nStartX, nStartY, 0, 0,
nEndX-nStartX, nWaveHeight,