vcl/inc/vcl/region.hxx | 16 +++---- vcl/source/control/edit.cxx | 3 - vcl/source/gdi/region.cxx | 90 ++++++++++++++++++-------------------------- 3 files changed, 47 insertions(+), 62 deletions(-)
New commits: commit 2d691f26c6d4fd6fac11559f9b5b854d306e137a Author: Daniel Bankston <daniel.dev.libreoff...@gmail.com> Date: Mon Apr 2 19:35:34 2012 -0500 Ignore return type of Region::Intersect Caller of Region::Intersect was not ignore the return value in a conditional, so I refactored the conditional to not depend on the return value of Intersect without affect the original functionality of the code. This usage of Intersect may be a possible defect and should be checked out. diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 7d03316..b3f7516 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -670,7 +670,8 @@ void Edit::ImplRepaint( xub_StrLen nStart, xub_StrLen nEnd, bool bLayout ) nIndex++; } i = nIndex; - if( aClip.Intersect( aRegion ) && nAttr ) + aClip.Intersect(aRegion); + if( nAttr ) { Font aFont = GetFont(); if ( nAttr & EXTTEXTINPUT_ATTR_UNDERLINE ) commit 93acb28e10760513b8bffd2c36dcbd68e75e57c7 Author: Daniel Bankston <daniel.dev.libreoff...@gmail.com> Date: Mon Apr 2 19:01:35 2012 -0500 fdo#44610 - EasyHack Since they always return sal_Bool values that are not used by any callers, I changed the Region class methods (both versions of each Union, Intersect, Exclude, XOr) from sal_Bool return type to void return type. diff --git a/vcl/inc/vcl/region.hxx b/vcl/inc/vcl/region.hxx index f21cca4..5d3eccd 100644 --- a/vcl/inc/vcl/region.hxx +++ b/vcl/inc/vcl/region.hxx @@ -99,14 +99,14 @@ public: void Move( long nHorzMove, long nVertMove ); void Scale( double fScaleX, double fScaleY ); - sal_Bool Union( const Rectangle& rRegion ); - sal_Bool Intersect( const Rectangle& rRegion ); - sal_Bool Exclude( const Rectangle& rRegion ); - sal_Bool XOr( const Rectangle& rRegion ); - sal_Bool Union( const Region& rRegion ); - sal_Bool Intersect( const Region& rRegion ); - sal_Bool Exclude( const Region& rRegion ); - sal_Bool XOr( const Region& rRegion ); + void Union( const Rectangle& rRegion ); + void Intersect( const Rectangle& rRegion ); + void Exclude( const Rectangle& rRegion ); + void XOr( const Rectangle& rRegion ); + void Union( const Region& rRegion ); + void Intersect( const Region& rRegion ); + void Exclude( const Region& rRegion ); + void XOr( const Region& rRegion ); RegionType GetType() const; sal_Bool IsEmpty() const { return GetType() == REGION_EMPTY; }; diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index fa8ee5c..ee975d0 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -1336,13 +1336,13 @@ void Region::Scale( double fScaleX, double fScaleY ) // ----------------------------------------------------------------------- -sal_Bool Region::Union( const Rectangle& rRect ) +void Region::Union( const Rectangle& rRect ) { DBG_CHKTHIS( Region, ImplDbgTestRegion ); // is rectangle empty? -> nothing to do if ( rRect.IsEmpty() ) - return sal_True; + return; if( HasPolyPolygon() ) { @@ -1353,7 +1353,7 @@ sal_Bool Region::Union( const Rectangle& rRect ) if( aThisPolyPoly.count() == 0 ) { *this = rRect; - return true; + return; } // get the other B2DPolyPolygon @@ -1363,7 +1363,7 @@ sal_Bool Region::Union( const Rectangle& rRect ) basegfx::B2DPolyPolygon aClip = basegfx::tools::solvePolygonOperationOr( aThisPolyPoly, aOtherPolyPoly ); *this = Region( aClip ); - return sal_True; + return; } ImplPolyPolyRegionToBandRegion(); @@ -1394,13 +1394,11 @@ sal_Bool Region::Union( const Rectangle& rRect ) delete mpImplRegion; mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); } - - return sal_True; } // ----------------------------------------------------------------------- -sal_Bool Region::Intersect( const Rectangle& rRect ) +void Region::Intersect( const Rectangle& rRect ) { DBG_CHKTHIS( Region, ImplDbgTestRegion ); @@ -1416,7 +1414,7 @@ sal_Bool Region::Intersect( const Rectangle& rRect ) delete mpImplRegion; } mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); - return sal_True; + return; } // #103137# Avoid banding for special cases @@ -1434,7 +1432,7 @@ sal_Bool Region::Intersect( const Rectangle& rRect ) // unnecessary banding mpImplRegion->mpPolyPoly->Clip( rRect ); - return sal_True; + return; } else if( mpImplRegion->mpB2DPolyPoly ) { @@ -1450,14 +1448,14 @@ sal_Bool Region::Intersect( const Rectangle& rRect ) basegfx::B2DRange( rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() ), true, false ); - return sal_True; + return; } else ImplPolyPolyRegionToBandRegion(); // is region empty? -> nothing to do! if ( mpImplRegion == &aImplEmptyRegion ) - return sal_True; + return; // get justified rectangle long nLeft = Min( rRect.Left(), rRect.Right() ); @@ -1478,7 +1476,7 @@ sal_Bool Region::Intersect( const Rectangle& rRect ) mpImplRegion->mpFirstBand->Union( nLeft, nRight ); mpImplRegion->mnRectCount = 1; - return sal_True; + return; } // no own instance data? -> make own copy! @@ -1521,19 +1519,17 @@ sal_Bool Region::Intersect( const Rectangle& rRect ) delete mpImplRegion; mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); } - - return sal_True; } // ----------------------------------------------------------------------- -sal_Bool Region::Exclude( const Rectangle& rRect ) +void Region::Exclude( const Rectangle& rRect ) { DBG_CHKTHIS( Region, ImplDbgTestRegion ); // is rectangle empty? -> nothing to do if ( rRect.IsEmpty() ) - return sal_True; + return; if( HasPolyPolygon() ) { @@ -1542,7 +1538,7 @@ sal_Bool Region::Exclude( const Rectangle& rRect ) aThisPolyPoly = basegfx::tools::prepareForPolygonOperation( aThisPolyPoly ); if( aThisPolyPoly.count() == 0 ) - return sal_True; + return; // get the other B2DPolyPolygon basegfx::B2DPolygon aRectPoly( basegfx::tools::createPolygonFromRect( basegfx::B2DRectangle( rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() ) ) ); @@ -1551,14 +1547,14 @@ sal_Bool Region::Exclude( const Rectangle& rRect ) basegfx::B2DPolyPolygon aClip = basegfx::tools::solvePolygonOperationDiff( aThisPolyPoly, aOtherPolyPoly ); *this = Region( aClip ); - return sal_True; + return; } ImplPolyPolyRegionToBandRegion(); // no instance data? -> create! if ( (mpImplRegion == &aImplEmptyRegion) || (mpImplRegion == &aImplNullRegion) ) - return sal_True; + return; // no own instance data? -> make own copy! if ( mpImplRegion->mnRefCount > 1 ) @@ -1582,19 +1578,17 @@ sal_Bool Region::Exclude( const Rectangle& rRect ) delete mpImplRegion; mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); } - - return sal_True; } // ----------------------------------------------------------------------- -sal_Bool Region::XOr( const Rectangle& rRect ) +void Region::XOr( const Rectangle& rRect ) { DBG_CHKTHIS( Region, ImplDbgTestRegion ); // is rectangle empty? -> nothing to do if ( rRect.IsEmpty() ) - return sal_True; + return; if( HasPolyPolygon() ) { @@ -1605,7 +1599,7 @@ sal_Bool Region::XOr( const Rectangle& rRect ) if( aThisPolyPoly.count() == 0 ) { *this = rRect; - return sal_True; + return; } // get the other B2DPolyPolygon @@ -1615,7 +1609,7 @@ sal_Bool Region::XOr( const Rectangle& rRect ) basegfx::B2DPolyPolygon aClip = basegfx::tools::solvePolygonOperationXor( aThisPolyPoly, aOtherPolyPoly ); *this = Region( aClip ); - return sal_True; + return; } ImplPolyPolyRegionToBandRegion(); @@ -1646,8 +1640,6 @@ sal_Bool Region::XOr( const Rectangle& rRect ) delete mpImplRegion; mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); } - - return sal_True; } // ----------------------------------------------------------------------- @@ -1673,14 +1665,14 @@ void Region::ImplUnionPolyPolygon( const Region& i_rRegion ) *this = Region( aClip ); } -sal_Bool Region::Union( const Region& rRegion ) +void Region::Union( const Region& rRegion ) { DBG_CHKTHIS( Region, ImplDbgTestRegion ); if( rRegion.HasPolyPolygon() || HasPolyPolygon() ) { ImplUnionPolyPolygon( rRegion ); - return sal_True; + return; } ImplPolyPolyRegionToBandRegion(); @@ -1688,7 +1680,7 @@ sal_Bool Region::Union( const Region& rRegion ) // is region empty or null? -> nothing to do if ( (rRegion.mpImplRegion == &aImplEmptyRegion) || (rRegion.mpImplRegion == &aImplNullRegion) ) - return sal_True; + return; // no instance data? -> create! if ( (mpImplRegion == &aImplEmptyRegion) || (mpImplRegion == &aImplNullRegion) ) @@ -1723,8 +1715,6 @@ sal_Bool Region::Union( const Region& rRegion ) delete mpImplRegion; mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); } - - return sal_True; } // ----------------------------------------------------------------------- @@ -1745,29 +1735,29 @@ void Region::ImplIntersectWithPolyPolygon( const Region& i_rRegion ) *this = Region( aClip ); } -sal_Bool Region::Intersect( const Region& rRegion ) +void Region::Intersect( const Region& rRegion ) { DBG_CHKTHIS( Region, ImplDbgTestRegion ); // same instance data? -> nothing to do! if ( mpImplRegion == rRegion.mpImplRegion ) - return sal_True; + return; if( rRegion.HasPolyPolygon() || HasPolyPolygon() ) { ImplIntersectWithPolyPolygon( rRegion ); - return sal_True; + return; } ImplPolyPolyRegionToBandRegion(); ((Region*)&rRegion)->ImplPolyPolyRegionToBandRegion(); if ( mpImplRegion == &aImplEmptyRegion ) - return sal_True; + return; // is region null? -> nothing to do if ( rRegion.mpImplRegion == &aImplNullRegion ) - return sal_True; + return; // is rectangle empty? -> nothing to do if ( rRegion.mpImplRegion == &aImplEmptyRegion ) @@ -1781,7 +1771,7 @@ sal_Bool Region::Intersect( const Region& rRegion ) delete mpImplRegion; } mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); - return sal_True; + return; } // is own region NULL-region? -> copy data! @@ -1789,7 +1779,7 @@ sal_Bool Region::Intersect( const Region& rRegion ) { mpImplRegion = rRegion.mpImplRegion; rRegion.mpImplRegion->mnRefCount++; - return sal_True; + return; } // Wenn wir weniger Rechtecke haben, drehen wir den Intersect-Aufruf um @@ -1884,8 +1874,6 @@ sal_Bool Region::Intersect( const Region& rRegion ) mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); } } - - return sal_True; } // ----------------------------------------------------------------------- @@ -1905,14 +1893,14 @@ void Region::ImplExcludePolyPolygon( const Region& i_rRegion ) *this = Region( aClip ); } -sal_Bool Region::Exclude( const Region& rRegion ) +void Region::Exclude( const Region& rRegion ) { DBG_CHKTHIS( Region, ImplDbgTestRegion ); if( rRegion.HasPolyPolygon() || HasPolyPolygon() ) { ImplExcludePolyPolygon( rRegion ); - return sal_True; + return; } ImplPolyPolyRegionToBandRegion(); @@ -1920,11 +1908,11 @@ sal_Bool Region::Exclude( const Region& rRegion ) // is region empty or null? -> nothing to do if ( (rRegion.mpImplRegion == &aImplEmptyRegion) || (rRegion.mpImplRegion == &aImplNullRegion) ) - return sal_True; + return; // no instance data? -> nothing to do if ( (mpImplRegion == &aImplEmptyRegion) || (mpImplRegion == &aImplNullRegion) ) - return sal_True; + return; // no own instance data? -> make own copy! if ( mpImplRegion->mnRefCount > 1 ) @@ -1958,8 +1946,6 @@ sal_Bool Region::Exclude( const Region& rRegion ) pBand = pBand->mpNextBand; } - - return sal_True; } // ----------------------------------------------------------------------- @@ -1982,14 +1968,14 @@ void Region::ImplXOrPolyPolygon( const Region& i_rRegion ) *this = Region( aClip ); } -sal_Bool Region::XOr( const Region& rRegion ) +void Region::XOr( const Region& rRegion ) { DBG_CHKTHIS( Region, ImplDbgTestRegion ); if( rRegion.HasPolyPolygon() || HasPolyPolygon() ) { ImplXOrPolyPolygon( rRegion ); - return sal_True; + return; } ImplPolyPolyRegionToBandRegion(); @@ -1997,13 +1983,13 @@ sal_Bool Region::XOr( const Region& rRegion ) // is region empty or null? -> nothing to do if ( (rRegion.mpImplRegion == &aImplEmptyRegion) || (rRegion.mpImplRegion == &aImplNullRegion) ) - return sal_True; + return; // no own instance data? -> XOr = copy if ( (mpImplRegion == &aImplEmptyRegion) || (mpImplRegion == &aImplNullRegion) ) { *this = rRegion; - return sal_True; + return; } // no own instance data? -> make own copy! @@ -2035,8 +2021,6 @@ sal_Bool Region::XOr( const Region& rRegion ) delete mpImplRegion; mpImplRegion = (ImplRegion*)(&aImplEmptyRegion); } - - return sal_True; } // ----------------------------------------------------------------------- _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits