fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / canvas / base / spritecanvasbase.hxx
blobf892bf4170a71857dddafe0d1c92a1d0cde46fec
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 INCLUDED_CANVAS_SPRITECANVASBASE_HXX
21 #define INCLUDED_CANVAS_SPRITECANVASBASE_HXX
23 #include <rtl/ref.hxx>
24 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
25 #include <com/sun/star/rendering/InterpolationMode.hpp>
26 #include <canvas/base/integerbitmapbase.hxx>
27 #include <canvas/spriteredrawmanager.hxx>
30 namespace canvas
32 /** Helper template to handle XIntegerBitmap method forwarding to
33 BitmapCanvasHelper
35 Use this helper to handle the XIntegerBitmap part of your
36 implementation.
38 @tpl Base
39 Base class to use, most probably one of the
40 WeakComponentImplHelperN templates with the appropriate
41 interfaces. At least XSpriteCanvas and SpriteSurface should be
42 among them (why else would you use this template, then?). Base
43 class must have an Base( const Mutex& ) constructor (like the
44 WeakComponentImplHelperN templates have).
46 @tpl CanvasHelper
47 Canvas helper implementation for the backend in question
49 @tpl Mutex
50 Lock strategy to use. Defaults to using the
51 OBaseMutex-provided lock. Everytime one of the methods is
52 entered, an object of type Mutex is created with m_aMutex as
53 the sole parameter, and destroyed again when the method scope
54 is left.
56 @tpl UnambiguousBase
57 Optional unambiguous base class for XInterface of Base. It's
58 sometimes necessary to specify this parameter, e.g. if Base
59 derives from multiple UNO interface (were each provides its
60 own version of XInterface, making the conversion ambiguous)
62 @see CanvasBase for further contractual requirements towards
63 the CanvasHelper type, and some examples.
65 template< class Base,
66 class CanvasHelper,
67 class Mutex=::osl::MutexGuard,
68 class UnambiguousBase=::com::sun::star::uno::XInterface > class SpriteCanvasBase :
69 public IntegerBitmapBase< Base, CanvasHelper, Mutex, UnambiguousBase >
71 public:
72 typedef IntegerBitmapBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType;
73 typedef ::rtl::Reference< SpriteCanvasBase > Reference;
75 SpriteCanvasBase() :
76 maRedrawManager()
80 virtual void disposeThis()
82 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
84 maRedrawManager.disposing();
86 // pass on to base class
87 BaseType::disposeThis();
90 // XSpriteCanvas
91 virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromAnimation( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation ) throw (::com::sun::star::lang::IllegalArgumentException,
92 ::com::sun::star::uno::RuntimeException)
94 tools::verifyArgs(animation,
95 BOOST_CURRENT_FUNCTION,
96 static_cast< typename BaseType::UnambiguousBaseType* >(this));
98 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
100 return BaseType::maCanvasHelper.createSpriteFromAnimation(animation);
103 virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromBitmaps( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > >& animationBitmaps,
104 sal_Int8 interpolationMode ) throw (::com::sun::star::lang::IllegalArgumentException,
105 ::com::sun::star::rendering::VolatileContentDestroyedException,
106 ::com::sun::star::uno::RuntimeException)
108 tools::verifyArgs(animationBitmaps,
109 BOOST_CURRENT_FUNCTION,
110 static_cast< typename BaseType::UnambiguousBaseType* >(this));
111 tools::verifyRange( interpolationMode,
112 ::com::sun::star::rendering::InterpolationMode::NEAREST_NEIGHBOR,
113 ::com::sun::star::rendering::InterpolationMode::BEZIERSPLINE4 );
115 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
117 return BaseType::maCanvasHelper.createSpriteFromBitmaps(animationBitmaps, interpolationMode);
120 virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCustomSprite > SAL_CALL createCustomSprite( const ::com::sun::star::geometry::RealSize2D& spriteSize ) throw (::com::sun::star::lang::IllegalArgumentException,
121 ::com::sun::star::uno::RuntimeException)
123 tools::verifySpriteSize(spriteSize,
124 BOOST_CURRENT_FUNCTION,
125 static_cast< typename BaseType::UnambiguousBaseType* >(this));
127 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
129 return BaseType::maCanvasHelper.createCustomSprite(spriteSize);
132 virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite > SAL_CALL createClonedSprite( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original ) throw (::com::sun::star::lang::IllegalArgumentException,
133 ::com::sun::star::uno::RuntimeException)
135 tools::verifyArgs(original,
136 BOOST_CURRENT_FUNCTION,
137 static_cast< typename BaseType::UnambiguousBaseType* >(this));
139 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
141 return BaseType::maCanvasHelper.createClonedSprite(original);
144 // SpriteSurface
145 virtual void showSprite( const Sprite::Reference& rSprite )
147 OSL_ASSERT( rSprite.is() );
149 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
151 maRedrawManager.showSprite( rSprite );
154 virtual void hideSprite( const Sprite::Reference& rSprite )
156 OSL_ASSERT( rSprite.is() );
158 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
160 maRedrawManager.hideSprite( rSprite );
163 virtual void moveSprite( const Sprite::Reference& rSprite,
164 const ::basegfx::B2DPoint& rOldPos,
165 const ::basegfx::B2DPoint& rNewPos,
166 const ::basegfx::B2DVector& rSpriteSize )
168 OSL_ASSERT( rSprite.is() );
170 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
172 maRedrawManager.moveSprite( rSprite, rOldPos, rNewPos, rSpriteSize );
175 virtual void updateSprite( const Sprite::Reference& rSprite,
176 const ::basegfx::B2DPoint& rPos,
177 const ::basegfx::B2DRange& rUpdateArea )
179 OSL_ASSERT( rSprite.is() );
181 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
183 maRedrawManager.updateSprite( rSprite, rPos, rUpdateArea );
186 protected:
187 SpriteRedrawManager maRedrawManager;
191 #endif /* INCLUDED_CANVAS_SPRITECANVASBASE_HXX */
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */