tdf#128337 clip the metafile Gradient drawing
This basically reverts the patches for tdf#125670. Instead this
just checks the mpGraphics in InitClipRegion() before using it,
to prevent the crash from the tdf#125670 bug report.
Additionally it drops the early mbOutputClipped return, as the
output device doesn't matter for the metafile drawing and the
preview of the tdf#125670 bugdoc and the Impress full screen
view otherwise don't show the gradients.
This patch works for me in the following tested scenarios:
1. Bugdoc tdf#125670 doesn't crash
2. Bugdoc tdf#125670 draws gradients in Impress full screen
3. Correct thumbnail pictures for both bug documents
With all these side effects, I have no idea, if this is finally
the correct fix and doesn't break anything else...
Change-Id: I8c48210d4255e50339710fc14819d15686417c9c
Reviewed-on: https://gerrit.libreoffice.org/83722
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
diff --git a/vcl/source/outdev/clipping.cxx b/vcl/source/outdev/clipping.cxx
index 416dc3b..1c6e455 100644
--- a/vcl/source/outdev/clipping.cxx
+++ b/vcl/source/outdev/clipping.cxx
@@ -170,7 +170,8 @@ void OutputDevice::InitClipRegion()
{
if ( mbClipRegionSet )
{
mpGraphics->ResetClipRegion();
if (mpGraphics)
mpGraphics->ResetClipRegion();
mbClipRegionSet = false;
}
diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index 7fc37b3..2e84067 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -50,6 +50,10 @@ void OutputDevice::DrawGradient( const tools::PolyPolygon& rPolyPoly,
{
assert(!is_double_buffered_window());
if (mbInitClipRegion)
InitClipRegion();
// don't return on mbOutputClipped here, as we may need to draw the clipped metafile, even if the output is clipped
if ( rPolyPoly.Count() && rPolyPoly[ 0 ].GetSize() )
{
if ( mnDrawMode & ( DrawModeFlags::BlackGradient | DrawModeFlags::WhiteGradient | DrawModeFlags::SettingsGradient) )
@@ -94,20 +98,17 @@ void OutputDevice::DrawGradient( const tools::PolyPolygon& rPolyPoly,
if( !mpGraphics && !AcquireGraphics() )
return;
if( mbInitClipRegion )
InitClipRegion();
if (mbOutputClipped)
return;
// secure clip region
Push( PushFlags::CLIPREGION );
IntersectClipRegion( aBoundRect );
if (mbInitClipRegion)
InitClipRegion();
// try to draw gradient natively
bDrawn = mpGraphics->DrawGradient( aClixPolyPoly, aGradient );
if (!bDrawn)
if (!bDrawn && !mbOutputClipped)
{
// draw gradients without border
if( mbLineColor || mbInitLineColor )