1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_CANVAS_BITMAPCANVASBASE_HXX 25 #define INCLUDED_CANVAS_BITMAPCANVASBASE_HXX 26 27 #include <canvas/base/canvasbase.hxx> 28 #include <com/sun/star/rendering/XBitmapCanvas.hpp> 29 30 namespace canvas 31 { 32 /** Helper template to handle XBitmapCanvas method forwarding to 33 BitmapCanvasHelper 34 35 Use this helper to handle the XBitmapCanvas part of your 36 implementation. 37 38 @tpl Base 39 Base class to use, most probably one of the 40 WeakComponentImplHelperN templates with the appropriate 41 interfaces. At least XBitmapCanvas should be among them (why 42 else would you use this template, then?). Base class must have 43 an Base( const Mutex& ) constructor (like the 44 WeakComponentImplHelperN templates have). 45 46 @tpl CanvasHelper 47 Canvas helper implementation for the backend in question 48 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. 55 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) 61 62 @see CanvasBase for further contractual requirements towards 63 the CanvasHelper type, and some examples. 64 */ 65 template< class Base, 66 class CanvasHelper, 67 class Mutex=::osl::MutexGuard, 68 class UnambiguousBase=::com::sun::star::uno::XInterface > class BitmapCanvasBase : 69 public CanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > 70 { 71 public: 72 typedef CanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType; 73 74 // XBitmapCanvas copyRect(const::com::sun::star::uno::Reference<::com::sun::star::rendering::XBitmapCanvas> & sourceCanvas,const::com::sun::star::geometry::RealRectangle2D & sourceRect,const::com::sun::star::rendering::ViewState & sourceViewState,const::com::sun::star::rendering::RenderState & sourceRenderState,const::com::sun::star::geometry::RealRectangle2D & destRect,const::com::sun::star::rendering::ViewState & destViewState,const::com::sun::star::rendering::RenderState & destRenderState)75 virtual void SAL_CALL copyRect( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas, 76 const ::com::sun::star::geometry::RealRectangle2D& sourceRect, 77 const ::com::sun::star::rendering::ViewState& sourceViewState, 78 const ::com::sun::star::rendering::RenderState& sourceRenderState, 79 const ::com::sun::star::geometry::RealRectangle2D& destRect, 80 const ::com::sun::star::rendering::ViewState& destViewState, 81 const ::com::sun::star::rendering::RenderState& destRenderState ) throw (::com::sun::star::lang::IllegalArgumentException, 82 ::com::sun::star::uno::RuntimeException) 83 { 84 tools::verifyArgs(sourceCanvas, sourceRect, sourceViewState, sourceRenderState, 85 destRect, destViewState, destRenderState, 86 BOOST_CURRENT_FUNCTION, 87 static_cast< typename BaseType::UnambiguousBaseType* >(this)); 88 89 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 90 91 BaseType::mbSurfaceDirty = true; 92 BaseType::maCanvasHelper.modifying(); 93 94 BaseType::maCanvasHelper.copyRect( this, 95 sourceCanvas, 96 sourceRect, 97 sourceViewState, 98 sourceRenderState, 99 destRect, 100 destViewState, 101 destRenderState ); 102 } 103 104 // XBitmap getSize()105 virtual ::com::sun::star::geometry::IntegerSize2D SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException) 106 { 107 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 108 109 return BaseType::maCanvasHelper.getSize(); 110 } 111 hasAlpha()112 virtual ::sal_Bool SAL_CALL hasAlpha( ) throw (::com::sun::star::uno::RuntimeException) 113 { 114 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 115 116 return BaseType::maCanvasHelper.hasAlpha(); 117 } 118 getScaledBitmap(const::com::sun::star::geometry::RealSize2D & newSize,sal_Bool beFast)119 virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > SAL_CALL getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize, 120 sal_Bool beFast ) throw (::com::sun::star::uno::RuntimeException) 121 { 122 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 123 124 return BaseType::maCanvasHelper.getScaledBitmap( newSize, beFast ); 125 } 126 127 }; 128 } 129 130 #endif /* INCLUDED_CANVAS_BITMAPCANVASBASE_HXX */ 131