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_DOUBLEBITMAPBASE_HXX
25 #define INCLUDED_CANVAS_DOUBLEBITMAPBASE_HXX
26 
27 #include <com/sun/star/rendering/XIeeeDoubleBitmap.hpp>
28 #include <canvas/bitmapcanvasbase.hxx>
29 
30 
31 namespace canvas
32 {
33     /** Helper template to handle XIeeeDoubleBitmap method forwarding to
34         BitmapCanvasHelper
35 
36     	Use this helper to handle the XIeeeDoubleBitmap part of your
37     	implementation.
38 
39         @tpl Base
40         Base class to use, most probably one of the
41         WeakComponentImplHelperN templates with the appropriate
42         interfaces. At least XIeeeDoubleBitmap should be among them (why
43         else would you use this template, then?). Base class must have
44         an Base( const Mutex& ) constructor (like the
45         WeakComponentImplHelperN templates have).
46 
47         @tpl CanvasHelper
48         Canvas helper implementation for the backend in question
49 
50         @tpl Mutex
51         Lock strategy to use. Defaults to using the
52         OBaseMutex-provided lock.  Every time one of the methods is
53         entered, an object of type Mutex is created with m_aMutex as
54         the sole parameter, and destroyed again when the method scope
55         is left.
56 
57         @tpl UnambiguousBase
58         Optional unambiguous base class for XInterface of Base. It's
59         sometimes necessary to specify this parameter, e.g. if Base
60         derives from multiple UNO interface (were each provides its
61         own version of XInterface, making the conversion ambiguous)
62 
63         @see CanvasBase for further contractual requirements towards
64         the CanvasHelper type, and some examples.
65      */
66     template< class Base,
67               class CanvasHelper,
68               class Mutex=::osl::MutexGuard,
69               class UnambiguousBase=::com::sun::star::uno::XInterface > class DoubleBitmapBase :
70         public BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >
71     {
72     public:
73         typedef BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >	BaseType;
74 
75         // XIeeeDoubleBitmap
getData(::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerRectangle2D & rect)76         virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getData( ::com::sun::star::rendering::FloatingPointBitmapLayout&	bitmapLayout,
77                                                                             const ::com::sun::star::geometry::IntegerRectangle2D& 	rect ) throw (::com::sun::star::lang::IndexOutOfBoundsException,
78                                                                                                                                                   ::com::sun::star::rendering::VolatileContentDestroyedException,
79                                                                                                                                                   ::com::sun::star::uno::RuntimeException)
80         {
81             verifyInput(rect, this);
82             verifyIndexRange(rect, getSize() );
83 
84             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
85 
86             return BaseType::maCanvasHelper.getData( bitmapLayout,
87                                                      rect );
88         }
89 
setData(const::com::sun::star::uno::Sequence<double> & data,const::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerRectangle2D & rect)90         virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< double >& 			 data,
91                                        const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout,
92                                        const ::com::sun::star::geometry::IntegerRectangle2D& 		 rect ) throw (::com::sun::star::lang::IllegalArgumentException,
93                                                                                                                    ::com::sun::star::lang::IndexOutOfBoundsException,
94                                                                                                                    ::com::sun::star::uno::RuntimeException)
95         {
96             verifyInput(bitmapLayout, rect, this);
97             verifyIndexRange(rect, getSize() );
98 
99             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
100 
101             BaseType::mbSurfaceDirty = true;
102             BaseType::maCanvasHelper.modifying();
103 
104             BaseType::maCanvasHelper.setData( data, bitmapLayout, rect );
105         }
106 
setPixel(const::com::sun::star::uno::Sequence<double> & color,const::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerPoint2D & pos)107         virtual void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< double >& 				color,
108                                         const ::com::sun::star::rendering::FloatingPointBitmapLayout&	bitmapLayout,
109                                         const ::com::sun::star::geometry::IntegerPoint2D& 				pos ) throw (::com::sun::star::lang::IllegalArgumentException,
110                                                                                                                      ::com::sun::star::lang::IndexOutOfBoundsException,
111                                                                                                                      ::com::sun::star::uno::RuntimeException)
112         {
113             verifyInput(bitmapLayout, pos, this);
114             verifyIndexRange(pos, getSize() );
115 
116             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
117 
118             BaseType::mbSurfaceDirty = true;
119             BaseType::maCanvasHelper.modifying();
120 
121             BaseType::maCanvasHelper.setPixel( color, bitmapLayout, pos );
122         }
123 
getPixel(::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerPoint2D & pos)124         virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getPixel( ::com::sun::star::rendering::FloatingPointBitmapLayout&	bitmapLayout,
125                                                                              const ::com::sun::star::geometry::IntegerPoint2D& 			pos ) throw (::com::sun::star::lang::IndexOutOfBoundsException,
126                                                                                                                                                      ::com::sun::star::rendering::VolatileContentDestroyedException,
127                                                                                                                                                      ::com::sun::star::uno::RuntimeException)
128         {
129             verifyInput(pos, this);
130             verifyIndexRange(pos, getSize() );
131 
132             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
133 
134             return BaseType::maCanvasHelper.getPixel( bitmapLayout,
135                                                       pos );
136         }
137 
getMemoryLayout()138         virtual ::com::sun::star::rendering::FloatingPointBitmapLayout SAL_CALL getMemoryLayout(  ) throw (::com::sun::star::uno::RuntimeException)
139         {
140             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
141 
142             return BaseType::maCanvasHelper.getMemoryLayout();
143         }
144     };
145 }
146 
147 #endif /* INCLUDED_CANVAS_DOUBLEBITMAPBASE_HXX */
148