From c0b8dd85d4b49e8800e69e614c567ce272ac9780 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 27 Sep 2012 15:31:38 +0000 Subject: Resolves: #i121128# added missing original data export for SVG... in XOutBitmap::WriteGraphic (cherry picked from commit 04f10de02296b9bff1e022daabf0b8ff59234e38) Conflicts: svx/source/xoutdev/_xoutbmp.cxx Change-Id: I774557451c924d6e5b2beb22a83de0ce95a429f1 --- svx/source/xoutdev/_xoutbmp.cxx | 77 +++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 23 deletions(-) (limited to 'svx/source/xoutdev/_xoutbmp.cxx') diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index 62a613774829..33e36ee0fd10 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -141,40 +141,71 @@ sal_uInt16 XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName, aURL.setBase( aName ); } - if( ( nFlags & XOUTBMP_USE_NATIVE_IF_POSSIBLE ) && - !( nFlags & XOUTBMP_MIRROR_HORZ ) && - !( nFlags & XOUTBMP_MIRROR_VERT ) && - ( rGraphic.GetType() != GRAPHIC_GDIMETAFILE ) && rGraphic.IsLink() ) + // #i121128# use shortcut to write SVG data in original form (if possible) + const SvgDataPtr aSvgDataPtr(rGraphic.getSvgData()); + + if(aSvgDataPtr.get() + && aSvgDataPtr->getSvgDataArrayLength() + && rFilterName.EqualsIgnoreCaseAscii("svg")) { - // try to write native link - const GfxLink aGfxLink( ( (Graphic&) rGraphic ).GetLink() ); + if(!(nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + { + aURL.setExtension(rFilterName); + } - switch( aGfxLink.GetType() ) + rFileName = aURL.GetMainURL(INetURLObject::NO_DECODE); + SfxMedium aMedium(aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_WRITE|STREAM_SHARE_DENYNONE|STREAM_TRUNC); + SvStream* pOStm = aMedium.GetOutStream(); + + if(pOStm) { - case( GFX_LINK_TYPE_NATIVE_GIF ): aExt = FORMAT_GIF; break; - case( GFX_LINK_TYPE_NATIVE_JPG ): aExt = FORMAT_JPG; break; - case( GFX_LINK_TYPE_NATIVE_PNG ): aExt = FORMAT_PNG; break; + pOStm->Write(aSvgDataPtr->getSvgDataArray().get(), aSvgDataPtr->getSvgDataArrayLength()); + aMedium.Commit(); - default: - break; + if(!aMedium.GetError()) + { + nErr = GRFILTER_OK; + } } + } - if( aExt.Len() ) + if( GRFILTER_OK != nErr ) + { + if( ( nFlags & XOUTBMP_USE_NATIVE_IF_POSSIBLE ) && + !( nFlags & XOUTBMP_MIRROR_HORZ ) && + !( nFlags & XOUTBMP_MIRROR_VERT ) && + ( rGraphic.GetType() != GRAPHIC_GDIMETAFILE ) && rGraphic.IsLink() ) { - if( 0 == (nFlags & XOUTBMP_DONT_ADD_EXTENSION)) - aURL.setExtension( aExt ); - rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); + // try to write native link + const GfxLink aGfxLink( ( (Graphic&) rGraphic ).GetLink() ); - SfxMedium aMedium( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_SHARE_DENYNONE | STREAM_TRUNC ); - SvStream* pOStm = aMedium.GetOutStream(); + switch( aGfxLink.GetType() ) + { + case( GFX_LINK_TYPE_NATIVE_GIF ): aExt = FORMAT_GIF; break; + case( GFX_LINK_TYPE_NATIVE_JPG ): aExt = FORMAT_JPG; break; + case( GFX_LINK_TYPE_NATIVE_PNG ): aExt = FORMAT_PNG; break; - if( pOStm && aGfxLink.GetDataSize() && aGfxLink.GetData() ) + default: + break; + } + + if( aExt.Len() ) { - pOStm->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() ); - aMedium.Commit(); + if( 0 == (nFlags & XOUTBMP_DONT_ADD_EXTENSION)) + aURL.setExtension( aExt ); + rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE ); - if( !aMedium.GetError() ) - nErr = GRFILTER_OK; + SfxMedium aMedium(aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_WRITE | STREAM_SHARE_DENYNONE | STREAM_TRUNC); + SvStream* pOStm = aMedium.GetOutStream(); + + if( pOStm && aGfxLink.GetDataSize() && aGfxLink.GetData() ) + { + pOStm->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() ); + aMedium.Commit(); + + if( !aMedium.GetError() ) + nErr = GRFILTER_OK; + } } } } -- cgit