Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2010 Novell, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "uno_mtfrenderer.hxx"
30 : : #include <cppcanvas/vclfactory.hxx>
31 : : #include <comphelper/servicedecl.hxx>
32 : : #include <cppuhelper/factory.hxx>
33 : :
34 : : using namespace ::com::sun::star;
35 : :
36 : 0 : void MtfRenderer::setMetafile (const uno::Sequence< sal_Int8 >& /*rMtf*/) throw (uno::RuntimeException)
37 : : {
38 : : // printf ("MtfRenderer::setMetafile unimplemented, use fast property set or implement me\n");
39 : 0 : }
40 : :
41 : 0 : void MtfRenderer::draw (double fScaleX, double fScaleY) throw (uno::RuntimeException)
42 : : {
43 : 0 : if (mpMetafile && mxCanvas.get()) {
44 : 0 : cppcanvas::VCLFactory& factory = cppcanvas::VCLFactory::getInstance();
45 : 0 : cppcanvas::BitmapCanvasSharedPtr canvas = factory.createCanvas (mxCanvas);
46 : 0 : cppcanvas::RendererSharedPtr renderer = factory.createRenderer (canvas, *mpMetafile, cppcanvas::Renderer::Parameters ());
47 : 0 : ::basegfx::B2DHomMatrix aMatrix;
48 : 0 : aMatrix.scale( fScaleX, fScaleY );
49 : 0 : canvas->setTransformation( aMatrix );
50 : 0 : renderer->draw ();
51 : : }
52 : 0 : }
53 : :
54 : 0 : void MtfRenderer::setFastPropertyValue( sal_Int32 nHandle, const uno::Any& aAny) throw (uno::RuntimeException)
55 : : {
56 : 0 : if (nHandle == 0) {
57 : 0 : mpMetafile = (GDIMetaFile*) *reinterpret_cast<const sal_Int64*>(aAny.getValue());
58 : : }
59 : 0 : }
60 : :
61 : 0 : MtfRenderer::MtfRenderer (uno::Sequence<uno::Any> const& aArgs, uno::Reference<uno::XComponentContext> const&) : MtfRendererBase (m_aMutex), mpMetafile (NULL)
62 : : {
63 : 0 : if( aArgs.getLength() == 1 ) {
64 : 0 : aArgs[0] >>= mxCanvas;
65 : : }
66 : 0 : }
67 : :
68 : : namespace sdecl = comphelper::service_decl;
69 : 0 : const sdecl::ServiceDecl MtfRendererDecl(
70 : : sdecl::class_<MtfRenderer, sdecl::with_args<true> >(),
71 : : "com.sun.star.comp.rendering.MtfRenderer",
72 : 0 : "com.sun.star.rendering.MtfRenderer" );
73 : :
74 : : // The C shared lib entry points
75 : 0 : COMPHELPER_SERVICEDECL_EXPORTS1(mtfrenderer, MtfRendererDecl)
76 : :
77 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|