summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-06-11 08:38:23 +0000
committerJan Holesovsky <kendy@collabora.com>2015-10-19 09:04:09 +0200
commitf4bfbc56bdf2b942740628ce28e08994227142cf (patch)
treeef2d158f2734393ba38e5513e2d89e7cf4a0caa7
parent5cd27c4b93c171b4afda73a6d62da06512d1908a (diff)
Resolves: #i119735# missing css.svg.SVGWriter when using GraphicProvider
missing implementation for com.sun.star.svg.SVGWriter when using GraphicProvider Adapted patch provided by Sven Jacobi (thanks), added some fixes/cleanups to make it work with all kind of graphics (SVG, Bitmap, Metafile) (cherry picked from commit 891011181285d7ad54984ffd05ed44d825a70647) Conflicts: filter/inc/filter/msfilter/msdffimp.hxx filter/source/graphicfilter/epict/epict.cxx filter/source/svg/svgexport.cxx filter/source/svg/svguno.cxx filter/source/svg/svgwriter.cxx filter/source/svg/svgwriter.hxx svtools/source/filter/filter.cxx Change-Id: Ie53f995614060a00c709f620f89d132913a25c5c
-rw-r--r--filter/source/graphicfilter/eos2met/eos2met.cxx16
-rw-r--r--filter/source/graphicfilter/epict/epict.cxx21
-rw-r--r--filter/source/svg/svgexport.cxx42
-rw-r--r--filter/source/svg/svgfilter.component3
-rw-r--r--filter/source/svg/svgfilter.cxx27
-rw-r--r--filter/source/svg/svgfilter.hxx2
-rw-r--r--filter/source/svg/svgwriter.cxx38
-rw-r--r--filter/source/svg/svgwriter.hxx22
-rw-r--r--svx/source/svdraw/svdxcgv.cxx12
-rw-r--r--svx/source/unodraw/unoshap4.cxx14
-rw-r--r--svx/source/unodraw/unoshape.cxx14
-rw-r--r--vcl/source/filter/graphicfilter.cxx58
-rw-r--r--vcl/source/gdi/impgraph.cxx34
13 files changed, 183 insertions, 120 deletions
diff --git a/filter/source/graphicfilter/eos2met/eos2met.cxx b/filter/source/graphicfilter/eos2met/eos2met.cxx
index 834a0f462798..09110c7967b3 100644
--- a/filter/source/graphicfilter/eos2met/eos2met.cxx
+++ b/filter/source/graphicfilter/eos2met/eos2met.cxx
@@ -2561,20 +2561,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool __LOADONCALLAPI
GraphicExport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pFilterConfigItem, sal_Bool )
{ METWriter aMETWriter;
- if ( rGraphic.GetType() == GRAPHIC_GDIMETAFILE )
- return aMETWriter.WriteMET( rGraphic.GetGDIMetaFile(), rStream, pFilterConfigItem );
- else
- {
- Bitmap aBmp=rGraphic.GetBitmap();
- GDIMetaFile aMTF;
- VirtualDevice aVirDev;
-
- aMTF.Record(&aVirDev);
- aVirDev.DrawBitmap(Point(),aBmp);
- aMTF.Stop();
- aMTF.SetPrefSize(aBmp.GetSizePixel());
- return aMETWriter.WriteMET( aMTF, rStream, pFilterConfigItem );
- }
+ // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+ return aMETWriter.WriteMET( rGraphic.GetGDIMetaFile(), rStream, pFilterConfigItem );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx
index 7af0456b7fb5..f94ce97683cf 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -2282,23 +2282,10 @@ GraphicExport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pFilterC
{
PictWriter aPictWriter;
- if (rGraphic.GetType()==GRAPHIC_GDIMETAFILE)
- {
- GDIMetaFile aScaledMtf( rGraphic.GetGDIMetaFile() );
- return aPictWriter.WritePict( aScaledMtf, rStream, pFilterConfigItem );
- }
- else
- {
- Bitmap aBmp=rGraphic.GetBitmap();
- GDIMetaFile aMTF;
- VirtualDevice aVirDev;
-
- aMTF.Record(&aVirDev);
- aVirDev.DrawBitmap(Point(),aBmp);
- aMTF.Stop();
- aMTF.SetPrefSize(aBmp.GetSizePixel());
- return aPictWriter.WritePict( aMTF, rStream, pFilterConfigItem );
- }
+ // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+ GDIMetaFile aScaledMtf( rGraphic.GetGDIMetaFile() );
+
+ return aPictWriter.WritePict( aScaledMtf, rStream, pFilterConfigItem );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 4289a30abb67..5e61ce3058b8 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -2345,4 +2345,46 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo )
return ( bFieldProcessed ? 0 : maOldFieldHdl.Call( pInfo ) );
}
+// -----------------------------------------------------------------------------
+
+void SVGExport::writeMtf( const GDIMetaFile& rMtf )
+{
+ const Size aSize( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_MM ) );
+ rtl::OUString aAttr;
+ Reference< XExtendedDocumentHandler> xExtDocHandler( GetDocHandler(), UNO_QUERY );
+
+ if( xExtDocHandler.is() )
+ xExtDocHandler->unknown( SVG_DTD_STRING );
+
+ aAttr = rtl::OUString::valueOf( aSize.Width() );
+ aAttr += "mm";
+ AddAttribute( XML_NAMESPACE_NONE, "width", aAttr );
+
+ aAttr = rtl::OUString::valueOf( aSize.Height() );
+ aAttr += "mm";
+ AddAttribute( XML_NAMESPACE_NONE, "height", aAttr );
+
+ aAttr = "0 0 ";
+ aAttr += rtl::OUString::valueOf( aSize.Width() * 100L );
+ aAttr += " ";
+ aAttr += rtl::OUString::valueOf( aSize.Height() * 100L );
+ AddAttribute( XML_NAMESPACE_NONE, "viewBox", aAttr );
+
+ {
+ SvXMLElementExport aSVG( *this, XML_NAMESPACE_NONE, "svg", sal_True, sal_True );
+
+ std::vector< ObjectRepresentation > aObjects;
+
+ aObjects.push_back( ObjectRepresentation( Reference< XInterface >(), rMtf ) );
+ SVGFontExport aSVGFontExport( *this, aObjects );
+
+ Point aPoint100thmm( OutputDevice::LogicToLogic( rMtf.GetPrefMapMode().GetOrigin(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) );
+ Size aSize100thmm( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) );
+
+ SVGActionWriter aWriter( *this, aSVGFontExport );
+ aWriter.WriteMetaFile( aPoint100thmm, aSize100thmm, rMtf,
+ SVGWRITER_WRITE_FILL | SVGWRITER_WRITE_TEXT, NULL );
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgfilter.component b/filter/source/svg/svgfilter.component
index 51fd50d6895e..1bf7b47f8413 100644
--- a/filter/source/svg/svgfilter.component
+++ b/filter/source/svg/svgfilter.component
@@ -24,4 +24,7 @@
<service name="com.sun.star.document.ExportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>
</implementation>
+ <implementation name="com.sun.star.comp.Draw.SVGWriter">
+ <service name="com.sun.star.svg.SVGWriter"/>
+ </implementation>
</component>
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index bbe2a3c35dfd..365caea97b38 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -43,6 +43,7 @@
#include <osl/mutex.hxx>
#include "svgfilter.hxx"
+#include "svgwriter.hxx"
using ::rtl::OUString;
using namespace ::com::sun::star;
@@ -309,23 +310,39 @@ rtl::OUString SAL_CALL SVGFilter::detect( Sequence< PropertyValue >& io_rDescrip
// -----------------------------------------------------------------------------
+#define SVG_FILTER_IMPL_NAME "com.sun.star.comp.Draw.SVGFilter"
+#define SVG_WRITER_IMPL_NAME "com.sun.star.comp.Draw.SVGWriter"
+
namespace sdecl = comphelper::service_decl;
- sdecl::class_<SVGFilter> serviceImpl;
+ sdecl::class_<SVGFilter> serviceFilterImpl;
const sdecl::ServiceDecl svgFilter(
- serviceImpl,
- "com.sun.star.comp.Draw.SVGFilter",
+ serviceFilterImpl,
+ SVG_FILTER_IMPL_NAME,
"com.sun.star.document.ImportFilter;"
"com.sun.star.document.ExportFilter;"
"com.sun.star.document.ExtendedTypeDetection" );
+ sdecl::class_<SVGWriter> serviceWriterImpl;
+ const sdecl::ServiceDecl svgWriter(
+ serviceWriterImpl,
+ SVG_WRITER_IMPL_NAME,
+ "com.sun.star.svg.SVGWriter" );
+
// The C shared lib entry points
extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL svgfilter_component_getFactory(
sal_Char const* pImplName,
::com::sun::star::lang::XMultiServiceFactory* pServiceManager,
::com::sun::star::registry::XRegistryKey* pRegistryKey )
{
- return component_getFactoryHelper( pImplName, pServiceManager,
- pRegistryKey, svgFilter );
+ if ( rtl_str_compare (pImplName, SVG_FILTER_IMPL_NAME) == 0 )
+ {
+ return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, svgFilter );
+ }
+ else if ( rtl_str_compare (pImplName, SVG_WRITER_IMPL_NAME) == 0 )
+ {
+ return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, svgWriter );
+ }
+ return NULL;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 975b7c6f226e..2469198e740b 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -133,6 +133,8 @@ public:
sal_Bool IsUseNativeTextDecoration() const;
sal_Bool IsUseOpacity() const;
+ void writeMtf( const GDIMetaFile& rMtf );
+
protected:
virtual void _ExportStyles( sal_Bool /* bUsed */ ) {}
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 2f269ba9fda9..849298ff443f 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2848,7 +2848,10 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText,
if( bCont )
{
// #118796# do NOT access pDXArray, it may be zero (!)
- nX = aPos.X() + pDX[ nCurPos - 1 ];
+ sal_Int32 nDXWidth = pDX[ nCurPos - 1 ];
+ if ( bApplyMapping )
+ nDXWidth = ImplMap( nDXWidth );
+ nX = aPos.X() + nDXWidth;
}
}
}
@@ -3906,4 +3909,37 @@ void SVGActionWriter::WriteMetaFile( const Point& rPos100thmm,
mpVDev->Pop();
}
+// -------------
+// - SVGWriter -
+// -------------
+
+SVGWriter::SVGWriter( const Reference< XComponentContext >& rxCtx )
+ : mxContext(rxCtx)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SVGWriter::~SVGWriter()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGWriter::write( const Reference<XDocumentHandler>& rxDocHandler,
+ const Sequence<sal_Int8>& rMtfSeq ) throw( RuntimeException )
+{
+ SvMemoryStream aMemStm( (char*) rMtfSeq.getConstArray(), rMtfSeq.getLength(), STREAM_READ );
+ GDIMetaFile aMtf;
+
+ aMemStm >> aMtf;
+
+ const Reference< XDocumentHandler > xDocumentHandler( rxDocHandler );
+ const Sequence< PropertyValue > aFilterData;
+
+ SVGExport* pWriter = new SVGExport( mxContext, xDocumentHandler, aFilterData );
+ pWriter->writeMtf( aMtf );
+ delete pWriter;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx
index ebffda9a5f10..8813646ed48e 100644
--- a/filter/source/svg/svgwriter.hxx
+++ b/filter/source/svg/svgwriter.hxx
@@ -21,7 +21,7 @@
#define SVGWRITER_HXX
#include <stack>
-#include <cppuhelper/weak.hxx>
+#include <cppuhelper/implbase1.hxx>
#include <rtl/ustring.hxx>
#include <tools/stream.hxx>
#include <tools/string.hxx>
@@ -58,6 +58,7 @@
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XTextField.hpp>
#include <com/sun/star/style/NumberingType.hpp>
+#include <com/sun/star/svg/XSVGWriter.hpp>
// -----------------------------------------------------------------------------
@@ -68,6 +69,8 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::svg;
+using namespace ::com::sun::star::xml::sax;
// -----------------------------------------------------------------------------
@@ -162,6 +165,7 @@ struct SVGShapeDescriptor
class SVGAttributeWriter;
+class SVGExport;
class GDIMetaFile;
@@ -409,6 +413,22 @@ public:
const GDIMetaFile* pTextEmbeddedBitmapMtf = NULL );
};
+class SVGWriter : public cppu::WeakImplHelper1< XSVGWriter >
+{
+private:
+ Reference< XComponentContext > mxContext;
+
+ SVGWriter();
+
+public:
+ explicit SVGWriter( const Reference< XComponentContext >& rxCtx );
+ virtual ~SVGWriter();
+
+ // XSVGWriter
+ virtual void SAL_CALL write( const Reference<XDocumentHandler>& rxDocHandler,
+ const Sequence<sal_Int8>& rMtfSeq ) throw( RuntimeException );
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index df282db62db8..4c9cfedec46f 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -514,16 +514,8 @@ GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked) co
{
Graphic aGraphic( pGrafObj->GetTransformedGraphic() );
- if( aGraphic.GetType() == GRAPHIC_BITMAP )
- {
- const Point aPos;
-
- aMtf.AddAction( new MetaBmpExScaleAction( aPos, aBoundSize, aGraphic.GetBitmapEx() ) );
- aMtf.SetPrefMapMode( aMap );
- aMtf.SetPrefSize( aBoundSize );
- }
- else
- aMtf = aGraphic.GetGDIMetaFile();
+ // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+ aMtf = aGraphic.GetGDIMetaFile();
}
}
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index c516b6ff6563..8d806e9651cd 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -235,18 +235,8 @@ bool SvxOle2Shape::getPropertyValueImpl( const ::rtl::OUString& rName, const Sfx
}
if ( !bIsWMF )
{
- GDIMetaFile aMtf;
- if ( pGraphic->GetType() != GRAPHIC_BITMAP )
- aMtf = pObj->GetGraphic()->GetGDIMetaFile();
- else
- {
- VirtualDevice aVirDev;
- aMtf.Record( &aVirDev );
- pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() );
- aMtf.Stop();
- aMtf.SetPrefSize( pGraphic->GetPrefSize() );
- aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() );
- }
+ // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+ GDIMetaFile aMtf(pObj->GetGraphic()->GetGDIMetaFile());
SvMemoryStream aDestStrm( 65535, 65535 );
ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
const uno::Sequence<sal_Int8> aSeq(
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index dc41794de75f..28f174c033f4 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -2945,18 +2945,8 @@ bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper
}
if ( !bIsWMF )
{
- GDIMetaFile aMtf;
- if ( pGraphic->GetType() != GRAPHIC_BITMAP )
- aMtf = pObj->GetGraphic()->GetGDIMetaFile();
- else
- {
- VirtualDevice aVirDev;
- aMtf.Record( &aVirDev );
- pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() );
- aMtf.Stop();
- aMtf.SetPrefSize( pGraphic->GetPrefSize() );
- aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() );
- }
+ // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
+ GDIMetaFile aMtf(pObj->GetGraphic()->GetGDIMetaFile());
SvMemoryStream aDestStrm( 65535, 65535 );
ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
const uno::Sequence<sal_Int8> aSeq(
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 3a68acd31c5a..4af61de9096f 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -2017,69 +2017,30 @@ sal_uInt16 GraphicFilter::ExportGraphic( const Graphic& rGraphic, const String&
sal_Int32 nVersion = aConfigItem.ReadInt32( String( RTL_CONSTASCII_USTRINGPARAM( "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;
}
@@ -2195,6 +2156,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 2421bcb32841..9a036b48e33f 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -666,6 +666,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;
}