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/lang/XComponent.hpp>
27 #include <com/sun/star/rendering/XCustomSprite.hpp>
28 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
29 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
31 #include <basegfx/point/b2dpoint.hxx>
32 #include <basegfx/vector/b2isize.hxx>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
35 #include <base/basemutexhelper.hxx>
36 #include <base/canvascustomspritebase.hxx>
38 #include "dx_sprite.hxx"
39 #include "dx_surfacebitmap.hxx"
40 #include "dx_bitmapcanvashelper.hxx"
41 #include "dx_spritehelper.hxx"
42 #include "dx_spritecanvas.hxx"
47 typedef ::cppu::WeakComponentImplHelper
< css::rendering::XCustomSprite
,
48 css::rendering::XBitmapCanvas
,
49 css::rendering::XIntegerBitmap
,
50 css::lang::XServiceInfo
> CanvasCustomSpriteBase_Base
;
53 Have to mixin the Sprite interface before deriving from
54 ::canvas::CanvasCustomSpriteBase, as this template should
55 already implement some of those interface methods.
57 The reason why this appears kinda convoluted is the fact that
58 we cannot specify non-IDL types as WeakComponentImplHelper
59 template args, and furthermore, don't want to derive
60 ::canvas::CanvasCustomSpriteBase directly from
61 ::canvas::Sprite (because derivees of
62 ::canvas::CanvasCustomSpriteBase have to explicitly forward
63 the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
64 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
65 remain a base class that provides implementation, not to
66 enforce any specific interface on its derivees.
68 class CanvasCustomSpriteSpriteBase_Base
: public ::canvas::BaseMutexHelper
< CanvasCustomSpriteBase_Base
>,
73 typedef ::canvas::CanvasCustomSpriteBase
< CanvasCustomSpriteSpriteBase_Base
,
77 ::cppu::OWeakObject
> CanvasCustomSpriteBaseT
;
79 /* Definition of CanvasCustomSprite class */
81 class CanvasCustomSprite
: public CanvasCustomSpriteBaseT
84 /** Create a custom sprite
87 Size of the sprite in pixel
90 Associated output device
98 CanvasCustomSprite( const css::geometry::RealSize2D
& rSpriteSize
,
99 const SpriteCanvasRef
& rRefDevice
,
100 const IDXRenderModuleSharedPtr
& rRenderModule
,
101 const std::shared_ptr
<canvas::ISurfaceProxyManager
>& rSurfaceProxy
,
102 bool bShowSpriteBounds
);
104 virtual void disposeThis() override
;
106 // Forwarding the XComponent implementation to the
107 // cppu::ImplHelper templated base
108 // Classname Base doing refcount Base implementing the XComponent interface
111 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite
, CanvasCustomSpriteBase_Base
, ::cppu::WeakComponentImplHelperBase
)
114 virtual OUString SAL_CALL
getImplementationName() override
;
115 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
116 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
119 virtual void redraw() const override
;
122 /** MUST hold here, too, since BitmapCanvasHelper only contains a
123 raw pointer (without refcounting)
125 SpriteCanvasRef mpSpriteCanvas
;
126 DXSurfaceBitmapSharedPtr mpSurface
;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */