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 SD_PRESENTER_PRESENTER_CANVAS_HXX
21 #define SD_PRESENTER_PRESENTER_CANVAS_HXX
23 #include "CanvasUpdateRequester.hxx"
24 #include <basegfx/range/b2drectangle.hxx>
25 #include <com/sun/star/awt/Point.hpp>
26 #include <com/sun/star/awt/XWindow.hpp>
27 #include <com/sun/star/awt/XWindowListener.hpp>
28 #include <com/sun/star/geometry/AffineMatrix2D.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/lang/IllegalArgumentException.hpp>
31 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
32 #include <com/sun/star/rendering/VolatileContentDestroyedException.hpp>
33 #include <cppuhelper/basemutex.hxx>
34 #include <cppuhelper/compbase4.hxx>
35 #include <boost/noncopyable.hpp>
36 #include <boost/shared_ptr.hpp>
38 namespace sd
{ namespace presenter
{
41 typedef ::cppu::WeakComponentImplHelper4
<
42 css::rendering::XSpriteCanvas
,
43 css::rendering::XBitmap
,
44 css::awt::XWindowListener
,
45 css::lang::XInitialization
46 > PresenterCanvasInterfaceBase
;
49 /** Wrapper around a shared canvas that forwards most of its methods to the
50 shared canvas. Most notable differences are:
51 1. The transformation of the ViewState of forwarded calls is modified by adding
53 2. The clip polygon of the ViewState of forwarded calls is intersected
54 with a clip rectangle that can be set via SetClip().
55 3. Calls to updateScreen() are collected. One call to the updateScreen()
56 method of the shared canvas is made asynchronously.
58 The canvas can use different canvases for sharing and for sprite
59 construction. This allows the shared canvas to be a canvas of sprite itself.
62 : private ::boost::noncopyable
,
63 private ::cppu::BaseMutex
,
64 public PresenterCanvasInterfaceBase
67 /** This constructor is used when a PresenterCanvas object is created as
70 PresenterCanvas (void);
72 /** This constructor is used when a PresenterCanvas object is created
73 directly, typically by the PresenterCanvasFactory.
75 This canvas is used to call updateScreen() at and to create
76 sprites. In the typical case this canvas is identical to the
77 rxSharedCanvas argument.
79 The window that belongs to the canvas given by the
80 rxUpdateCanvas argument.
82 The canvas that is wrapped by the new instance of this class.
83 Typically this is a regular XSpriteCanvas and then is identical
84 to the one given by the rxUpdateCanvas argument. It may be the
85 canvas of a sprite which does not support the XSpriteCanvas
86 interface. In that case the canvas that created the sprite can
87 be given as rxUpdateCanvas argument to allow to create further
88 sprites and to have proper calls to updateScreen().
90 The window that belongs to the canvas given by the
91 rxSharedCanvas argument.
93 The window that is represented by the new PresenterCanvas
94 object. It is expected to be a direct decendent of
95 rxSharedWindow. Its position inside rxSharedWindow defines the
96 offset of the canvas implemented by the new PresenterCanvas
97 object and rxSharedCanvas.
100 const css::uno::Reference
<css::rendering::XSpriteCanvas
>& rxUpdateCanvas
,
101 const css::uno::Reference
<css::awt::XWindow
>& rxUpdateWindow
,
102 const css::uno::Reference
<css::rendering::XCanvas
>& rxSharedCanvas
,
103 const css::uno::Reference
<css::awt::XWindow
>& rxSharedWindow
,
104 const css::uno::Reference
<css::awt::XWindow
>& rxWindow
);
105 virtual ~PresenterCanvas (void);
107 virtual void SAL_CALL
disposing (void)
108 throw (css::uno::RuntimeException
);
110 css::awt::Point
GetOffset (const css::uno::Reference
<css::awt::XWindow
>& rxBaseWindow
);
112 /** Merge the given view state with the view state that translates the
113 (virtual) child canvas to the shared canvas.
115 css::rendering::ViewState
MergeViewState (
116 const css::rendering::ViewState
& rViewState
,
117 const css::awt::Point
& raOffset
);
119 css::uno::Reference
<css::rendering::XCanvas
> GetSharedCanvas (void) const;
121 /** This method is typically called by CanvasPane objects to set the
122 repaint rectangle of a windowPaint() call as clip rectangle. When
123 no or an empty rectangle is given then the window bounds are used
125 @param rClipRectangle
126 A valid rectangle is used to clip the view state clip polygon.
127 When an empty rectangle is given then the view state clip
128 polygons are clipped against the window bounds.
130 void SetClip (const css::awt::Rectangle
& rClipRectangle
);
132 /** Called by custom sprites to update their clip polygon so that they
133 are clipped at the borders of the canvas. This method has to be
134 called after each change of the sprite location so that the bounds
135 of the canvas can be transformed into the coordinate system of the
138 css::uno::Reference
<css::rendering::XPolyPolygon2D
> UpdateSpriteClip (
139 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& rxOriginalClip
,
140 const css::geometry::RealPoint2D
& rLocation
,
141 const css::geometry::RealSize2D
& rSize
);
146 virtual void SAL_CALL
initialize (
147 const css::uno::Sequence
<css::uno::Any
>& rArguments
)
148 throw(css::uno::Exception
, css::uno::RuntimeException
);
153 virtual void SAL_CALL
clear (void)
154 throw (css::uno::RuntimeException
);
156 virtual void SAL_CALL
drawPoint (
157 const css::geometry::RealPoint2D
& aPoint
,
158 const css::rendering::ViewState
& aViewState
,
159 const css::rendering::RenderState
& aRenderState
)
160 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
162 virtual void SAL_CALL
drawLine (
163 const css::geometry::RealPoint2D
& aStartPoint
,
164 const css::geometry::RealPoint2D
& aEndPoint
,
165 const css::rendering::ViewState
& aViewState
,
166 const css::rendering::RenderState
& aRenderState
)
167 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
169 virtual void SAL_CALL
drawBezier (
170 const css::geometry::RealBezierSegment2D
& aBezierSegment
,
171 const css::geometry::RealPoint2D
& aEndPoint
,
172 const css::rendering::ViewState
& aViewState
,
173 const css::rendering::RenderState
& aRenderState
)
174 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
176 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
drawPolyPolygon (
177 const css::uno::Reference
< css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
178 const css::rendering::ViewState
& aViewState
,
179 const css::rendering::RenderState
& aRenderState
)
180 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
182 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
strokePolyPolygon (
183 const css::uno::Reference
< css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
184 const css::rendering::ViewState
& aViewState
,
185 const css::rendering::RenderState
& aRenderState
,
186 const css::rendering::StrokeAttributes
& aStrokeAttributes
)
187 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
189 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
190 strokeTexturedPolyPolygon (
191 const css::uno::Reference
< css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
192 const css::rendering::ViewState
& aViewState
,
193 const css::rendering::RenderState
& aRenderState
,
194 const css::uno::Sequence
< css::rendering::Texture
>& aTextures
,
195 const css::rendering::StrokeAttributes
& aStrokeAttributes
)
196 throw (css::lang::IllegalArgumentException
,
197 css::rendering::VolatileContentDestroyedException
,
198 css::uno::RuntimeException
);
200 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
201 strokeTextureMappedPolyPolygon(
202 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
203 const css::rendering::ViewState
& aViewState
,
204 const css::rendering::RenderState
& aRenderState
,
205 const css::uno::Sequence
<css::rendering::Texture
>& aTextures
,
206 const css::uno::Reference
<css::geometry::XMapping2D
>& xMapping
,
207 const css::rendering::StrokeAttributes
& aStrokeAttributes
)
208 throw (css::lang::IllegalArgumentException
,
209 css::rendering::VolatileContentDestroyedException
,
210 css::uno::RuntimeException
);
212 virtual css::uno::Reference
<css::rendering::XPolyPolygon2D
> SAL_CALL
214 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
215 const css::rendering::ViewState
& aViewState
,
216 const css::rendering::RenderState
& aRenderState
,
217 const css::rendering::StrokeAttributes
& aStrokeAttributes
)
218 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
220 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
222 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
223 const css::rendering::ViewState
& aViewState
,
224 const css::rendering::RenderState
& aRenderState
)
225 throw (css::lang::IllegalArgumentException
,
226 css::uno::RuntimeException
);
228 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
229 fillTexturedPolyPolygon(
230 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
231 const css::rendering::ViewState
& aViewState
,
232 const css::rendering::RenderState
& aRenderState
,
233 const css::uno::Sequence
<css::rendering::Texture
>& xTextures
)
234 throw (css::lang::IllegalArgumentException
,
235 css::rendering::VolatileContentDestroyedException
,
236 css::uno::RuntimeException
);
238 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
239 fillTextureMappedPolyPolygon(
240 const css::uno::Reference
< css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
241 const css::rendering::ViewState
& aViewState
,
242 const css::rendering::RenderState
& aRenderState
,
243 const css::uno::Sequence
< css::rendering::Texture
>& xTextures
,
244 const css::uno::Reference
< css::geometry::XMapping2D
>& xMapping
)
245 throw (css::lang::IllegalArgumentException
,
246 css::rendering::VolatileContentDestroyedException
,
247 css::uno::RuntimeException
);
249 virtual css::uno::Reference
<css::rendering::XCanvasFont
> SAL_CALL
251 const css::rendering::FontRequest
& aFontRequest
,
252 const css::uno::Sequence
< css::beans::PropertyValue
>& aExtraFontProperties
,
253 const css::geometry::Matrix2D
& aFontMatrix
)
254 throw (css::lang::IllegalArgumentException
,
255 css::uno::RuntimeException
);
257 virtual css::uno::Sequence
<css::rendering::FontInfo
> SAL_CALL
259 const css::rendering::FontInfo
& aFilter
,
260 const css::uno::Sequence
< css::beans::PropertyValue
>& aFontProperties
)
261 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
263 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
265 const css::rendering::StringContext
& aText
,
266 const css::uno::Reference
< css::rendering::XCanvasFont
>& xFont
,
267 const css::rendering::ViewState
& aViewState
,
268 const css::rendering::RenderState
& aRenderState
,
269 ::sal_Int8 nTextDirection
)
270 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
272 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
274 const css::uno::Reference
< css::rendering::XTextLayout
>& xLayoutetText
,
275 const css::rendering::ViewState
& aViewState
,
276 const css::rendering::RenderState
& aRenderState
)
277 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
279 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
281 const css::uno::Reference
< css::rendering::XBitmap
>& xBitmap
,
282 const css::rendering::ViewState
& aViewState
,
283 const css::rendering::RenderState
& aRenderState
)
284 throw (css::lang::IllegalArgumentException
,
285 css::rendering::VolatileContentDestroyedException
,
286 css::uno::RuntimeException
);
288 virtual css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
290 const css::uno::Reference
< css::rendering::XBitmap
>& xBitmap
,
291 const css::rendering::ViewState
& aViewState
,
292 const css::rendering::RenderState
& aRenderState
)
293 throw (css::lang::IllegalArgumentException
,
294 css::rendering::VolatileContentDestroyedException
,
295 css::uno::RuntimeException
);
297 virtual css::uno::Reference
<css::rendering::XGraphicDevice
> SAL_CALL
299 throw (css::uno::RuntimeException
);
304 void SAL_CALL
copyRect(
305 const css::uno::Reference
< css::rendering::XBitmapCanvas
>& sourceCanvas
,
306 const css::geometry::RealRectangle2D
& sourceRect
,
307 const css::rendering::ViewState
& sourceViewState
,
308 const css::rendering::RenderState
& sourceRenderState
,
309 const css::geometry::RealRectangle2D
& destRect
,
310 const css::rendering::ViewState
& destViewState
,
311 const css::rendering::RenderState
& destRenderState
)
312 throw (css::lang::IllegalArgumentException
,
313 css::rendering::VolatileContentDestroyedException
,
314 css::uno::RuntimeException
);
319 css::uno::Reference
< css::rendering::XAnimatedSprite
> SAL_CALL
320 createSpriteFromAnimation (
321 const css::uno::Reference
< css::rendering::XAnimation
>& animation
)
322 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
324 css::uno::Reference
< css::rendering::XAnimatedSprite
> SAL_CALL
325 createSpriteFromBitmaps (
326 const css::uno::Sequence
<
327 css::uno::Reference
< css::rendering::XBitmap
> >& animationBitmaps
,
328 ::sal_Int8 interpolationMode
)
329 throw (css::lang::IllegalArgumentException
,
330 css::rendering::VolatileContentDestroyedException
,
331 css::uno::RuntimeException
);
333 css::uno::Reference
< css::rendering::XCustomSprite
> SAL_CALL
335 const css::geometry::RealSize2D
& spriteSize
)
336 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
338 css::uno::Reference
< css::rendering::XSprite
> SAL_CALL
340 const css::uno::Reference
< css::rendering::XSprite
>& original
)
341 throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
343 ::sal_Bool SAL_CALL
updateScreen (::sal_Bool bUpdateAll
)
344 throw (css::uno::RuntimeException
);
349 virtual void SAL_CALL
disposing (const css::lang::EventObject
& rEvent
)
350 throw (css::uno::RuntimeException
);
355 virtual void SAL_CALL
windowResized (const css::awt::WindowEvent
& rEvent
)
356 throw (css::uno::RuntimeException
);
358 virtual void SAL_CALL
windowMoved (const css::awt::WindowEvent
& rEvent
)
359 throw (css::uno::RuntimeException
);
361 virtual void SAL_CALL
windowShown (const css::lang::EventObject
& rEvent
)
362 throw (css::uno::RuntimeException
);
364 virtual void SAL_CALL
windowHidden (const css::lang::EventObject
& rEvent
)
365 throw (css::uno::RuntimeException
);
370 virtual css::geometry::IntegerSize2D SAL_CALL
getSize (void)
371 throw (css::uno::RuntimeException
);
373 virtual sal_Bool SAL_CALL
hasAlpha (void)
374 throw (css::uno::RuntimeException
);
376 virtual css::uno::Reference
<css::rendering::XBitmapCanvas
> SAL_CALL
queryBitmapCanvas (void)
377 throw (css::uno::RuntimeException
);
379 virtual css::uno::Reference
<css::rendering::XBitmap
> SAL_CALL
getScaledBitmap(
380 const css::geometry::RealSize2D
& rNewSize
,
382 throw (css::uno::RuntimeException
,
383 css::lang::IllegalArgumentException
,
384 css::rendering::VolatileContentDestroyedException
);
387 css::uno::Reference
<css::rendering::XSpriteCanvas
> mxUpdateCanvas
;
388 css::uno::Reference
<css::awt::XWindow
> mxUpdateWindow
;
389 css::uno::Reference
<css::rendering::XCanvas
> mxSharedCanvas
;
390 css::uno::Reference
<css::awt::XWindow
> mxSharedWindow
;
392 /** The window for which a canvas is emulated.
394 css::uno::Reference
<css::awt::XWindow
> mxWindow
;
396 /** Offset of the emulated canvas with respect to the shared canvas.
398 css::awt::Point maOffset
;
400 /** The UpdateRequester is used by updateScreen() to schedule
401 updateScreen() calls at the shared canvas.
403 ::boost::shared_ptr
<CanvasUpdateRequester
> mpUpdateRequester
;
405 /** The clip rectangle as given to SetClip().
407 css::awt::Rectangle maClipRectangle
;
409 /** When this flag is true (it is set to true after every call to
410 updateScreen()) then the next call to MergeViewState updates the
411 maOffset member. A possible optimization would set this flag only
412 to true when one of the windows between mxWindow and mxSharedWindow
413 changes its position.
415 bool mbOffsetUpdatePending
;
417 ::basegfx::B2DRectangle
GetClipRectangle (
418 const css::geometry::AffineMatrix2D
& rViewTransform
,
419 const css::awt::Point
& rOffset
);
421 css::rendering::ViewState
MergeViewState (const css::rendering::ViewState
& rViewState
);
423 /** This method throws a DisposedException when the object has already been
426 void ThrowIfDisposed (void)
427 throw (css::lang::DisposedException
);
432 } } // end of namespace ::sd::presenter
436 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */