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 .
22 #include <com/sun/star/uno/XComponentContext.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/lang/XServiceName.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/util/XUpdatable.hpp>
27 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
28 #include <com/sun/star/rendering/XGraphicDevice.hpp>
29 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
31 #include <cppuhelper/compbase.hxx>
32 #include <comphelper/uno3.hxx>
34 #include <base/basemutexhelper.hxx>
35 #include <base/bitmapcanvasbase.hxx>
36 #include <base/graphicdevicebase.hxx>
37 #include <base/integerbitmapbase.hxx>
39 #include "cairo_canvashelper.hxx"
40 #include "cairo_devicehelper.hxx"
41 #include "cairo_repainttarget.hxx"
42 #include "cairo_surfaceprovider.hxx"
46 typedef ::cppu::WeakComponentImplHelper
< css::rendering::XBitmapCanvas
,
47 css::rendering::XIntegerBitmap
,
48 css::rendering::XGraphicDevice
,
49 css::lang::XMultiServiceFactory
,
50 css::util::XUpdatable
,
51 css::beans::XPropertySet
,
52 css::lang::XServiceName
,
53 css::lang::XServiceInfo
> GraphicDeviceBase_Base
;
54 typedef ::canvas::GraphicDeviceBase
< ::canvas::BaseMutexHelper
< GraphicDeviceBase_Base
>,
57 ::cppu::OWeakObject
> CanvasBase_Base
;
59 /** Mixin SurfaceProvider
61 Have to mixin the SurfaceProvider before deriving from
62 ::canvas::CanvasBase, as this template should already
63 implement some of those interface methods.
65 The reason why this appears kinda convoluted is the fact that
66 we cannot specify non-IDL types as WeakComponentImplHelper
67 template args, and furthermore, don't want to derive
68 ::canvas::CanvasBase directly from
69 SurfaceProvider (because derivees of
70 ::canvas::CanvasBase have to explicitly forward the
71 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
74 class CanvasBaseSurfaceProvider_Base
: public CanvasBase_Base
,
75 public SurfaceProvider
79 typedef ::canvas::IntegerBitmapBase
<
80 canvas::BitmapCanvasBase2
<
81 CanvasBaseSurfaceProvider_Base
,
84 ::cppu::OWeakObject
> > CanvasBaseT
;
86 /** Product of this component's factory.
88 The Canvas object combines the actual Window canvas with
89 the XGraphicDevice interface. This is because there's a
90 one-to-one relation between them, anyway, since each window
91 can have exactly one canvas and one associated
92 XGraphicDevice. And to avoid messing around with circular
93 references, this is implemented as one single object.
95 class Canvas
: public CanvasBaseT
,
99 Canvas( const css::uno::Sequence
< css::uno::Any
>& aArguments
,
100 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
104 /// For resource tracking
105 virtual ~Canvas() override
;
107 /// Dispose all internal references
108 virtual void disposeThis() override
;
110 // Forwarding the XComponent implementation to the
111 // cppu::ImplHelper templated base
112 // Classname Base doing refcounting Base implementing the XComponent interface
115 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( Canvas
, GraphicDeviceBase_Base
, ::cppu::WeakComponentImplHelperBase
)
118 virtual OUString SAL_CALL
getServiceName( ) override
;
121 virtual sal_Bool SAL_CALL
supportsService(const OUString
& sServiceName
) override
;
122 virtual OUString SAL_CALL
getImplementationName() override
;
123 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
126 virtual bool repaint( const ::cairo::SurfaceSharedPtr
& pSurface
,
127 const css::rendering::ViewState
& viewState
,
128 const css::rendering::RenderState
& renderState
) override
;
131 virtual ::cairo::SurfaceSharedPtr
getSurface() override
;
132 virtual ::cairo::SurfaceSharedPtr
createSurface( const ::basegfx::B2ISize
& rSize
, int aContent
) override
;
133 virtual ::cairo::SurfaceSharedPtr
createSurface( ::Bitmap
& rBitmap
) override
;
134 virtual ::cairo::SurfaceSharedPtr
changeSurface() override
;
135 virtual OutputDevice
* getOutputDevice() override
;
138 css::uno::Sequence
< css::uno::Any
> maArguments
;
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */