include/vcl/metric.hxx | 2 ++ vcl/inc/impfont.hxx | 10 +++++++--- vcl/qa/cppunit/fontmetric.cxx | 21 +++++++++++++++++++-- vcl/source/gdi/metric.cxx | 17 ++++++++++++++--- vcl/source/outdev/font.cxx | 6 ++---- 5 files changed, 44 insertions(+), 12 deletions(-)
New commits: commit e3746c66929f4f038d1dee58b4fa222fb3c31951 Author: Chris Sherlock <chris.sherloc...@gmail.com> Date: Wed Jan 13 17:14:53 2016 +1100 vcl: Create accessor and mutator for builtin font flag in FontMetric Accessor and mutator created for builtin font flag, removed the existing bit field. See commit description in 8bfccd3a71d911b6d ("vcl: Create accessor and mutator for font scaling in FontMetric") for reasoning behind patch. Unit tests - check to ensure that can set builtin font flag - check equality operator on FontMetric after setting builtin font flag Change-Id: Iac3f4270f86d10f9dcd0bb6e3951c0e983a4f22f Reviewed-on: https://gerrit.libreoffice.org/21414 Reviewed-by: Chris Sherlock <chris.sherloc...@gmail.com> Tested-by: Chris Sherlock <chris.sherloc...@gmail.com> diff --git a/include/vcl/metric.hxx b/include/vcl/metric.hxx index f3de018..7b3694d 100644 --- a/include/vcl/metric.hxx +++ b/include/vcl/metric.hxx @@ -56,9 +56,11 @@ public: bool IsScalable() const; bool IsFullstopCentered() const; + bool IsBuiltInFont() const; void SetScalableFlag(bool); void SetFullstopCenteredFlag(bool); + void SetBuiltInFontFlag(bool); FontMetric& operator=( const FontMetric& rMetric ); bool operator==( const FontMetric& rMetric ) const; diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx index 5367a77..13c7801 100644 --- a/vcl/inc/impfont.hxx +++ b/vcl/inc/impfont.hxx @@ -106,11 +106,12 @@ private: bool mbScalableFont; bool mbFullstopCentered; + bool mbDevice; // TODO: As these are progressively moved from bit fields into boolean variables, comment them out. // Eventually this enum will not be needed and we can remove it. enum { - DEVICE_FLAG=1, + /* DEVICE_FLAG=1, */ /* SCALABLE_FLAG=2, */ LATIN_FLAG=4, CJK_FLAG=8, @@ -136,9 +137,12 @@ public: bool IsScalable() const { return mbScalableFont; } bool IsFullstopCentered() const { return mbFullstopCentered; } + bool IsBuiltInFont() const { return mbDevice; } + + void SetScalableFlag( bool bScalable ) { mbScalableFont = bScalable; } + void SetFullstopCenteredFlag( bool bCentered ) { mbFullstopCentered = bCentered; } + void SetBuiltInFontFlag( bool bIsBuiltInFont ) { mbDevice = bIsBuiltInFont; } - void SetScalableFlag(bool bScalable) { mbScalableFont = bScalable; } - void SetFullstopCenteredFlag(bool bCentered) { mbFullstopCentered = bCentered; } }; diff --git a/vcl/qa/cppunit/fontmetric.cxx b/vcl/qa/cppunit/fontmetric.cxx index 1428cfb..f434ae0 100644 --- a/vcl/qa/cppunit/fontmetric.cxx +++ b/vcl/qa/cppunit/fontmetric.cxx @@ -23,11 +23,13 @@ public: void testScalableFlag(); void testFullstopCenteredFlag(); + void testBuiltInFontFlag(); void testEqualityOperator(); CPPUNIT_TEST_SUITE(VclFontMetricTest); CPPUNIT_TEST(testScalableFlag); CPPUNIT_TEST(testFullstopCenteredFlag); + CPPUNIT_TEST(testBuiltInFontFlag); CPPUNIT_TEST(testEqualityOperator); CPPUNIT_TEST_SUITE_END(); }; @@ -44,7 +46,6 @@ void VclFontMetricTest::testScalableFlag() CPPUNIT_ASSERT_MESSAGE( "Scalable flag should be true", aFontMetric.IsScalable() ); } - void VclFontMetricTest::testFullstopCenteredFlag() { // default constructor should set scalable flag to false @@ -57,6 +58,17 @@ void VclFontMetricTest::testFullstopCenteredFlag() CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag should be true", aFontMetric.IsFullstopCentered() ); } +void VclFontMetricTest::testBuiltInFontFlag() +{ + // default constructor should set scalable flag to false + FontMetric aFontMetric; + + CPPUNIT_ASSERT_MESSAGE( "Built-in font flag should be false after default constructor called", !aFontMetric.IsBuiltInFont() ); + + aFontMetric.SetBuiltInFontFlag(true); + + CPPUNIT_ASSERT_MESSAGE( "Built-in font flag should be true", aFontMetric.IsBuiltInFont() ); +} void VclFontMetricTest::testEqualityOperator() { @@ -71,7 +83,12 @@ void VclFontMetricTest::testEqualityOperator() aLhs.SetFullstopCenteredFlag(true); aRhs.SetFullstopCenteredFlag(true); - CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same", aLhs == aRhs ); + CPPUNIT_ASSERT_MESSAGE( "Scalable font flag set same", aLhs == aRhs ); + + aLhs.SetBuiltInFontFlag(true); + aRhs.SetBuiltInFontFlag(true); + + CPPUNIT_ASSERT_MESSAGE( "Scalable font flag set same", aLhs == aRhs ); } diff --git a/vcl/source/gdi/metric.cxx b/vcl/source/gdi/metric.cxx index 089e421..c7f5253 100644 --- a/vcl/source/gdi/metric.cxx +++ b/vcl/source/gdi/metric.cxx @@ -36,7 +36,8 @@ ImplFontMetric::ImplFontMetric() mnMiscFlags( 0 ), mnRefCount( 1 ), mbScalableFont( false ), - mbFullstopCentered( false ) + mbFullstopCentered( false ), + mbDevice( false ) {} inline void ImplFontMetric::AddReference() @@ -54,8 +55,9 @@ inline void ImplFontMetric::DeReference() bool ImplFontMetric::operator==( const ImplFontMetric& r ) const { - if( mbScalableFont != r.mbScalableFont - || mbFullstopCentered != r.mbFullstopCentered ) + if( mbScalableFont != r.mbScalableFont + || mbFullstopCentered != r.mbFullstopCentered + || mbDevice != r.mbDevice) return false; if( mnMiscFlags != r.mnMiscFlags ) return false; @@ -174,4 +176,13 @@ void FontMetric::SetFullstopCenteredFlag(bool bScalable) mpImplMetric->SetFullstopCenteredFlag( bScalable ); } +bool FontMetric::IsBuiltInFont() const +{ + return mpImplMetric->IsBuiltInFont(); +} + +void FontMetric::SetBuiltInFontFlag( bool bIsBuiltInFont ) +{ + mpImplMetric->SetBuiltInFontFlag( bIsBuiltInFont ); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 923347c..e56e07d 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -83,8 +83,7 @@ FontMetric OutputDevice::GetDevFont( int nDevFontIndex ) const aFontMetric.SetItalic( rData.GetSlantType() ); aFontMetric.SetWidthType( rData.GetWidthType() ); aFontMetric.SetScalableFlag( rData.IsScalable() ); - if( rData.IsBuiltInFont() ) - aFontMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::DEVICE_FLAG; + aFontMetric.SetBuiltInFontFlag( rData.IsBuiltInFont() ); } return aFontMetric; @@ -214,8 +213,7 @@ FontMetric OutputDevice::GetFontMetric() const // set remaining metric fields aMetric.mpImplMetric->mnMiscFlags = 0; - if( pFontAttributes->IsBuiltInFont() ) - aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::DEVICE_FLAG; + aMetric.SetBuiltInFontFlag( pFontAttributes->IsBuiltInFont() ); aMetric.SetScalableFlag( pFontAttributes->IsScalable() ); aMetric.SetFullstopCenteredFlag( pFontAttributes->IsFullstopCentered() ); aMetric.mpImplMetric->mnBulletOffset = pFontAttributes->GetBulletOffset(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits