From 8bfccd3a71d911b6da6c108a1312b712431f99d8 Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Wed, 13 Jan 2016 03:05:29 +1100 Subject: vcl: Create accessor and mutator for font scaling in FontMetric This is fragile code! There are actually *two* classes that do almost precisely the same thing, they are: - ImplFontMetric, and - ImplFontMetricData They both have much in common, including their class name, and even most of their functionality. In fact, they both have common accessor functions. When I look at the code, it looks like OutputDevice is actually given an ImplFontMetricData object, which it then uses to populate an ImplFontMetric object... Basically, I'm going to merge these classes. To do so, I'm going to do the following: Step 1: Implement accessor functions for ImplFontMetric and FontMetric (then remove the friendship of this class to OutputDevice!) Step 2: Write a unit test for each accessor function in ImplFontMetric Step 3: Ensure that ImplFontMetric and ImplFontMetricData use some sort of smart pointer (probably an intrusive_ptr like I did ages ago with FontCharMap) Step 4: Merge the two classes together once their class interfaces are the same and I am satisfied they do the same thing Step 5: Find all instances of inefficient usage - for instance, I can do away with the code that copies the ImplFontMetricData attributes into an ImplFontMetric object. Change-Id: I07c1cb848774b130fa2ca60b51da53e07754dd00 Reviewed-on: https://gerrit.libreoffice.org/21399 Reviewed-by: Chris Sherlock Tested-by: Chris Sherlock --- vcl/source/outdev/font.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'vcl/source/outdev') diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index ee4c204eb172..00a5f73326cd 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -82,8 +82,7 @@ FontMetric OutputDevice::GetDevFont( int nDevFontIndex ) const aFontMetric.SetWeight( rData.GetWeight() ); aFontMetric.SetItalic( rData.GetSlantType() ); aFontMetric.SetWidthType( rData.GetWidthType() ); - if( rData.IsScalable() ) - aFontMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::SCALABLE_FLAG; + aFontMetric.SetScalableFlag( rData.IsScalable() ); if( rData.IsBuiltInFont() ) aFontMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::DEVICE_FLAG; } @@ -217,8 +216,7 @@ FontMetric OutputDevice::GetFontMetric() const aMetric.mpImplMetric->mnMiscFlags = 0; if( pFontAttributes->IsBuiltInFont() ) aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::DEVICE_FLAG; - if( pFontAttributes->IsScalable() ) - aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::SCALABLE_FLAG; + aMetric.SetScalableFlag( pFontAttributes->IsScalable() ); if( pFontAttributes->IsFullstopCentered()) aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::FULLSTOP_CENTERED_FLAG; aMetric.mpImplMetric->mnBulletOffset = pFontAttributes->GetBulletOffset(); -- cgit