summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-09-27 12:07:14 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-23 15:19:11 +0100
commitc1acf1d72ea1421cbb460e65ee5b1d9d3200033c (patch)
tree827919cfed95018d15734b5c4329133b0c8d1646 /tools
parent59cc160f34c214ce1e6474e67ecc566a7faf6864 (diff)
Resolves: #i115630# secured OutputDevice::ImplDrawHatch in vcl
and PolyPolygon::Optimize in tools to useful fallbacks when working on PolyPolygons (what they do *not* support) (cherry picked from commit dbe489ab9766d96c5cafb079bc4778103bded783) Conflicts: vcl/source/gdi/outdev4.cxx Change-Id: I5d2374ec95702cb0cab29d2e82710d4aa29fa823
Diffstat (limited to 'tools')
-rw-r--r--tools/source/generic/poly2.cxx65
1 files changed, 44 insertions, 21 deletions
diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx
index 535ff9ac1c01..2650960db126 100644
--- a/tools/source/generic/poly2.cxx
+++ b/tools/source/generic/poly2.cxx
@@ -241,39 +241,62 @@ void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData*
{
DBG_CHKTHIS( PolyPolygon, NULL );
- if( nOptimizeFlags )
+ if(nOptimizeFlags && Count())
{
- double fArea;
- const sal_Bool bEdges = ( nOptimizeFlags & POLY_OPTIMIZE_EDGES ) == POLY_OPTIMIZE_EDGES;
- sal_uInt16 nPercent = 0;
+ // #115630# ImplDrawHatch does not work with beziers included in the polypolygon, take care of that
+ bool bIsCurve(false);
- if( bEdges )
+ for(sal_uInt16 a(0); !bIsCurve && a < Count(); a++)
{
- const Rectangle aBound( GetBoundRect() );
-
- fArea = ( aBound.GetWidth() + aBound.GetHeight() ) * 0.5;
- nPercent = pData ? pData->GetPercentValue() : 50;
- nOptimizeFlags &= ~POLY_OPTIMIZE_EDGES;
+ if((*this)[a].HasFlags())
+ {
+ bIsCurve = true;
+ }
}
- // watch for ref counter
- if( mpImplPolyPolygon->mnRefCount > 1 )
+ if(bIsCurve)
{
- mpImplPolyPolygon->mnRefCount--;
- mpImplPolyPolygon = new ImplPolyPolygon( *mpImplPolyPolygon );
- }
+ OSL_ENSURE(false, "Optimize does *not* support curves, falling back to AdaptiveSubdivide()...");
+ PolyPolygon aPolyPoly;
- // Optimize polygons
- for( sal_uInt16 i = 0, nPolyCount = mpImplPolyPolygon->mnCount; i < nPolyCount; i++ )
+ AdaptiveSubdivide(aPolyPoly);
+ aPolyPoly.Optimize(nOptimizeFlags, pData);
+ *this = aPolyPoly;
+ }
+ else
{
+ double fArea;
+ const sal_Bool bEdges = ( nOptimizeFlags & POLY_OPTIMIZE_EDGES ) == POLY_OPTIMIZE_EDGES;
+ sal_uInt16 nPercent = 0;
+
if( bEdges )
{
- mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( POLY_OPTIMIZE_NO_SAME );
- Polygon::ImplReduceEdges( *( mpImplPolyPolygon->mpPolyAry[ i ] ), fArea, nPercent );
+ const Rectangle aBound( GetBoundRect() );
+
+ fArea = ( aBound.GetWidth() + aBound.GetHeight() ) * 0.5;
+ nPercent = pData ? pData->GetPercentValue() : 50;
+ nOptimizeFlags &= ~POLY_OPTIMIZE_EDGES;
}
- if( nOptimizeFlags )
- mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( nOptimizeFlags, pData );
+ // watch for ref counter
+ if( mpImplPolyPolygon->mnRefCount > 1 )
+ {
+ mpImplPolyPolygon->mnRefCount--;
+ mpImplPolyPolygon = new ImplPolyPolygon( *mpImplPolyPolygon );
+ }
+
+ // Optimize polygons
+ for( sal_uInt16 i = 0, nPolyCount = mpImplPolyPolygon->mnCount; i < nPolyCount; i++ )
+ {
+ if( bEdges )
+ {
+ mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( POLY_OPTIMIZE_NO_SAME );
+ Polygon::ImplReduceEdges( *( mpImplPolyPolygon->mpPolyAry[ i ] ), fArea, nPercent );
+ }
+
+ if( nOptimizeFlags )
+ mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( nOptimizeFlags, pData );
+ }
}
}
}