1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DXCANVAS_CANVASBITMAP_HXX
29 #define _DXCANVAS_CANVASBITMAP_HXX
30 
31 #include <cppuhelper/compbase4.hxx>
32 
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
35 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
36 #include <com/sun/star/beans/XFastPropertySet.hpp>
37 
38 #include <basegfx/vector/b2isize.hxx>
39 
40 #include <boost/shared_ptr.hpp>
41 
42 #include <cppuhelper/compbase3.hxx>
43 #include <comphelper/uno3.hxx>
44 #include <canvas/base/basemutexhelper.hxx>
45 #include <canvas/base/integerbitmapbase.hxx>
46 
47 #include "dx_bitmapprovider.hxx"
48 #include "dx_bitmapcanvashelper.hxx"
49 #include "dx_devicehelper.hxx"
50 #include "dx_impltools.hxx"
51 #include "dx_ibitmap.hxx"
52 
53 
54 /* Definition of CanvasBitmap class */
55 
56 namespace dxcanvas
57 {
58     typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XBitmapCanvas,
59 											  ::com::sun::star::rendering::XIntegerBitmap,
60                          					  ::com::sun::star::lang::XServiceInfo,
61                          					  ::com::sun::star::beans::XFastPropertySet >  	CanvasBitmapBase_Base;
62     typedef ::canvas::IntegerBitmapBase< ::canvas::BaseMutexHelper< CanvasBitmapBase_Base >,
63                                          BitmapCanvasHelper,
64                                          ::osl::MutexGuard,
65                                          ::cppu::OWeakObject >							CanvasBitmap_Base;
66 
67     class CanvasBitmap : public CanvasBitmap_Base, public BitmapProvider
68     {
69     public:
70         /** Create a canvas bitmap for the given surface
71 
72             @param rSurface
73             Surface to create API object for.
74 
75             @param rDevice
76             Reference device, with which bitmap should be compatible
77          */
78         CanvasBitmap( const IBitmapSharedPtr& rSurface,
79                       const DeviceRef&        rDevice );
80 
81         /// Dispose all internal references
82         virtual void SAL_CALL disposing();
83 
84         // XServiceInfo
85         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
86         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
87         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
88 
89         // BitmapProvider
90         virtual IBitmapSharedPtr getBitmap() const { return mpBitmap; }
91 
92         virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle)  throw (::com::sun::star::uno::RuntimeException);
93         virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&)  throw (::com::sun::star::uno::RuntimeException) {}
94 
95     private:
96         /** MUST hold here, too, since CanvasHelper only contains a
97             raw pointer (without refcounting)
98         */
99         DeviceRef        mpDevice;
100         IBitmapSharedPtr mpBitmap;
101     };
102 }
103 
104 #endif /* _DXCANVAS_CANVASBITMAP_HXX */
105