bump product version to 7.6.3.2-android
[LibreOffice.git] / canvas / source / vcl / spritecanvas.hxx
blob8f7c76880f51d68d8ae6443704ea23093050655e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <rtl/ref.hxx>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/lang/XServiceName.hpp>
28 #include <com/sun/star/awt/XWindowListener.hpp>
29 #include <com/sun/star/util/XUpdatable.hpp>
30 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
31 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
32 #include <com/sun/star/rendering/XGraphicDevice.hpp>
33 #include <com/sun/star/rendering/XBufferController.hpp>
35 #include <cppuhelper/compbase.hxx>
36 #include <comphelper/uno3.hxx>
38 #include <base/spritecanvasbase.hxx>
39 #include <base/spritesurface.hxx>
40 #include <base/disambiguationhelper.hxx>
41 #include <base/bufferedgraphicdevicebase.hxx>
43 #include "spritecanvashelper.hxx"
44 #include "impltools.hxx"
45 #include "spritedevicehelper.hxx"
46 #include "repainttarget.hxx"
49 namespace vclcanvas
51 typedef ::cppu::WeakComponentImplHelper< css::rendering::XSpriteCanvas,
52 css::rendering::XIntegerBitmap,
53 css::rendering::XGraphicDevice,
54 css::lang::XMultiServiceFactory,
55 css::rendering::XBufferController,
56 css::awt::XWindowListener,
57 css::util::XUpdatable,
58 css::beans::XPropertySet,
59 css::lang::XServiceName,
60 css::lang::XServiceInfo > WindowGraphicDeviceBase_Base;
61 typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::DisambiguationHelper< WindowGraphicDeviceBase_Base >,
62 SpriteDeviceHelper,
63 tools::LocalGuard,
64 ::cppu::OWeakObject > SpriteCanvasBase_Base;
66 /** Mixin SpriteSurface
68 Have to mixin the SpriteSurface before deriving from
69 ::canvas::SpriteCanvasBase, as this template should already
70 implement some of those interface methods.
72 The reason why this appears kinda convoluted is the fact that
73 we cannot specify non-IDL types as WeakComponentImplHelper
74 template args, and furthermore, don't want to derive
75 ::canvas::SpriteCanvasBase directly from
76 ::canvas::SpriteSurface (because derivees of
77 ::canvas::SpriteCanvasBase have to explicitly forward the
78 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
79 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
80 remain a base class that provides implementation, not to
81 enforce any specific interface on its derivees.
83 class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base,
84 public ::canvas::SpriteSurface
88 typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base,
89 SpriteCanvasHelper,
90 tools::LocalGuard,
91 ::cppu::OWeakObject > SpriteCanvasBaseT;
93 /** Product of this component's factory.
95 The SpriteCanvas object combines the actual Window canvas with
96 the XGraphicDevice interface. This is because there's a
97 one-to-one relation between them, anyway, since each window
98 can have exactly one canvas and one associated
99 XGraphicDevice. And to avoid messing around with circular
100 references, this is implemented as one single object.
102 class SpriteCanvas : public SpriteCanvasBaseT,
103 public RepaintTarget
105 public:
106 SpriteCanvas( const css::uno::Sequence<
107 css::uno::Any >& aArguments,
108 const css::uno::Reference<
109 css::uno::XComponentContext >& rxContext );
111 void initialize();
113 /// For resource tracking
114 virtual ~SpriteCanvas() override;
116 /// Dispose all internal references
117 virtual void disposeThis() override;
119 // Forwarding the XComponent implementation to the
120 // cppu::ImplHelper templated base
121 // Classname Base doing refcounting Base implementing the XComponent interface
122 // | | |
123 // V V V
124 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase )
126 // XBufferController (partial)
127 virtual sal_Bool SAL_CALL showBuffer( sal_Bool bUpdateAll ) override;
128 virtual sal_Bool SAL_CALL switchBuffer( sal_Bool bUpdateAll ) override;
130 // XSpriteCanvas (partial)
131 virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) override;
133 // XServiceName
134 virtual OUString SAL_CALL getServiceName( ) override;
136 // XServiceInfo
137 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
138 virtual OUString SAL_CALL getImplementationName() override;
139 virtual sal_Bool SAL_CALL supportsService(const OUString&) override;
141 // RepaintTarget
142 virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
143 const css::rendering::ViewState& viewState,
144 const css::rendering::RenderState& renderState,
145 const ::Point& rPt,
146 const ::Size& rSz,
147 const GraphicAttr& rAttr ) const override;
149 /// Get backbuffer for this canvas
150 OutDevProviderSharedPtr const & getFrontBuffer() const { return maDeviceHelper.getOutDev(); }
151 /// Get window for this canvas
152 BackBufferSharedPtr const & getBackBuffer() const { return maDeviceHelper.getBackBuffer(); }
154 private:
155 css::uno::Sequence< css::uno::Any > maArguments;
158 typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
159 typedef ::rtl::Reference< SpriteCanvas > DeviceRef;
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */