LibreOffice Module canvas (master) 1
canvas.cxx
Go to the documentation of this file.
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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21
22#include "canvas.hxx"
23
24#include <com/sun/star/lang/NoSupportException.hpp>
25#include <sal/log.hxx>
28#include <vcl/outdev.hxx>
29
30#include "outdevholder.hxx"
31
32using namespace ::com::sun::star;
33
34namespace vclcanvas
35{
36 Canvas::Canvas( const uno::Sequence< uno::Any >& aArguments,
37 const uno::Reference< uno::XComponentContext >& /*rxContext*/ ) :
38 maArguments(aArguments)
39 {
40 }
41
42 void Canvas::initialize()
43 {
44 // #i64742# Only perform initialization when not in probe mode
45 if( !maArguments.hasElements() )
46 return;
47
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
54 */
55 SolarMutexGuard aGuard;
56
57 SAL_INFO("canvas.vcl", "VCLCanvas::initialize called" );
58
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" );
62
63 sal_Int64 nPtr = 0;
64 maArguments[0] >>= nPtr;
65
66 OutputDevice* pOutDev = reinterpret_cast<OutputDevice*>(nPtr);
67 if( !pOutDev )
68 throw lang::NoSupportException("Passed OutDev invalid!", nullptr);
69
70 OutDevProviderSharedPtr pOutdevProvider = std::make_shared<OutDevHolder>(*pOutDev);
71
72 // setup helper
73 maDeviceHelper.init( pOutdevProvider );
74 maCanvasHelper.init( *this,
75 pOutdevProvider,
76 true, // OutDev state preservation
77 false ); // no alpha on surface
78
79 maArguments.realloc(0);
80 }
81
82 Canvas::~Canvas()
83 {
84 SAL_INFO("canvas.vcl", "VCLCanvas destroyed" );
85 }
86
87 void Canvas::disposeThis()
88 {
89 SolarMutexGuard aGuard;
90
91 // forward to parent
92 CanvasBaseT::disposeThis();
93 }
94
95 OUString SAL_CALL Canvas::getServiceName( )
96 {
97 return "com.sun.star.rendering.Canvas.VCL";
98 }
99
100 OUString Canvas::getImplementationName() {
101 return "com.sun.star.comp.rendering.Canvas.VCL";
102 }
103
104 sal_Bool Canvas::supportsService(OUString const & ServiceName) {
106 }
107
108 css::uno::Sequence<OUString> Canvas::getSupportedServiceNames() {
109 return {getServiceName()};
110 }
111
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
118 {
119 SolarMutexGuard aGuard;
120
121 return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
122 }
123}
124
125extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
127 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
128{
130 p->initialize();
131 return cppu::acquire(p.get());
132}
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_rendering_Canvas_VCL_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &args)
Definition: canvas.cxx:126
Product of this component's factory.
Definition: canvas.hxx:76
Canvas(const css::uno::Sequence< css::uno::Any > &aArguments, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
#define ENSURE_ARG_OR_THROW(c, m)
Sequence< PropertyValue > aArguments
void * p
#define SAL_INFO(area, stream)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
args
std::shared_ptr< OutDevProvider > OutDevProviderSharedPtr
std::shared_ptr< GraphicObject > GraphicObjectSharedPtr
unsigned char sal_Bool