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 <cppuhelper/compbase.hxx>
23 #include <comphelper/uno3.hxx>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
27 #include <com/sun/star/rendering/XCustomSprite.hpp>
28 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
30 #include <basegfx/point/b2dpoint.hxx>
32 #include <base/basemutexhelper.hxx>
33 #include <base/canvascustomspritebase.hxx>
35 #include <vcl/cairo.hxx>
37 #include "cairo_sprite.hxx"
38 #include "cairo_canvashelper.hxx"
39 #include "cairo_repainttarget.hxx"
40 #include "cairo_spritehelper.hxx"
41 #include "cairo_spritecanvas.hxx"
46 typedef ::cppu::WeakComponentImplHelper
< css::rendering::XCustomSprite
,
47 css::rendering::XBitmapCanvas
,
48 css::rendering::XIntegerBitmap
,
49 css::lang::XServiceInfo
> CanvasCustomSpriteBase_Base
;
52 Have to mixin the Sprite interface before deriving from
53 ::canvas::CanvasCustomSpriteBase, as this template should
54 already implement some of those interface methods.
56 The reason why this appears kinda convoluted is the fact that
57 we cannot specify non-IDL types as WeakComponentImplHelper
58 template args, and furthermore, don't want to derive
59 ::canvas::CanvasCustomSpriteBase directly from
60 ::canvas::Sprite (because derivees of
61 ::canvas::CanvasCustomSpriteBase have to explicitly forward
62 the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
63 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
64 remain a base class that provides implementation, not to
65 enforce any specific interface on its derivees.
67 class CanvasCustomSpriteSpriteBase_Base
: public ::canvas::BaseMutexHelper
< CanvasCustomSpriteBase_Base
>,
69 public SurfaceProvider
73 typedef ::canvas::CanvasCustomSpriteBase
< CanvasCustomSpriteSpriteBase_Base
,
77 ::cppu::OWeakObject
> CanvasCustomSpriteBaseT
;
79 /* Definition of CanvasCustomSprite class */
81 class CanvasCustomSprite
: public CanvasCustomSpriteBaseT
,
85 /** Create a custom sprite
88 Size of the sprite in pixel
91 Associated output device
99 CanvasCustomSprite( const css::geometry::RealSize2D
& rSpriteSize
,
100 const SpriteCanvasRef
& rRefDevice
);
102 virtual void disposeThis() override
;
104 // Forwarding the XComponent implementation to the
105 // cppu::ImplHelper templated base
106 // Classname Base doing refcount Base implementing the XComponent interface
109 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite
, CanvasCustomSpriteBase_Base
, ::cppu::WeakComponentImplHelperBase
)
112 virtual OUString SAL_CALL
getImplementationName() override
;
113 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
114 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
117 virtual void redraw( const ::cairo::CairoSharedPtr
& pCairo
,
118 bool bBufferedUpdate
) const override
;
119 virtual void redraw( const ::cairo::CairoSharedPtr
& pCairo
,
120 const ::basegfx::B2DPoint
& rOrigOutputPos
,
121 bool bBufferedUpdate
) const override
;
124 virtual bool repaint( const ::cairo::SurfaceSharedPtr
& pSurface
,
125 const css::rendering::ViewState
& viewState
,
126 const css::rendering::RenderState
& renderState
) override
;
129 virtual ::cairo::SurfaceSharedPtr
getSurface() override
;
130 virtual ::cairo::SurfaceSharedPtr
createSurface( const ::basegfx::B2ISize
& rSize
, int aContent
) override
;
131 virtual ::cairo::SurfaceSharedPtr
createSurface( ::Bitmap
& rBitmap
) override
;
132 virtual ::cairo::SurfaceSharedPtr
changeSurface() override
;
133 virtual OutputDevice
* getOutputDevice() override
;
136 /** MUST hold here, too, since CanvasHelper only contains a
137 raw pointer (without refcounting)
139 SpriteCanvasRef mpSpriteCanvas
;
140 ::cairo::SurfaceSharedPtr mpBufferSurface
;
141 ::basegfx::B2ISize maSize
;
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */