diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/graphicfilter.cxx | 58 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 34 |
2 files changed, 44 insertions, 48 deletions
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index ecfd46976800..eb861046b4cd 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1902,69 +1902,30 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String& sal_Int32 nVersion = aConfigItem.ReadInt32( "Version", 0 ) ; if ( nVersion ) rOStm.SetVersion( nVersion ); - GDIMetaFile aMTF; - if ( eType != GRAPHIC_BITMAP ) - aMTF = aGraphic.GetGDIMetaFile(); - else - { - VirtualDevice aVirDev; + // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically + GDIMetaFile aMTF(aGraphic.GetGDIMetaFile()); - aMTF.Record( &aVirDev ); - aGraphic.Draw( &aVirDev, Point(), aGraphic.GetPrefSize() ); - aMTF.Stop(); - aMTF.SetPrefSize( aGraphic.GetPrefSize() ); - aMTF.SetPrefMapMode( aGraphic.GetPrefMapMode() ); - } aMTF.Write( rOStm ); + if( rOStm.GetError() ) nStatus = GRFILTER_IOERROR; } else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_WMF ) ) { - if( eType == GRAPHIC_GDIMETAFILE ) - { - if ( !ConvertGDIMetaFileToWMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) ) - nStatus = GRFILTER_FORMATERROR; - } - else - { - Bitmap aBmp( aGraphic.GetBitmap() ); - GDIMetaFile aMTF; - VirtualDevice aVirDev; - - aMTF.Record( &aVirDev ); - aVirDev.DrawBitmap( Point(), aBmp ); - aMTF.Stop(); - aMTF.SetPrefSize( aBmp.GetSizePixel() ); + // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically + if ( !ConvertGDIMetaFileToWMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) ) + nStatus = GRFILTER_FORMATERROR; - if( !ConvertGDIMetaFileToWMF( aMTF, rOStm, &aConfigItem ) ) - nStatus = GRFILTER_FORMATERROR; - } if( rOStm.GetError() ) nStatus = GRFILTER_IOERROR; } else if ( aFilterName.EqualsIgnoreCaseAscii( EXP_EMF ) ) { - if( eType == GRAPHIC_GDIMETAFILE ) - { - if ( !ConvertGDIMetaFileToEMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) ) - nStatus = GRFILTER_FORMATERROR; - } - else - { - Bitmap aBmp( aGraphic.GetBitmap() ); - GDIMetaFile aMTF; - VirtualDevice aVirDev; - - aMTF.Record( &aVirDev ); - aVirDev.DrawBitmap( Point(), aBmp ); - aMTF.Stop(); - aMTF.SetPrefSize( aBmp.GetSizePixel() ); + // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically + if ( !ConvertGDIMetaFileToEMF( aGraphic.GetGDIMetaFile(), rOStm, &aConfigItem ) ) + nStatus = GRFILTER_FORMATERROR; - if( !ConvertGDIMetaFileToEMF( aMTF, rOStm, &aConfigItem ) ) - nStatus = GRFILTER_FORMATERROR; - } if( rOStm.GetError() ) nStatus = GRFILTER_IOERROR; } @@ -2080,6 +2041,7 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String& SvMemoryStream aMemStm( 65535, 65535 ); + // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( aMemStm ); xActiveDataSource->setOutputStream( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >( diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index d980fc5f09c4..be5663754b6a 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -595,6 +595,40 @@ Animation ImpGraphic::ImplGetAnimation() const const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const { + if (GRAPHIC_BITMAP == meType && !maMetaFile.GetActionSize()) + { + // #i119735# + // Use the local maMetaFile as container for a metafile-representation + // of the bitmap graphic. This will be done only once, thus be buffered. + // I checked all usages of maMetaFile, it is only used when type is not + // GRAPHIC_BITMAP. In operator= it will get copied, thus buffering will + // survive copying (change this if not wanted) + ImpGraphic* pThat = const_cast< ImpGraphic* >(this); + + if(maSvgData.get() && !maEx) + { + // use maEx as local buffer for rendered svg + pThat->maEx = maSvgData->getReplacement(); + } + + VirtualDevice aVirDev; + const Size aSizePixel(maEx.GetSizePixel()); + + pThat->maMetaFile.Record(&aVirDev); + + if(maEx.IsTransparent()) + { + aVirDev.DrawBitmapEx(Point(), maEx); + } + else + { + aVirDev.DrawBitmap(Point(), maEx.GetBitmap()); + } + + pThat->maMetaFile.Stop(); + pThat->maMetaFile.SetPrefSize(aSizePixel); + } + return maMetaFile; } |