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 .
20 #ifndef INCLUDED_CANVAS_SOURCE_VCL_SPRITECANVAS_HXX
21 #define INCLUDED_CANVAS_SOURCE_VCL_SPRITECANVAS_HXX
23 #include <rtl/ref.hxx>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <com/sun/star/beans/XPropertySet.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/compbase9.hxx>
36 #include <comphelper/uno3.hxx>
38 #include <canvas/base/spritecanvasbase.hxx>
39 #include <canvas/base/disambiguationhelper.hxx>
40 #include <canvas/base/bufferedgraphicdevicebase.hxx>
42 #include "spritecanvashelper.hxx"
43 #include "impltools.hxx"
44 #include "spritedevicehelper.hxx"
45 #include "repainttarget.hxx"
48 #define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.VCL"
49 #define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.VCL"
53 typedef ::cppu::WeakComponentImplHelper9
< ::com::sun::star::rendering::XSpriteCanvas
,
54 ::com::sun::star::rendering::XIntegerBitmap
,
55 ::com::sun::star::rendering::XGraphicDevice
,
56 ::com::sun::star::lang::XMultiServiceFactory
,
57 ::com::sun::star::rendering::XBufferController
,
58 ::com::sun::star::awt::XWindowListener
,
59 ::com::sun::star::util::XUpdatable
,
60 ::com::sun::star::beans::XPropertySet
,
61 ::com::sun::star::lang::XServiceName
> WindowGraphicDeviceBase_Base
;
62 typedef ::canvas::BufferedGraphicDeviceBase
< ::canvas::DisambiguationHelper
< WindowGraphicDeviceBase_Base
>,
65 ::cppu::OWeakObject
> SpriteCanvasBase_Base
;
67 /** Mixin SpriteSurface
69 Have to mixin the SpriteSurface before deriving from
70 ::canvas::SpriteCanvasBase, as this template should already
71 implement some of those interface methods.
73 The reason why this appears kinda convoluted is the fact that
74 we cannot specify non-IDL types as WeakComponentImplHelperN
75 template args, and furthermore, don't want to derive
76 ::canvas::SpriteCanvasBase directly from
77 ::canvas::SpriteSurface (because derivees of
78 ::canvas::SpriteCanvasBase have to explicitly forward the
79 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
80 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
81 remain a base class that provides implementation, not to
82 enforce any specific interface on its derivees.
84 class SpriteCanvasBaseSpriteSurface_Base
: public SpriteCanvasBase_Base
,
85 public ::canvas::SpriteSurface
89 typedef ::canvas::SpriteCanvasBase
< SpriteCanvasBaseSpriteSurface_Base
,
92 ::cppu::OWeakObject
> SpriteCanvasBaseT
;
94 /** Product of this component's factory.
96 The SpriteCanvas object combines the actual Window canvas with
97 the XGraphicDevice interface. This is because there's a
98 one-to-one relation between them, anyway, since each window
99 can have exactly one canvas and one associated
100 XGraphicDevice. And to avoid messing around with circular
101 references, this is implemented as one single object.
103 class SpriteCanvas
: public SpriteCanvasBaseT
,
107 SpriteCanvas( const ::com::sun::star::uno::Sequence
<
108 ::com::sun::star::uno::Any
>& aArguments
,
109 const ::com::sun::star::uno::Reference
<
110 ::com::sun::star::uno::XComponentContext
>& rxContext
);
114 /// For resource tracking
115 virtual ~SpriteCanvas();
117 /// Dispose all internal references
118 virtual void disposeThis() SAL_OVERRIDE
;
120 // Forwarding the XComponent implementation to the
121 // cppu::ImplHelper templated base
122 // Classname Base doing refcounting Base implementing the XComponent interface
125 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas
, WindowGraphicDeviceBase_Base
, ::cppu::WeakComponentImplHelperBase
)
127 // XBufferController (partial)
128 virtual sal_Bool SAL_CALL
showBuffer( sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
129 virtual sal_Bool SAL_CALL
switchBuffer( sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
131 // XSpriteCanvas (partial)
132 virtual sal_Bool SAL_CALL
updateScreen( sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
135 virtual OUString SAL_CALL
getServiceName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
138 virtual bool repaint( const GraphicObjectSharedPtr
& rGrf
,
139 const ::com::sun::star::rendering::ViewState
& viewState
,
140 const ::com::sun::star::rendering::RenderState
& renderState
,
143 const GraphicAttr
& rAttr
) const SAL_OVERRIDE
;
145 /// Get backbuffer for this canvas
146 OutDevProviderSharedPtr
getFrontBuffer() const { return maDeviceHelper
.getOutDev(); }
147 /// Get window for this canvas
148 BackBufferSharedPtr
getBackBuffer() const { return maDeviceHelper
.getBackBuffer(); }
151 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> maArguments
;
152 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> mxComponentContext
;
155 typedef ::rtl::Reference
< SpriteCanvas
> SpriteCanvasRef
;
156 typedef ::rtl::Reference
< SpriteCanvas
> DeviceRef
;
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */