diff options
author | Armin Le Grand <alg@apache.org> | 2012-09-27 15:31:38 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-05-19 20:33:41 +0100 |
commit | c0b8dd85d4b49e8800e69e614c567ce272ac9780 (patch) | |
tree | ea603415c92e11800a40fac29f5193ef45340797 /svx/source/xoutdev/_xoutbmp.cxx | |
parent | 96a7c619659ec153a8a9ad319c02c7182224801f (diff) |
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
Diffstat (limited to 'svx/source/xoutdev/_xoutbmp.cxx')
-rw-r--r-- | svx/source/xoutdev/_xoutbmp.cxx | 77 |
1 files changed, 54 insertions, 23 deletions
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; + } } } } |