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_BASE_INTEGERBITMAPBASE_HXX
21 : #define INCLUDED_CANVAS_BASE_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 : Either BitmapCanvasBase (just XBitmap) or BitmapCanvasBase2 (XBitmap and
37 : XBitmapCanvas).
38 : */
39 0 : template< class Base > class IntegerBitmapBase :
40 : public Base
41 : {
42 : public:
43 : // XIntegerBitmap
44 0 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
45 : const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
46 : {
47 0 : tools::verifyArgs(rect,
48 : BOOST_CURRENT_FUNCTION,
49 0 : static_cast< typename Base::UnambiguousBaseType* >(this));
50 0 : tools::verifyIndexRange(rect, Base::getSize() );
51 :
52 0 : typename Base::MutexType aGuard( Base::m_aMutex );
53 :
54 : return Base::maCanvasHelper.getData( bitmapLayout,
55 0 : rect );
56 : }
57 :
58 0 : virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data,
59 : const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
60 : const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
61 : {
62 0 : tools::verifyArgs(bitmapLayout, rect,
63 : BOOST_CURRENT_FUNCTION,
64 0 : static_cast< typename Base::UnambiguousBaseType* >(this));
65 0 : tools::verifyIndexRange(rect, Base::getSize() );
66 :
67 0 : typename Base::MutexType aGuard( Base::m_aMutex );
68 :
69 0 : Base::mbSurfaceDirty = true;
70 0 : Base::maCanvasHelper.modifying();
71 :
72 0 : Base::maCanvasHelper.setData( data, bitmapLayout, rect );
73 0 : }
74 :
75 0 : virtual void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color,
76 : const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
77 : const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
78 : {
79 0 : tools::verifyArgs(bitmapLayout, pos,
80 : BOOST_CURRENT_FUNCTION,
81 0 : static_cast< typename Base::UnambiguousBaseType* >(this));
82 0 : tools::verifyIndexRange(pos, Base::getSize() );
83 :
84 0 : typename Base::MutexType aGuard( Base::m_aMutex );
85 :
86 0 : Base::mbSurfaceDirty = true;
87 0 : Base::maCanvasHelper.modifying();
88 :
89 0 : Base::maCanvasHelper.setPixel( color, bitmapLayout, pos );
90 0 : }
91 :
92 0 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
93 : const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
94 : {
95 0 : tools::verifyArgs(pos,
96 : BOOST_CURRENT_FUNCTION,
97 0 : static_cast< typename Base::UnambiguousBaseType* >(this));
98 0 : tools::verifyIndexRange(pos, Base::getSize() );
99 :
100 0 : typename Base::MutexType aGuard( Base::m_aMutex );
101 :
102 : return Base::maCanvasHelper.getPixel( bitmapLayout,
103 0 : pos );
104 : }
105 :
106 0 : virtual ::com::sun::star::rendering::IntegerBitmapLayout SAL_CALL getMemoryLayout( ) throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
107 : {
108 0 : typename Base::MutexType aGuard( Base::m_aMutex );
109 :
110 0 : return Base::maCanvasHelper.getMemoryLayout();
111 : }
112 : };
113 : }
114 :
115 : #endif // INCLUDED_CANVAS_BASE_INTEGERBITMAPBASE_HXX
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|