[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/qa vcl/source
Chris Sherlock
chris.sherlock79 at gmail.com
Tue Jan 12 21:55:47 PST 2016
include/vcl/metric.hxx | 4 +++-
vcl/inc/impfont.hxx | 10 ++++++----
vcl/qa/cppunit/fontmetric.cxx | 21 +++++++++++++++++++++
vcl/source/gdi/metric.cxx | 21 ++++++++++++++-------
vcl/source/outdev/font.cxx | 3 +--
5 files changed, 45 insertions(+), 14 deletions(-)
New commits:
commit bfd690701ff414496ad77c2b268bf7200947dc3a
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Wed Jan 13 12:13:12 2016 +1100
vcl: Create accessor and mutator for full stop centered in FontMetric
Accessor and mutator created for full stop centered flag, removed
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 full stop centered flag
- check equality operator on FontMetric after setting full stop
centered flag
Change-Id: I9cacb0fbf9ea65cfebcaebdc9f0481c0a796cbcf
Reviewed-on: https://gerrit.libreoffice.org/21413
Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>
diff --git a/include/vcl/metric.hxx b/include/vcl/metric.hxx
index e289b72..f3de018 100644
--- a/include/vcl/metric.hxx
+++ b/include/vcl/metric.hxx
@@ -52,11 +52,13 @@ public:
long GetExtLeading() const;
long GetLineHeight() const;
long GetSlant() const;
+ long GetBulletOffset() const;
+
bool IsScalable() const;
bool IsFullstopCentered() const;
- long GetBulletOffset() const;
void SetScalableFlag(bool);
+ void SetFullstopCenteredFlag(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 376c0cb..5367a77 100644
--- a/vcl/inc/impfont.hxx
+++ b/vcl/inc/impfont.hxx
@@ -105,6 +105,7 @@ private:
sal_uInt32 mnRefCount; // Reference Counter
bool mbScalableFont;
+ bool mbFullstopCentered;
// 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.
@@ -113,8 +114,8 @@ private:
/* SCALABLE_FLAG=2, */
LATIN_FLAG=4,
CJK_FLAG=8,
- CTL_FLAG=16,
- FULLSTOP_CENTERED_FLAG=32
+ CTL_FLAG=16
+ /* FULLSTOP_CENTERED_FLAG=32 */
};
public:
@@ -131,12 +132,13 @@ public:
long GetExtLeading() const { return mnExtLeading; }
long GetLineHeight() const { return mnLineHeight; }
long GetSlant() const { return mnSlant; }
+ long GetBulletOffset() const { return mnBulletOffset; }
bool IsScalable() const { return mbScalableFont; }
- bool IsFullstopCentered() const { return ((mnMiscFlags & FULLSTOP_CENTERED_FLAG ) != 0); }
- long GetBulletOffset() const { return mnBulletOffset; }
+ bool IsFullstopCentered() const { return mbFullstopCentered; }
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 b7db7df..1428cfb 100644
--- a/vcl/qa/cppunit/fontmetric.cxx
+++ b/vcl/qa/cppunit/fontmetric.cxx
@@ -22,10 +22,12 @@ public:
VclFontMetricTest() : BootstrapFixture(true, false) {}
void testScalableFlag();
+ void testFullstopCenteredFlag();
void testEqualityOperator();
CPPUNIT_TEST_SUITE(VclFontMetricTest);
CPPUNIT_TEST(testScalableFlag);
+ CPPUNIT_TEST(testFullstopCenteredFlag);
CPPUNIT_TEST(testEqualityOperator);
CPPUNIT_TEST_SUITE_END();
};
@@ -42,6 +44,20 @@ void VclFontMetricTest::testScalableFlag()
CPPUNIT_ASSERT_MESSAGE( "Scalable flag should be true", aFontMetric.IsScalable() );
}
+
+void VclFontMetricTest::testFullstopCenteredFlag()
+{
+ // default constructor should set scalable flag to false
+ FontMetric aFontMetric;
+
+ CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag should be false after default constructor called", !aFontMetric.IsFullstopCentered() );
+
+ aFontMetric.SetFullstopCenteredFlag(true);
+
+ CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag should be true", aFontMetric.IsFullstopCentered() );
+}
+
+
void VclFontMetricTest::testEqualityOperator()
{
// default constructor should set scalable flag to false
@@ -51,6 +67,11 @@ void VclFontMetricTest::testEqualityOperator()
aRhs.SetScalableFlag(true);
CPPUNIT_ASSERT_MESSAGE( "Scalable flag set same", aLhs == aRhs );
+
+ aLhs.SetFullstopCenteredFlag(true);
+ aRhs.SetFullstopCenteredFlag(true);
+
+ CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same", aLhs == aRhs );
}
diff --git a/vcl/source/gdi/metric.cxx b/vcl/source/gdi/metric.cxx
index a3d5a67..089e421 100644
--- a/vcl/source/gdi/metric.cxx
+++ b/vcl/source/gdi/metric.cxx
@@ -35,7 +35,8 @@ ImplFontMetric::ImplFontMetric()
mnBulletOffset( 0 ),
mnMiscFlags( 0 ),
mnRefCount( 1 ),
- mbScalableFont( false )
+ mbScalableFont( false ),
+ mbFullstopCentered( false )
{}
inline void ImplFontMetric::AddReference()
@@ -53,7 +54,8 @@ inline void ImplFontMetric::DeReference()
bool ImplFontMetric::operator==( const ImplFontMetric& r ) const
{
- if( mbScalableFont != r.mbScalableFont )
+ if( mbScalableFont != r.mbScalableFont
+ || mbFullstopCentered != r.mbFullstopCentered )
return false;
if( mnMiscFlags != r.mnMiscFlags )
return false;
@@ -147,11 +149,6 @@ long FontMetric::GetSlant() const
return mpImplMetric->GetSlant();
}
-bool FontMetric::IsFullstopCentered() const
-{
- return mpImplMetric->IsFullstopCentered();
-}
-
long FontMetric::GetBulletOffset() const
{
return mpImplMetric->GetBulletOffset();
@@ -167,4 +164,14 @@ void FontMetric::SetScalableFlag(bool bScalable)
mpImplMetric->SetScalableFlag( bScalable );
}
+bool FontMetric::IsFullstopCentered() const
+{
+ return mpImplMetric->IsFullstopCentered();
+}
+
+void FontMetric::SetFullstopCenteredFlag(bool bScalable)
+{
+ mpImplMetric->SetFullstopCenteredFlag( bScalable );
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 00a5f73..ef3929d 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -217,8 +217,7 @@ FontMetric OutputDevice::GetFontMetric() const
if( pFontAttributes->IsBuiltInFont() )
aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::DEVICE_FLAG;
aMetric.SetScalableFlag( pFontAttributes->IsScalable() );
- if( pFontAttributes->IsFullstopCentered())
- aMetric.mpImplMetric->mnMiscFlags |= ImplFontMetric::FULLSTOP_CENTERED_FLAG;
+ aMetric.SetFullstopCenteredFlag( pFontAttributes->IsFullstopCentered() );
aMetric.mpImplMetric->mnBulletOffset = pFontAttributes->GetBulletOffset();
aMetric.mpImplMetric->mnAscent = ImplDevicePixelToLogicHeight( pFontAttributes->GetAscent() + mnEmphasisAscent );
aMetric.mpImplMetric->mnDescent = ImplDevicePixelToLogicHeight( pFontAttributes->GetDescent() + mnEmphasisDescent );
More information about the Libreoffice-commits
mailing list