Branch data 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_BITMAPCANVASBASE_HXX
21 : : #define INCLUDED_CANVAS_BITMAPCANVASBASE_HXX
22 : :
23 : : #include <canvas/base/canvasbase.hxx>
24 : : #include <com/sun/star/rendering/XBitmapCanvas.hpp>
25 : :
26 : : namespace canvas
27 : : {
28 : : /** Helper template to handle XBitmapCanvas method forwarding to
29 : : BitmapCanvasHelper
30 : :
31 : : Use this helper to handle the XBitmapCanvas part of your
32 : : implementation.
33 : :
34 : : @tpl Base
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).
41 : :
42 : : @tpl CanvasHelper
43 : : Canvas helper implementation for the backend in question
44 : :
45 : : @tpl Mutex
46 : : Lock strategy to use. Defaults to using the
47 : : OBaseMutex-provided lock. Everytime 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
50 : : is left.
51 : :
52 : : @tpl UnambiguousBase
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)
57 : :
58 : : @see CanvasBase for further contractual requirements towards
59 : : the CanvasHelper type, and some examples.
60 : : */
61 : : template< class Base,
62 : : class CanvasHelper,
63 : : class Mutex=::osl::MutexGuard,
64 : 0 : class UnambiguousBase=::com::sun::star::uno::XInterface > class BitmapCanvasBase :
65 : : public CanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >
66 : : {
67 : : public:
68 : : typedef CanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType;
69 : :
70 : : // XBitmapCanvas
71 : 0 : virtual void SAL_CALL copyRect( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas,
72 : : const ::com::sun::star::geometry::RealRectangle2D& sourceRect,
73 : : const ::com::sun::star::rendering::ViewState& sourceViewState,
74 : : const ::com::sun::star::rendering::RenderState& sourceRenderState,
75 : : const ::com::sun::star::geometry::RealRectangle2D& destRect,
76 : : const ::com::sun::star::rendering::ViewState& destViewState,
77 : : const ::com::sun::star::rendering::RenderState& destRenderState ) throw (::com::sun::star::lang::IllegalArgumentException,
78 : : ::com::sun::star::uno::RuntimeException)
79 : : {
80 : 0 : tools::verifyArgs(sourceCanvas, sourceRect, sourceViewState, sourceRenderState,
81 : : destRect, destViewState, destRenderState,
82 : : BOOST_CURRENT_FUNCTION,
83 : : static_cast< typename BaseType::UnambiguousBaseType* >(this));
84 : :
85 : 0 : typename BaseType::MutexType aGuard( BaseType::m_aMutex );
86 : :
87 : 0 : BaseType::mbSurfaceDirty = true;
88 : 0 : BaseType::maCanvasHelper.modifying();
89 : :
90 : 0 : BaseType::maCanvasHelper.copyRect( this,
91 : : sourceCanvas,
92 : : sourceRect,
93 : : sourceViewState,
94 : : sourceRenderState,
95 : : destRect,
96 : : destViewState,
97 : : destRenderState );
98 : 0 : }
99 : :
100 : : // XBitmap
101 : 0 : virtual ::com::sun::star::geometry::IntegerSize2D SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException)
102 : : {
103 : 0 : typename BaseType::MutexType aGuard( BaseType::m_aMutex );
104 : :
105 : 0 : return BaseType::maCanvasHelper.getSize();
106 : : }
107 : :
108 : 0 : virtual ::sal_Bool SAL_CALL hasAlpha( ) throw (::com::sun::star::uno::RuntimeException)
109 : : {
110 : 0 : typename BaseType::MutexType aGuard( BaseType::m_aMutex );
111 : :
112 : 0 : return BaseType::maCanvasHelper.hasAlpha();
113 : : }
114 : :
115 : 0 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > SAL_CALL getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize,
116 : : sal_Bool beFast ) throw (::com::sun::star::uno::RuntimeException)
117 : : {
118 : 0 : typename BaseType::MutexType aGuard( BaseType::m_aMutex );
119 : :
120 : 0 : return BaseType::maCanvasHelper.getScaledBitmap( newSize, beFast );
121 : : }
122 : :
123 : : };
124 : : }
125 : :
126 : : #endif /* INCLUDED_CANVAS_BITMAPCANVASBASE_HXX */
127 : :
128 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|