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/.
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>
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
;
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() )
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" );
64 maArguments
[0] >>= nPtr
;
66 OutputDevice
* pOutDev
= reinterpret_cast<OutputDevice
*>(nPtr
);
68 throw lang::NoSupportException(u
"Passed OutDev invalid!"_ustr
, nullptr);
70 OutDevProviderSharedPtr pOutdevProvider
= std::make_shared
<OutDevHolder
>(*pOutDev
);
73 maDeviceHelper
.init( pOutdevProvider
);
74 maCanvasHelper
.init( *this,
76 true, // OutDev state preservation
77 false ); // no alpha on surface
79 maArguments
.realloc(0);
84 SAL_INFO("canvas.vcl", "VCLCanvas destroyed" );
87 void Canvas::disposeThis()
89 SolarMutexGuard aGuard
;
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
,
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
);
131 return cppu::acquire(p
.get());
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */