summaryrefslogtreecommitdiff
path: root/vcl/source/outdev/hatch.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 09:22:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 11:21:22 +0200
commitf45ff1a7147e6a9479c669f082dd74349c6bcb4b (patch)
tree9ec5eee03fe7bbc5e026318efd6dcca3502d4696 /vcl/source/outdev/hatch.cxx
parent58937aa4a50ecd681382f03331340da4c843b01e (diff)
loplugin:flatten in vcl
Change-Id: I271cc67ecf34acbf0edbda960e33315fb6a1f9dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100041 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/outdev/hatch.cxx')
-rw-r--r--vcl/source/outdev/hatch.cxx114
1 files changed, 57 insertions, 57 deletions
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<Point[]> 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<Point[]> 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]);
}
}