Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : */
9 :
10 : #include "uno_mtfrenderer.hxx"
11 : #include <cppcanvas/vclfactory.hxx>
12 : #include <comphelper/servicedecl.hxx>
13 : #include <cppuhelper/factory.hxx>
14 :
15 : using namespace ::com::sun::star;
16 :
17 0 : void MtfRenderer::setMetafile (const uno::Sequence< sal_Int8 >& /*rMtf*/) throw (uno::RuntimeException, std::exception)
18 : {
19 : // printf ("MtfRenderer::setMetafile unimplemented, use fast property set or implement me\n");
20 0 : }
21 :
22 0 : void MtfRenderer::draw (double fScaleX, double fScaleY) throw (uno::RuntimeException, std::exception)
23 : {
24 0 : if (mpMetafile && mxCanvas.get()) {
25 0 : cppcanvas::VCLFactory& factory = cppcanvas::VCLFactory::getInstance();
26 0 : cppcanvas::BitmapCanvasSharedPtr canvas = factory.createBitmapCanvas (mxCanvas);
27 0 : cppcanvas::RendererSharedPtr renderer = factory.createRenderer (canvas, *mpMetafile, cppcanvas::Renderer::Parameters ());
28 0 : ::basegfx::B2DHomMatrix aMatrix;
29 0 : aMatrix.scale( fScaleX, fScaleY );
30 0 : canvas->setTransformation( aMatrix );
31 0 : renderer->draw ();
32 : }
33 0 : }
34 :
35 0 : void MtfRenderer::setFastPropertyValue( sal_Int32 nHandle, const uno::Any& aAny) throw (uno::RuntimeException, std::exception)
36 : {
37 0 : if (nHandle == 0) {
38 0 : mpMetafile = reinterpret_cast<GDIMetaFile*>( *reinterpret_cast<const sal_Int64*>(aAny.getValue()) );
39 : }
40 0 : }
41 :
42 0 : MtfRenderer::MtfRenderer (uno::Sequence<uno::Any> const& aArgs, uno::Reference<uno::XComponentContext> const&) : MtfRendererBase (m_aMutex), mpMetafile (NULL)
43 : {
44 0 : if( aArgs.getLength() == 1 ) {
45 0 : aArgs[0] >>= mxCanvas;
46 : }
47 0 : }
48 :
49 : namespace sdecl = comphelper::service_decl;
50 0 : const sdecl::ServiceDecl MtfRendererDecl(
51 : sdecl::class_<MtfRenderer, sdecl::with_args<true> >(),
52 : "com.sun.star.comp.rendering.MtfRenderer",
53 0 : "com.sun.star.rendering.MtfRenderer" );
54 :
55 : // The C shared lib entry points
56 0 : COMPHELPER_SERVICEDECL_EXPORTS1(mtfrenderer, MtfRendererDecl)
57 :
58 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|