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>
26#include <tools/diagnose_ex.h>
27#include <vcl/outdev.hxx>
28
29#include "outdevholder.hxx"
30
31using namespace ::com::sun::star;
32
33namespace vclcanvas
34{
35 Canvas::Canvas( const uno::Sequence< uno::Any >& aArguments,
36 const uno::Reference< uno::XComponentContext >& /*rxContext*/ ) :
37 maArguments(aArguments)
38 {
39 }
40
41 void Canvas::initialize()
42 {
43 // #i64742# Only perform initialization when not in probe mode
44 if( !maArguments.hasElements() )
45 return;
46
47 /* maArguments:
48 0: ptr to creating instance (Window or VirtualDevice)
49 1: current bounds of creating instance
50 2: bool, denoting always on top state for Window (always false for VirtualDevice)
51 3: XWindow for creating Window (or empty for VirtualDevice)
52 4: SystemGraphicsData as a streamed Any
53 */
54 SolarMutexGuard aGuard;
55
56 SAL_INFO("canvas.vcl", "VCLCanvas::initialize called" );
57
58 ENSURE_ARG_OR_THROW( maArguments.getLength() >= 5 &&
59 maArguments[0].getValueTypeClass() == uno::TypeClass_HYPER,
60 "Canvas::initialize: wrong number of arguments, or wrong types" );
61
62 sal_Int64 nPtr = 0;
63 maArguments[0] >>= nPtr;
64
65 OutputDevice* pOutDev = reinterpret_cast<OutputDevice*>(nPtr);
66 if( !pOutDev )
67 throw lang::NoSupportException("Passed OutDev invalid!", nullptr);
68
69 OutDevProviderSharedPtr pOutdevProvider = std::make_shared<OutDevHolder>(*pOutDev);
70
71 // setup helper
72 maDeviceHelper.init( pOutdevProvider );
73 maCanvasHelper.init( *this,
74 pOutdevProvider,
75 true, // OutDev state preservation
76 false ); // no alpha on surface
77
78 maArguments.realloc(0);
79 }
80
81 Canvas::~Canvas()
82 {
83 SAL_INFO("canvas.vcl", "VCLCanvas destroyed" );
84 }
85
86 void Canvas::disposeThis()
87 {
88 SolarMutexGuard aGuard;
89
90 // forward to parent
91 CanvasBaseT::disposeThis();
92 }
93
94 OUString SAL_CALL Canvas::getServiceName( )
95 {
96 return "com.sun.star.rendering.Canvas.VCL";
97 }
98
99 bool Canvas::repaint( const GraphicObjectSharedPtr& rGrf,
100 const rendering::ViewState& viewState,
101 const rendering::RenderState& renderState,
102 const ::Point& rPt,
103 const ::Size& rSz,
104 const GraphicAttr& rAttr ) const
105 {
106 SolarMutexGuard aGuard;
107
108 return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
109 }
110}
111
112extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
114 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
115{
117 cppu::acquire(p.get());
118 p->initialize();
119 return static_cast<cppu::OWeakObject*>(p.get());
120}
121
122/* 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:113
Product of this component's factory.
Definition: canvas.hxx:74
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)
args
std::shared_ptr< OutDevProvider > OutDevProviderSharedPtr
std::shared_ptr< GraphicObject > GraphicObjectSharedPtr