diff options
author | Radek Doulik <rodo@novell.com> | 2012-03-07 16:58:37 +0100 |
---|---|---|
committer | Radek Doulik <rodo@novell.com> | 2012-03-07 16:59:53 +0100 |
commit | 0d396171b6345e6077dd85dc7ff6d9f9fdcd523d (patch) | |
tree | ef20cb5bd5c54ac8cd5d7c16fa55d64b03beedc2 /cppcanvas | |
parent | d86d122a986292d76fe0a57c6285667356ee5170 (diff) |
workaround for buggy metafile images
Diffstat (limited to 'cppcanvas')
-rw-r--r-- | cppcanvas/source/inc/implrenderer.hxx | 2 | ||||
-rw-r--r-- | cppcanvas/source/mtfrenderer/emfplus.cxx | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/cppcanvas/source/inc/implrenderer.hxx b/cppcanvas/source/inc/implrenderer.hxx index c93c83c50d06..d41d50410fa2 100644 --- a/cppcanvas/source/inc/implrenderer.hxx +++ b/cppcanvas/source/inc/implrenderer.hxx @@ -271,7 +271,7 @@ static float GetSwapFloat( SvStream& rSt ) ActionVector::const_iterator& o_rRangeBegin, ActionVector::const_iterator& o_rRangeEnd ) const; - void processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags); + void processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_Bool bUseWholeStream = sal_False); void processEMFPlus( MetaCommentAction* pAct, const ActionFactoryParameters& rFactoryParms, OutDevState& rState, const CanvasSharedPtr& rCanvas ); void EMFPPlusFillPolygon (::basegfx::B2DPolyPolygon& polygon, const ActionFactoryParameters& rParms, OutDevState& rState, const CanvasSharedPtr& rCanvas, bool isColor, sal_uInt32 brushIndexOrColor); diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx index 8ccb75bfdad1..953a0c86467b 100644 --- a/cppcanvas/source/mtfrenderer/emfplus.cxx +++ b/cppcanvas/source/mtfrenderer/emfplus.cxx @@ -717,7 +717,7 @@ namespace cppcanvas Graphic graphic; - void Read (SvMemoryStream &s) + void Read (SvMemoryStream &s, sal_Bool bUseWholeStream) { sal_uInt32 header, unknown; @@ -742,13 +742,19 @@ namespace cppcanvas EMFP_DEBUG (printf ("EMF+\tmetafile type: %d dataSize: %d\n", mfType, mfSize)); GraphicFilter filter; - SvMemoryStream mfStream (((char *)s.GetData()) + s.Tell(), mfSize, STREAM_READ); + // workaround buggy metafiles, which have wrong mfSize set (n#705956 for example) + SvMemoryStream mfStream (((char *)s.GetData()) + s.Tell(), bUseWholeStream ? s.remainingSize() : mfSize, STREAM_READ); filter.ImportGraphic (graphic, String (), mfStream); // debug code - write the stream to debug file /tmp/emf-stream.emf EMFP_DEBUG(mfStream.Seek(0); - SvFileStream file( UniString::CreateFromAscii( "/tmp/emf-embedded-stream.emf" ), STREAM_WRITE | STREAM_TRUNC ); + static int emfp_debug_stream_numnber = 0; + UniString emfp_debug_filename = UniString::CreateFromAscii( "/tmp/emf-embedded-stream" ); + emfp_debug_filename.Append( UniString::CreateFromInt32( emfp_debug_stream_numnber++ )); + emfp_debug_filename.Append( UniString::CreateFromAscii( ".emf" )); + + SvFileStream file( emfp_debug_filename, STREAM_WRITE | STREAM_TRUNC ); mfStream >> file; file.Flush(); @@ -1087,7 +1093,7 @@ namespace cppcanvas } } - void ImplRenderer::processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags) + void ImplRenderer::processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_Bool bUseWholeStream) { sal_uInt32 index; @@ -1142,7 +1148,7 @@ namespace cppcanvas { EMFPImage *image; aObjects [index] = image = new EMFPImage (); - image->Read (rObjectStream); + image->Read (rObjectStream, bUseWholeStream); break; } @@ -1193,7 +1199,7 @@ namespace cppcanvas if (mbMultipart) { EMFP_DEBUG (printf ("EMF+ multipart record flags: %04hx\n", mMFlags)); mMStream.Seek (0); - processObjectRecord (mMStream, mMFlags); + processObjectRecord (mMStream, mMFlags, sal_True); } mbMultipart = false; } |