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_BASE_BITMAPCANVASBASE_HXX
21 #define INCLUDED_CANVAS_BASE_BITMAPCANVASBASE_HXX
23 #include <canvas/base/canvasbase.hxx>
24 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
28 /** Helper template to handle XBitmapCanvas method forwarding to
31 Use this helper to handle the XBitmapCanvas part of your
35 Base class to use, most probably one of the
36 WeakComponentImplHelperN templates with the appropriate
37 interfaces. At least XBitmapCanvas should be among them (why
38 else would you use this template, then?). Base class must have
39 an Base( const Mutex& ) constructor (like the
40 WeakComponentImplHelperN templates have).
43 Canvas helper implementation for the backend in question
46 Lock strategy to use. Defaults to using the
47 OBaseMutex-provided lock. Every time one of the methods is
48 entered, an object of type Mutex is created with m_aMutex as
49 the sole parameter, and destroyed again when the method scope
53 Optional unambiguous base class for XInterface of Base. It's
54 sometimes necessary to specify this parameter, e.g. if Base
55 derives from multiple UNO interface (were each provides its
56 own version of XInterface, making the conversion ambiguous)
58 @see CanvasBase for further contractual requirements towards
59 the CanvasHelper type, and some examples.
63 class Mutex
=::osl::MutexGuard
,
64 class UnambiguousBase
=::com::sun::star::uno::XInterface
> class BitmapCanvasBase
:
65 public CanvasBase
< Base
, CanvasHelper
, Mutex
, UnambiguousBase
>
68 typedef CanvasBase
< Base
, CanvasHelper
, Mutex
, UnambiguousBase
> BaseType
;
71 virtual ::com::sun::star::geometry::IntegerSize2D SAL_CALL
getSize( ) throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
73 typename
BaseType::MutexType
aGuard( BaseType::m_aMutex
);
75 return BaseType::maCanvasHelper
.getSize();
78 virtual sal_Bool SAL_CALL
hasAlpha( ) throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
83 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBitmap
> SAL_CALL
getScaledBitmap( const ::com::sun::star::geometry::RealSize2D
& newSize
,
84 sal_Bool beFast
) throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
86 typename
BaseType::MutexType
aGuard( BaseType::m_aMutex
);
88 return BaseType::maCanvasHelper
.getScaledBitmap( newSize
, beFast
);
95 class Mutex
=::osl::MutexGuard
,
96 class UnambiguousBase
=::com::sun::star::uno::XInterface
> class BitmapCanvasBase2
:
97 public BitmapCanvasBase
< Base
, CanvasHelper
, Mutex
, UnambiguousBase
>
99 typedef BitmapCanvasBase
< Base
, CanvasHelper
, Mutex
, UnambiguousBase
>
104 virtual void SAL_CALL
copyRect( const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBitmapCanvas
>& sourceCanvas
,
105 const ::com::sun::star::geometry::RealRectangle2D
& sourceRect
,
106 const ::com::sun::star::rendering::ViewState
& sourceViewState
,
107 const ::com::sun::star::rendering::RenderState
& sourceRenderState
,
108 const ::com::sun::star::geometry::RealRectangle2D
& destRect
,
109 const ::com::sun::star::rendering::ViewState
& destViewState
,
110 const ::com::sun::star::rendering::RenderState
& destRenderState
) throw (::com::sun::star::lang::IllegalArgumentException
,
111 ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
113 tools::verifyArgs(sourceCanvas
, sourceRect
, sourceViewState
, sourceRenderState
,
114 destRect
, destViewState
, destRenderState
,
115 BOOST_CURRENT_FUNCTION
,
116 static_cast< typename
BaseType::UnambiguousBaseType
* >(this));
118 typename
BaseType::BaseType::MutexType
aGuard( BaseType::m_aMutex
);
120 BaseType::BaseType::mbSurfaceDirty
= true;
125 #endif // INCLUDED_CANVAS_BASE_BITMAPCANVASBASE_HXX
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */