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 #include "PresenterCanvas.hxx"
21 #include "CanvasUpdateRequester.hxx"
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <basegfx/polygon/b2dpolygontools.hxx>
25 #include <basegfx/polygon/b2dpolypolygon.hxx>
26 #include <basegfx/polygon/b2dpolygonclipper.hxx>
27 #include <basegfx/range/b2drectangle.hxx>
28 #include <basegfx/utils/canvastools.hxx>
29 #include <com/sun/star/awt/XWindow.hpp>
30 #include <comphelper/compbase.hxx>
31 #include <rtl/ref.hxx>
32 #include <toolkit/helper/vclunohelper.hxx>
34 #include <vcl/window.hxx>
36 using namespace ::com::sun::star
;
37 using namespace ::com::sun::star::uno
;
39 namespace sd::presenter
{
41 //===== PresenterCustomSprite =================================================
43 /** Wrapper around a sprite that is displayed on a PresenterCanvas.
46 typedef comphelper::WeakComponentImplHelper
<
47 css::rendering::XCustomSprite
48 > PresenterCustomSpriteInterfaceBase
;
50 class PresenterCustomSprite final
51 : public PresenterCustomSpriteInterfaceBase
54 PresenterCustomSprite (
55 rtl::Reference
<PresenterCanvas
> pCanvas
,
56 const Reference
<rendering::XCustomSprite
>& rxSprite
,
57 const Reference
<awt::XWindow
>& rxBaseWindow
);
58 PresenterCustomSprite(const PresenterCustomSprite
&) = delete;
59 PresenterCustomSprite
& operator=(const PresenterCustomSprite
&) = delete;
60 virtual void disposing(std::unique_lock
<std::mutex
>&) override
;
64 virtual void SAL_CALL
setAlpha (double nAlpha
) override
;
66 virtual void SAL_CALL
move (const geometry::RealPoint2D
& rNewPos
,
67 const rendering::ViewState
& rViewState
,
68 const rendering::RenderState
& rRenderState
) override
;
70 virtual void SAL_CALL
transform (const geometry::AffineMatrix2D
& rTransformation
) override
;
72 virtual void SAL_CALL
clip (const Reference
<rendering::XPolyPolygon2D
>& rClip
) override
;
74 virtual void SAL_CALL
setPriority (double nPriority
) override
;
76 virtual void SAL_CALL
show() override
;
78 virtual void SAL_CALL
hide() override
;
82 virtual Reference
<rendering::XCanvas
> SAL_CALL
getContentCanvas() override
;
85 rtl::Reference
<PresenterCanvas
> mpCanvas
;
86 Reference
<rendering::XCustomSprite
> mxSprite
;
87 Reference
<awt::XWindow
> mxBaseWindow
;
88 geometry::RealPoint2D maPosition
;
90 /// @throws css::lang::DisposedException
91 void ThrowIfDisposed();
96 //===== PresenterCanvas =======================================================
98 PresenterCanvas::PresenterCanvas (
99 const Reference
<rendering::XSpriteCanvas
>& rxUpdateCanvas
,
100 const Reference
<awt::XWindow
>& rxUpdateWindow
,
101 const Reference
<rendering::XCanvas
>& rxSharedCanvas
,
102 const Reference
<awt::XWindow
>& rxSharedWindow
,
103 const Reference
<awt::XWindow
>& rxWindow
)
104 : mxUpdateCanvas(rxUpdateCanvas
),
105 mxUpdateWindow(rxUpdateWindow
),
106 mxSharedCanvas(rxSharedCanvas
),
107 mxSharedWindow(rxSharedWindow
),
109 mbOffsetUpdatePending(true)
112 mxWindow
->addWindowListener(this);
114 if (mxUpdateCanvas
.is())
116 m_pUpdateRequester
= CanvasUpdateRequester::Instance(mxUpdateCanvas
);
120 PresenterCanvas::~PresenterCanvas()
124 void PresenterCanvas::disposing(std::unique_lock
<std::mutex
>&)
128 mxWindow
->removeWindowListener(this);
133 //----- XCanvas ---------------------------------------------------------------
135 void SAL_CALL
PresenterCanvas::clear()
138 // ToDo: Clear the area covered by the child window. A simple forward
139 // would clear the whole shared canvas.
142 void SAL_CALL
PresenterCanvas::drawPoint (
143 const css::geometry::RealPoint2D
& aPoint
,
144 const css::rendering::ViewState
& aViewState
,
145 const css::rendering::RenderState
& aRenderState
)
148 mxSharedCanvas
->drawPoint(aPoint
,MergeViewState(aViewState
),aRenderState
);
151 void SAL_CALL
PresenterCanvas::drawLine (
152 const css::geometry::RealPoint2D
& aStartPoint
,
153 const css::geometry::RealPoint2D
& aEndPoint
,
154 const css::rendering::ViewState
& aViewState
,
155 const css::rendering::RenderState
& aRenderState
)
158 mxSharedCanvas
->drawLine(aStartPoint
,aEndPoint
,MergeViewState(aViewState
),aRenderState
);
161 void SAL_CALL
PresenterCanvas::drawBezier (
162 const css::geometry::RealBezierSegment2D
& aBezierSegment
,
163 const css::geometry::RealPoint2D
& aEndPoint
,
164 const css::rendering::ViewState
& aViewState
,
165 const css::rendering::RenderState
& aRenderState
)
168 mxSharedCanvas
->drawBezier(aBezierSegment
,aEndPoint
,MergeViewState(aViewState
),aRenderState
);
171 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
PresenterCanvas::drawPolyPolygon (
172 const css::uno::Reference
< css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
173 const css::rendering::ViewState
& aViewState
,
174 const css::rendering::RenderState
& aRenderState
)
177 return mxSharedCanvas
->drawPolyPolygon(
178 xPolyPolygon
, MergeViewState(aViewState
), aRenderState
);
181 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
PresenterCanvas::strokePolyPolygon (
182 const css::uno::Reference
< css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
183 const css::rendering::ViewState
& aViewState
,
184 const css::rendering::RenderState
& aRenderState
,
185 const css::rendering::StrokeAttributes
& aStrokeAttributes
)
188 return mxSharedCanvas
->strokePolyPolygon(
189 xPolyPolygon
, MergeViewState(aViewState
), aRenderState
, aStrokeAttributes
);
192 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
193 PresenterCanvas::strokeTexturedPolyPolygon (
194 const css::uno::Reference
< css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
195 const css::rendering::ViewState
& aViewState
,
196 const css::rendering::RenderState
& aRenderState
,
197 const css::uno::Sequence
< css::rendering::Texture
>& aTextures
,
198 const css::rendering::StrokeAttributes
& aStrokeAttributes
)
201 return mxSharedCanvas
->strokeTexturedPolyPolygon(
202 xPolyPolygon
, MergeViewState(aViewState
), aRenderState
, aTextures
, aStrokeAttributes
);
205 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
206 PresenterCanvas::strokeTextureMappedPolyPolygon(
207 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
208 const css::rendering::ViewState
& aViewState
,
209 const css::rendering::RenderState
& aRenderState
,
210 const css::uno::Sequence
<css::rendering::Texture
>& aTextures
,
211 const css::uno::Reference
<css::geometry::XMapping2D
>& xMapping
,
212 const css::rendering::StrokeAttributes
& aStrokeAttributes
)
215 return mxSharedCanvas
->strokeTextureMappedPolyPolygon(
217 MergeViewState(aViewState
),
224 css::uno::Reference
<css::rendering::XPolyPolygon2D
> SAL_CALL
225 PresenterCanvas::queryStrokeShapes(
226 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
227 const css::rendering::ViewState
& aViewState
,
228 const css::rendering::RenderState
& aRenderState
,
229 const css::rendering::StrokeAttributes
& aStrokeAttributes
)
232 return mxSharedCanvas
->queryStrokeShapes(
233 xPolyPolygon
, MergeViewState(aViewState
), aRenderState
, aStrokeAttributes
);
236 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
237 PresenterCanvas::fillPolyPolygon(
238 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
239 const css::rendering::ViewState
& aViewState
,
240 const css::rendering::RenderState
& aRenderState
)
243 return mxSharedCanvas
->fillPolyPolygon(
244 xPolyPolygon
, MergeViewState(aViewState
), aRenderState
);
247 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
248 PresenterCanvas::fillTexturedPolyPolygon(
249 const css::uno::Reference
<css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
250 const css::rendering::ViewState
& aViewState
,
251 const css::rendering::RenderState
& aRenderState
,
252 const css::uno::Sequence
<css::rendering::Texture
>& xTextures
)
255 return mxSharedCanvas
->fillTexturedPolyPolygon(
256 xPolyPolygon
, MergeViewState(aViewState
), aRenderState
, xTextures
);
259 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
260 PresenterCanvas::fillTextureMappedPolyPolygon(
261 const css::uno::Reference
< css::rendering::XPolyPolygon2D
>& xPolyPolygon
,
262 const css::rendering::ViewState
& aViewState
,
263 const css::rendering::RenderState
& aRenderState
,
264 const css::uno::Sequence
< css::rendering::Texture
>& xTextures
,
265 const css::uno::Reference
< css::geometry::XMapping2D
>& xMapping
)
268 return mxSharedCanvas
->fillTextureMappedPolyPolygon(
269 xPolyPolygon
, MergeViewState(aViewState
), aRenderState
, xTextures
, xMapping
);
272 css::uno::Reference
<css::rendering::XCanvasFont
> SAL_CALL
273 PresenterCanvas::createFont(
274 const css::rendering::FontRequest
& aFontRequest
,
275 const css::uno::Sequence
< css::beans::PropertyValue
>& aExtraFontProperties
,
276 const css::geometry::Matrix2D
& aFontMatrix
)
279 return mxSharedCanvas
->createFont(
280 aFontRequest
, aExtraFontProperties
, aFontMatrix
);
283 css::uno::Sequence
<css::rendering::FontInfo
> SAL_CALL
284 PresenterCanvas::queryAvailableFonts(
285 const css::rendering::FontInfo
& aFilter
,
286 const css::uno::Sequence
< css::beans::PropertyValue
>& aFontProperties
)
289 return mxSharedCanvas
->queryAvailableFonts(aFilter
, aFontProperties
);
292 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
293 PresenterCanvas::drawText(
294 const css::rendering::StringContext
& aText
,
295 const css::uno::Reference
< css::rendering::XCanvasFont
>& xFont
,
296 const css::rendering::ViewState
& aViewState
,
297 const css::rendering::RenderState
& aRenderState
,
298 ::sal_Int8 nTextDirection
)
301 return mxSharedCanvas
->drawText(
302 aText
, xFont
, MergeViewState(aViewState
), aRenderState
, nTextDirection
);
305 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
306 PresenterCanvas::drawTextLayout(
307 const css::uno::Reference
< css::rendering::XTextLayout
>& xLayoutetText
,
308 const css::rendering::ViewState
& aViewState
,
309 const css::rendering::RenderState
& aRenderState
)
312 return mxSharedCanvas
->drawTextLayout(
313 xLayoutetText
, MergeViewState(aViewState
), aRenderState
);
316 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
317 PresenterCanvas::drawBitmap(
318 const css::uno::Reference
< css::rendering::XBitmap
>& xBitmap
,
319 const css::rendering::ViewState
& aViewState
,
320 const css::rendering::RenderState
& aRenderState
)
323 return mxSharedCanvas
->drawBitmap(
324 xBitmap
, MergeViewState(aViewState
), aRenderState
);
327 css::uno::Reference
<css::rendering::XCachedPrimitive
> SAL_CALL
328 PresenterCanvas::drawBitmapModulated(
329 const css::uno::Reference
< css::rendering::XBitmap
>& xBitmap
,
330 const css::rendering::ViewState
& aViewState
,
331 const css::rendering::RenderState
& aRenderState
)
334 return mxSharedCanvas
->drawBitmapModulated(
335 xBitmap
, MergeViewState(aViewState
), aRenderState
);
338 css::uno::Reference
<css::rendering::XGraphicDevice
> SAL_CALL
339 PresenterCanvas::getDevice()
342 return mxSharedCanvas
->getDevice();
345 //----- XSpriteCanvas ---------------------------------------------------------
347 Reference
<rendering::XAnimatedSprite
> SAL_CALL
348 PresenterCanvas::createSpriteFromAnimation (
349 const css::uno::Reference
<css::rendering::XAnimation
>& rAnimation
)
353 Reference
<rendering::XSpriteCanvas
> xSpriteCanvas (mxSharedCanvas
, UNO_QUERY
);
354 if (xSpriteCanvas
.is())
355 return xSpriteCanvas
->createSpriteFromAnimation(rAnimation
);
360 Reference
<rendering::XAnimatedSprite
> SAL_CALL
361 PresenterCanvas::createSpriteFromBitmaps (
362 const css::uno::Sequence
<
363 css::uno::Reference
< css::rendering::XBitmap
> >& rAnimationBitmaps
,
364 ::sal_Int8 nInterpolationMode
)
368 Reference
<rendering::XSpriteCanvas
> xSpriteCanvas (mxSharedCanvas
, UNO_QUERY
);
369 if (xSpriteCanvas
.is())
370 return xSpriteCanvas
->createSpriteFromBitmaps(rAnimationBitmaps
, nInterpolationMode
);
375 Reference
<rendering::XCustomSprite
> SAL_CALL
376 PresenterCanvas::createCustomSprite (
377 const css::geometry::RealSize2D
& rSpriteSize
)
381 Reference
<rendering::XSpriteCanvas
> xSpriteCanvas (mxSharedCanvas
, UNO_QUERY
);
382 if (xSpriteCanvas
.is())
383 return new PresenterCustomSprite(
385 xSpriteCanvas
->createCustomSprite(rSpriteSize
),
387 else if (mxUpdateCanvas
.is())
388 return new PresenterCustomSprite(
390 mxUpdateCanvas
->createCustomSprite(rSpriteSize
),
396 Reference
<rendering::XSprite
> SAL_CALL
397 PresenterCanvas::createClonedSprite (
398 const css::uno::Reference
< css::rendering::XSprite
>& rxOriginal
)
402 Reference
<rendering::XSpriteCanvas
> xSpriteCanvas (mxSharedCanvas
, UNO_QUERY
);
403 if (xSpriteCanvas
.is())
404 return xSpriteCanvas
->createClonedSprite(rxOriginal
);
405 if (mxUpdateCanvas
.is())
406 return mxUpdateCanvas
->createClonedSprite(rxOriginal
);
410 sal_Bool SAL_CALL
PresenterCanvas::updateScreen (sal_Bool bUpdateAll
)
414 mbOffsetUpdatePending
= true;
415 if (m_pUpdateRequester
!= nullptr)
417 m_pUpdateRequester
->RequestUpdate(bUpdateAll
);
426 //----- XEventListener --------------------------------------------------------
428 void SAL_CALL
PresenterCanvas::disposing (const css::lang::EventObject
& rEvent
)
431 if (rEvent
.Source
== mxWindow
)
435 //----- XWindowListener -------------------------------------------------------
437 void SAL_CALL
PresenterCanvas::windowResized (const css::awt::WindowEvent
&)
440 mbOffsetUpdatePending
= true;
443 void SAL_CALL
PresenterCanvas::windowMoved (const css::awt::WindowEvent
&)
446 mbOffsetUpdatePending
= true;
449 void SAL_CALL
PresenterCanvas::windowShown (const css::lang::EventObject
&)
452 mbOffsetUpdatePending
= true;
455 void SAL_CALL
PresenterCanvas::windowHidden (const css::lang::EventObject
&)
460 //----- XBitmap ---------------------------------------------------------------
462 geometry::IntegerSize2D SAL_CALL
PresenterCanvas::getSize()
468 const awt::Rectangle
aWindowBox (mxWindow
->getPosSize());
469 return geometry::IntegerSize2D(aWindowBox
.Width
, aWindowBox
.Height
);
472 return geometry::IntegerSize2D(0,0);
475 sal_Bool SAL_CALL
PresenterCanvas::hasAlpha()
477 Reference
<rendering::XBitmap
> xBitmap (mxSharedCanvas
, UNO_QUERY
);
479 return xBitmap
->hasAlpha();
484 Reference
<rendering::XBitmap
> SAL_CALL
PresenterCanvas::getScaledBitmap(
485 const css::geometry::RealSize2D
&,
495 rendering::ViewState
PresenterCanvas::MergeViewState (
496 const rendering::ViewState
& rViewState
)
498 // Make sure the offset is up-to-date.
499 if (mbOffsetUpdatePending
)
500 maOffset
= GetOffset(mxSharedWindow
);
501 return MergeViewState(rViewState
, maOffset
);
504 css::rendering::ViewState
PresenterCanvas::MergeViewState (
505 const css::rendering::ViewState
& rViewState
,
506 const css::awt::Point
& rOffset
)
509 if ( ! mxSharedCanvas
.is())
512 Reference
<rendering::XGraphicDevice
> xDevice (mxSharedCanvas
->getDevice());
516 // Create a modifiable copy of the given view state.
517 rendering::ViewState
aViewState (rViewState
);
519 // Prepare the local clip rectangle.
520 ::basegfx::B2DRectangle
aWindowRange (GetClipRectangle(aViewState
.AffineTransform
, rOffset
));
522 // Adapt the offset of the view state.
523 aViewState
.AffineTransform
.m02
+= rOffset
.X
;
524 aViewState
.AffineTransform
.m12
+= rOffset
.Y
;
526 // Adapt the clip polygon.
527 if ( ! aViewState
.Clip
.is())
529 // Cancel out the later multiplication with the view state
531 aViewState
.Clip
= ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
533 ::basegfx::B2DPolyPolygon(::basegfx::utils::createPolygonFromRect(aWindowRange
)));
537 // Have to compute the intersection of the given clipping polygon in
538 // the view state and the local clip rectangle.
540 // Clip the view state clipping polygon against the local clip rectangle.
541 const ::basegfx::B2DPolyPolygon
aClipPolygon (
542 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(
544 const ::basegfx::B2DPolyPolygon
aClippedClipPolygon (
545 ::basegfx::utils::clipPolyPolygonOnRange(
549 false /* bStroke */));
551 aViewState
.Clip
= ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
553 aClippedClipPolygon
);
559 awt::Point
PresenterCanvas::GetOffset (const Reference
<awt::XWindow
>& rxBaseWindow
)
561 mbOffsetUpdatePending
= false;
562 if (mxWindow
.is() && rxBaseWindow
.is())
564 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow(mxWindow
);
565 VclPtr
<vcl::Window
> pSharedWindow
= VCLUnoHelper::GetWindow(rxBaseWindow
);
566 if (pWindow
&& pSharedWindow
)
568 ::tools::Rectangle aBox
= pWindow
->GetWindowExtentsRelative(*pSharedWindow
);
570 // Calculate offset of this canvas with respect to the shared
572 return awt::Point(aBox
.Left(), aBox
.Top());
576 return awt::Point(0, 0);
579 ::basegfx::B2DRectangle
PresenterCanvas::GetClipRectangle (
580 const css::geometry::AffineMatrix2D
& rViewTransform
,
581 const awt::Point
& rOffset
)
583 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow(mxWindow
);
585 return ::basegfx::B2DRectangle();
587 VclPtr
<vcl::Window
> pSharedWindow
= VCLUnoHelper::GetWindow(mxSharedWindow
);
589 return ::basegfx::B2DRectangle();
591 // Get the bounding box of the window and create a range in the
592 // coordinate system of the child window.
593 // Use the window extents.
594 ::tools::Rectangle aLocalClip
= pWindow
->GetWindowExtentsRelative(*pSharedWindow
);
596 // The local clip rectangle is used to clip the view state clipping
598 ::basegfx::B2DRectangle
aWindowRectangle (
599 aLocalClip
.Left() - rOffset
.X
,
600 aLocalClip
.Top() - rOffset
.Y
,
601 aLocalClip
.Right() - rOffset
.X
+ 1,
602 aLocalClip
.Bottom() - rOffset
.Y
+ 1);
604 // Calculate the inverted view state transformation to cancel out a
605 // later transformation of the local clip polygon with the view state
607 ::basegfx::B2DHomMatrix aInvertedViewStateTransformation
;
608 ::basegfx::unotools::homMatrixFromAffineMatrix(
609 aInvertedViewStateTransformation
,
611 if (aInvertedViewStateTransformation
.invert())
613 // Cancel out the later multiplication with the view state
615 aWindowRectangle
.transform(aInvertedViewStateTransformation
);
618 return aWindowRectangle
;
621 Reference
<rendering::XPolyPolygon2D
> PresenterCanvas::UpdateSpriteClip (
622 const Reference
<rendering::XPolyPolygon2D
>& rxOriginalClip
,
623 const geometry::RealPoint2D
& rLocation
)
625 // Check used resources and just return the original clip when not
626 // every one of them is available.
627 if ( ! mxWindow
.is())
628 return rxOriginalClip
;
630 Reference
<rendering::XGraphicDevice
> xDevice (mxSharedCanvas
->getDevice());
632 return rxOriginalClip
;
634 // Determine the bounds of the clip rectangle (the window border) in the
635 // coordinate system of the sprite.
636 const awt::Rectangle
aWindowBox (mxWindow
->getPosSize());
637 const double nMinX (-rLocation
.X
);
638 const double nMinY (-rLocation
.Y
);
639 const double nMaxX (aWindowBox
.Width
-rLocation
.X
);
640 const double nMaxY (aWindowBox
.Height
-rLocation
.Y
);
642 // Create a clip polygon.
643 Reference
<rendering::XPolyPolygon2D
> xPolygon
;
644 if (rxOriginalClip
.is())
646 // Combine the original clip with the window clip.
647 const ::basegfx::B2DPolyPolygon
aOriginalClip (
648 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rxOriginalClip
));
649 ::basegfx::B2DRectangle
aWindowRange (nMinX
, nMinY
, nMaxX
, nMaxY
);
650 const ::basegfx::B2DPolyPolygon
aClippedClipPolygon (
651 ::basegfx::utils::clipPolyPolygonOnRange(
655 false /* bStroke */));
656 xPolygon
= ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
658 aClippedClipPolygon
);
662 // Create a new clip polygon from the window clip rectangle.
663 Sequence
<Sequence
<geometry::RealPoint2D
> > aPoints
672 Reference
<rendering::XLinePolyPolygon2D
> xLinePolygon(
673 xDevice
->createCompatibleLinePolyPolygon(aPoints
));
674 if (xLinePolygon
.is())
675 xLinePolygon
->setClosed(0, true);
676 xPolygon
= xLinePolygon
;
682 void PresenterCanvas::ThrowIfDisposed()
684 if (m_bDisposed
|| ! mxSharedCanvas
.is())
686 throw lang::DisposedException (u
"PresenterCanvas object has already been disposed"_ustr
,
687 static_cast<uno::XWeak
*>(this));
691 //===== PresenterCustomSprite =================================================
693 PresenterCustomSprite::PresenterCustomSprite (
694 rtl::Reference
<PresenterCanvas
> pCanvas
,
695 const Reference
<rendering::XCustomSprite
>& rxSprite
,
696 const Reference
<awt::XWindow
>& rxBaseWindow
)
697 : mpCanvas(std::move(pCanvas
)),
699 mxBaseWindow(rxBaseWindow
),
704 void PresenterCustomSprite::disposing(std::unique_lock
<std::mutex
>&)
706 Reference
<XComponent
> xComponent (mxSprite
, UNO_QUERY
);
709 xComponent
->dispose();
713 //----- XSprite ---------------------------------------------------------------
715 void SAL_CALL
PresenterCustomSprite::setAlpha (const double nAlpha
)
718 mxSprite
->setAlpha(nAlpha
);
721 void SAL_CALL
PresenterCustomSprite::move (
722 const geometry::RealPoint2D
& rNewPos
,
723 const rendering::ViewState
& rViewState
,
724 const rendering::RenderState
& rRenderState
)
727 maPosition
= rNewPos
;
730 mpCanvas
->MergeViewState(rViewState
, mpCanvas
->GetOffset(mxBaseWindow
)),
732 // Clip sprite against window bounds. This call is necessary because
733 // sprite clipping is done in the coordinate system of the sprite.
734 // Therefore, after each change of the sprites location the window
735 // bounds have to be transformed into the sprites coordinate system.
739 void SAL_CALL
PresenterCustomSprite::transform (const geometry::AffineMatrix2D
& rTransformation
)
742 mxSprite
->transform(rTransformation
);
745 void SAL_CALL
PresenterCustomSprite::clip (const Reference
<rendering::XPolyPolygon2D
>& rxClip
)
748 // The clip region is expected in the coordinate system of the sprite.
749 // UpdateSpriteClip() integrates the window bounds, transformed into the
750 // sprites coordinate system, with the given clip.
751 mxSprite
->clip(mpCanvas
->UpdateSpriteClip(rxClip
, maPosition
));
754 void SAL_CALL
PresenterCustomSprite::setPriority (const double nPriority
)
757 mxSprite
->setPriority(nPriority
);
760 void SAL_CALL
PresenterCustomSprite::show()
766 void SAL_CALL
PresenterCustomSprite::hide()
772 //----- XCustomSprite ---------------------------------------------------------
774 Reference
<rendering::XCanvas
> PresenterCustomSprite::getContentCanvas()
777 return mxSprite
->getContentCanvas();
780 void PresenterCustomSprite::ThrowIfDisposed()
782 if (m_bDisposed
|| ! mxSprite
.is())
784 throw lang::DisposedException (u
"PresenterCustomSprite object has already been disposed"_ustr
,
785 static_cast<uno::XWeak
*>(this));
789 } // end of namespace ::sd::presenter
791 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */