summaryrefslogtreecommitdiff
path: root/cppcanvas
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-04-13 12:28:03 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-04-13 13:15:26 +0100
commit35fb870b5f4382b8e589b29c72f2623c6b2fd0c0 (patch)
treec415500a5093f73af46a773e913b71a7504bc895 /cppcanvas
parent830724367d69bd4e223713d720c695e2b84a2ca0 (diff)
fix crash on invalid/missing pen
Diffstat (limited to 'cppcanvas')
-rw-r--r--cppcanvas/source/mtfrenderer/emfplus.cxx46
1 files changed, 26 insertions, 20 deletions
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 2e67d9f219b0..8409d7f302c0 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -902,7 +902,7 @@ namespace cppcanvas
} else {
rState.isFillColorSet = true;
// extract UseBrush
- EMFPBrush* brush = (EMFPBrush*) aObjects [brushIndexOrColor];
+ EMFPBrush* brush = (EMFPBrush*) aObjects [brushIndexOrColor & 0xff];
EMFP_DEBUG (printf ("EMF+\tbrush fill slot: %u (type: %u)\n", (unsigned int)brushIndexOrColor, (unsigned int)brush->GetType ()));
// give up in case something wrong happened
@@ -1356,31 +1356,37 @@ namespace cppcanvas
EMFP_DEBUG (printf ("EMF+\tpen: %u\n", (unsigned int)penIndex));
EMFPPath* path = (EMFPPath*) aObjects [flags & 0xff];
- EMFPPen* pen = (EMFPPen*) aObjects [penIndex];
+ EMFPPen* pen = (EMFPPen*) aObjects [penIndex & 0xff];
- rState.isFillColorSet = false;
- rState.isLineColorSet = true;
- rState.lineColor = ::vcl::unotools::colorToDoubleSequence (pen->GetColor (),
- rCanvas->getUNOCanvas ()->getDevice()->getDeviceColorSpace());
- ::basegfx::B2DPolyPolygon& polygon (path->GetPolygon (*this));
+ SAL_WARN_IF( !pen, "cppcanvas", "EmfPlusRecordTypeDrawPath missing pen" );
+ SAL_WARN_IF( !path, "cppcanvas", "EmfPlusRecordTypeDrawPath missing path" );
- polygon.transform( rState.mapModeTransform );
- rendering::StrokeAttributes aStrokeAttributes;
+ if (pen && path)
+ {
+ rState.isFillColorSet = false;
+ rState.isLineColorSet = true;
+ rState.lineColor = ::vcl::unotools::colorToDoubleSequence (pen->GetColor (),
+ rCanvas->getUNOCanvas ()->getDevice()->getDeviceColorSpace());
+ ::basegfx::B2DPolyPolygon& polygon (path->GetPolygon (*this));
- pen->SetStrokeAttributes (aStrokeAttributes, *this, rState);
+ polygon.transform( rState.mapModeTransform );
+ rendering::StrokeAttributes aStrokeAttributes;
- ActionSharedPtr pPolyAction(
- internal::PolyPolyActionFactory::createPolyPolyAction(
- polygon, rFactoryParms.mrCanvas, rState, aStrokeAttributes ) );
+ pen->SetStrokeAttributes (aStrokeAttributes, *this, rState);
- if( pPolyAction )
- {
- maActions.push_back(
- MtfAction(
- pPolyAction,
- rFactoryParms.mrCurrActionIndex ) );
+ ActionSharedPtr pPolyAction(
+ internal::PolyPolyActionFactory::createPolyPolyAction(
+ polygon, rFactoryParms.mrCanvas, rState, aStrokeAttributes ) );
- rFactoryParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
+ if( pPolyAction )
+ {
+ maActions.push_back(
+ MtfAction(
+ pPolyAction,
+ rFactoryParms.mrCurrActionIndex ) );
+
+ rFactoryParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
+ }
}
break;
}