From f45ff1a7147e6a9479c669f082dd74349c6bcb4b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 4 Aug 2020 09:22:10 +0200 Subject: loplugin:flatten in vcl Change-Id: I271cc67ecf34acbf0edbda960e33315fb6a1f9dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100041 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/source/outdev/bitmap.cxx | 222 ++++++++++++------------- vcl/source/outdev/font.cxx | 50 +++--- vcl/source/outdev/gradient.cxx | 164 +++++++++--------- vcl/source/outdev/hatch.cxx | 114 ++++++------- vcl/source/outdev/mask.cxx | 30 ++-- vcl/source/outdev/outdevstate.cxx | 54 +++--- vcl/source/outdev/rect.cxx | 58 +++---- vcl/source/outdev/textline.cxx | 340 +++++++++++++++++++------------------- 8 files changed, 516 insertions(+), 516 deletions(-) (limited to 'vcl/source/outdev') diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 508b7df307d3..58a096a79045 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -644,60 +644,60 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r aOutPt.AdjustY( -(aOutSz.Height() - 1) ); } - if (!aDstRect.Intersection(tools::Rectangle(aOutPt, aOutSz)).IsEmpty()) - { - static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA"); - bool bTryDirectPaint(!pDisableNative && !bHMirr && !bVMirr); + if (aDstRect.Intersection(tools::Rectangle(aOutPt, aOutSz)).IsEmpty()) + return; - if (bTryDirectPaint) - { - Point aRelPt = aOutPt + Point(mnOutOffX, mnOutOffY); - SalTwoRect aTR( - rSrcPtPixel.X(), rSrcPtPixel.Y(), - rSrcSizePixel.Width(), rSrcSizePixel.Height(), - aRelPt.X(), aRelPt.Y(), - aOutSz.Width(), aOutSz.Height()); + static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA"); + bool bTryDirectPaint(!pDisableNative && !bHMirr && !bVMirr); - SalBitmap* pSalSrcBmp = rBmp.ImplGetSalBitmap().get(); - SalBitmap* pSalAlphaBmp = rAlpha.ImplGetSalBitmap().get(); + if (bTryDirectPaint) + { + Point aRelPt = aOutPt + Point(mnOutOffX, mnOutOffY); + SalTwoRect aTR( + rSrcPtPixel.X(), rSrcPtPixel.Y(), + rSrcSizePixel.Width(), rSrcSizePixel.Height(), + aRelPt.X(), aRelPt.Y(), + aOutSz.Width(), aOutSz.Height()); - // #i83087# Naturally, system alpha blending (SalGraphics::DrawAlphaBitmap) cannot work - // with separate alpha VDev + SalBitmap* pSalSrcBmp = rBmp.ImplGetSalBitmap().get(); + SalBitmap* pSalAlphaBmp = rAlpha.ImplGetSalBitmap().get(); - // try to blend the alpha bitmap with the alpha virtual device - if (mpAlphaVDev) + // #i83087# Naturally, system alpha blending (SalGraphics::DrawAlphaBitmap) cannot work + // with separate alpha VDev + + // try to blend the alpha bitmap with the alpha virtual device + if (mpAlphaVDev) + { + Bitmap aAlphaBitmap( mpAlphaVDev->GetBitmap( aRelPt, aOutSz ) ); + if (SalBitmap* pSalAlphaBmp2 = aAlphaBitmap.ImplGetSalBitmap().get()) { - Bitmap aAlphaBitmap( mpAlphaVDev->GetBitmap( aRelPt, aOutSz ) ); - if (SalBitmap* pSalAlphaBmp2 = aAlphaBitmap.ImplGetSalBitmap().get()) + if (mpGraphics->BlendAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, *pSalAlphaBmp2, this)) { - if (mpGraphics->BlendAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, *pSalAlphaBmp2, this)) - { - mpAlphaVDev->BlendBitmap(aTR, rAlpha); - return; - } - } - } - else - { - if (mpGraphics->DrawAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, this)) + mpAlphaVDev->BlendBitmap(aTR, rAlpha); return; + } } } + else + { + if (mpGraphics->DrawAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, this)) + return; + } + } - // we need to make sure OpenGL never reaches this slow code path + // we need to make sure OpenGL never reaches this slow code path - assert(!SkiaHelper::isVCLSkiaEnabled()); + assert(!SkiaHelper::isVCLSkiaEnabled()); #if HAVE_FEATURE_OPENGL - assert(!OpenGLHelper::isVCLOpenGLEnabled()); + assert(!OpenGLHelper::isVCLOpenGLEnabled()); #endif - tools::Rectangle aBmpRect(Point(), rBmp.GetSizePixel()); - if (!aBmpRect.Intersection(tools::Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty()) - { - Point auxOutPt(LogicToPixel(rDestPt)); - Size auxOutSz(LogicToPixel(rDestSize)); + tools::Rectangle aBmpRect(Point(), rBmp.GetSizePixel()); + if (!aBmpRect.Intersection(tools::Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty()) + { + Point auxOutPt(LogicToPixel(rDestPt)); + Size auxOutSz(LogicToPixel(rDestSize)); - DrawDeviceAlphaBitmapSlowPath(rBmp, rAlpha, aDstRect, aBmpRect, auxOutSz, auxOutPt); - } + DrawDeviceAlphaBitmapSlowPath(rBmp, rAlpha, aDstRect, aBmpRect, auxOutSz, auxOutPt); } } @@ -1350,88 +1350,88 @@ void OutputDevice::DrawTransformedBitmapEx( return; } - if(!aVisibleRange.isEmpty()) - { - BitmapEx aTransformed(rBitmapEx); + if(aVisibleRange.isEmpty()) + return; - // #122923# when the result needs an alpha channel due to being rotated or sheared - // and thus uncovering areas, add these channels so that the own transformer (used - // in getTransformed) also creates a transformed alpha channel - if(!aTransformed.IsTransparent() && (bSheared || bRotated)) - { - // parts will be uncovered, extend aTransformed with a mask bitmap - const Bitmap aContent(aTransformed.GetBitmap()); + BitmapEx aTransformed(rBitmapEx); - AlphaMask aMaskBmp(aContent.GetSizePixel()); - aMaskBmp.Erase(0); + // #122923# when the result needs an alpha channel due to being rotated or sheared + // and thus uncovering areas, add these channels so that the own transformer (used + // in getTransformed) also creates a transformed alpha channel + if(!aTransformed.IsTransparent() && (bSheared || bRotated)) + { + // parts will be uncovered, extend aTransformed with a mask bitmap + const Bitmap aContent(aTransformed.GetBitmap()); - aTransformed = BitmapEx(aContent, aMaskBmp); - } + AlphaMask aMaskBmp(aContent.GetSizePixel()); + aMaskBmp.Erase(0); - // Remove scaling from aFulltransform: we transform due to shearing or rotation, scaling - // will happen according to aDestSize. - basegfx::B2DVector aFullScale, aFullTranslate; - double fFullRotate, fFullShearX; - aFullTransform.decompose(aFullScale, aFullTranslate, fFullRotate, fFullShearX); - // Require positive scaling, negative scaling would loose horizontal or vertical flip. - if (aFullScale.getX() > 0 && aFullScale.getY() > 0) - { - basegfx::B2DHomMatrix aTransform = basegfx::utils::createScaleB2DHomMatrix( - rOriginalSizePixel.getWidth() / aFullScale.getX(), - rOriginalSizePixel.getHeight() / aFullScale.getY()); - aFullTransform *= aTransform; - } + aTransformed = BitmapEx(aContent, aMaskBmp); + } - double fSourceRatio = 1.0; - if (rOriginalSizePixel.getHeight() != 0) - { - fSourceRatio = rOriginalSizePixel.getWidth() / rOriginalSizePixel.getHeight(); - } - double fTargetRatio = 1.0; - if (aFullScale.getY() != 0) - { - fTargetRatio = aFullScale.getX() / aFullScale.getY(); - } - bool bAspectRatioKept = rtl::math::approxEqual(fSourceRatio, fTargetRatio); - if (bSheared || !bAspectRatioKept) - { - // Not only rotation, or scaling does not keep aspect ratio. - aTransformed = aTransformed.getTransformed( - aFullTransform, - aVisibleRange, - fMaximumArea); - } - else + // Remove scaling from aFulltransform: we transform due to shearing or rotation, scaling + // will happen according to aDestSize. + basegfx::B2DVector aFullScale, aFullTranslate; + double fFullRotate, fFullShearX; + aFullTransform.decompose(aFullScale, aFullTranslate, fFullRotate, fFullShearX); + // Require positive scaling, negative scaling would loose horizontal or vertical flip. + if (aFullScale.getX() > 0 && aFullScale.getY() > 0) + { + basegfx::B2DHomMatrix aTransform = basegfx::utils::createScaleB2DHomMatrix( + rOriginalSizePixel.getWidth() / aFullScale.getX(), + rOriginalSizePixel.getHeight() / aFullScale.getY()); + aFullTransform *= aTransform; + } + + double fSourceRatio = 1.0; + if (rOriginalSizePixel.getHeight() != 0) + { + fSourceRatio = rOriginalSizePixel.getWidth() / rOriginalSizePixel.getHeight(); + } + double fTargetRatio = 1.0; + if (aFullScale.getY() != 0) + { + fTargetRatio = aFullScale.getX() / aFullScale.getY(); + } + bool bAspectRatioKept = rtl::math::approxEqual(fSourceRatio, fTargetRatio); + if (bSheared || !bAspectRatioKept) + { + // Not only rotation, or scaling does not keep aspect ratio. + aTransformed = aTransformed.getTransformed( + aFullTransform, + aVisibleRange, + fMaximumArea); + } + else + { + // Just rotation, can do that directly. + fFullRotate = fmod(fFullRotate * -1, F_2PI); + if (fFullRotate < 0) { - // Just rotation, can do that directly. - fFullRotate = fmod(fFullRotate * -1, F_2PI); - if (fFullRotate < 0) - { - fFullRotate += F_2PI; - } - long nAngle10 = basegfx::fround(basegfx::rad2deg(fFullRotate) * 10); - aTransformed.Rotate(nAngle10, COL_TRANSPARENT); + fFullRotate += F_2PI; } - basegfx::B2DRange aTargetRange(0.0, 0.0, 1.0, 1.0); + long nAngle10 = basegfx::fround(basegfx::rad2deg(fFullRotate) * 10); + aTransformed.Rotate(nAngle10, COL_TRANSPARENT); + } + basegfx::B2DRange aTargetRange(0.0, 0.0, 1.0, 1.0); - // get logic object target range - aTargetRange.transform(rTransformation); + // get logic object target range + aTargetRange.transform(rTransformation); - // get from unified/relative VisibleRange to logoc one - aVisibleRange.transform( - basegfx::utils::createScaleTranslateB2DHomMatrix( - aTargetRange.getRange(), - aTargetRange.getMinimum())); + // get from unified/relative VisibleRange to logoc one + aVisibleRange.transform( + basegfx::utils::createScaleTranslateB2DHomMatrix( + aTargetRange.getRange(), + aTargetRange.getMinimum())); - // extract point and size; do not remove size, the bitmap may have been prepared reduced by purpose - // #i124580# the correct DestSize needs to be calculated based on MaxXY values - const Point aDestPt(basegfx::fround(aVisibleRange.getMinX()), basegfx::fround(aVisibleRange.getMinY())); - const Size aDestSize( - basegfx::fround(aVisibleRange.getMaxX()) - aDestPt.X(), - basegfx::fround(aVisibleRange.getMaxY()) - aDestPt.Y()); + // extract point and size; do not remove size, the bitmap may have been prepared reduced by purpose + // #i124580# the correct DestSize needs to be calculated based on MaxXY values + const Point aDestPt(basegfx::fround(aVisibleRange.getMinX()), basegfx::fround(aVisibleRange.getMinY())); + const Size aDestSize( + basegfx::fround(aVisibleRange.getMaxX()) - aDestPt.X(), + basegfx::fround(aVisibleRange.getMaxY()) - aDestPt.Y()); - DrawBitmapEx(aDestPt, aDestSize, aTransformed); - } + DrawBitmapEx(aDestPt, aDestSize, aTransformed); } void OutputDevice::DrawShadowBitmapEx( diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index b7d8bfeeba7c..e5b8a9fbc1bf 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -525,18 +525,18 @@ void OutputDevice::ImplClearAllFontData(bool bNewFontLists) // clear global font lists to have them updated pSVData->maGDIData.mxScreenFontCache->Invalidate(); - if ( bNewFontLists ) + if ( !bNewFontLists ) + return; + + pSVData->maGDIData.mxScreenFontList->Clear(); + vcl::Window * pFrame = pSVData->maFrameData.mpFirstFrame; + if ( pFrame ) { - pSVData->maGDIData.mxScreenFontList->Clear(); - vcl::Window * pFrame = pSVData->maFrameData.mpFirstFrame; - if ( pFrame ) + if ( pFrame->AcquireGraphics() ) { - if ( pFrame->AcquireGraphics() ) - { - OutputDevice *pDevice = pFrame; - pDevice->mpGraphics->ClearDevFontCache(); - pDevice->mpGraphics->GetDevFontList(pFrame->mpWindowImpl->mpFrameData->mxFontCollection.get()); - } + OutputDevice *pDevice = pFrame; + pDevice->mpGraphics->ClearDevFontCache(); + pDevice->mpGraphics->GetDevFontList(pFrame->mpWindowImpl->mpFrameData->mxFontCollection.get()); } } } @@ -908,23 +908,23 @@ vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLan void OutputDevice::ImplInitFontList() const { + if( mxFontCollection->Count() ) + return; + + if( !(mpGraphics || AcquireGraphics()) ) + return; + + SAL_INFO( "vcl.gdi", "OutputDevice::ImplInitFontList()" ); + mpGraphics->GetDevFontList(mxFontCollection.get()); + + // There is absolutely no way there should be no fonts available on the device if( !mxFontCollection->Count() ) { - if( mpGraphics || AcquireGraphics() ) - { - SAL_INFO( "vcl.gdi", "OutputDevice::ImplInitFontList()" ); - mpGraphics->GetDevFontList(mxFontCollection.get()); - - // There is absolutely no way there should be no fonts available on the device - if( !mxFontCollection->Count() ) - { - OUString aError( "Application error: no fonts and no vcl resource found on your system" ); - OUString aResStr(VclResId(SV_ACCESSERROR_NO_FONTS)); - if (!aResStr.isEmpty()) - aError = aResStr; - Application::Abort(aError); - } - } + OUString aError( "Application error: no fonts and no vcl resource found on your system" ); + OUString aResStr(VclResId(SV_ACCESSERROR_NO_FONTS)); + if (!aResStr.isEmpty()) + aError = aResStr; + Application::Abort(aError); } } diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx index 2e8406714daf..8919c474ba65 100644 --- a/vcl/source/outdev/gradient.cxx +++ b/vcl/source/outdev/gradient.cxx @@ -176,70 +176,70 @@ void OutputDevice::DrawGradientToMetafile ( const tools::PolyPolygon& rPolyPoly, if ( !mpMetaFile ) return; - if ( rPolyPoly.Count() && rPolyPoly[ 0 ].GetSize() ) + if ( !(rPolyPoly.Count() && rPolyPoly[ 0 ].GetSize()) ) + return; + + Gradient aGradient( rGradient ); + + if ( mnDrawMode & DrawModeFlags::GrayGradient ) { - Gradient aGradient( rGradient ); + SetGrayscaleColors( aGradient ); + } - if ( mnDrawMode & DrawModeFlags::GrayGradient ) - { - SetGrayscaleColors( aGradient ); - } + const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() ); - const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() ); + if ( rPolyPoly.IsRect() ) + { + mpMetaFile->AddAction( new MetaGradientAction( aBoundRect, aGradient ) ); + } + else + { + mpMetaFile->AddAction( new MetaCommentAction( "XGRAD_SEQ_BEGIN" ) ); + mpMetaFile->AddAction( new MetaGradientExAction( rPolyPoly, rGradient ) ); - if ( rPolyPoly.IsRect() ) - { - mpMetaFile->AddAction( new MetaGradientAction( aBoundRect, aGradient ) ); - } - else - { - mpMetaFile->AddAction( new MetaCommentAction( "XGRAD_SEQ_BEGIN" ) ); - mpMetaFile->AddAction( new MetaGradientExAction( rPolyPoly, rGradient ) ); + ClipAndDrawGradientMetafile ( rGradient, rPolyPoly ); - ClipAndDrawGradientMetafile ( rGradient, rPolyPoly ); + mpMetaFile->AddAction( new MetaCommentAction( "XGRAD_SEQ_END" ) ); + } - mpMetaFile->AddAction( new MetaCommentAction( "XGRAD_SEQ_END" ) ); - } + if( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) + return; - if( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) - return; + // Clip and then draw the gradient + if( tools::Rectangle( PixelToLogic( Point() ), GetOutputSize() ).IsEmpty() ) + return; - // Clip and then draw the gradient - if( !tools::Rectangle( PixelToLogic( Point() ), GetOutputSize() ).IsEmpty() ) - { - // convert rectangle to pixels - tools::Rectangle aRect( ImplLogicToDevicePixel( aBoundRect ) ); - aRect.Justify(); + // convert rectangle to pixels + tools::Rectangle aRect( ImplLogicToDevicePixel( aBoundRect ) ); + aRect.Justify(); - // do nothing if the rectangle is empty - if ( !aRect.IsEmpty() ) - { - if( !mbOutputClipped ) - { - // calculate step count if necessary - if ( !aGradient.GetSteps() ) - aGradient.SetSteps( GRADIENT_DEFAULT_STEPCOUNT ); + // do nothing if the rectangle is empty + if ( aRect.IsEmpty() ) + return; - if ( rPolyPoly.IsRect() ) - { - // because we draw with no border line, we have to expand gradient - // rect to avoid missing lines on the right and bottom edge - aRect.AdjustLeft( -1 ); - aRect.AdjustTop( -1 ); - aRect.AdjustRight( 1 ); - aRect.AdjustBottom( 1 ); - } + if( mbOutputClipped ) + return; - // if the clipping polypolygon is a rectangle, then it's the same size as the bounding of the - // polypolygon, so pass in a NULL for the clipping parameter - if( aGradient.GetStyle() == GradientStyle::Linear || rGradient.GetStyle() == GradientStyle::Axial ) - DrawLinearGradientToMetafile( aRect, aGradient ); - else - DrawComplexGradientToMetafile( aRect, aGradient ); - } - } - } + // calculate step count if necessary + if ( !aGradient.GetSteps() ) + aGradient.SetSteps( GRADIENT_DEFAULT_STEPCOUNT ); + + if ( rPolyPoly.IsRect() ) + { + // because we draw with no border line, we have to expand gradient + // rect to avoid missing lines on the right and bottom edge + aRect.AdjustLeft( -1 ); + aRect.AdjustTop( -1 ); + aRect.AdjustRight( 1 ); + aRect.AdjustBottom( 1 ); } + + // if the clipping polypolygon is a rectangle, then it's the same size as the bounding of the + // polypolygon, so pass in a NULL for the clipping parameter + if( aGradient.GetStyle() == GradientStyle::Linear || rGradient.GetStyle() == GradientStyle::Axial ) + DrawLinearGradientToMetafile( aRect, aGradient ); + else + DrawComplexGradientToMetafile( aRect, aGradient ); } namespace @@ -592,26 +592,26 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, } // we should draw last inner Polygon if we output PolyPolygon - if( xPolyPoly ) - { - const tools::Polygon& rPoly = xPolyPoly->GetObject( 1 ); + if( !xPolyPoly ) + return; - if( !rPoly.GetBoundRect().IsEmpty() ) - { - // #107349# Paint last polygon with end color only if loop - // has generated output. Otherwise, the current - // (i.e. start) color is taken, to generate _any_ output. - if( bPaintLastPolygon ) - { - nRed = GetGradientColorValue( nEndRed ); - nGreen = GetGradientColorValue( nEndGreen ); - nBlue = GetGradientColorValue( nEndBlue ); - } + const tools::Polygon& rPoly = xPolyPoly->GetObject( 1 ); - mpGraphics->SetFillColor( Color( nRed, nGreen, nBlue ) ); - ImplDrawPolygon( rPoly, pClixPolyPoly ); - } + if( rPoly.GetBoundRect().IsEmpty() ) + return; + + // #107349# Paint last polygon with end color only if loop + // has generated output. Otherwise, the current + // (i.e. start) color is taken, to generate _any_ output. + if( bPaintLastPolygon ) + { + nRed = GetGradientColorValue( nEndRed ); + nGreen = GetGradientColorValue( nEndGreen ); + nBlue = GetGradientColorValue( nEndBlue ); } + + mpGraphics->SetFillColor( Color( nRed, nGreen, nBlue ) ); + ImplDrawPolygon( rPoly, pClixPolyPoly ); } void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, @@ -916,21 +916,21 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, const tools::Polygon& rPoly = xPolyPoly->GetObject( 1 ); - if( !rPoly.GetBoundRect().IsEmpty() ) - { - // #107349# Paint last polygon with end color only if loop - // has generated output. Otherwise, the current - // (i.e. start) color is taken, to generate _any_ output. - if( bPaintLastPolygon ) - { - nRed = GetGradientColorValue( nEndRed ); - nGreen = GetGradientColorValue( nEndGreen ); - nBlue = GetGradientColorValue( nEndBlue ); - } + if( rPoly.GetBoundRect().IsEmpty() ) + return; - mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); - mpMetaFile->AddAction( new MetaPolygonAction( rPoly ) ); + // #107349# Paint last polygon with end color only if loop + // has generated output. Otherwise, the current + // (i.e. start) color is taken, to generate _any_ output. + if( bPaintLastPolygon ) + { + nRed = GetGradientColorValue( nEndRed ); + nGreen = GetGradientColorValue( nEndGreen ); + nBlue = GetGradientColorValue( nEndBlue ); } + + mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); + mpMetaFile->AddAction( new MetaPolygonAction( rPoly ) ); } long OutputDevice::GetGradientStepCount( long nMinRect ) diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx index c5cba12778e7..5f9396394a27 100644 --- a/vcl/source/outdev/hatch.cxx +++ b/vcl/source/outdev/hatch.cxx @@ -141,39 +141,52 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& { assert(!is_double_buffered_window()); - if(rPolyPoly.Count()) - { - // #i115630# DrawHatch does not work with beziers included in the polypolygon, take care of that - bool bIsCurve(false); + if(!rPolyPoly.Count()) + return; - for(sal_uInt16 a(0); !bIsCurve && a < rPolyPoly.Count(); a++) + // #i115630# DrawHatch does not work with beziers included in the polypolygon, take care of that + bool bIsCurve(false); + + for(sal_uInt16 a(0); !bIsCurve && a < rPolyPoly.Count(); a++) + { + if(rPolyPoly[a].HasFlags()) { - if(rPolyPoly[a].HasFlags()) - { - bIsCurve = true; - } + bIsCurve = true; } + } - if(bIsCurve) - { - OSL_ENSURE(false, "DrawHatch does *not* support curves, falling back to AdaptiveSubdivide()..."); - tools::PolyPolygon aPolyPoly; + if(bIsCurve) + { + OSL_ENSURE(false, "DrawHatch does *not* support curves, falling back to AdaptiveSubdivide()..."); + tools::PolyPolygon aPolyPoly; - rPolyPoly.AdaptiveSubdivide(aPolyPoly); - DrawHatch(aPolyPoly, rHatch, bMtf); + rPolyPoly.AdaptiveSubdivide(aPolyPoly); + DrawHatch(aPolyPoly, rHatch, bMtf); + } + else + { + tools::Rectangle aRect( rPolyPoly.GetBoundRect() ); + const long nLogPixelWidth = ImplDevicePixelToLogicWidth( 1 ); + const long nWidth = ImplDevicePixelToLogicWidth( std::max( ImplLogicWidthToDevicePixel( rHatch.GetDistance() ), 3L ) ); + std::unique_ptr pPtBuffer(new Point[ HATCH_MAXPOINTS ]); + Point aPt1, aPt2, aEndPt1; + Size aInc; + + // Single hatch + aRect.AdjustLeft( -nLogPixelWidth ); aRect.AdjustTop( -nLogPixelWidth ); aRect.AdjustRight(nLogPixelWidth ); aRect.AdjustBottom(nLogPixelWidth ); + CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 ); + do + { + DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); + aPt1.AdjustX(aInc.Width() ); aPt1.AdjustY(aInc.Height() ); + aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); } - else + while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); + + if( ( rHatch.GetStyle() == HatchStyle::Double ) || ( rHatch.GetStyle() == HatchStyle::Triple ) ) { - tools::Rectangle aRect( rPolyPoly.GetBoundRect() ); - const long nLogPixelWidth = ImplDevicePixelToLogicWidth( 1 ); - const long nWidth = ImplDevicePixelToLogicWidth( std::max( ImplLogicWidthToDevicePixel( rHatch.GetDistance() ), 3L ) ); - std::unique_ptr pPtBuffer(new Point[ HATCH_MAXPOINTS ]); - Point aPt1, aPt2, aEndPt1; - Size aInc; - - // Single hatch - aRect.AdjustLeft( -nLogPixelWidth ); aRect.AdjustTop( -nLogPixelWidth ); aRect.AdjustRight(nLogPixelWidth ); aRect.AdjustBottom(nLogPixelWidth ); - CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 ); + // Double hatch + CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900, aPt1, aPt2, aInc, aEndPt1 ); do { DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); @@ -182,10 +195,10 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& } while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - if( ( rHatch.GetStyle() == HatchStyle::Double ) || ( rHatch.GetStyle() == HatchStyle::Triple ) ) + if( rHatch.GetStyle() == HatchStyle::Triple ) { - // Double hatch - CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900, aPt1, aPt2, aInc, aEndPt1 ); + // Triple hatch + CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450, aPt1, aPt2, aInc, aEndPt1 ); do { DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); @@ -193,19 +206,6 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); } while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - - if( rHatch.GetStyle() == HatchStyle::Triple ) - { - // Triple hatch - CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450, aPt1, aPt2, aInc, aEndPt1 ); - do - { - DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); - aPt1.AdjustX(aInc.Width() ); aPt1.AdjustY(aInc.Height() ); - aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); - } - while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - } } } } @@ -380,23 +380,23 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol } } - if( nPCounter > 1 ) - { - qsort( pPtBuffer, nPCounter, sizeof( Point ), HatchCmpFnc ); + if( nPCounter <= 1 ) + return; - if( nPCounter & 1 ) - nPCounter--; + qsort( pPtBuffer, nPCounter, sizeof( Point ), HatchCmpFnc ); - if( bMtf ) - { - for( long i = 0; i < nPCounter; i += 2 ) - mpMetaFile->AddAction( new MetaLineAction( pPtBuffer[ i ], pPtBuffer[ i + 1 ] ) ); - } - else - { - for( long i = 0; i < nPCounter; i += 2 ) - DrawHatchLine_DrawLine(pPtBuffer[i], pPtBuffer[i+1]); - } + if( nPCounter & 1 ) + nPCounter--; + + if( bMtf ) + { + for( long i = 0; i < nPCounter; i += 2 ) + mpMetaFile->AddAction( new MetaLineAction( pPtBuffer[ i ], pPtBuffer[ i + 1 ] ) ); + } + else + { + for( long i = 0; i < nPCounter; i += 2 ) + DrawHatchLine_DrawLine(pPtBuffer[i], pPtBuffer[i+1]); } } diff --git a/vcl/source/outdev/mask.cxx b/vcl/source/outdev/mask.cxx index 209389cfbb56..90b3cbc1b0e5 100644 --- a/vcl/source/outdev/mask.cxx +++ b/vcl/source/outdev/mask.cxx @@ -134,21 +134,21 @@ void OutputDevice::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, } // TODO: Use mask here - if( mpAlphaVDev ) - { - const Bitmap& rAlphaMask( rMask.CreateMask( rMaskColor ) ); - - // #i25167# Restrict mask painting to _opaque_ areas - // of the mask, otherwise we spoil areas where no - // bitmap content was ever visible. Interestingly - // enough, this can be achieved by taking the mask as - // the transparency mask of itself - mpAlphaVDev->DrawBitmapEx( rDestPt, - rDestSize, - rSrcPtPixel, - rSrcSizePixel, - BitmapEx( rAlphaMask, rMask ) ); - } + if( !mpAlphaVDev ) + return; + + const Bitmap& rAlphaMask( rMask.CreateMask( rMaskColor ) ); + + // #i25167# Restrict mask painting to _opaque_ areas + // of the mask, otherwise we spoil areas where no + // bitmap content was ever visible. Interestingly + // enough, this can be achieved by taking the mask as + // the transparency mask of itself + mpAlphaVDev->DrawBitmapEx( rDestPt, + rDestSize, + rSrcPtPixel, + rSrcSizePixel, + BitmapEx( rAlphaMask, rMask ) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index a9ca52d9449b..804ba883c210 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -516,37 +516,37 @@ void OutputDevice::SetFont( const vcl::Font& rNewFont ) mpMetaFile->AddAction( new MetaTextFillColorAction( aFont.GetFillColor(), !aFont.IsTransparent() ) ); } - if ( !maFont.IsSameInstance( aFont ) ) + if ( maFont.IsSameInstance( aFont ) ) + return; + + // Optimization MT/HDU: COL_TRANSPARENT means SetFont should ignore the font color, + // because SetTextColor() is used for this. + // #i28759# maTextColor might have been changed behind our back, commit then, too. + if( aFont.GetColor() != COL_TRANSPARENT + && (aFont.GetColor() != maFont.GetColor() || aFont.GetColor() != maTextColor ) ) { - // Optimization MT/HDU: COL_TRANSPARENT means SetFont should ignore the font color, - // because SetTextColor() is used for this. - // #i28759# maTextColor might have been changed behind our back, commit then, too. - if( aFont.GetColor() != COL_TRANSPARENT - && (aFont.GetColor() != maFont.GetColor() || aFont.GetColor() != maTextColor ) ) - { - maTextColor = aFont.GetColor(); - mbInitTextColor = true; - if( mpMetaFile ) - mpMetaFile->AddAction( new MetaTextColorAction( aFont.GetColor() ) ); - } - maFont = aFont; - mbNewFont = true; + maTextColor = aFont.GetColor(); + mbInitTextColor = true; + if( mpMetaFile ) + mpMetaFile->AddAction( new MetaTextColorAction( aFont.GetColor() ) ); + } + maFont = aFont; + mbNewFont = true; - if( mpAlphaVDev ) - { - // #i30463# - // Since SetFont might change the text color, apply that only - // selectively to alpha vdev (which normally paints opaque text - // with COL_BLACK) - if( aFont.GetColor() != COL_TRANSPARENT ) - { - mpAlphaVDev->SetTextColor( COL_BLACK ); - aFont.SetColor( COL_TRANSPARENT ); - } + if( !mpAlphaVDev ) + return; - mpAlphaVDev->SetFont( aFont ); - } + // #i30463# + // Since SetFont might change the text color, apply that only + // selectively to alpha vdev (which normally paints opaque text + // with COL_BLACK) + if( aFont.GetColor() != COL_TRANSPARENT ) + { + mpAlphaVDev->SetTextColor( COL_BLACK ); + aFont.SetColor( COL_TRANSPARENT ); } + + mpAlphaVDev->SetFont( aFont ); } diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index 2d8fe4524155..a9bc729c002b 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -394,40 +394,40 @@ BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix ) void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect ) { - if( ( rTwoRect.mnSrcX < rValidSrcRect.Left() ) || ( rTwoRect.mnSrcX >= rValidSrcRect.Right() ) || + if( !(( rTwoRect.mnSrcX < rValidSrcRect.Left() ) || ( rTwoRect.mnSrcX >= rValidSrcRect.Right() ) || ( rTwoRect.mnSrcY < rValidSrcRect.Top() ) || ( rTwoRect.mnSrcY >= rValidSrcRect.Bottom() ) || ( ( rTwoRect.mnSrcX + rTwoRect.mnSrcWidth ) > rValidSrcRect.Right() ) || - ( ( rTwoRect.mnSrcY + rTwoRect.mnSrcHeight ) > rValidSrcRect.Bottom() ) ) - { - const tools::Rectangle aSourceRect( Point( rTwoRect.mnSrcX, rTwoRect.mnSrcY ), - Size( rTwoRect.mnSrcWidth, rTwoRect.mnSrcHeight ) ); - tools::Rectangle aCropRect( aSourceRect ); + ( ( rTwoRect.mnSrcY + rTwoRect.mnSrcHeight ) > rValidSrcRect.Bottom() )) ) + return; - aCropRect.Intersection( rValidSrcRect ); + const tools::Rectangle aSourceRect( Point( rTwoRect.mnSrcX, rTwoRect.mnSrcY ), + Size( rTwoRect.mnSrcWidth, rTwoRect.mnSrcHeight ) ); + tools::Rectangle aCropRect( aSourceRect ); - if( aCropRect.IsEmpty() ) - { - rTwoRect.mnSrcWidth = rTwoRect.mnSrcHeight = rTwoRect.mnDestWidth = rTwoRect.mnDestHeight = 0; - } - else - { - const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? static_cast( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; - const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? static_cast( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + aCropRect.Intersection( rValidSrcRect ); - const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); - const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); - const long nDstX2 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Right() - rTwoRect.mnSrcX ) ); - const long nDstY2 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Bottom() - rTwoRect.mnSrcY ) ); - - rTwoRect.mnSrcX = aCropRect.Left(); - rTwoRect.mnSrcY = aCropRect.Top(); - rTwoRect.mnSrcWidth = aCropRect.GetWidth(); - rTwoRect.mnSrcHeight = aCropRect.GetHeight(); - rTwoRect.mnDestX = nDstX1; - rTwoRect.mnDestY = nDstY1; - rTwoRect.mnDestWidth = nDstX2 - nDstX1 + 1; - rTwoRect.mnDestHeight = nDstY2 - nDstY1 + 1; - } + if( aCropRect.IsEmpty() ) + { + rTwoRect.mnSrcWidth = rTwoRect.mnSrcHeight = rTwoRect.mnDestWidth = rTwoRect.mnDestHeight = 0; + } + else + { + const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? static_cast( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; + const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? static_cast( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + + const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); + const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); + const long nDstX2 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Right() - rTwoRect.mnSrcX ) ); + const long nDstY2 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Bottom() - rTwoRect.mnSrcY ) ); + + rTwoRect.mnSrcX = aCropRect.Left(); + rTwoRect.mnSrcY = aCropRect.Top(); + rTwoRect.mnSrcWidth = aCropRect.GetWidth(); + rTwoRect.mnSrcHeight = aCropRect.GetHeight(); + rTwoRect.mnDestX = nDstX1; + rTwoRect.mnDestY = nDstY1; + rTwoRect.mnDestWidth = nDstX2 - nDstX1 + 1; + rTwoRect.mnDestHeight = nDstY2 - nDstY1 + 1; } } diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index 6ade6113fc99..26866aaaeedb 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -330,176 +330,176 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, break; } - if ( nLineHeight ) + if ( !nLineHeight ) + return; + + if ( mbLineColor || mbInitLineColor ) { - if ( mbLineColor || mbInitLineColor ) - { - mpGraphics->SetLineColor(); - mbInitLineColor = true; - } - mpGraphics->SetFillColor( aColor ); - mbInitFillColor = true; + mpGraphics->SetLineColor(); + mbInitLineColor = true; + } + mpGraphics->SetFillColor( aColor ); + mbInitFillColor = true; - long nLeft = nDistX; + long nLeft = nDistX; - switch ( eTextLine ) + switch ( eTextLine ) + { + case LINESTYLE_SINGLE: + case LINESTYLE_BOLD: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + break; + case LINESTYLE_DOUBLE: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); + break; + case LINESTYLE_DOTTED: + case LINESTYLE_BOLDDOTTED: { - case LINESTYLE_SINGLE: - case LINESTYLE_BOLD: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - break; - case LINESTYLE_DOUBLE: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); - break; - case LINESTYLE_DOTTED: - case LINESTYLE_BOLDDOTTED: - { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; - long nTempWidth = nDotWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempWidth > nEnd ) - nTempWidth = nEnd-nLeft; + long nTempWidth = nDotWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) + { + if ( nLeft+nTempWidth > nEnd ) + nTempWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); - nLeft += nDotWidth*2; - } + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); + nLeft += nDotWidth*2; } - break; - case LINESTYLE_DASH: - case LINESTYLE_LONGDASH: - case LINESTYLE_BOLDDASH: - case LINESTYLE_BOLDLONGDASH: + } + break; + case LINESTYLE_DASH: + case LINESTYLE_LONGDASH: + case LINESTYLE_BOLDDASH: + case LINESTYLE_BOLDLONGDASH: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nMinDashWidth; + long nMinSpaceWidth; + long nSpaceWidth; + long nDashWidth; + if ( (eTextLine == LINESTYLE_LONGDASH) || + (eTextLine == LINESTYLE_BOLDLONGDASH) ) { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - - long nMinDashWidth; - long nMinSpaceWidth; - long nSpaceWidth; - long nDashWidth; - if ( (eTextLine == LINESTYLE_LONGDASH) || - (eTextLine == LINESTYLE_BOLDLONGDASH) ) - { - nMinDashWidth = nDotWidth*6; - nMinSpaceWidth = nDotWidth*2; - nDashWidth = 200; - nSpaceWidth = 100; - } - else - { - nMinDashWidth = nDotWidth*4; - nMinSpaceWidth = (nDotWidth*150)/100; - nDashWidth = 100; - nSpaceWidth = 50; - } - nDashWidth = ((nDashWidth*mnDPIX)+1270)/2540; - nSpaceWidth = ((nSpaceWidth*mnDPIX)+1270)/2540; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - if ( nSpaceWidth < nMinSpaceWidth ) - nSpaceWidth = nMinSpaceWidth; - - long nTempWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempWidth > nEnd ) - nTempWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); - nLeft += nDashWidth+nSpaceWidth; - } + nMinDashWidth = nDotWidth*6; + nMinSpaceWidth = nDotWidth*2; + nDashWidth = 200; + nSpaceWidth = 100; } - break; - case LINESTYLE_DASHDOT: - case LINESTYLE_BOLDDASHDOT: + else { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - - long nDashWidth = ((100*mnDPIX)+1270)/2540; - long nMinDashWidth = nDotWidth*4; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - - long nTempDotWidth = nDotWidth; - long nTempDashWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; + nMinDashWidth = nDotWidth*4; + nMinSpaceWidth = (nDotWidth*150)/100; + nDashWidth = 100; + nSpaceWidth = 50; + } + nDashWidth = ((nDashWidth*mnDPIX)+1270)/2540; + nSpaceWidth = ((nSpaceWidth*mnDPIX)+1270)/2540; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + if ( nSpaceWidth < nMinSpaceWidth ) + nSpaceWidth = nMinSpaceWidth; + + long nTempWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) + { + if ( nLeft+nTempWidth > nEnd ) + nTempWidth = nEnd-nLeft; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); + nLeft += nDashWidth+nSpaceWidth; + } + } + break; + case LINESTYLE_DASHDOT: + case LINESTYLE_BOLDDASHDOT: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nDashWidth = ((100*mnDPIX)+1270)/2540; + long nMinDashWidth = nDotWidth*4; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + + long nTempDotWidth = nDotWidth; + long nTempDashWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) + { + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; - if ( nLeft+nTempDashWidth > nEnd ) - nTempDashWidth = nEnd-nLeft; + if ( nLeft+nTempDashWidth > nEnd ) + nTempDashWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); - nLeft += nDashWidth+nDotWidth; - } + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); + nLeft += nDashWidth+nDotWidth; } - break; - case LINESTYLE_DASHDOTDOT: - case LINESTYLE_BOLDDASHDOTDOT: + } + break; + case LINESTYLE_DASHDOTDOT: + case LINESTYLE_BOLDDASHDOTDOT: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nDashWidth = ((100*mnDPIX)+1270)/2540; + long nMinDashWidth = nDotWidth*4; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + + long nTempDotWidth = nDotWidth; + long nTempDashWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - - long nDashWidth = ((100*mnDPIX)+1270)/2540; - long nMinDashWidth = nDotWidth*4; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - - long nTempDotWidth = nDotWidth; - long nTempDashWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; - if ( nLeft+nTempDashWidth > nEnd ) - nTempDashWidth = nEnd-nLeft; + if ( nLeft+nTempDashWidth > nEnd ) + nTempDashWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); - nLeft += nDashWidth+nDotWidth; - } + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); + nLeft += nDashWidth+nDotWidth; } - break; - default: - break; } + break; + default: + break; } } @@ -537,31 +537,31 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, break; } - if ( nLineHeight ) + if ( !nLineHeight ) + return; + + if ( mbLineColor || mbInitLineColor ) { - if ( mbLineColor || mbInitLineColor ) - { - mpGraphics->SetLineColor(); - mbInitLineColor = true; - } - mpGraphics->SetFillColor( aColor ); - mbInitFillColor = true; + mpGraphics->SetLineColor(); + mbInitLineColor = true; + } + mpGraphics->SetFillColor( aColor ); + mbInitFillColor = true; - const long& nLeft = nDistX; + const long& nLeft = nDistX; - switch ( eStrikeout ) - { - case STRIKEOUT_SINGLE: - case STRIKEOUT_BOLD: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - break; - case STRIKEOUT_DOUBLE: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); - break; - default: - break; - } + switch ( eStrikeout ) + { + case STRIKEOUT_SINGLE: + case STRIKEOUT_BOLD: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + break; + case STRIKEOUT_DOUBLE: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); + break; + default: + break; } } -- cgit v1.2.3