summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-06-11 08:38:23 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-04-14 21:33:59 +0100
commit4fa8df7320f6bdc8333f5936537d2ed93e8892ce (patch)
tree3b3d06d3ba0dd698e1fb168171e4de1b4d60c12a
parent9bc0ca091b7037f7c8f4782103a81b7287bc1de3 (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 1fe92ac9806d..9e5ae3bf20e3 100644
--- a/filter/source/graphicfilter/eos2met/eos2met.cxx
+++ b/filter/source/graphicfilter/eos2met/eos2met.cxx
@@ -2560,20 +2560,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL
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 c68d400ffa2c..3c02e0ae98fc 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -2275,23 +2275,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 918ef4830e58..27a7125b0e61 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -2343,4 +2343,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 eb22854abca8..755684091bc0 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 namespace ::com::sun::star;
@@ -306,23 +307,39 @@ OUString SAL_CALL SVGFilter::detect( Sequence< PropertyValue >& io_rDescriptor )
// -----------------------------------------------------------------------------
+#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 3c8e5a88156a..b0a6546af601 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -119,6 +119,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 cbb33e358307..80cd9ca509d9 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2679,7 +2679,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;
}
}
}
@@ -3728,4 +3731,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 dbce63487b74..31ef4239c334 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;
// -----------------------------------------------------------------------------
@@ -152,6 +155,7 @@ struct SVGShapeDescriptor
class SVGAttributeWriter;
+class SVGExport;
class GDIMetaFile;
@@ -400,6 +404,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 72268f682058..6ed282dd17e2 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -504,16 +504,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 bacf34b392a0..6c3d9228536b 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -236,18 +236,8 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
}
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 a60030dd70df..245d1016c06b 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -2942,18 +2942,8 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
}
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 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;
}