Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / canvas / source / vcl / canvas.cxx
blobb66b9751bb38818dd89d8c1c8f03887c75e42c2c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include "canvas.hxx"
24 #include <com/sun/star/lang/NoSupportException.hpp>
25 #include <sal/log.hxx>
26 #include <comphelper/diagnose_ex.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <vcl/outdev.hxx>
30 #include "outdevholder.hxx"
32 using namespace ::com::sun::star;
34 namespace vclcanvas
36 Canvas::Canvas( const uno::Sequence< uno::Any >& aArguments,
37 const uno::Reference< uno::XComponentContext >& /*rxContext*/ ) :
38 maArguments(aArguments)
42 void Canvas::initialize()
44 // #i64742# Only perform initialization when not in probe mode
45 if( !maArguments.hasElements() )
46 return;
48 /* maArguments:
49 0: ptr to creating instance (Window or VirtualDevice)
50 1: current bounds of creating instance
51 2: bool, denoting always on top state for Window (always false for VirtualDevice)
52 3: XWindow for creating Window (or empty for VirtualDevice)
53 4: SystemGraphicsData as a streamed Any
55 SolarMutexGuard aGuard;
57 SAL_INFO("canvas.vcl", "VCLCanvas::initialize called" );
59 ENSURE_ARG_OR_THROW( maArguments.getLength() >= 5 &&
60 maArguments[0].getValueTypeClass() == uno::TypeClass_HYPER,
61 "Canvas::initialize: wrong number of arguments, or wrong types" );
63 sal_Int64 nPtr = 0;
64 maArguments[0] >>= nPtr;
66 OutputDevice* pOutDev = reinterpret_cast<OutputDevice*>(nPtr);
67 if( !pOutDev )
68 throw lang::NoSupportException(u"Passed OutDev invalid!"_ustr, nullptr);
70 OutDevProviderSharedPtr pOutdevProvider = std::make_shared<OutDevHolder>(*pOutDev);
72 // setup helper
73 maDeviceHelper.init( pOutdevProvider );
74 maCanvasHelper.init( *this,
75 pOutdevProvider,
76 true, // OutDev state preservation
77 false ); // no alpha on surface
79 maArguments.realloc(0);
82 Canvas::~Canvas()
84 SAL_INFO("canvas.vcl", "VCLCanvas destroyed" );
87 void Canvas::disposeThis()
89 SolarMutexGuard aGuard;
91 // forward to parent
92 CanvasBaseT::disposeThis();
95 OUString SAL_CALL Canvas::getServiceName( )
97 return u"com.sun.star.rendering.Canvas.VCL"_ustr;
100 OUString Canvas::getImplementationName() {
101 return u"com.sun.star.comp.rendering.Canvas.VCL"_ustr;
104 sal_Bool Canvas::supportsService(OUString const & ServiceName) {
105 return cppu::supportsService(this, ServiceName);
108 css::uno::Sequence<OUString> Canvas::getSupportedServiceNames() {
109 return {getServiceName()};
112 bool Canvas::repaint( const GraphicObjectSharedPtr& rGrf,
113 const rendering::ViewState& viewState,
114 const rendering::RenderState& renderState,
115 const ::Point& rPt,
116 const ::Size& rSz,
117 const GraphicAttr& rAttr ) const
119 SolarMutexGuard aGuard;
121 return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
125 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
126 com_sun_star_comp_rendering_Canvas_VCL_get_implementation(
127 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
129 rtl::Reference<vclcanvas::Canvas> p = new vclcanvas::Canvas(args, context);
130 p->initialize();
131 return cppu::acquire(p.get());
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */