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_BITMAPCANVASBASE_HXX
21 : #define INCLUDED_CANVAS_BASE_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. 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
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 10 : 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 : // XBitmap
71 0 : virtual ::com::sun::star::geometry::IntegerSize2D SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
72 : {
73 0 : typename BaseType::MutexType aGuard( BaseType::m_aMutex );
74 :
75 0 : return BaseType::maCanvasHelper.getSize();
76 : }
77 :
78 0 : virtual sal_Bool SAL_CALL hasAlpha( ) throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
79 : {
80 0 : return sal_True;
81 : }
82 :
83 0 : 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
85 : {
86 0 : typename BaseType::MutexType aGuard( BaseType::m_aMutex );
87 :
88 0 : return BaseType::maCanvasHelper.getScaledBitmap( newSize, beFast );
89 : }
90 :
91 : };
92 :
93 : template< class Base,
94 : class CanvasHelper,
95 : class Mutex=::osl::MutexGuard,
96 10 : class UnambiguousBase=::com::sun::star::uno::XInterface > class BitmapCanvasBase2 :
97 : public BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >
98 : {
99 : typedef BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >
100 : BaseType;
101 :
102 : public:
103 : // XBitmapCanvas
104 0 : 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
112 : {
113 0 : tools::verifyArgs(sourceCanvas, sourceRect, sourceViewState, sourceRenderState,
114 : destRect, destViewState, destRenderState,
115 : BOOST_CURRENT_FUNCTION,
116 0 : static_cast< typename BaseType::UnambiguousBaseType* >(this));
117 :
118 0 : typename BaseType::BaseType::MutexType aGuard( BaseType::m_aMutex );
119 :
120 0 : BaseType::BaseType::mbSurfaceDirty = true;
121 0 : }
122 : };
123 : }
124 :
125 : #endif // INCLUDED_CANVAS_BASE_BITMAPCANVASBASE_HXX
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|