summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-05-06 13:47:14 +0200
committerNoel Grandin <noel@peralex.com>2013-05-08 08:06:45 +0200
commit2c625e036ddaadb71db36f3e44c737b069e6fcb4 (patch)
treeb4e7dcf6c24f0ac6b7262d0b3f570b8102f60232
parent48ad2f61fe71edc1a8967b322d3e0f368f4be06f (diff)
fdo#46808, Use service constructor for rendering::MtfRenderer
Change-Id: If15cd2ac23bf76aa79ee8134ee0fb97c64d747c3
-rw-r--r--offapi/com/sun/star/rendering/MtfRenderer.idl7
-rw-r--r--vcl/source/gdi/gdimtf.cxx67
2 files changed, 36 insertions, 38 deletions
diff --git a/offapi/com/sun/star/rendering/MtfRenderer.idl b/offapi/com/sun/star/rendering/MtfRenderer.idl
index 0dafbfbef146..6e4ef4baf81f 100644
--- a/offapi/com/sun/star/rendering/MtfRenderer.idl
+++ b/offapi/com/sun/star/rendering/MtfRenderer.idl
@@ -21,10 +21,15 @@
#define __com_sun_star_rendering_MtfRenderer_idl__
#include <com/sun/star/rendering/XMtfRenderer.idl>
+#include <com/sun/star/rendering/XBitmapCanvas.idl>
module com { module sun { module star { module rendering {
- service MtfRenderer : XMtfRenderer;
+service MtfRenderer : XMtfRenderer
+{
+ createWithBitmapCanvas([in] XBitmapCanvas Canvas);
+};
+
}; }; }; };
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 14051a604e48..223fd65547dd 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -408,55 +408,48 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
Size aSize (rDestSize.Width () + 1, rDestSize.Height () + 1);
uno::Reference<rendering::XBitmap> xBitmap = xCanvas->getDevice ()->createCompatibleAlphaBitmap (vcl::unotools::integerSize2DFromSize( aSize));
- uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
if( xBitmap.is () )
{
- uno::Reference< rendering::XMtfRenderer > xMtfRenderer;
- uno::Sequence< uno::Any > args (1);
uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( xBitmap, uno::UNO_QUERY );
if( xBitmapCanvas.is() )
{
- args[0] = uno::Any( xBitmapCanvas );
- xMtfRenderer.set( xFactory->createInstanceWithArguments( OUString("com.sun.star.rendering.MtfRenderer"),
- args ), uno::UNO_QUERY );
+ uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
+ uno::Reference< rendering::XMtfRenderer > xMtfRenderer = rendering::MtfRenderer::createWithBitmapCanvas( xContext, xBitmapCanvas );
- if( xMtfRenderer.is() )
- {
- xBitmapCanvas->clear();
- uno::Reference< beans::XFastPropertySet > xMtfFastPropertySet( xMtfRenderer, uno::UNO_QUERY );
- if( xMtfFastPropertySet.is() )
- // set this metafile to the renderer to
- // speedup things (instead of copying data to
- // sequence of bytes passed to renderer)
- xMtfFastPropertySet->setFastPropertyValue( 0, uno::Any( reinterpret_cast<sal_Int64>( this ) ) );
-
- xMtfRenderer->draw( rDestSize.Width(), rDestSize.Height() );
-
- uno::Reference< beans::XFastPropertySet > xFastPropertySet( xBitmapCanvas, uno::UNO_QUERY );
- if( xFastPropertySet.get() )
- {
- // 0 means get BitmapEx
- uno::Any aAny = xFastPropertySet->getFastPropertyValue( 0 );
- BitmapEx* pBitmapEx = (BitmapEx*) *reinterpret_cast<const sal_Int64*>(aAny.getValue());
- if( pBitmapEx ) {
- pOut->DrawBitmapEx( rPos, *pBitmapEx );
- delete pBitmapEx;
- return true;
- }
- }
+ xBitmapCanvas->clear();
+ uno::Reference< beans::XFastPropertySet > xMtfFastPropertySet( xMtfRenderer, uno::UNO_QUERY );
+ if( xMtfFastPropertySet.is() )
+ // set this metafile to the renderer to
+ // speedup things (instead of copying data to
+ // sequence of bytes passed to renderer)
+ xMtfFastPropertySet->setFastPropertyValue( 0, uno::Any( reinterpret_cast<sal_Int64>( this ) ) );
- SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
- pSalBmp->SetHasAlpha( true );
+ xMtfRenderer->draw( rDestSize.Width(), rDestSize.Height() );
- if( pSalBmp->Create( xBitmapCanvas, aSize ) )
- {
- Bitmap aBitmap( pSalBmp );
- pOut->DrawBitmap( rPos, aBitmap );
+ uno::Reference< beans::XFastPropertySet > xFastPropertySet( xBitmapCanvas, uno::UNO_QUERY );
+ if( xFastPropertySet.get() )
+ {
+ // 0 means get BitmapEx
+ uno::Any aAny = xFastPropertySet->getFastPropertyValue( 0 );
+ BitmapEx* pBitmapEx = (BitmapEx*) *reinterpret_cast<const sal_Int64*>(aAny.getValue());
+ if( pBitmapEx ) {
+ pOut->DrawBitmapEx( rPos, *pBitmapEx );
+ delete pBitmapEx;
return true;
}
+ }
+
+ SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
+ pSalBmp->SetHasAlpha( true );
- delete pSalBmp;
+ if( pSalBmp->Create( xBitmapCanvas, aSize ) )
+ {
+ Bitmap aBitmap( pSalBmp );
+ pOut->DrawBitmap( rPos, aBitmap );
+ return true;
}
+
+ delete pSalBmp;
}
}
}