update dev300-m58
[ooovba.git] / canvas / source / cairo / cairo_canvas.hxx
blob55bb725cd46e1a90ba8c7542fc21b7bbf8577050
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cairo_canvas.hxx,v $
10 * $Revision: 1.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CAIROCANVAS_CANVAS_HXX_
32 #define _CAIROCANVAS_CANVAS_HXX_
34 #include <rtl/ref.hxx>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/lang/XServiceName.hpp>
41 #include <com/sun/star/awt/XWindowListener.hpp>
42 #include <com/sun/star/util/XUpdatable.hpp>
43 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
44 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
45 #include <com/sun/star/rendering/XGraphicDevice.hpp>
46 #include <com/sun/star/rendering/XBufferController.hpp>
47 #include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
49 #include <cppuhelper/compbase7.hxx>
50 #include <comphelper/uno3.hxx>
52 #include <canvas/base/spritecanvasbase.hxx>
53 #include <canvas/base/basemutexhelper.hxx>
54 #include <canvas/base/bufferedgraphicdevicebase.hxx>
56 #include <basegfx/vector/b2isize.hxx>
58 #include "cairo_devicehelper.hxx"
59 #include "cairo_repainttarget.hxx"
60 #include "cairo_surfaceprovider.hxx"
61 #include "cairo_spritecanvashelper.hxx"
63 #define CANVAS_SERVICE_NAME "com.sun.star.rendering.Canvas.Cairo"
64 #define CANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.Canvas.Cairo"
66 namespace cairocanvas
68 typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
69 ::com::sun::star::rendering::XIntegerBitmap,
70 ::com::sun::star::rendering::XGraphicDevice,
71 ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
72 ::com::sun::star::util::XUpdatable,
73 ::com::sun::star::beans::XPropertySet,
74 ::com::sun::star::lang::XServiceName > GraphicDeviceBase_Base;
75 typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase_Base >,
76 DeviceHelper,
77 ::osl::MutexGuard,
78 ::cppu::OWeakObject > CanvasBase_Base;
80 /** Mixin SurfaceProvider
82 Have to mixin the SurfaceProvider before deriving from
83 ::canvas::CanvasBase, as this template should already
84 implement some of those interface methods.
86 The reason why this appears kinda convoluted is the fact that
87 we cannot specify non-IDL types as WeakComponentImplHelperN
88 template args, and furthermore, don't want to derive
89 ::canvas::CanvasBase directly from
90 SurfaceProvider (because derivees of
91 ::canvas::CanvasBase have to explicitely forward the
92 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
93 anyway).
95 class CanvasBaseSurfaceProvider_Base : public CanvasBase_Base,
96 public SurfaceProvider
100 typedef ::canvas::IntegerBitmapBase< CanvasBaseSurfaceProvider_Base,
101 CanvasHelper,
102 ::osl::MutexGuard,
103 ::cppu::OWeakObject > CanvasBaseT;
105 /** Product of this component's factory.
107 The Canvas object combines the actual Window canvas with
108 the XGraphicDevice interface. This is because there's a
109 one-to-one relation between them, anyway, since each window
110 can have exactly one canvas and one associated
111 XGraphicDevice. And to avoid messing around with circular
112 references, this is implemented as one single object.
114 class Canvas : public CanvasBaseT,
115 public RepaintTarget
117 public:
118 Canvas( const ::com::sun::star::uno::Sequence<
119 ::com::sun::star::uno::Any >& aArguments,
120 const ::com::sun::star::uno::Reference<
121 ::com::sun::star::uno::XComponentContext >& rxContext );
123 void initialize();
125 /// For resource tracking
126 ~Canvas();
128 #if defined __SUNPRO_CC
129 using CanvasBaseT::disposing;
130 #endif
132 /// Dispose all internal references
133 virtual void SAL_CALL disposing();
135 // Forwarding the XComponent implementation to the
136 // cppu::ImplHelper templated base
137 // Classname Base doing refcounting Base implementing the XComponent interface
138 // | | |
139 // V V V
140 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( Canvas, GraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase );
142 // XServiceName
143 virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException);
145 // RepaintTarget
146 virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
147 const ::com::sun::star::rendering::ViewState& viewState,
148 const ::com::sun::star::rendering::RenderState& renderState );
150 // SurfaceProvider
151 virtual SurfaceSharedPtr getSurface();
152 virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
153 virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap );
154 virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent );
155 virtual OutputDevice* getOutputDevice();
157 private:
158 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > maArguments;
159 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
162 typedef ::rtl::Reference< Canvas > CanvasRef;
165 #endif