LibreOffice Module canvas (master) 1
graphicdevicebase.hxx
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#pragma once
21
22#include <com/sun/star/rendering/XBufferController.hpp>
23#include <com/sun/star/rendering/XLinePolyPolygon2D.hpp>
24#include <com/sun/star/rendering/XBezierPolyPolygon2D.hpp>
25#include <com/sun/star/rendering/XBitmap.hpp>
26#include <com/sun/star/rendering/XVolatileBitmap.hpp>
27
28#include <rtl/ref.hxx>
29
30#include <parametricpolypolygon.hxx>
31#include <propertysethelper.hxx>
32#include <verifyinput.hxx>
33
34namespace com::sun::star::beans { class XPropertySetInfo; }
35namespace com::sun::star::lang { class XMultiServiceFactory; }
36namespace com::sun::star::rendering { class XColorSpace; }
37
38
39/* Definition of GraphicDeviceBase class */
40
41namespace canvas
42{
104 template< class Base,
105 class DeviceHelper,
106 class Mutex=::osl::MutexGuard,
107 class UnambiguousBase=css::uno::XInterface > class GraphicDeviceBase :
108 public Base
109 {
110 public:
111 typedef Base BaseType;
112 typedef Mutex MutexType;
113 typedef UnambiguousBase UnambiguousBaseType;
114
115 typedef ::rtl::Reference< GraphicDeviceBase > Reference;
116
120 {
123 {"HardwareAcceleration",
124 { [this] () { return this->maDeviceHelper.isAccelerated(); }, {} } },
125 {"DeviceHandle",
126 { [this] () { return this->maDeviceHelper.getDeviceHandle(); }, {} } },
127 {"SurfaceHandle",
128 { [this] () { return this->maDeviceHelper.getSurfaceHandle(); }, {} } },
129 {"DumpScreenContent",
130 { [this] () { return this->getDumpScreenContent(); },
131 [this] (css::uno::Any const& rAny) { this->setDumpScreenContent(rAny); } } } } );
132 }
133
134 virtual void disposeThis() override
135 {
136 MutexType aGuard( BaseType::m_aMutex );
137
138 maDeviceHelper.disposing();
139
140 // pass on to base class
141 BaseType::disposeThis();
142 }
143
144 // XGraphicDevice
145 virtual css::uno::Reference< css::rendering::XBufferController > SAL_CALL getBufferController( ) override
146 {
147 return css::uno::Reference< css::rendering::XBufferController >();
148 }
149
150 virtual css::uno::Reference< css::rendering::XColorSpace > SAL_CALL getDeviceColorSpace( ) override
151 {
152 MutexType aGuard( BaseType::m_aMutex );
153
154 return maDeviceHelper.getColorSpace();
155 }
156
157 virtual css::geometry::RealSize2D SAL_CALL getPhysicalResolution() override
158 {
159 MutexType aGuard( BaseType::m_aMutex );
160
161 return maDeviceHelper.getPhysicalResolution();
162 }
163
164 virtual css::geometry::RealSize2D SAL_CALL getPhysicalSize() override
165 {
166 MutexType aGuard( BaseType::m_aMutex );
167
168 return maDeviceHelper.getPhysicalSize();
169 }
170
171 virtual css::uno::Reference< css::rendering::XLinePolyPolygon2D > SAL_CALL createCompatibleLinePolyPolygon( const css::uno::Sequence< css::uno::Sequence< css::geometry::RealPoint2D > >& points ) override
172 {
173 MutexType aGuard( BaseType::m_aMutex );
174
175 return maDeviceHelper.createCompatibleLinePolyPolygon( this, points );
176 }
177
178 virtual css::uno::Reference< css::rendering::XBezierPolyPolygon2D > SAL_CALL createCompatibleBezierPolyPolygon( const css::uno::Sequence< css::uno::Sequence< css::geometry::RealBezierSegment2D > >& points ) override
179 {
180 MutexType aGuard( BaseType::m_aMutex );
181
182 return maDeviceHelper.createCompatibleBezierPolyPolygon( this, points );
183 }
184
185 virtual css::uno::Reference< css::rendering::XBitmap > SAL_CALL createCompatibleBitmap( const css::geometry::IntegerSize2D& size ) override
186 {
188 __func__,
189 static_cast< UnambiguousBaseType* >(this));
190
191 MutexType aGuard( BaseType::m_aMutex );
192
193 return maDeviceHelper.createCompatibleBitmap( this, size );
194 }
195
196 virtual css::uno::Reference< css::rendering::XVolatileBitmap > SAL_CALL createVolatileBitmap( const css::geometry::IntegerSize2D& size ) override
197 {
199 __func__,
200 static_cast< UnambiguousBaseType* >(this));
201
202 MutexType aGuard( BaseType::m_aMutex );
203
204 return maDeviceHelper.createVolatileBitmap( this, size );
205 }
206
207 virtual css::uno::Reference< css::rendering::XBitmap > SAL_CALL createCompatibleAlphaBitmap( const css::geometry::IntegerSize2D& size ) override
208 {
210 __func__,
211 static_cast< UnambiguousBaseType* >(this));
212
213 MutexType aGuard( BaseType::m_aMutex );
214
215 return maDeviceHelper.createCompatibleAlphaBitmap( this, size );
216 }
217
218 virtual css::uno::Reference< css::rendering::XVolatileBitmap > SAL_CALL createVolatileAlphaBitmap( const css::geometry::IntegerSize2D& size ) override
219 {
221 __func__,
222 static_cast< UnambiguousBaseType* >(this));
223
224 MutexType aGuard( BaseType::m_aMutex );
225
226 return maDeviceHelper.createVolatileAlphaBitmap( this, size );
227 }
228
229 virtual css::uno::Reference< css::lang::XMultiServiceFactory > SAL_CALL getParametricPolyPolygonFactory( ) override
230 {
231 return this;
232 }
233
234 virtual sal_Bool SAL_CALL hasFullScreenMode( ) override
235 {
236 return false;
237 }
238
239 virtual sal_Bool SAL_CALL enterFullScreenMode( sal_Bool ) override
240 {
241 return false;
242 }
243
244 // XMultiServiceFactory
245 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override
246 {
247 return css::uno::Reference< css::rendering::XParametricPolyPolygon2D >(
249 aServiceSpecifier,
250 css::uno::Sequence< css::uno::Any >()));
251 }
252
253 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& aServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override
254 {
255 return css::uno::Reference< css::rendering::XParametricPolyPolygon2D >(
257 aServiceSpecifier,
258 Arguments));
259 }
260
261 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) override
262 {
264 }
265
266
267 // XUpdatable
268 virtual void SAL_CALL update() override
269 {
270 MutexType aGuard( BaseType::m_aMutex );
271
273 maDeviceHelper.dumpScreenContent();
274 }
275
276
277 // XPropertySet
278 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
279 {
280 MutexType aGuard( BaseType::m_aMutex );
282 }
283
284 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
285 const css::uno::Any& aValue ) override
286 {
287 MutexType aGuard( BaseType::m_aMutex );
288 maPropHelper.setPropertyValue( aPropertyName, aValue );
289 }
290
291 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& aPropertyName ) override
292 {
293 MutexType aGuard( BaseType::m_aMutex );
294 return maPropHelper.getPropertyValue( aPropertyName );
295 }
296
297 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
298 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override
299 {
300 MutexType aGuard( BaseType::m_aMutex );
302 xListener );
303 }
304
305 virtual void SAL_CALL removePropertyChangeListener( const OUString& ,
306 const css::uno::Reference< css::beans::XPropertyChangeListener >& ) override
307 {
308 }
309
310 virtual void SAL_CALL addVetoableChangeListener( const OUString& aPropertyName,
311 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener ) override
312 {
313 MutexType aGuard( BaseType::m_aMutex );
315 xListener );
316 }
317
318 virtual void SAL_CALL removeVetoableChangeListener( const OUString& ,
319 const css::uno::Reference< css::beans::XVetoableChangeListener >& ) override
320 {
321 }
322
323 protected:
324 ~GraphicDeviceBase() {} // we're a ref-counted UNO class. _We_ destroy ourselves.
325
326 css::uno::Any getDumpScreenContent() const
327 {
328 return css::uno::Any( mbDumpScreenContent );
329 }
330
331 void setDumpScreenContent( const css::uno::Any& rAny )
332 {
333 // TODO(Q1): this was mbDumpScreenContent =
334 // rAny.get<bool>(), only that gcc3.3 wouldn't eat it
335 rAny >>= mbDumpScreenContent;
336 }
337
338 DeviceHelper maDeviceHelper;
341
342 private:
345 };
346}
347
348/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper template base class for XGraphicDevice implementations.
virtual css::uno::Reference< css::lang::XMultiServiceFactory > SAL_CALL getParametricPolyPolygonFactory() override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void disposeThis() override
virtual css::uno::Reference< css::rendering::XVolatileBitmap > SAL_CALL createVolatileBitmap(const css::geometry::IntegerSize2D &size) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const OUString &aServiceSpecifier, const css::uno::Sequence< css::uno::Any > &Arguments) override
virtual css::geometry::RealSize2D SAL_CALL getPhysicalSize() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &aPropertyName) override
virtual css::uno::Reference< css::rendering::XBitmap > SAL_CALL createCompatibleBitmap(const css::geometry::IntegerSize2D &size) override
virtual css::uno::Reference< css::rendering::XColorSpace > SAL_CALL getDeviceColorSpace() override
::rtl::Reference< GraphicDeviceBase > Reference
virtual void SAL_CALL removePropertyChangeListener(const OUString &, const css::uno::Reference< css::beans::XPropertyChangeListener > &) override
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
css::uno::Any getDumpScreenContent() const
virtual void SAL_CALL update() override
virtual css::geometry::RealSize2D SAL_CALL getPhysicalResolution() override
virtual css::uno::Reference< css::rendering::XVolatileBitmap > SAL_CALL createVolatileAlphaBitmap(const css::geometry::IntegerSize2D &size) override
void setDumpScreenContent(const css::uno::Any &rAny)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
GraphicDeviceBase(const GraphicDeviceBase &)=delete
virtual sal_Bool SAL_CALL enterFullScreenMode(sal_Bool) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(const OUString &aServiceSpecifier) override
virtual sal_Bool SAL_CALL hasFullScreenMode() override
virtual css::uno::Reference< css::rendering::XBufferController > SAL_CALL getBufferController() override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &, const css::uno::Reference< css::beans::XVetoableChangeListener > &) override
GraphicDeviceBase & operator=(const GraphicDeviceBase &)=delete
virtual css::uno::Reference< css::rendering::XBitmap > SAL_CALL createCompatibleAlphaBitmap(const css::geometry::IntegerSize2D &size) override
virtual css::uno::Reference< css::rendering::XLinePolyPolygon2D > SAL_CALL createCompatibleLinePolyPolygon(const css::uno::Sequence< css::uno::Sequence< css::geometry::RealPoint2D > > &points) override
virtual css::uno::Reference< css::rendering::XBezierPolyPolygon2D > SAL_CALL createCompatibleBezierPolyPolygon(const css::uno::Sequence< css::uno::Sequence< css::geometry::RealBezierSegment2D > > &points) override
static rtl::Reference< ParametricPolyPolygon > create(const css::uno::Reference< css::rendering::XGraphicDevice > &rDevice, std::u16string_view rServiceName, const css::uno::Sequence< css::uno::Any > &rArgs)
static css::uno::Sequence< OUString > getAvailableServiceNames()
Really simplistic XPropertySet helper for properties.
std::vector< MapType::MapEntry > InputMap
void addVetoableChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener)
void setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue)
void addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener)
css::uno::Any getPropertyValue(const OUString &PropertyName) const
css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfo() const
void initProperties(InputMap &&rMap)
Init helper with new name/value map.
size
void verifyBitmapSize(const geometry::IntegerSize2D &size, const char *pStr, const uno::Reference< uno::XInterface > &xIf)
unsigned char sal_Bool
Base