Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _NULLCANVAS_CANVASCUSTOMSPRITE_HXX
21 : #define _NULLCANVAS_CANVASCUSTOMSPRITE_HXX
22 :
23 : #include <cppuhelper/compbase4.hxx>
24 : #include <comphelper/uno3.hxx>
25 :
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>
31 :
32 : #include <basegfx/point/b2dpoint.hxx>
33 : #include <basegfx/vector/b2isize.hxx>
34 : #include <basegfx/matrix/b2dhommatrix.hxx>
35 :
36 : #include <canvas/base/disambiguationhelper.hxx>
37 : #include <canvas/base/canvascustomspritebase.hxx>
38 :
39 : #include "sprite.hxx"
40 : #include "null_canvashelper.hxx"
41 : #include "null_spritehelper.hxx"
42 : #include "null_spritecanvas.hxx"
43 : #include "null_usagecounter.hxx"
44 :
45 :
46 : namespace nullcanvas
47 : {
48 : typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XCustomSprite,
49 : ::com::sun::star::rendering::XBitmapCanvas,
50 : ::com::sun::star::rendering::XIntegerBitmap,
51 : ::com::sun::star::lang::XServiceInfo > CanvasCustomSpriteBase_Base;
52 : /** Mixin Sprite
53 :
54 : Have to mixin the Sprite interface before deriving from
55 : ::canvas::CanvasCustomSpriteBase, as this template should
56 : already implement some of those interface methods.
57 :
58 : The reason why this appears kinda convoluted is the fact that
59 : we cannot specify non-IDL types as WeakComponentImplHelperN
60 : template args, and furthermore, don't want to derive
61 : ::canvas::CanvasCustomSpriteBase directly from
62 : ::canvas::Sprite (because derivees of
63 : ::canvas::CanvasCustomSpriteBase have to explicitly forward
64 : the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
65 : anyway). Basically, ::canvas::CanvasCustomSpriteBase should
66 : remain a base class that provides implementation, not to
67 : enforce any specific interface on its derivees.
68 : */
69 0 : class CanvasCustomSpriteSpriteBase_Base : public ::canvas::DisambiguationHelper< CanvasCustomSpriteBase_Base >,
70 : public Sprite
71 : {
72 : };
73 :
74 : typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base,
75 : SpriteHelper,
76 : CanvasHelper,
77 : ::osl::MutexGuard,
78 : ::cppu::OWeakObject > CanvasCustomSpriteBaseT;
79 :
80 : /* Definition of CanvasCustomSprite class */
81 :
82 0 : class CanvasCustomSprite : public CanvasCustomSpriteBaseT,
83 : private UsageCounter< CanvasCustomSprite >
84 : {
85 : public:
86 : /** Create a custom sprite
87 :
88 : @param rSpriteSize
89 : Size of the sprite in pixel
90 :
91 : @param rRefDevice
92 : Associated output device
93 :
94 : @param rSpriteCanvas
95 : Target canvas
96 :
97 : @param rDevice
98 : Target DX device
99 : */
100 : CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
101 : const SpriteCanvasRef& rRefDevice );
102 :
103 : virtual void disposeThis();
104 :
105 : // Forwarding the XComponent implementation to the
106 : // cppu::ImplHelper templated base
107 : // Classname Base doing refcount Base implementing the XComponent interface
108 : // | | |
109 : // V V V
110 0 : DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase );
111 :
112 : // XServiceInfo
113 : virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
114 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
115 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
116 :
117 : // Sprite
118 : virtual void redraw() const;
119 :
120 : private:
121 : /** MUST hold here, too, since CanvasHelper only contains a
122 : raw pointer (without refcounting)
123 : */
124 : SpriteCanvasRef mpSpriteCanvas;
125 : };
126 : }
127 :
128 : #endif /* _NULLCANVAS_CANVASCUSTOMSPRITE_HXX */
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|