1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "uno_mtfrenderer.hxx"
11 #include <cppcanvas/vclfactory.hxx>
12 #include <comphelper/servicedecl.hxx>
13 #include <cppuhelper/factory.hxx>
15 using namespace ::com::sun::star
;
17 void MtfRenderer::setMetafile (const uno::Sequence
< sal_Int8
>& /*rMtf*/) throw (uno::RuntimeException
)
19 // printf ("MtfRenderer::setMetafile unimplemented, use fast property set or implement me\n");
22 void MtfRenderer::draw (double fScaleX
, double fScaleY
) throw (uno::RuntimeException
)
24 if (mpMetafile
&& mxCanvas
.get()) {
25 cppcanvas::VCLFactory
& factory
= cppcanvas::VCLFactory::getInstance();
26 cppcanvas::BitmapCanvasSharedPtr canvas
= factory
.createBitmapCanvas (mxCanvas
);
27 cppcanvas::RendererSharedPtr renderer
= factory
.createRenderer (canvas
, *mpMetafile
, cppcanvas::Renderer::Parameters ());
28 ::basegfx::B2DHomMatrix aMatrix
;
29 aMatrix
.scale( fScaleX
, fScaleY
);
30 canvas
->setTransformation( aMatrix
);
35 void MtfRenderer::setFastPropertyValue( sal_Int32 nHandle
, const uno::Any
& aAny
) throw (uno::RuntimeException
)
38 mpMetafile
= (GDIMetaFile
*) *reinterpret_cast<const sal_Int64
*>(aAny
.getValue());
42 MtfRenderer::MtfRenderer (uno::Sequence
<uno::Any
> const& aArgs
, uno::Reference
<uno::XComponentContext
> const&) : MtfRendererBase (m_aMutex
), mpMetafile (NULL
)
44 if( aArgs
.getLength() == 1 ) {
45 aArgs
[0] >>= mxCanvas
;
49 namespace sdecl
= comphelper::service_decl
;
50 const sdecl::ServiceDecl
MtfRendererDecl(
51 sdecl::class_
<MtfRenderer
, sdecl::with_args
<true> >(),
52 "com.sun.star.comp.rendering.MtfRenderer",
53 "com.sun.star.rendering.MtfRenderer" );
55 // The C shared lib entry points
56 COMPHELPER_SERVICEDECL_EXPORTS1(mtfrenderer
, MtfRendererDecl
)
58 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */