Kaydet (Commit) dbe489ab authored tarafından Armin Le Grand's avatar Armin Le Grand

#115630# secured OutputDevice::ImplDrawHatch in vcl and PolyPolygon::Optimize in…

#115630# secured OutputDevice::ImplDrawHatch in vcl and PolyPolygon::Optimize in tools to useful fallbacks when working on PolyPolygons (what they do *not* support)
üst 3a23ea92
...@@ -281,7 +281,29 @@ void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData* ...@@ -281,7 +281,29 @@ void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData*
{ {
DBG_CHKTHIS( PolyPolygon, NULL ); DBG_CHKTHIS( PolyPolygon, NULL );
if( nOptimizeFlags ) if(nOptimizeFlags && Count())
{
// #115630# ImplDrawHatch does not work with beziers included in the polypolygon, take care of that
bool bIsCurve(false);
for(sal_uInt16 a(0); !bIsCurve && a < Count(); a++)
{
if((*this)[a].HasFlags())
{
bIsCurve = true;
}
}
if(bIsCurve)
{
OSL_ENSURE(false, "Optimize does *not* support curves, falling back to AdaptiveSubdivide()...");
PolyPolygon aPolyPoly;
AdaptiveSubdivide(aPolyPoly);
aPolyPoly.Optimize(nOptimizeFlags, pData);
*this = aPolyPoly;
}
else
{ {
double fArea; double fArea;
const sal_Bool bEdges = ( nOptimizeFlags & POLY_OPTIMIZE_EDGES ) == POLY_OPTIMIZE_EDGES; const sal_Bool bEdges = ( nOptimizeFlags & POLY_OPTIMIZE_EDGES ) == POLY_OPTIMIZE_EDGES;
...@@ -316,6 +338,7 @@ void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData* ...@@ -316,6 +338,7 @@ void PolyPolygon::Optimize( sal_uIntPtr nOptimizeFlags, const PolyOptimizeData*
mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( nOptimizeFlags, pData ); mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( nOptimizeFlags, pData );
} }
} }
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
......
...@@ -1170,6 +1170,29 @@ void OutputDevice::AddHatchActions( const PolyPolygon& rPolyPoly, const Hatch& r ...@@ -1170,6 +1170,29 @@ void OutputDevice::AddHatchActions( const PolyPolygon& rPolyPoly, const Hatch& r
void OutputDevice::ImplDrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch, sal_Bool bMtf ) void OutputDevice::ImplDrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch, sal_Bool bMtf )
{ {
if(rPolyPoly.Count())
{
// #115630# ImplDrawHatch 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())
{
bIsCurve = true;
}
}
if(bIsCurve)
{
OSL_ENSURE(false, "ImplDrawHatch does *not* support curves, falling back to AdaptiveSubdivide()...");
PolyPolygon aPolyPoly;
rPolyPoly.AdaptiveSubdivide(aPolyPoly);
ImplDrawHatch(aPolyPoly, rHatch, bMtf);
}
else
{
Rectangle aRect( rPolyPoly.GetBoundRect() ); Rectangle aRect( rPolyPoly.GetBoundRect() );
const long nLogPixelWidth = ImplDevicePixelToLogicWidth( 1 ); const long nLogPixelWidth = ImplDevicePixelToLogicWidth( 1 );
const long nWidth = ImplDevicePixelToLogicWidth( Max( ImplLogicWidthToDevicePixel( rHatch.GetDistance() ), 3L ) ); const long nWidth = ImplDevicePixelToLogicWidth( Max( ImplLogicWidthToDevicePixel( rHatch.GetDistance() ), 3L ) );
...@@ -1215,6 +1238,8 @@ void OutputDevice::ImplDrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHa ...@@ -1215,6 +1238,8 @@ void OutputDevice::ImplDrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHa
} }
delete[] pPtBuffer; delete[] pPtBuffer;
}
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment