include/vcl/metric.hxx | 1 vcl/inc/impfont.hxx | 1 vcl/qa/cppunit/fontmetric.cxx | 7 ++++- vcl/source/gdi/metric.cxx | 5 ++++ vcl/source/outdev/font.cxx | 52 +++++++++++++++++++++--------------------- vcl/workben/svpclient.cxx | 19 +++++++++++++-- 6 files changed, 56 insertions(+), 29 deletions(-)
New commits: commit d9c20d142539b53b052937274efd2e576d0712ec Author: Chris Sherlock <[email protected]> Date: Thu Jan 14 08:33:12 2016 +1100 vcl: (workbench) check error status of socket writes Change-Id: I0825a4e1a0dc49d7ab2d74ad4b11cfb8baf973f7 diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx index 1d25daf..65d16c1 100644 --- a/vcl/workben/svpclient.cxx +++ b/vcl/workben/svpclient.cxx @@ -44,6 +44,7 @@ #include <math.h> #include <errno.h> +#include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> @@ -214,8 +215,22 @@ OString MyWin::processCommand( const OString& rCommand ) else { ssize_t nBytes = 0; - write( nSocket, rCommand.getStr(), rCommand.getLength() ); - write( nSocket, "\n", 1 ); + ssize_t fd = 0; + fd = write( nSocket, rCommand.getStr(), rCommand.getLength() ); + + if (fd == 0) + SAL_WARN("vcl", "Connection closed on other end"); + else if (fd < 0) + SAL_WARN("vcl", "Error writing to socket: " << strerror( errno )); + + fd = write( nSocket, "\n", 1 ); + + if (fd == 0) + SAL_WARN("vcl", "Connection closed on other end"); + else if (fd < 0) + SAL_WARN("vcl", "Error writing to socket: " << strerror( errno )); + + char buf[256]; do { commit a5bc28e073c2dd1eb8ad733687dc827e6bac31bd Author: Chris Sherlock <[email protected]> Date: Thu Jan 14 08:15:40 2016 +1100 vcl: Create mutator for line height attribute in FontMetric Mutator created for line height in attribute 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 get and set line height attribute - check equality operator on FontMetric after setting line height attribute Change-Id: I86dff217fa24850b5f9d04a17ddda464dfb0156a diff --git a/include/vcl/metric.hxx b/include/vcl/metric.hxx index 0a7d0e6..e4e6661 100644 --- a/include/vcl/metric.hxx +++ b/include/vcl/metric.hxx @@ -58,6 +58,7 @@ public: void SetDescent(long); void SetExternalLeading(long); void SetInternalLeading(long); + void SetLineHeight(long); bool IsScalable() const; bool IsFullstopCentered() const; diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx index 182f4e8..e0a1ca1 100644 --- a/vcl/inc/impfont.hxx +++ b/vcl/inc/impfont.hxx @@ -127,6 +127,7 @@ public: void SetDescent( long nDescent ) { mnDescent = nDescent; } void SetInternalLeading( long nIntLeading ) { mnIntLeading = nIntLeading; } void SetExternalLeading( long nExtLeading ) { mnExtLeading = nExtLeading; } + void SetLineHeight( long nHeight ) { mnLineHeight = nHeight; } bool IsScalable() const { return mbScalableFont; } bool IsFullstopCentered() const { return mbFullstopCentered; } diff --git a/vcl/qa/cppunit/fontmetric.cxx b/vcl/qa/cppunit/fontmetric.cxx index 07fc0e6..3093783 100644 --- a/vcl/qa/cppunit/fontmetric.cxx +++ b/vcl/qa/cppunit/fontmetric.cxx @@ -33,8 +33,8 @@ public: CPPUNIT_TEST(testScalableFlag); CPPUNIT_TEST(testFullstopCenteredFlag); CPPUNIT_TEST(testBuiltInFontFlag); - CPPUNIT_TEST(testEqualityOperator); CPPUNIT_TEST(testSpacings); + CPPUNIT_TEST(testEqualityOperator); CPPUNIT_TEST_SUITE_END(); }; @@ -83,6 +83,8 @@ void VclFontMetricTest::testSpacings() CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetDescent(), 0L ); CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetExternalLeading(), 0L ); CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetInternalLeading(), 0L ); + CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetLineHeight(), 0L ); + aFontMetric.SetAscent( 100 ); CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetAscent(), 100L ); @@ -95,6 +97,9 @@ void VclFontMetricTest::testSpacings() aFontMetric.SetInternalLeading( 100L ); CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetInternalLeading(), 100L ); + + aFontMetric.SetLineHeight( 100L ); + CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetLineHeight(), 100L ); } diff --git a/vcl/source/gdi/metric.cxx b/vcl/source/gdi/metric.cxx index df4d11d..1b7206f 100644 --- a/vcl/source/gdi/metric.cxx +++ b/vcl/source/gdi/metric.cxx @@ -163,6 +163,11 @@ long FontMetric::GetLineHeight() const return mpImplMetric->GetLineHeight(); } +void FontMetric::SetLineHeight( long nHeight ) +{ + mpImplMetric->SetLineHeight( nHeight ); +} + long FontMetric::GetSlant() const { return mpImplMetric->GetSlant(); diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index fe0255f..2165677 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -221,7 +221,7 @@ FontMetric OutputDevice::GetFontMetric() const aMetric.SetInternalLeading( ImplDevicePixelToLogicHeight( pFontAttributes->GetInternalLeading() + mnEmphasisAscent ) ); // OutputDevice has its own external leading function due to #i60945# aMetric.SetExternalLeading( ImplDevicePixelToLogicHeight( GetFontExtLeading() ) ); - aMetric.mpImplMetric->mnLineHeight = ImplDevicePixelToLogicHeight( pFontAttributes->GetAscent() + pFontAttributes->GetDescent() + mnEmphasisAscent + mnEmphasisDescent ); + aMetric.SetLineHeight( ImplDevicePixelToLogicHeight( pFontAttributes->GetAscent() + pFontAttributes->GetDescent() + mnEmphasisAscent + mnEmphasisDescent ) ); aMetric.mpImplMetric->mnSlant = ImplDevicePixelToLogicHeight( pFontAttributes->GetSlant() ); SAL_INFO("vcl.gdi.fontmetric", "OutputDevice::GetFontMetric:" << aMetric); @@ -1076,9 +1076,9 @@ bool OutputDevice::ImplNewFont() const if( pOldFontInstance ) mpFontCache->Release( pOldFontInstance ); - LogicalFontInstance* pFontEntry = mpFontInstance; + LogicalFontInstance* pFontInstance = mpFontInstance; - if (!pFontEntry) + if (!pFontInstance) { SAL_WARN("vcl.gdi", "OutputDevice::ImplNewFont(): no LogicalFontInstance, no Font"); return false; @@ -1086,28 +1086,28 @@ bool OutputDevice::ImplNewFont() const // mark when lower layers need to get involved mbNewFont = false; - if( pFontEntry != pOldFontInstance ) + if( pFontInstance != pOldFontInstance ) mbInitFont = true; // select font when it has not been initialized yet - if ( !pFontEntry->mbInit ) + if ( !pFontInstance->mbInit ) { InitFont(); // get metric data from device layers if ( pGraphics ) { - pFontEntry->mbInit = true; + pFontInstance->mbInit = true; - pFontEntry->maFontMetric.SetOrientation( sal::static_int_cast<short>(pFontEntry->maFontSelData.mnOrientation) ); - pGraphics->GetFontMetric( &(pFontEntry->maFontMetric) ); + pFontInstance->maFontMetric.SetOrientation( sal::static_int_cast<short>(pFontInstance->maFontSelData.mnOrientation) ); + pGraphics->GetFontMetric( &(pFontInstance->maFontMetric) ); - pFontEntry->maFontMetric.ImplInitTextLineSize( this ); - pFontEntry->maFontMetric.ImplInitAboveTextLineSize(); + pFontInstance->maFontMetric.ImplInitTextLineSize( this ); + pFontInstance->maFontMetric.ImplInitAboveTextLineSize(); - pFontEntry->mnLineHeight = pFontEntry->maFontMetric.GetAscent() + pFontEntry->maFontMetric.GetDescent(); + pFontInstance->mnLineHeight = pFontInstance->maFontMetric.GetAscent() + pFontInstance->maFontMetric.GetDescent(); - SetFontOrientation( pFontEntry ); + SetFontOrientation( pFontInstance ); } } @@ -1115,7 +1115,7 @@ bool OutputDevice::ImplNewFont() const if ( maFont.GetKerning() & FontKerning::FontSpecific ) { // TODO: test if physical font supports kerning and disable if not - if( pFontEntry->maFontMetric.IsKernable() ) + if( pFontInstance->maFontMetric.IsKernable() ) mbKerning = true; } else @@ -1132,7 +1132,7 @@ bool OutputDevice::ImplNewFont() const if ( maFont.GetEmphasisMark() & EMPHASISMARK_STYLE ) { FontEmphasisMark nEmphasisMark = ImplGetEmphasisMarkStyle( maFont ); - long nEmphasisHeight = (pFontEntry->mnLineHeight*250)/1000; + long nEmphasisHeight = (pFontInstance->mnLineHeight*250)/1000; if ( nEmphasisHeight < 1 ) nEmphasisHeight = 1; if ( nEmphasisMark & EMPHASISMARK_POS_BELOW ) @@ -1151,21 +1151,21 @@ bool OutputDevice::ImplNewFont() const else if ( eAlign == ALIGN_TOP ) { mnTextOffX = 0; - mnTextOffY = +pFontEntry->maFontMetric.GetAscent() + mnEmphasisAscent; - if ( pFontEntry->mnOrientation ) + mnTextOffY = +pFontInstance->maFontMetric.GetAscent() + mnEmphasisAscent; + if ( pFontInstance->mnOrientation ) { Point aOriginPt(0, 0); - aOriginPt.RotateAround( mnTextOffX, mnTextOffY, pFontEntry->mnOrientation ); + aOriginPt.RotateAround( mnTextOffX, mnTextOffY, pFontInstance->mnOrientation ); } } else // eAlign == ALIGN_BOTTOM { mnTextOffX = 0; - mnTextOffY = -pFontEntry->maFontMetric.GetDescent() + mnEmphasisDescent; - if ( pFontEntry->mnOrientation ) + mnTextOffY = -pFontInstance->maFontMetric.GetDescent() + mnEmphasisDescent; + if ( pFontInstance->mnOrientation ) { Point aOriginPt(0, 0); - aOriginPt.RotateAround( mnTextOffX, mnTextOffY, pFontEntry->mnOrientation ); + aOriginPt.RotateAround( mnTextOffX, mnTextOffY, pFontInstance->mnOrientation ); } } @@ -1179,7 +1179,7 @@ bool OutputDevice::ImplNewFont() const // #95414# fix for OLE objects which use scale factors very creatively if( mbMap && !aSize.Width() ) { - int nOrigWidth = pFontEntry->maFontMetric.GetWidth(); + int nOrigWidth = pFontInstance->maFontMetric.GetWidth(); float fStretch = (float)maMapRes.mnMapScNumX * maMapRes.mnMapScDenomY; fStretch /= (float)maMapRes.mnMapScNumY * maMapRes.mnMapScDenomX; int nNewWidth = (int)(nOrigWidth * fStretch + 0.5); @@ -1198,16 +1198,16 @@ bool OutputDevice::ImplNewFont() const return true; } -void OutputDevice::SetFontOrientation( LogicalFontInstance* const pFontEntry ) const +void OutputDevice::SetFontOrientation( LogicalFontInstance* const pFontInstance ) const { - if( pFontEntry->maFontSelData.mnOrientation && !pFontEntry->maFontMetric.GetOrientation() ) + if( pFontInstance->maFontSelData.mnOrientation && !pFontInstance->maFontMetric.GetOrientation() ) { - pFontEntry->mnOwnOrientation = sal::static_int_cast<short>(pFontEntry->maFontSelData.mnOrientation); - pFontEntry->mnOrientation = pFontEntry->mnOwnOrientation; + pFontInstance->mnOwnOrientation = sal::static_int_cast<short>(pFontInstance->maFontSelData.mnOrientation); + pFontInstance->mnOrientation = pFontInstance->mnOwnOrientation; } else { - pFontEntry->mnOrientation = pFontEntry->maFontMetric.GetOrientation(); + pFontInstance->mnOrientation = pFontInstance->maFontMetric.GetOrientation(); } } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
