fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / canvas / source / cairo / cairo_canvascustomsprite.hxx
blobcfb6377f6a695bea13d4b8dc98fc20ae31bb6ef7
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 #ifndef _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX
21 #define _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX
23 #include <cppuhelper/compbase4.hxx>
24 #include <comphelper/uno3.hxx>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/rendering/XCustomSprite.hpp>
29 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
30 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
32 #include <basegfx/point/b2dpoint.hxx>
33 #include <basegfx/vector/b2isize.hxx>
34 #include <basegfx/matrix/b2dhommatrix.hxx>
36 #include <canvas/base/disambiguationhelper.hxx>
37 #include <canvas/base/canvascustomspritebase.hxx>
39 #include "cairo_sprite.hxx"
40 #include "cairo_cairo.hxx"
41 #include "cairo_canvashelper.hxx"
42 #include "cairo_repainttarget.hxx"
43 #include "cairo_spritehelper.hxx"
44 #include "cairo_spritecanvas.hxx"
47 namespace cairocanvas
49 typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XCustomSprite,
50 ::com::sun::star::rendering::XBitmapCanvas,
51 ::com::sun::star::rendering::XIntegerBitmap,
52 ::com::sun::star::lang::XServiceInfo > CanvasCustomSpriteBase_Base;
53 /** Mixin Sprite
55 Have to mixin the Sprite interface before deriving from
56 ::canvas::CanvasCustomSpriteBase, as this template should
57 already implement some of those interface methods.
59 The reason why this appears kinda convoluted is the fact that
60 we cannot specify non-IDL types as WeakComponentImplHelperN
61 template args, and furthermore, don't want to derive
62 ::canvas::CanvasCustomSpriteBase directly from
63 ::canvas::Sprite (because derivees of
64 ::canvas::CanvasCustomSpriteBase have to explicitly forward
65 the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
66 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
67 remain a base class that provides implementation, not to
68 enforce any specific interface on its derivees.
70 class CanvasCustomSpriteSpriteBase_Base : public ::canvas::DisambiguationHelper< CanvasCustomSpriteBase_Base >,
71 public Sprite,
72 public SurfaceProvider
76 typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base,
77 SpriteHelper,
78 CanvasHelper,
79 ::osl::MutexGuard,
80 ::cppu::OWeakObject > CanvasCustomSpriteBaseT;
82 /* Definition of CanvasCustomSprite class */
84 class CanvasCustomSprite : public CanvasCustomSpriteBaseT,
85 public RepaintTarget
87 public:
88 /** Create a custom sprite
90 @param rSpriteSize
91 Size of the sprite in pixel
93 @param rRefDevice
94 Associated output device
96 @param rSpriteCanvas
97 Target canvas
99 @param rDevice
100 Target DX device
102 CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
103 const SpriteCanvasRef& rRefDevice );
105 virtual void disposeThis();
107 // Forwarding the XComponent implementation to the
108 // cppu::ImplHelper templated base
109 // Classname Base doing refcount Base implementing the XComponent interface
110 // | | |
111 // V V V
112 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase );
114 // XServiceInfo
115 virtual OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
116 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
117 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
119 // Sprite
120 virtual void redraw( const ::cairo::CairoSharedPtr& pCairo,
121 bool bBufferedUpdate ) const;
122 virtual void redraw( const ::cairo::CairoSharedPtr& pCairo,
123 const ::basegfx::B2DPoint& rOrigOutputPos,
124 bool bBufferedUpdate ) const;
126 // RepaintTarget
127 virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
128 const ::com::sun::star::rendering::ViewState& viewState,
129 const ::com::sun::star::rendering::RenderState& renderState );
131 // SurfaceProvider
132 virtual SurfaceSharedPtr getSurface();
133 virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
134 virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap );
135 virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent );
136 virtual OutputDevice* getOutputDevice();
138 private:
139 /** MUST hold here, too, since CanvasHelper only contains a
140 raw pointer (without refcounting)
142 SpriteCanvasRef mpSpriteCanvas;
143 ::cairo::SurfaceSharedPtr mpBufferSurface;
144 ::basegfx::B2ISize maSize;
148 #endif /* _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX */
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */