[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/qa vcl/source
Chris Sherlock
chris.sherlock79 at gmail.com
Wed Jan 13 12:53:08 PST 2016
include/vcl/metric.hxx | 2 +
vcl/inc/impfont.hxx | 2 +
vcl/qa/cppunit/fontmetric.cxx | 43 +++++++++++++++++++++++++++++++++++++-----
vcl/source/gdi/metric.cxx | 10 +++++++++
4 files changed, 52 insertions(+), 5 deletions(-)
New commits:
commit f8ffe2ff7a654052e0e2d6cb168841025bcc2f25
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Thu Jan 14 07:48:48 2016 +1100
vcl: Create accessor and mutator for ascent and descent in FontMetric
Accessor and mutator created for ascent and descent spacing in
FontMetric.
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 font ascent and descent spacing
- check equality operator on FontMetric after setting both ascent
and descent font spacing
Change-Id: I714363b14bdc61ddfa37a619fe4b03f4e4e96f7a
Reviewed-on: https://gerrit.libreoffice.org/21458
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 2c8d9f2..0a7d0e6 100644
--- a/include/vcl/metric.hxx
+++ b/include/vcl/metric.hxx
@@ -54,6 +54,8 @@ public:
long GetSlant() const;
long GetBulletOffset() const;
+ void SetAscent(long);
+ void SetDescent(long);
void SetExternalLeading(long);
void SetInternalLeading(long);
diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx
index 0b9577a..182f4e8 100644
--- a/vcl/inc/impfont.hxx
+++ b/vcl/inc/impfont.hxx
@@ -123,6 +123,8 @@ public:
long GetSlant() const { return mnSlant; }
long GetBulletOffset() const { return mnBulletOffset; }
+ void SetAscent( long nAscent ) { mnAscent = nAscent; }
+ void SetDescent( long nDescent ) { mnDescent = nDescent; }
void SetInternalLeading( long nIntLeading ) { mnIntLeading = nIntLeading; }
void SetExternalLeading( long nExtLeading ) { mnExtLeading = nExtLeading; }
diff --git a/vcl/qa/cppunit/fontmetric.cxx b/vcl/qa/cppunit/fontmetric.cxx
index 316e03d..07fc0e6 100644
--- a/vcl/qa/cppunit/fontmetric.cxx
+++ b/vcl/qa/cppunit/fontmetric.cxx
@@ -8,6 +8,8 @@
*/
#include <test/bootstrapfixture.hxx>
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
#include <osl/file.hxx>
#include <osl/process.h>
@@ -24,6 +26,7 @@ public:
void testScalableFlag();
void testFullstopCenteredFlag();
void testBuiltInFontFlag();
+ void testSpacings();
void testEqualityOperator();
CPPUNIT_TEST_SUITE(VclFontMetricTest);
@@ -31,6 +34,7 @@ public:
CPPUNIT_TEST(testFullstopCenteredFlag);
CPPUNIT_TEST(testBuiltInFontFlag);
CPPUNIT_TEST(testEqualityOperator);
+ CPPUNIT_TEST(testSpacings);
CPPUNIT_TEST_SUITE_END();
};
@@ -70,6 +74,30 @@ void VclFontMetricTest::testBuiltInFontFlag()
CPPUNIT_ASSERT_MESSAGE( "Built-in font flag should be true", aFontMetric.IsBuiltInFont() );
}
+void VclFontMetricTest::testSpacings()
+{
+ // default constructor should set scalable flag to false
+ FontMetric aFontMetric;
+
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetAscent(), 0L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetDescent(), 0L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetExternalLeading(), 0L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetInternalLeading(), 0L );
+
+ aFontMetric.SetAscent( 100 );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetAscent(), 100L );
+
+ aFontMetric.SetDescent( 100 );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetDescent(), 100L );
+
+ aFontMetric.SetExternalLeading( 100L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetExternalLeading(), 100L );
+
+ aFontMetric.SetInternalLeading( 100L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetInternalLeading(), 100L );
+}
+
+
void VclFontMetricTest::testEqualityOperator()
{
// default constructor should set scalable flag to false
@@ -77,33 +105,38 @@ void VclFontMetricTest::testEqualityOperator()
aLhs.SetScalableFlag(true);
aRhs.SetScalableFlag(true);
-
CPPUNIT_ASSERT_MESSAGE( "Scalable flag set same, aLhs == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "Scalable flag set same, aLhs != aRhs succeeded", !(aLhs != aRhs) );
aLhs.SetFullstopCenteredFlag(true);
aRhs.SetFullstopCenteredFlag(true);
-
CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs != aRhs succeeded", !(aLhs != aRhs) );
aLhs.SetBuiltInFontFlag(true);
aRhs.SetBuiltInFontFlag(true);
-
CPPUNIT_ASSERT_MESSAGE( "Builtin font flag set same, aLHS == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "Builtin font flag set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
aLhs.SetExternalLeading(10);
aRhs.SetExternalLeading(10);
-
CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
aLhs.SetInternalLeading(10);
aRhs.SetInternalLeading(10);
-
CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+
+ aLhs.SetAscent( 100 );
+ aRhs.SetAscent( 100 );
+ CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS == aRhs failed", aLhs == aRhs );
+ CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+
+ aLhs.SetDescent( 100 );
+ aRhs.SetDescent( 100 );
+ CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS == aRhs failed", aLhs == aRhs );
+ CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
}
diff --git a/vcl/source/gdi/metric.cxx b/vcl/source/gdi/metric.cxx
index 1227a4a..df4d11d 100644
--- a/vcl/source/gdi/metric.cxx
+++ b/vcl/source/gdi/metric.cxx
@@ -123,11 +123,21 @@ long FontMetric::GetAscent() const
return mpImplMetric->GetAscent();
}
+void FontMetric::SetAscent( long nAscent )
+{
+ mpImplMetric->SetAscent( nAscent );
+}
+
long FontMetric::GetDescent() const
{
return mpImplMetric->GetDescent();
}
+void FontMetric::SetDescent( long nDescent )
+{
+ mpImplMetric->SetDescent( nDescent );
+}
+
long FontMetric::GetInternalLeading() const
{
return mpImplMetric->GetInternalLeading();
More information about the Libreoffice-commits
mailing list