1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_INTEGERBITMAPBASE_HXX
21 #define INCLUDED_CANVAS_INTEGERBITMAPBASE_HXX
23 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
24 #include <canvas/base/bitmapcanvasbase.hxx>
29 /** Helper template to handle XIntegerBitmap method forwarding to
32 Use this helper to handle the XIntegerBitmap part of your
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).
44 Canvas helper implementation for the backend in question
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
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)
59 @see CanvasBase for further contractual requirements towards
60 the CanvasHelper type, and some examples.
64 class Mutex
=::osl::MutexGuard
,
65 class UnambiguousBase
=::com::sun::star::uno::XInterface
> class IntegerBitmapBase
:
66 public BitmapCanvasBase
< Base
, CanvasHelper
, Mutex
, UnambiguousBase
>
69 typedef BitmapCanvasBase
< Base
, CanvasHelper
, Mutex
, UnambiguousBase
> BaseType
;
72 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
)
75 tools::verifyArgs(rect
,
76 BOOST_CURRENT_FUNCTION
,
77 static_cast< typename
BaseType::UnambiguousBaseType
* >(this));
78 tools::verifyIndexRange(rect
, BaseType::getSize() );
80 typename
BaseType::MutexType
aGuard( BaseType::m_aMutex
);
82 return BaseType::maCanvasHelper
.getData( bitmapLayout
,
86 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
)
90 tools::verifyArgs(bitmapLayout
, rect
,
91 BOOST_CURRENT_FUNCTION
,
92 static_cast< typename
BaseType::UnambiguousBaseType
* >(this));
93 tools::verifyIndexRange(rect
, BaseType::getSize() );
95 typename
BaseType::MutexType
aGuard( BaseType::m_aMutex
);
97 BaseType::mbSurfaceDirty
= true;
98 BaseType::maCanvasHelper
.modifying();
100 BaseType::maCanvasHelper
.setData( data
, bitmapLayout
, rect
);
103 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
)
107 tools::verifyArgs(bitmapLayout
, pos
,
108 BOOST_CURRENT_FUNCTION
,
109 static_cast< typename
BaseType::UnambiguousBaseType
* >(this));
110 tools::verifyIndexRange(pos
, BaseType::getSize() );
112 typename
BaseType::MutexType
aGuard( BaseType::m_aMutex
);
114 BaseType::mbSurfaceDirty
= true;
115 BaseType::maCanvasHelper
.modifying();
117 BaseType::maCanvasHelper
.setPixel( color
, bitmapLayout
, pos
);
120 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
)
123 tools::verifyArgs(pos
,
124 BOOST_CURRENT_FUNCTION
,
125 static_cast< typename
BaseType::UnambiguousBaseType
* >(this));
126 tools::verifyIndexRange(pos
, BaseType::getSize() );
128 typename
BaseType::MutexType
aGuard( BaseType::m_aMutex
);
130 return BaseType::maCanvasHelper
.getPixel( bitmapLayout
,
134 virtual ::com::sun::star::rendering::IntegerBitmapLayout SAL_CALL
getMemoryLayout( ) throw (::com::sun::star::uno::RuntimeException
)
136 typename
BaseType::MutexType
aGuard( BaseType::m_aMutex
);
138 return BaseType::maCanvasHelper
.getMemoryLayout();
143 #endif /* INCLUDED_CANVAS_INTEGERBITMAPBASE_HXX */
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */