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