Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "PresenterCanvas.hxx"
31 : :
32 : : #include <basegfx/matrix/b2dhommatrix.hxx>
33 : : #include <basegfx/polygon/b2dpolygontools.hxx>
34 : : #include <basegfx/polygon/b2dpolypolygon.hxx>
35 : : #include <basegfx/polygon/b2dpolygonclipper.hxx>
36 : : #include <basegfx/range/b2drectangle.hxx>
37 : : #include <basegfx/tools/canvastools.hxx>
38 : : #include <canvas/canvastools.hxx>
39 : : #include <cppuhelper/basemutex.hxx>
40 : : #include <cppuhelper/compbase1.hxx>
41 : : #include <rtl/ref.hxx>
42 : : #include <toolkit/helper/vclunohelper.hxx>
43 : : #include <vcl/window.hxx>
44 : : #include <vcl/svapp.hxx>
45 : :
46 : : using namespace ::com::sun::star;
47 : : using namespace ::com::sun::star::uno;
48 : : using ::rtl::OUString;
49 : :
50 : : namespace sd { namespace presenter {
51 : :
52 : : //===== Service ===============================================================
53 : :
54 : 0 : Reference<XInterface> SAL_CALL PresenterCanvas_createInstance (
55 : : const Reference<XComponentContext>& rxContext)
56 : : {
57 : : (void)rxContext;
58 [ # # ]: 0 : return Reference<XInterface>(static_cast<XWeak*>(new PresenterCanvas()));
59 : : }
60 : :
61 : :
62 : :
63 : :
64 : 22 : ::rtl::OUString PresenterCanvas_getImplementationName (void) throw(RuntimeException)
65 : : {
66 : 22 : return OUString("com.sun.star.comp.Draw.PresenterCanvasFactory");
67 : : }
68 : :
69 : :
70 : :
71 : :
72 : 0 : Sequence<rtl::OUString> SAL_CALL PresenterCanvas_getSupportedServiceNames (void)
73 : : throw (RuntimeException)
74 : : {
75 [ # # ][ # # ]: 0 : static const ::rtl::OUString sServiceName("com.sun.star.rendering.Canvas");
76 : 0 : return Sequence<rtl::OUString>(&sServiceName, 1);
77 : : }
78 : :
79 : :
80 : :
81 : :
82 : : //===== PresenterCustomSprite =================================================
83 : :
84 : : /** Wrapper around a sprite that is displayed on a PresenterCanvas.
85 : : */
86 : : namespace {
87 : : typedef ::cppu::WeakComponentImplHelper1 <
88 : : css::rendering::XCustomSprite
89 : : > PresenterCustomSpriteInterfaceBase;
90 : : }
91 : : class PresenterCustomSprite
92 : : : private ::boost::noncopyable,
93 : : protected ::cppu::BaseMutex,
94 : : public PresenterCustomSpriteInterfaceBase
95 : : {
96 : : public:
97 : : PresenterCustomSprite (
98 : : const rtl::Reference<PresenterCanvas>& rpCanvas,
99 : : const Reference<rendering::XCustomSprite>& rxSprite,
100 : : const Reference<awt::XWindow>& rxBaseWindow,
101 : : const css::geometry::RealSize2D& rSpriteSize);
102 : : virtual ~PresenterCustomSprite (void);
103 : : virtual void SAL_CALL disposing (void)
104 : : throw (RuntimeException);
105 : :
106 : : // XSprite
107 : :
108 : : virtual void SAL_CALL setAlpha (double nAlpha)
109 : : throw (lang::IllegalArgumentException,RuntimeException);
110 : :
111 : : virtual void SAL_CALL move (const geometry::RealPoint2D& rNewPos,
112 : : const rendering::ViewState& rViewState,
113 : : const rendering::RenderState& rRenderState)
114 : : throw (lang::IllegalArgumentException,RuntimeException);
115 : :
116 : : virtual void SAL_CALL transform (const geometry::AffineMatrix2D& rTransformation)
117 : : throw (lang::IllegalArgumentException,RuntimeException);
118 : :
119 : : virtual void SAL_CALL clip (const Reference<rendering::XPolyPolygon2D>& rClip)
120 : : throw (RuntimeException);
121 : :
122 : : virtual void SAL_CALL setPriority (double nPriority)
123 : : throw (RuntimeException);
124 : :
125 : : virtual void SAL_CALL show (void)
126 : : throw (RuntimeException);
127 : :
128 : : virtual void SAL_CALL hide (void)
129 : : throw (RuntimeException);
130 : :
131 : :
132 : : // XCustomSprite
133 : :
134 : : virtual Reference<rendering::XCanvas> SAL_CALL getContentCanvas (void)
135 : : throw (RuntimeException);
136 : :
137 : : private:
138 : : rtl::Reference<PresenterCanvas> mpCanvas;
139 : : Reference<rendering::XCustomSprite> mxSprite;
140 : : Reference<awt::XWindow> mxBaseWindow;
141 : : geometry::RealPoint2D maPosition;
142 : : geometry::RealSize2D maSpriteSize;
143 : :
144 : : void ThrowIfDisposed (void)
145 : : throw (css::lang::DisposedException);
146 : : };
147 : :
148 : :
149 : :
150 : :
151 : : //===== PresenterCanvas =======================================================
152 : :
153 : :
154 : 0 : PresenterCanvas::PresenterCanvas (void)
155 : : : PresenterCanvasInterfaceBase(m_aMutex),
156 : : mxUpdateCanvas(),
157 : : mxSharedCanvas(),
158 : : mxSharedWindow(),
159 : : mxWindow(),
160 : : maOffset(),
161 : : mpUpdateRequester(),
162 : : maClipRectangle(),
163 [ # # ][ # # ]: 0 : mbOffsetUpdatePending(true)
164 : : {
165 : 0 : }
166 : :
167 : :
168 : :
169 : :
170 : 0 : PresenterCanvas::PresenterCanvas (
171 : : const Reference<rendering::XSpriteCanvas>& rxUpdateCanvas,
172 : : const Reference<awt::XWindow>& rxUpdateWindow,
173 : : const Reference<rendering::XCanvas>& rxSharedCanvas,
174 : : const Reference<awt::XWindow>& rxSharedWindow,
175 : : const Reference<awt::XWindow>& rxWindow)
176 : : : PresenterCanvasInterfaceBase(m_aMutex),
177 : : mxUpdateCanvas(rxUpdateCanvas),
178 : : mxUpdateWindow(rxUpdateWindow),
179 : : mxSharedCanvas(rxSharedCanvas),
180 : : mxSharedWindow(rxSharedWindow),
181 : : mxWindow(rxWindow),
182 : : maOffset(),
183 : : mpUpdateRequester(),
184 : : maClipRectangle(),
185 [ # # ][ # # ]: 0 : mbOffsetUpdatePending(true)
186 : : {
187 [ # # ]: 0 : if (mxWindow.is())
188 [ # # ][ # # ]: 0 : mxWindow->addWindowListener(this);
[ # # ]
189 : :
190 [ # # ]: 0 : if (mxUpdateCanvas.is())
191 [ # # ][ # # ]: 0 : mpUpdateRequester = CanvasUpdateRequester::Instance(mxUpdateCanvas);
[ # # ]
192 : 0 : }
193 : :
194 : :
195 : :
196 : :
197 [ # # ][ # # ]: 0 : PresenterCanvas::~PresenterCanvas (void)
[ # # ]
198 : : {
199 [ # # ]: 0 : }
200 : :
201 : :
202 : :
203 : :
204 : 0 : void SAL_CALL PresenterCanvas::disposing (void)
205 : : throw (css::uno::RuntimeException)
206 : : {
207 [ # # ]: 0 : if (mxWindow.is())
208 [ # # ]: 0 : mxWindow->removeWindowListener(this);
209 : 0 : }
210 : :
211 : :
212 : :
213 : :
214 : : //----- XInitialization -------------------------------------------------------
215 : :
216 : 0 : void SAL_CALL PresenterCanvas::initialize (
217 : : const Sequence<Any>& rArguments)
218 : : throw(Exception, RuntimeException)
219 : : {
220 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose)
221 : 0 : ThrowIfDisposed();
222 : :
223 [ # # ]: 0 : if (rArguments.getLength() == 5)
224 : : {
225 : : try
226 : : {
227 : : // First and second argument may be NULL.
228 [ # # ]: 0 : rArguments[0] >>= mxUpdateCanvas;
229 [ # # ]: 0 : rArguments[1] >>= mxUpdateWindow;
230 : :
231 [ # # ][ # # ]: 0 : if ( ! (rArguments[2] >>= mxSharedWindow))
232 : : {
233 : : throw lang::IllegalArgumentException("PresenterCanvas: invalid shared window",
234 : : static_cast<XWeak*>(this),
235 [ # # ][ # # ]: 0 : 1);
236 : : }
237 : :
238 [ # # ][ # # ]: 0 : if ( ! (rArguments[3] >>= mxSharedCanvas))
239 : : {
240 : : throw lang::IllegalArgumentException("PresenterCanvas: invalid shared canvas",
241 : : static_cast<XWeak*>(this),
242 [ # # ][ # # ]: 0 : 2);
243 : : }
244 : :
245 [ # # ][ # # ]: 0 : if ( ! (rArguments[4] >>= mxWindow))
246 : : {
247 : : throw lang::IllegalArgumentException("PresenterCanvas: invalid window",
248 : : static_cast<XWeak*>(this),
249 [ # # ][ # # ]: 0 : 3);
250 : : }
251 : :
252 [ # # ][ # # ]: 0 : mpUpdateRequester = CanvasUpdateRequester::Instance(mxUpdateCanvas);
[ # # ]
253 : :
254 : 0 : mbOffsetUpdatePending = true;
255 [ # # ]: 0 : if (mxWindow.is())
256 [ # # ][ # # ]: 0 : mxWindow->addWindowListener(this);
[ # # ]
257 : : }
258 [ # # ]: 0 : catch (RuntimeException&)
259 : : {
260 [ # # ]: 0 : mxSharedWindow = NULL;
261 [ # # ]: 0 : mxWindow = NULL;
262 : 0 : throw;
263 : : }
264 : : }
265 : : else
266 : : {
267 : : throw RuntimeException("PresenterCanvas: invalid number of arguments",
268 [ # # ][ # # ]: 0 : static_cast<XWeak*>(this));
269 : : }
270 : 0 : }
271 : :
272 : :
273 : :
274 : :
275 : : //----- XCanvas ---------------------------------------------------------------
276 : :
277 : 0 : void SAL_CALL PresenterCanvas::clear (void)
278 : : throw (css::uno::RuntimeException)
279 : : {
280 : 0 : ThrowIfDisposed();
281 : : // ToDo: Clear the area covered by the child window. A simple forward
282 : : // would clear the whole shared canvas.
283 : 0 : }
284 : :
285 : :
286 : :
287 : :
288 : 0 : void SAL_CALL PresenterCanvas::drawPoint (
289 : : const css::geometry::RealPoint2D& aPoint,
290 : : const css::rendering::ViewState& aViewState,
291 : : const css::rendering::RenderState& aRenderState)
292 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
293 : : {
294 : 0 : ThrowIfDisposed();
295 [ # # ]: 0 : mxSharedCanvas->drawPoint(aPoint,MergeViewState(aViewState),aRenderState);
296 : 0 : }
297 : :
298 : :
299 : :
300 : :
301 : 0 : void SAL_CALL PresenterCanvas::drawLine (
302 : : const css::geometry::RealPoint2D& aStartPoint,
303 : : const css::geometry::RealPoint2D& aEndPoint,
304 : : const css::rendering::ViewState& aViewState,
305 : : const css::rendering::RenderState& aRenderState)
306 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
307 : : {
308 : 0 : ThrowIfDisposed();
309 [ # # ]: 0 : mxSharedCanvas->drawLine(aStartPoint,aEndPoint,MergeViewState(aViewState),aRenderState);
310 : 0 : }
311 : :
312 : :
313 : :
314 : :
315 : 0 : void SAL_CALL PresenterCanvas::drawBezier (
316 : : const css::geometry::RealBezierSegment2D& aBezierSegment,
317 : : const css::geometry::RealPoint2D& aEndPoint,
318 : : const css::rendering::ViewState& aViewState,
319 : : const css::rendering::RenderState& aRenderState)
320 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
321 : : {
322 : 0 : ThrowIfDisposed();
323 [ # # ]: 0 : mxSharedCanvas->drawBezier(aBezierSegment,aEndPoint,MergeViewState(aViewState),aRenderState);
324 : 0 : }
325 : :
326 : :
327 : :
328 : :
329 : 0 : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL PresenterCanvas::drawPolyPolygon (
330 : : const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
331 : : const css::rendering::ViewState& aViewState,
332 : : const css::rendering::RenderState& aRenderState)
333 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
334 : : {
335 : 0 : ThrowIfDisposed();
336 : 0 : return mxSharedCanvas->drawPolyPolygon(
337 [ # # ]: 0 : xPolyPolygon, MergeViewState(aViewState), aRenderState);
338 : : }
339 : :
340 : :
341 : :
342 : :
343 : 0 : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL PresenterCanvas::strokePolyPolygon (
344 : : const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
345 : : const css::rendering::ViewState& aViewState,
346 : : const css::rendering::RenderState& aRenderState,
347 : : const css::rendering::StrokeAttributes& aStrokeAttributes)
348 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
349 : : {
350 : 0 : ThrowIfDisposed();
351 : 0 : return mxSharedCanvas->strokePolyPolygon(
352 [ # # ]: 0 : xPolyPolygon, MergeViewState(aViewState), aRenderState, aStrokeAttributes);
353 : : }
354 : :
355 : :
356 : :
357 : :
358 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
359 : 0 : PresenterCanvas::strokeTexturedPolyPolygon (
360 : : const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
361 : : const css::rendering::ViewState& aViewState,
362 : : const css::rendering::RenderState& aRenderState,
363 : : const css::uno::Sequence< css::rendering::Texture >& aTextures,
364 : : const css::rendering::StrokeAttributes& aStrokeAttributes)
365 : : throw (css::lang::IllegalArgumentException,
366 : : css::rendering::VolatileContentDestroyedException,
367 : : css::uno::RuntimeException)
368 : : {
369 : 0 : ThrowIfDisposed();
370 : 0 : return mxSharedCanvas->strokeTexturedPolyPolygon(
371 [ # # ]: 0 : xPolyPolygon, MergeViewState(aViewState), aRenderState, aTextures, aStrokeAttributes);
372 : : }
373 : :
374 : :
375 : :
376 : :
377 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
378 : 0 : PresenterCanvas::strokeTextureMappedPolyPolygon(
379 : : const css::uno::Reference<css::rendering::XPolyPolygon2D >& xPolyPolygon,
380 : : const css::rendering::ViewState& aViewState,
381 : : const css::rendering::RenderState& aRenderState,
382 : : const css::uno::Sequence<css::rendering::Texture>& aTextures,
383 : : const css::uno::Reference<css::geometry::XMapping2D>& xMapping,
384 : : const css::rendering::StrokeAttributes& aStrokeAttributes)
385 : : throw (css::lang::IllegalArgumentException,
386 : : css::rendering::VolatileContentDestroyedException,
387 : : css::uno::RuntimeException)
388 : : {
389 : 0 : ThrowIfDisposed();
390 : 0 : return mxSharedCanvas->strokeTextureMappedPolyPolygon(
391 : : xPolyPolygon,
392 : : MergeViewState(aViewState),
393 : : aRenderState,
394 : : aTextures,
395 : : xMapping,
396 [ # # ]: 0 : aStrokeAttributes);
397 : : }
398 : :
399 : :
400 : :
401 : :
402 : : css::uno::Reference<css::rendering::XPolyPolygon2D> SAL_CALL
403 : 0 : PresenterCanvas::queryStrokeShapes(
404 : : const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
405 : : const css::rendering::ViewState& aViewState,
406 : : const css::rendering::RenderState& aRenderState,
407 : : const css::rendering::StrokeAttributes& aStrokeAttributes)
408 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
409 : : {
410 : 0 : ThrowIfDisposed();
411 : 0 : return mxSharedCanvas->queryStrokeShapes(
412 [ # # ]: 0 : xPolyPolygon, MergeViewState(aViewState), aRenderState, aStrokeAttributes);
413 : : }
414 : :
415 : :
416 : :
417 : :
418 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
419 : 0 : PresenterCanvas::fillPolyPolygon(
420 : : const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
421 : : const css::rendering::ViewState& aViewState,
422 : : const css::rendering::RenderState& aRenderState)
423 : : throw (css::lang::IllegalArgumentException,
424 : : css::uno::RuntimeException)
425 : : {
426 : 0 : ThrowIfDisposed();
427 : 0 : return mxSharedCanvas->fillPolyPolygon(
428 [ # # ]: 0 : xPolyPolygon, MergeViewState(aViewState), aRenderState);
429 : : }
430 : :
431 : :
432 : :
433 : :
434 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
435 : 0 : PresenterCanvas::fillTexturedPolyPolygon(
436 : : const css::uno::Reference<css::rendering::XPolyPolygon2D>& xPolyPolygon,
437 : : const css::rendering::ViewState& aViewState,
438 : : const css::rendering::RenderState& aRenderState,
439 : : const css::uno::Sequence<css::rendering::Texture>& xTextures)
440 : : throw (css::lang::IllegalArgumentException,
441 : : css::rendering::VolatileContentDestroyedException,
442 : : css::uno::RuntimeException)
443 : : {
444 : 0 : ThrowIfDisposed();
445 : 0 : return mxSharedCanvas->fillTexturedPolyPolygon(
446 [ # # ]: 0 : xPolyPolygon, MergeViewState(aViewState), aRenderState, xTextures);
447 : : }
448 : :
449 : :
450 : :
451 : :
452 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
453 : 0 : PresenterCanvas::fillTextureMappedPolyPolygon(
454 : : const css::uno::Reference< css::rendering::XPolyPolygon2D >& xPolyPolygon,
455 : : const css::rendering::ViewState& aViewState,
456 : : const css::rendering::RenderState& aRenderState,
457 : : const css::uno::Sequence< css::rendering::Texture >& xTextures,
458 : : const css::uno::Reference< css::geometry::XMapping2D >& xMapping)
459 : : throw (css::lang::IllegalArgumentException,
460 : : css::rendering::VolatileContentDestroyedException,
461 : : css::uno::RuntimeException)
462 : : {
463 : 0 : ThrowIfDisposed();
464 : 0 : return mxSharedCanvas->fillTextureMappedPolyPolygon(
465 [ # # ]: 0 : xPolyPolygon, MergeViewState(aViewState), aRenderState, xTextures, xMapping);
466 : : }
467 : :
468 : :
469 : :
470 : :
471 : : css::uno::Reference<css::rendering::XCanvasFont> SAL_CALL
472 : 0 : PresenterCanvas::createFont(
473 : : const css::rendering::FontRequest& aFontRequest,
474 : : const css::uno::Sequence< css::beans::PropertyValue >& aExtraFontProperties,
475 : : const css::geometry::Matrix2D& aFontMatrix)
476 : : throw (css::lang::IllegalArgumentException,
477 : : css::uno::RuntimeException)
478 : : {
479 : 0 : ThrowIfDisposed();
480 : 0 : return mxSharedCanvas->createFont(
481 : 0 : aFontRequest, aExtraFontProperties, aFontMatrix);
482 : : }
483 : :
484 : :
485 : :
486 : :
487 : : css::uno::Sequence<css::rendering::FontInfo> SAL_CALL
488 : 0 : PresenterCanvas::queryAvailableFonts(
489 : : const css::rendering::FontInfo& aFilter,
490 : : const css::uno::Sequence< css::beans::PropertyValue >& aFontProperties)
491 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
492 : : {
493 : 0 : ThrowIfDisposed();
494 : 0 : return mxSharedCanvas->queryAvailableFonts(aFilter, aFontProperties);
495 : : }
496 : :
497 : :
498 : :
499 : :
500 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
501 : 0 : PresenterCanvas::drawText(
502 : : const css::rendering::StringContext& aText,
503 : : const css::uno::Reference< css::rendering::XCanvasFont >& xFont,
504 : : const css::rendering::ViewState& aViewState,
505 : : const css::rendering::RenderState& aRenderState,
506 : : ::sal_Int8 nTextDirection)
507 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
508 : : {
509 : 0 : ThrowIfDisposed();
510 : 0 : return mxSharedCanvas->drawText(
511 [ # # ]: 0 : aText, xFont, MergeViewState(aViewState), aRenderState, nTextDirection);
512 : : }
513 : :
514 : :
515 : :
516 : :
517 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
518 : 0 : PresenterCanvas::drawTextLayout(
519 : : const css::uno::Reference< css::rendering::XTextLayout >& xLayoutetText,
520 : : const css::rendering::ViewState& aViewState,
521 : : const css::rendering::RenderState& aRenderState)
522 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
523 : : {
524 : 0 : ThrowIfDisposed();
525 : 0 : return mxSharedCanvas->drawTextLayout(
526 [ # # ]: 0 : xLayoutetText, MergeViewState(aViewState), aRenderState);
527 : : }
528 : :
529 : :
530 : :
531 : :
532 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
533 : 0 : PresenterCanvas::drawBitmap(
534 : : const css::uno::Reference< css::rendering::XBitmap >& xBitmap,
535 : : const css::rendering::ViewState& aViewState,
536 : : const css::rendering::RenderState& aRenderState)
537 : : throw (css::lang::IllegalArgumentException,
538 : : css::rendering::VolatileContentDestroyedException,
539 : : css::uno::RuntimeException)
540 : : {
541 : 0 : ThrowIfDisposed();
542 : 0 : return mxSharedCanvas->drawBitmap(
543 [ # # ]: 0 : xBitmap, MergeViewState(aViewState), aRenderState);
544 : : }
545 : :
546 : :
547 : :
548 : :
549 : : css::uno::Reference<css::rendering::XCachedPrimitive> SAL_CALL
550 : 0 : PresenterCanvas::drawBitmapModulated(
551 : : const css::uno::Reference< css::rendering::XBitmap>& xBitmap,
552 : : const css::rendering::ViewState& aViewState,
553 : : const css::rendering::RenderState& aRenderState)
554 : : throw (css::lang::IllegalArgumentException,
555 : : css::rendering::VolatileContentDestroyedException,
556 : : css::uno::RuntimeException)
557 : : {
558 : 0 : ThrowIfDisposed();
559 : 0 : return mxSharedCanvas->drawBitmapModulated(
560 [ # # ]: 0 : xBitmap, MergeViewState(aViewState), aRenderState);
561 : : }
562 : :
563 : :
564 : :
565 : :
566 : : css::uno::Reference<css::rendering::XGraphicDevice> SAL_CALL
567 : 0 : PresenterCanvas::getDevice (void)
568 : : throw (css::uno::RuntimeException)
569 : : {
570 : 0 : ThrowIfDisposed();
571 : 0 : return mxSharedCanvas->getDevice();
572 : : }
573 : :
574 : :
575 : :
576 : :
577 : : //----- XBitmapCanvas ---------------------------------------------------------
578 : :
579 : 0 : void SAL_CALL PresenterCanvas::copyRect(
580 : : const css::uno::Reference<css::rendering::XBitmapCanvas>& rxSourceCanvas,
581 : : const css::geometry::RealRectangle2D& rSourceRect,
582 : : const css::rendering::ViewState& rSourceViewState,
583 : : const css::rendering::RenderState& rSourceRenderState,
584 : : const css::geometry::RealRectangle2D& rDestRect,
585 : : const css::rendering::ViewState& rDestViewState,
586 : : const css::rendering::RenderState& rDestRenderState)
587 : : throw (css::lang::IllegalArgumentException,
588 : : css::rendering::VolatileContentDestroyedException,
589 : : css::uno::RuntimeException)
590 : : {
591 [ # # ]: 0 : ThrowIfDisposed();
592 : :
593 [ # # ]: 0 : Reference<rendering::XBitmapCanvas> xBitmapCanvas (mxSharedCanvas, UNO_QUERY);
594 [ # # ]: 0 : if (xBitmapCanvas.is())
595 : : {
596 [ # # ]: 0 : rendering::ViewState aSourceViewState (rSourceViewState);
597 [ # # ][ # # ]: 0 : if (rxSourceCanvas == Reference<rendering::XCanvas>(this))
[ # # ]
598 [ # # ][ # # ]: 0 : aSourceViewState = MergeViewState(aSourceViewState);
[ # # ]
599 [ # # ]: 0 : xBitmapCanvas->copyRect(
600 : : rxSourceCanvas, rSourceRect, aSourceViewState, rSourceRenderState,
601 [ # # ][ # # ]: 0 : rDestRect, MergeViewState(rDestViewState), rDestRenderState);
[ # # ][ # # ]
602 : 0 : }
603 : 0 : }
604 : :
605 : :
606 : :
607 : :
608 : : //----- XSpriteCanvas ---------------------------------------------------------
609 : :
610 : : Reference<rendering::XAnimatedSprite> SAL_CALL
611 : 0 : PresenterCanvas::createSpriteFromAnimation (
612 : : const css::uno::Reference<css::rendering::XAnimation>& rAnimation)
613 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
614 : : {
615 [ # # ]: 0 : ThrowIfDisposed();
616 : :
617 [ # # ]: 0 : Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxSharedCanvas, UNO_QUERY);
618 [ # # ]: 0 : if (xSpriteCanvas.is())
619 [ # # ][ # # ]: 0 : return xSpriteCanvas->createSpriteFromAnimation(rAnimation);
620 : : else
621 [ # # ]: 0 : return NULL;
622 : : }
623 : :
624 : :
625 : :
626 : :
627 : : Reference<rendering::XAnimatedSprite> SAL_CALL
628 : 0 : PresenterCanvas::createSpriteFromBitmaps (
629 : : const css::uno::Sequence<
630 : : css::uno::Reference< css::rendering::XBitmap > >& rAnimationBitmaps,
631 : : ::sal_Int8 nInterpolationMode)
632 : : throw (css::lang::IllegalArgumentException,
633 : : css::rendering::VolatileContentDestroyedException,
634 : : css::uno::RuntimeException)
635 : : {
636 [ # # ]: 0 : ThrowIfDisposed();
637 : :
638 [ # # ]: 0 : Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxSharedCanvas, UNO_QUERY);
639 [ # # ]: 0 : if (xSpriteCanvas.is())
640 [ # # ][ # # ]: 0 : return xSpriteCanvas->createSpriteFromBitmaps(rAnimationBitmaps, nInterpolationMode);
641 : : else
642 [ # # ]: 0 : return NULL;
643 : : }
644 : :
645 : :
646 : :
647 : :
648 : : Reference<rendering::XCustomSprite> SAL_CALL
649 : 0 : PresenterCanvas::createCustomSprite (
650 : : const css::geometry::RealSize2D& rSpriteSize)
651 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
652 : : {
653 [ # # ]: 0 : ThrowIfDisposed();
654 : :
655 [ # # ]: 0 : Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxSharedCanvas, UNO_QUERY);
656 [ # # ]: 0 : if (xSpriteCanvas.is())
657 : : return new PresenterCustomSprite(
658 : : this,
659 [ # # ]: 0 : xSpriteCanvas->createCustomSprite(rSpriteSize),
660 : : mxSharedWindow,
661 [ # # ][ # # ]: 0 : rSpriteSize);
[ # # ][ # # ]
662 [ # # ]: 0 : else if (mxUpdateCanvas.is())
663 : : return new PresenterCustomSprite(
664 : : this,
665 [ # # ]: 0 : mxUpdateCanvas->createCustomSprite(rSpriteSize),
666 : : mxUpdateWindow,
667 [ # # ][ # # ]: 0 : rSpriteSize);
[ # # ][ # # ]
668 : : else
669 [ # # ]: 0 : return NULL;
670 : : }
671 : :
672 : :
673 : :
674 : :
675 : : Reference<rendering::XSprite> SAL_CALL
676 : 0 : PresenterCanvas::createClonedSprite (
677 : : const css::uno::Reference< css::rendering::XSprite >& rxOriginal)
678 : : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
679 : : {
680 [ # # ]: 0 : ThrowIfDisposed();
681 : :
682 [ # # ]: 0 : Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxSharedCanvas, UNO_QUERY);
683 [ # # ]: 0 : if (xSpriteCanvas.is())
684 [ # # ][ # # ]: 0 : return xSpriteCanvas->createClonedSprite(rxOriginal);
685 [ # # ]: 0 : if (mxUpdateCanvas.is())
686 [ # # ][ # # ]: 0 : return mxUpdateCanvas->createClonedSprite(rxOriginal);
687 [ # # ]: 0 : return NULL;
688 : : }
689 : :
690 : :
691 : :
692 : :
693 : 0 : ::sal_Bool SAL_CALL PresenterCanvas::updateScreen (::sal_Bool bUpdateAll)
694 : : throw (css::uno::RuntimeException)
695 : : {
696 : 0 : ThrowIfDisposed();
697 : :
698 : 0 : mbOffsetUpdatePending = true;
699 [ # # ]: 0 : if (mpUpdateRequester.get() != NULL)
700 : : {
701 : 0 : mpUpdateRequester->RequestUpdate(bUpdateAll);
702 : 0 : return sal_True;
703 : : }
704 : : else
705 : : {
706 : 0 : return sal_False;
707 : : }
708 : : }
709 : :
710 : :
711 : :
712 : :
713 : : //----- XEventListener --------------------------------------------------------
714 : :
715 : 0 : void SAL_CALL PresenterCanvas::disposing (const css::lang::EventObject& rEvent)
716 : : throw (css::uno::RuntimeException)
717 : : {
718 : 0 : ThrowIfDisposed();
719 [ # # ]: 0 : if (rEvent.Source == mxWindow)
720 : 0 : mxWindow = NULL;
721 : 0 : }
722 : :
723 : :
724 : :
725 : :
726 : : //----- XWindowListener -------------------------------------------------------
727 : :
728 : 0 : void SAL_CALL PresenterCanvas::windowResized (const css::awt::WindowEvent& rEvent)
729 : : throw (css::uno::RuntimeException)
730 : : {
731 : : (void)rEvent;
732 : 0 : ThrowIfDisposed();
733 : 0 : mbOffsetUpdatePending = true;
734 : 0 : }
735 : :
736 : :
737 : :
738 : :
739 : 0 : void SAL_CALL PresenterCanvas::windowMoved (const css::awt::WindowEvent& rEvent)
740 : : throw (css::uno::RuntimeException)
741 : : {
742 : : (void)rEvent;
743 : 0 : ThrowIfDisposed();
744 : 0 : mbOffsetUpdatePending = true;
745 : 0 : }
746 : :
747 : :
748 : :
749 : :
750 : 0 : void SAL_CALL PresenterCanvas::windowShown (const css::lang::EventObject& rEvent)
751 : : throw (css::uno::RuntimeException)
752 : : {
753 : : (void)rEvent;
754 : 0 : ThrowIfDisposed();
755 : 0 : mbOffsetUpdatePending = true;
756 : 0 : }
757 : :
758 : :
759 : :
760 : :
761 : 0 : void SAL_CALL PresenterCanvas::windowHidden (const css::lang::EventObject& rEvent)
762 : : throw (css::uno::RuntimeException)
763 : : {
764 : : (void)rEvent;
765 : 0 : ThrowIfDisposed();
766 : 0 : }
767 : :
768 : :
769 : :
770 : :
771 : : //----- XBitmap ---------------------------------------------------------------
772 : :
773 : 0 : geometry::IntegerSize2D SAL_CALL PresenterCanvas::getSize (void)
774 : : throw (RuntimeException)
775 : : {
776 : 0 : ThrowIfDisposed();
777 : :
778 [ # # ]: 0 : if (mxWindow.is())
779 : : {
780 [ # # ][ # # ]: 0 : const awt::Rectangle aWindowBox (mxWindow->getPosSize());
781 : 0 : return geometry::IntegerSize2D(aWindowBox.Width, aWindowBox.Height);
782 : : }
783 : : else
784 : 0 : return geometry::IntegerSize2D(0,0);
785 : : }
786 : :
787 : :
788 : :
789 : :
790 : 0 : sal_Bool SAL_CALL PresenterCanvas::hasAlpha (void)
791 : : throw (RuntimeException)
792 : : {
793 [ # # ]: 0 : Reference<rendering::XBitmap> xBitmap (mxSharedCanvas, UNO_QUERY);
794 [ # # ]: 0 : if (xBitmap.is())
795 [ # # ][ # # ]: 0 : return xBitmap->hasAlpha();
796 : : else
797 : 0 : return sal_False;
798 : : }
799 : :
800 : :
801 : :
802 : :
803 : 0 : Reference<rendering::XBitmapCanvas> SAL_CALL PresenterCanvas::queryBitmapCanvas (void)
804 : : throw (RuntimeException)
805 : : {
806 : 0 : ThrowIfDisposed();
807 : :
808 : 0 : return this;
809 : : }
810 : :
811 : :
812 : :
813 : :
814 : 0 : Reference<rendering::XBitmap> SAL_CALL PresenterCanvas::getScaledBitmap(
815 : : const css::geometry::RealSize2D& rNewSize,
816 : : sal_Bool bFast)
817 : : throw (css::uno::RuntimeException,
818 : : css::lang::IllegalArgumentException,
819 : : css::rendering::VolatileContentDestroyedException)
820 : : {
821 : : (void)rNewSize;
822 : : (void)bFast;
823 : :
824 : 0 : ThrowIfDisposed();
825 : :
826 : : // Not implemented.
827 : :
828 : 0 : return NULL;
829 : : }
830 : :
831 : :
832 : :
833 : :
834 : : //-----------------------------------------------------------------------------
835 : :
836 : 0 : rendering::ViewState PresenterCanvas::MergeViewState (
837 : : const rendering::ViewState& rViewState)
838 : : {
839 : : // Make sure the offset is up-to-date.
840 [ # # ]: 0 : if (mbOffsetUpdatePending)
841 : 0 : maOffset = GetOffset(mxSharedWindow);
842 : 0 : return MergeViewState(rViewState, maOffset);
843 : : }
844 : :
845 : :
846 : :
847 : :
848 : 0 : css::rendering::ViewState PresenterCanvas::MergeViewState (
849 : : const css::rendering::ViewState& rViewState,
850 : : const css::awt::Point& rOffset)
851 : : {
852 : : // Early rejects.
853 [ # # ]: 0 : if ( ! mxSharedCanvas.is())
854 [ # # ]: 0 : return rViewState;
855 : :
856 [ # # ][ # # ]: 0 : Reference<rendering::XGraphicDevice> xDevice (mxSharedCanvas->getDevice());
857 [ # # ]: 0 : if ( ! xDevice.is())
858 [ # # ]: 0 : return rViewState;
859 : :
860 : : // Create a modifiable copy of the given view state.
861 [ # # ]: 0 : rendering::ViewState aViewState (rViewState);
862 : :
863 : : // Prepare the local clip rectangle.
864 [ # # ]: 0 : ::basegfx::B2DRectangle aWindowRange (GetClipRectangle(aViewState.AffineTransform, rOffset));
865 : :
866 : : // Adapt the offset of the view state.
867 : 0 : aViewState.AffineTransform.m02 += rOffset.X;
868 : 0 : aViewState.AffineTransform.m12 += rOffset.Y;
869 : :
870 : : // Adapt the clip polygon.
871 [ # # ]: 0 : if ( ! aViewState.Clip.is())
872 : : {
873 : : // Cancel out the later multiplication with the view state
874 : : // transformation.
875 : : aViewState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
876 : : xDevice,
877 [ # # ][ # # ]: 0 : ::basegfx::B2DPolyPolygon(::basegfx::tools::createPolygonFromRect(aWindowRange)));
[ # # ][ # # ]
[ # # ][ # # ]
878 : : }
879 : : else
880 : : {
881 : : // Have to compute the intersection of the given clipping polygon in
882 : : // the view state and the local clip rectangle.
883 : :
884 : : // Clip the view state clipping polygon against the local clip rectangle.
885 : : const ::basegfx::B2DPolyPolygon aClipPolygon (
886 : : ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(
887 [ # # ]: 0 : aViewState.Clip));
888 : : const ::basegfx::B2DPolyPolygon aClippedClipPolygon (
889 : : ::basegfx::tools::clipPolyPolygonOnRange(
890 : : aClipPolygon,
891 : : aWindowRange,
892 : : true, /* bInside */
893 [ # # ]: 0 : false /* bStroke */));
894 : :
895 : : aViewState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
896 : : xDevice,
897 [ # # ][ # # ]: 0 : aClippedClipPolygon);
[ # # ][ # # ]
898 : : }
899 : :
900 [ # # ][ # # ]: 0 : return aViewState;
901 : : }
902 : :
903 : :
904 : :
905 : :
906 : 0 : awt::Point PresenterCanvas::GetOffset (const Reference<awt::XWindow>& rxBaseWindow)
907 : : {
908 : 0 : mbOffsetUpdatePending = false;
909 [ # # ][ # # ]: 0 : if (mxWindow.is() && rxBaseWindow.is())
[ # # ]
910 : : {
911 : 0 : ::Window* pWindow = VCLUnoHelper::GetWindow(mxWindow);
912 : 0 : ::Window* pSharedWindow = VCLUnoHelper::GetWindow(rxBaseWindow);
913 [ # # ][ # # ]: 0 : if (pWindow!=NULL && pSharedWindow!=NULL)
914 : : {
915 [ # # ]: 0 : Rectangle aBox = pWindow->GetWindowExtentsRelative(pSharedWindow);
916 : :
917 : : // Calculate offset of this canvas with respect to the shared
918 : : // canvas.
919 : 0 : return awt::Point(aBox.Left(), aBox.Top());
920 : : }
921 : : }
922 : :
923 : 0 : return awt::Point(0, 0);
924 : : }
925 : :
926 : :
927 : :
928 : :
929 : 0 : ::basegfx::B2DRectangle PresenterCanvas::GetClipRectangle (
930 : : const css::geometry::AffineMatrix2D& rViewTransform,
931 : : const awt::Point& rOffset)
932 : : {
933 [ # # ]: 0 : ::basegfx::B2DRectangle aClipRectangle;
934 : :
935 [ # # ]: 0 : ::Window* pWindow = VCLUnoHelper::GetWindow(mxWindow);
936 [ # # ]: 0 : if (pWindow == NULL)
937 [ # # ]: 0 : return ::basegfx::B2DRectangle();
938 : :
939 [ # # ]: 0 : ::Window* pSharedWindow = VCLUnoHelper::GetWindow(mxSharedWindow);
940 [ # # ]: 0 : if (pSharedWindow == NULL)
941 [ # # ]: 0 : return ::basegfx::B2DRectangle();
942 : :
943 : : // Get the bounding box of the window and create a range in the
944 : : // coordinate system of the child window.
945 [ # # ]: 0 : Rectangle aLocalClip;
946 [ # # ][ # # ]: 0 : if (maClipRectangle.Width <= 0 || maClipRectangle.Height <= 0)
947 : : {
948 : : // No clip rectangle has been set via SetClip by the pane.
949 : : // Use the window extents instead.
950 [ # # ]: 0 : aLocalClip = pWindow->GetWindowExtentsRelative(pSharedWindow);
951 : : }
952 : : else
953 : : {
954 : : // Use a previously given clip rectangle.
955 : : aLocalClip = Rectangle(
956 : : maClipRectangle.X + rOffset.X,
957 : : maClipRectangle.Y + rOffset.Y,
958 : : maClipRectangle.X + maClipRectangle.Width + rOffset.X,
959 [ # # ]: 0 : maClipRectangle.Y + maClipRectangle.Height + rOffset.Y);
960 : : }
961 : :
962 : : // The local clip rectangle is used to clip the view state clipping
963 : : // polygon.
964 : : ::basegfx::B2DRectangle aWindowRectangle (
965 : 0 : aLocalClip.Left() - rOffset.X,
966 : 0 : aLocalClip.Top() - rOffset.Y,
967 : 0 : aLocalClip.Right() - rOffset.X + 1,
968 [ # # ]: 0 : aLocalClip.Bottom() - rOffset.Y + 1);
969 : :
970 : : // Calculate the inverted view state transformation to cancel out a
971 : : // later transformation of the local clip polygon with the view state
972 : : // transformation.
973 [ # # ]: 0 : ::basegfx::B2DHomMatrix aInvertedViewStateTransformation;
974 : : ::basegfx::unotools::homMatrixFromAffineMatrix(
975 : : aInvertedViewStateTransformation,
976 [ # # ]: 0 : rViewTransform);
977 [ # # ][ # # ]: 0 : if (aInvertedViewStateTransformation.invert())
978 : : {
979 : : // Cancel out the later multiplication with the view state
980 : : // transformation.
981 [ # # ]: 0 : aWindowRectangle.transform(aInvertedViewStateTransformation);
982 : : }
983 : :
984 [ # # ]: 0 : return aWindowRectangle;
985 : : }
986 : :
987 : :
988 : :
989 : 0 : Reference<rendering::XPolyPolygon2D> PresenterCanvas::UpdateSpriteClip (
990 : : const Reference<rendering::XPolyPolygon2D>& rxOriginalClip,
991 : : const geometry::RealPoint2D& rLocation,
992 : : const geometry::RealSize2D& rSize)
993 : : {
994 : : (void)rSize;
995 : :
996 : : // Check used resources and just return the original clip when not
997 : : // every one of them is available.
998 [ # # ]: 0 : if ( ! mxWindow.is())
999 : 0 : return rxOriginalClip;
1000 : :
1001 [ # # ][ # # ]: 0 : Reference<rendering::XGraphicDevice> xDevice (mxSharedCanvas->getDevice());
1002 [ # # ]: 0 : if ( ! xDevice.is())
1003 : 0 : return rxOriginalClip;
1004 : :
1005 : : // Determine the bounds of the clip rectangle (the window border) in the
1006 : : // coordinate system of the sprite.
1007 [ # # ][ # # ]: 0 : const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1008 : 0 : const double nMinX (-rLocation.X);
1009 : 0 : const double nMinY (-rLocation.Y);
1010 : 0 : const double nMaxX (aWindowBox.Width-rLocation.X);
1011 : 0 : const double nMaxY (aWindowBox.Height-rLocation.Y);
1012 : :
1013 : : // Create a clip polygon.
1014 : 0 : Reference<rendering::XPolyPolygon2D> xPolygon;
1015 [ # # ]: 0 : if (rxOriginalClip.is())
1016 : : {
1017 : : // Combine the original clip with the window clip.
1018 : : const ::basegfx::B2DPolyPolygon aOriginalClip (
1019 [ # # ]: 0 : ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rxOriginalClip));
1020 [ # # ]: 0 : ::basegfx::B2DRectangle aWindowRange (nMinX, nMinY, nMaxX, nMaxY);
1021 : : const ::basegfx::B2DPolyPolygon aClippedClipPolygon (
1022 : : ::basegfx::tools::clipPolyPolygonOnRange(
1023 : : aOriginalClip,
1024 : : aWindowRange,
1025 : : true, /* bInside */
1026 [ # # ]: 0 : false /* bStroke */));
1027 : : xPolygon = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
1028 : : xDevice,
1029 [ # # ][ # # ]: 0 : aClippedClipPolygon);
[ # # ][ # # ]
1030 : : }
1031 : : else
1032 : : {
1033 : : // Create a new clip polygon from the window clip rectangle.
1034 [ # # ]: 0 : Sequence<Sequence<geometry::RealPoint2D> > aPoints (1);
1035 [ # # ][ # # ]: 0 : aPoints[0] = Sequence<geometry::RealPoint2D>(4);
[ # # ][ # # ]
1036 [ # # ][ # # ]: 0 : aPoints[0][0] = geometry::RealPoint2D(nMinX,nMinY);
1037 [ # # ][ # # ]: 0 : aPoints[0][1] = geometry::RealPoint2D(nMaxX,nMinY);
1038 [ # # ][ # # ]: 0 : aPoints[0][2] = geometry::RealPoint2D(nMaxX,nMaxY);
1039 [ # # ][ # # ]: 0 : aPoints[0][3] = geometry::RealPoint2D(nMinX,nMaxY);
1040 : : Reference<rendering::XLinePolyPolygon2D> xLinePolygon(
1041 [ # # ][ # # ]: 0 : xDevice->createCompatibleLinePolyPolygon(aPoints));
1042 [ # # ]: 0 : if (xLinePolygon.is())
1043 [ # # ][ # # ]: 0 : xLinePolygon->setClosed(0, sal_True);
1044 [ # # ][ # # ]: 0 : xPolygon = Reference<rendering::XPolyPolygon2D>(xLinePolygon, UNO_QUERY);
[ # # ]
1045 : : }
1046 : :
1047 : 0 : return xPolygon;
1048 : : }
1049 : :
1050 : :
1051 : :
1052 : :
1053 : 0 : void PresenterCanvas::ThrowIfDisposed (void)
1054 : : throw (css::lang::DisposedException)
1055 : : {
1056 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose || ! mxSharedCanvas.is())
[ # # ][ # # ]
1057 : : {
1058 : : throw lang::DisposedException ("PresenterCanvas object has already been disposed",
1059 [ # # ][ # # ]: 0 : static_cast<uno::XWeak*>(this));
1060 : : }
1061 : 0 : }
1062 : :
1063 : :
1064 : :
1065 : :
1066 : : //===== PresenterCustomSprite =================================================
1067 : :
1068 : :
1069 : 0 : PresenterCustomSprite::PresenterCustomSprite (
1070 : : const rtl::Reference<PresenterCanvas>& rpCanvas,
1071 : : const Reference<rendering::XCustomSprite>& rxSprite,
1072 : : const Reference<awt::XWindow>& rxBaseWindow,
1073 : : const css::geometry::RealSize2D& rSpriteSize)
1074 : : : PresenterCustomSpriteInterfaceBase(m_aMutex),
1075 : : mpCanvas(rpCanvas),
1076 : : mxSprite(rxSprite),
1077 : : mxBaseWindow(rxBaseWindow),
1078 : : maPosition(0,0),
1079 [ # # ]: 0 : maSpriteSize(rSpriteSize)
1080 : : {
1081 : 0 : }
1082 : :
1083 : :
1084 : :
1085 : :
1086 [ # # ][ # # ]: 0 : PresenterCustomSprite::~PresenterCustomSprite (void)
1087 : : {
1088 [ # # ]: 0 : }
1089 : :
1090 : :
1091 : :
1092 : :
1093 : 0 : void SAL_CALL PresenterCustomSprite::disposing (void)
1094 : : throw (RuntimeException)
1095 : : {
1096 [ # # ]: 0 : Reference<XComponent> xComponent (mxSprite, UNO_QUERY);
1097 [ # # ]: 0 : mxSprite = NULL;
1098 [ # # ]: 0 : if (xComponent.is())
1099 [ # # ][ # # ]: 0 : xComponent->dispose();
1100 [ # # ]: 0 : mpCanvas = rtl::Reference<PresenterCanvas>();
1101 : 0 : }
1102 : :
1103 : :
1104 : :
1105 : :
1106 : : //----- XSprite ---------------------------------------------------------------
1107 : :
1108 : 0 : void SAL_CALL PresenterCustomSprite::setAlpha (const double nAlpha)
1109 : : throw (lang::IllegalArgumentException,RuntimeException)
1110 : : {
1111 : 0 : ThrowIfDisposed();
1112 : 0 : mxSprite->setAlpha(nAlpha);
1113 : 0 : }
1114 : :
1115 : :
1116 : :
1117 : :
1118 : 0 : void SAL_CALL PresenterCustomSprite::move (
1119 : : const geometry::RealPoint2D& rNewPos,
1120 : : const rendering::ViewState& rViewState,
1121 : : const rendering::RenderState& rRenderState)
1122 : : throw (lang::IllegalArgumentException,RuntimeException)
1123 : : {
1124 : 0 : ThrowIfDisposed();
1125 : 0 : maPosition = rNewPos;
1126 : 0 : mxSprite->move(
1127 : : rNewPos,
1128 : 0 : mpCanvas->MergeViewState(rViewState, mpCanvas->GetOffset(mxBaseWindow)),
1129 [ # # ][ # # ]: 0 : rRenderState);
[ # # ]
1130 : : // Clip sprite against window bounds. This call is necessary because
1131 : : // sprite clipping is done in the corrdinate system of the sprite.
1132 : : // Therefore, after each change of the sprites location the window
1133 : : // bounds have to be transformed into the sprites coordinate system.
1134 [ # # ]: 0 : clip(NULL);
1135 : 0 : }
1136 : :
1137 : :
1138 : :
1139 : :
1140 : 0 : void SAL_CALL PresenterCustomSprite::transform (const geometry::AffineMatrix2D& rTransformation)
1141 : : throw (lang::IllegalArgumentException,RuntimeException)
1142 : : {
1143 : 0 : ThrowIfDisposed();
1144 : 0 : mxSprite->transform(rTransformation);
1145 : 0 : }
1146 : :
1147 : :
1148 : :
1149 : :
1150 : 0 : void SAL_CALL PresenterCustomSprite::clip (const Reference<rendering::XPolyPolygon2D>& rxClip)
1151 : : throw (RuntimeException)
1152 : : {
1153 : 0 : ThrowIfDisposed();
1154 : : // The clip region is expected in the coordinate system of the sprite.
1155 : : // UpdateSpriteClip() integrates the window bounds, transformed into the
1156 : : // sprites coordinate system, with the given clip.
1157 [ # # ]: 0 : mxSprite->clip(mpCanvas->UpdateSpriteClip(rxClip, maPosition, maSpriteSize));
1158 : 0 : }
1159 : :
1160 : :
1161 : :
1162 : :
1163 : 0 : void SAL_CALL PresenterCustomSprite::setPriority (const double nPriority)
1164 : : throw (RuntimeException)
1165 : : {
1166 : 0 : ThrowIfDisposed();
1167 : 0 : mxSprite->setPriority(nPriority);
1168 : 0 : }
1169 : :
1170 : :
1171 : :
1172 : 0 : void SAL_CALL PresenterCustomSprite::show (void)
1173 : : throw (RuntimeException)
1174 : : {
1175 : 0 : ThrowIfDisposed();
1176 : 0 : mxSprite->show();
1177 : 0 : }
1178 : :
1179 : :
1180 : :
1181 : :
1182 : 0 : void SAL_CALL PresenterCustomSprite::hide (void)
1183 : : throw (RuntimeException)
1184 : : {
1185 : 0 : ThrowIfDisposed();
1186 : 0 : mxSprite->hide();
1187 : 0 : }
1188 : :
1189 : :
1190 : :
1191 : :
1192 : : //----- XCustomSprite ---------------------------------------------------------
1193 : :
1194 : 0 : Reference<rendering::XCanvas> PresenterCustomSprite::getContentCanvas (void)
1195 : : throw (RuntimeException)
1196 : : {
1197 : 0 : ThrowIfDisposed();
1198 : 0 : return mxSprite->getContentCanvas();
1199 : : }
1200 : :
1201 : :
1202 : :
1203 : :
1204 : : //-----------------------------------------------------------------------------
1205 : :
1206 : 0 : void PresenterCustomSprite::ThrowIfDisposed (void)
1207 : : throw (css::lang::DisposedException)
1208 : : {
1209 [ # # ][ # # ]: 0 : if (rBHelper.bDisposed || rBHelper.bInDispose || ! mxSprite.is())
[ # # ][ # # ]
1210 : : {
1211 : : throw lang::DisposedException ("PresenterCustomSprite object has already been disposed",
1212 [ # # ][ # # ]: 0 : static_cast<uno::XWeak*>(this));
1213 : : }
1214 : 0 : }
1215 : :
1216 : :
1217 : :
1218 : :
1219 : : } } // end of namespace ::sd::presenter
1220 : :
1221 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|