2 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "PresenterSlideShowView.hxx"
22 #include "vcl/svapp.hxx"
23 #include "PresenterCanvasHelper.hxx"
24 #include "PresenterGeometryHelper.hxx"
25 #include "PresenterHelper.hxx"
26 #include "PresenterPaneContainer.hxx"
27 #include <com/sun/star/awt/InvalidateStyle.hpp>
28 #include <com/sun/star/awt/PosSize.hpp>
29 #include <com/sun/star/awt/Pointer.hpp>
30 #include <com/sun/star/awt/Toolkit.hpp>
31 #include <com/sun/star/awt/WindowAttribute.hpp>
32 #include <com/sun/star/awt/XWindow.hpp>
33 #include <com/sun/star/awt/XWindow2.hpp>
34 #include <com/sun/star/awt/XWindowPeer.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/drawing/CanvasFeature.hpp>
37 #include <com/sun/star/drawing/XPresenterHelper.hpp>
38 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
39 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
40 #include <com/sun/star/rendering/CompositeOperation.hpp>
41 #include <com/sun/star/rendering/TextDirection.hpp>
42 #include <com/sun/star/rendering/TexturingMode.hpp>
43 #include <osl/mutex.hxx>
45 using namespace ::com::sun::star
;
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::drawing::framework
;
49 namespace sdext
{ namespace presenter
{
51 //===== PresenterSlideShowView ================================================
53 PresenterSlideShowView::PresenterSlideShowView (
54 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
55 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxViewId
,
56 const css::uno::Reference
<css::frame::XController
>& rxController
,
57 const ::rtl::Reference
<PresenterController
>& rpPresenterController
)
58 : PresenterSlideShowViewInterfaceBase(m_aMutex
),
59 mxComponentContext(rxContext
),
60 mpPresenterController(rpPresenterController
),
62 mxController(rxController
),
63 mxSlideShowController(PresenterHelper::GetSlideShowController(rxController
)),
72 mxBackgroundPolygon1(),
73 mxBackgroundPolygon2(),
75 mnPageAspectRatio(28.0/21.0),
76 maBroadcaster(m_aMutex
),
78 mbIsInModifyNotification(false),
79 mbIsForcedPaintPending(false),
80 mbIsPaintPending(true),
81 msClickToExitPresentationText(),
82 msClickToExitPresentationTitle(),
84 mbIsEndSlideVisible(false),
87 if (mpPresenterController
.get() != NULL
)
89 mnPageAspectRatio
= mpPresenterController
->GetSlideAspectRatio();
90 mpBackground
= mpPresenterController
->GetViewBackground(mxViewId
->getResourceURL());
94 void PresenterSlideShowView::LateInit (void)
96 mxSlideShow
= Reference
<presentation::XSlideShow
> (
97 mxSlideShowController
->getSlideShow(), UNO_QUERY_THROW
);
98 Reference
<lang::XComponent
> xSlideShowComponent (mxSlideShow
, UNO_QUERY
);
99 if (xSlideShowComponent
.is())
100 xSlideShowComponent
->addEventListener(static_cast<awt::XWindowListener
*>(this));
102 Reference
<lang::XMultiComponentFactory
> xFactory (
103 mxComponentContext
->getServiceManager(), UNO_QUERY_THROW
);
104 mxPresenterHelper
.set (xFactory
->createInstanceWithContext(
105 OUString("com.sun.star.comp.Draw.PresenterHelper"),
109 // Use view id and controller to retrieve window and canvas from
110 // configuration controller.
111 Reference
<XControllerManager
> xCM (mxController
, UNO_QUERY_THROW
);
112 Reference
<XConfigurationController
> xCC (xCM
->getConfigurationController());
116 mxTopPane
.set(xCC
->getResource(mxViewId
->getAnchor()->getAnchor()), UNO_QUERY
);
118 Reference
<XPane
> xPane (xCC
->getResource(mxViewId
->getAnchor()), UNO_QUERY_THROW
);
120 mxWindow
= xPane
->getWindow();
121 mxCanvas
= xPane
->getCanvas();
125 mxWindow
->addPaintListener(this);
126 mxWindow
->addWindowListener(this);
129 // The window does not have to paint a background. We do
131 Reference
<awt::XWindowPeer
> xPeer (mxWindow
, UNO_QUERY
);
133 xPeer
->setBackground(util::Color(0xff000000));
136 // Create a window for the actual slide show view. It is places
137 // centered and with maximal size inside the pane.
138 mxViewWindow
= CreateViewWindow(mxWindow
);
140 mxViewCanvas
= CreateViewCanvas(mxViewWindow
);
142 if (mxViewWindow
.is())
144 // Register listeners at window.
145 mxViewWindow
->addPaintListener(this);
146 mxViewWindow
->addMouseListener(this);
147 mxViewWindow
->addMouseMotionListener(this);
150 if (mxViewWindow
.is())
154 mxWindow
->setVisible(sal_True
);
156 // Add the new slide show view to the slide show.
157 if (mxSlideShow
.is() && ! mbIsViewAdded
)
159 impl_addAndConfigureView();
160 mbIsViewAdded
= true;
163 // Read text for one past last slide.
164 PresenterConfigurationAccess
aConfiguration (
166 PresenterConfigurationAccess::msPresenterScreenRootName
,
167 PresenterConfigurationAccess::READ_ONLY
);
168 aConfiguration
.GetConfigurationNode(
169 "Presenter/Views/CurrentSlidePreview/"
170 "Strings/ClickToExitPresentationText/String")
171 >>= msClickToExitPresentationText
;
172 aConfiguration
.GetConfigurationNode(
173 "Presenter/Views/CurrentSlidePreview/"
174 "Strings/ClickToExitPresentationTitle/String")
175 >>= msClickToExitPresentationTitle
;
178 PresenterSlideShowView::~PresenterSlideShowView (void)
182 void PresenterSlideShowView::disposing (void)
184 // Tell all listeners that we are disposed.
185 lang::EventObject aEvent
;
186 aEvent
.Source
= static_cast<XWeak
*>(this);
188 ::cppu::OInterfaceContainerHelper
* pIterator
189 = maBroadcaster
.getContainer(getCppuType((Reference
<lang::XEventListener
>*)NULL
));
190 if (pIterator
!= NULL
)
191 pIterator
->disposeAndClear(aEvent
);
194 // XPaintListener, XModifyListener,XMouseListener,XMouseMotionListener,XWindowListener?
198 mxWindow
->removePaintListener(this);
199 mxWindow
->removeMouseListener(this);
200 mxWindow
->removeMouseMotionListener(this);
201 mxWindow
->removeWindowListener(this);
204 mxSlideShowController
= NULL
;
206 if (mxViewCanvas
.is())
208 Reference
<XComponent
> xComponent (mxViewCanvas
, UNO_QUERY
);
211 xComponent
->dispose();
213 if (mxViewWindow
.is())
215 Reference
<XComponent
> xComponent (mxViewWindow
, UNO_QUERY
);
218 xComponent
->dispose();
222 Reference
<XComponent
> xComponent (mxPointer
, UNO_QUERY
);
225 xComponent
->dispose();
227 if (mxBackgroundPolygon1
.is())
229 Reference
<XComponent
> xComponent (mxBackgroundPolygon1
, UNO_QUERY
);
230 mxBackgroundPolygon1
= NULL
;
232 xComponent
->dispose();
234 if (mxBackgroundPolygon2
.is())
236 Reference
<XComponent
> xComponent (mxBackgroundPolygon2
, UNO_QUERY
);
237 mxBackgroundPolygon2
= NULL
;
239 xComponent
->dispose();
242 mxComponentContext
= NULL
;
243 mpPresenterController
= NULL
;
247 mpBackground
.reset();
248 msClickToExitPresentationText
= OUString();
249 msClickToExitPresentationTitle
= OUString();
250 msTitleTemplate
= OUString();
251 mxCurrentSlide
= NULL
;
254 //----- XDrawView -------------------------------------------------------------
256 void SAL_CALL
PresenterSlideShowView::setCurrentPage (
257 const css::uno::Reference
<css::drawing::XDrawPage
>& rxSlide
)
258 throw (css::uno::RuntimeException
)
260 mxCurrentSlide
= rxSlide
;
261 if (mpPresenterController
.get() != NULL
262 && mxSlideShowController
.is()
263 && ! mpPresenterController
->GetCurrentSlide().is()
264 && ! mxSlideShowController
->isPaused())
266 mbIsEndSlideVisible
= true;
267 Reference
<awt::XWindowPeer
> xPeer (mxViewWindow
, UNO_QUERY
);
269 xPeer
->invalidate(awt::InvalidateStyle::NOTRANSPARENT
);
271 // For the end slide we use a special title, without the (n of m)
272 // part. Save the title template for the case that the user goes
274 PresenterPaneContainer::SharedPaneDescriptor
pDescriptor (
275 mpPresenterController
->GetPaneContainer()->FindViewURL(mxViewId
->getResourceURL()));
276 if (pDescriptor
.get() != NULL
)
278 msTitleTemplate
= pDescriptor
->msTitleTemplate
;
279 pDescriptor
->msTitleTemplate
= msClickToExitPresentationTitle
;
280 mpPresenterController
->UpdatePaneTitles();
283 else if (mbIsEndSlideVisible
)
285 mbIsEndSlideVisible
= false;
287 // Restore the title template.
288 PresenterPaneContainer::SharedPaneDescriptor
pDescriptor (
289 mpPresenterController
->GetPaneContainer()->FindViewURL(mxViewId
->getResourceURL()));
290 if (pDescriptor
.get() != NULL
)
292 pDescriptor
->msTitleTemplate
= msTitleTemplate
;
293 pDescriptor
->msTitle
= OUString();
294 mpPresenterController
->UpdatePaneTitles();
299 css::uno::Reference
<css::drawing::XDrawPage
> SAL_CALL
PresenterSlideShowView::getCurrentPage (void)
300 throw (css::uno::RuntimeException
)
302 return mxCurrentSlide
;
305 //----- CachablePresenterView -------------------------------------------------
307 void PresenterSlideShowView::ReleaseView (void)
309 if (mxSlideShow
.is() && mbIsViewAdded
)
311 mxSlideShow
->removeView(this);
312 mbIsViewAdded
= false;
316 //----- XSlideShowView --------------------------------------------------------
318 Reference
<rendering::XSpriteCanvas
> SAL_CALL
PresenterSlideShowView::getCanvas (void)
319 throw (RuntimeException
)
323 return Reference
<rendering::XSpriteCanvas
>(mxViewCanvas
, UNO_QUERY
);
326 void SAL_CALL
PresenterSlideShowView::clear (void)
327 throw (RuntimeException
)
330 mbIsForcedPaintPending
= false;
331 mbIsPaintPending
= false;
333 if (mxViewCanvas
.is() && mxViewWindow
.is())
335 // Create a polygon for the window outline.
336 awt::Rectangle
aViewWindowBox (mxViewWindow
->getPosSize());
337 Reference
<rendering::XPolyPolygon2D
> xPolygon (PresenterGeometryHelper::CreatePolygon(
338 awt::Rectangle(0,0, aViewWindowBox
.Width
,aViewWindowBox
.Height
),
339 mxViewCanvas
->getDevice()));
341 rendering::ViewState
aViewState (
342 geometry::AffineMatrix2D(1,0,0, 0,1,0),
344 double aColor
[4] = {0,0,0,0};
345 rendering::RenderState
aRenderState(
346 geometry::AffineMatrix2D(1,0,0, 0,1,0),
348 Sequence
<double>(aColor
,4),
349 rendering::CompositeOperation::SOURCE
);
350 mxViewCanvas
->fillPolyPolygon(xPolygon
, aViewState
, aRenderState
);
354 geometry::AffineMatrix2D SAL_CALL
PresenterSlideShowView::getTransformation (void)
355 throw (RuntimeException
)
359 if (mxViewWindow
.is())
361 // When the mbIsInModifyNotification is set then a slightly modifed
362 // version of the transformation is returned in order to get past
363 // optimizations the avoid updates when the transformation is
364 // unchanged (when the window size changes then due to the constant
365 // aspect ratio the size of the preview may remain the same while
366 // the position changes. The position, however, is repesented by
367 // the position of the view window. This transformation is given
368 // relative to the view window and therefore does not contain the
370 const awt::Rectangle aWindowBox
= mxViewWindow
->getPosSize();
371 return geometry::AffineMatrix2D(
372 aWindowBox
.Width
-1, 0, (mbIsInModifyNotification
? 1 : 0),
373 0, aWindowBox
.Height
-1, 0);
377 return geometry::AffineMatrix2D(1,0,0, 0,1,0);
381 void SAL_CALL
PresenterSlideShowView::addTransformationChangedListener(
382 const Reference
<util::XModifyListener
>& rxListener
)
383 throw (RuntimeException
)
386 maBroadcaster
.addListener(
387 getCppuType((Reference
<util::XModifyListener
>*)NULL
),
391 void SAL_CALL
PresenterSlideShowView::removeTransformationChangedListener(
392 const Reference
<util::XModifyListener
>& rxListener
)
393 throw (RuntimeException
)
396 maBroadcaster
.removeListener(
397 getCppuType((Reference
<util::XModifyListener
>*)NULL
),
401 void SAL_CALL
PresenterSlideShowView::addPaintListener(
402 const Reference
<awt::XPaintListener
>& rxListener
)
403 throw (RuntimeException
)
406 maBroadcaster
.addListener(
407 getCppuType((Reference
<awt::XPaintListener
>*)NULL
),
411 void SAL_CALL
PresenterSlideShowView::removePaintListener(
412 const Reference
<awt::XPaintListener
>& rxListener
)
413 throw (RuntimeException
)
416 maBroadcaster
.removeListener(
417 getCppuType((Reference
<awt::XPaintListener
>*)NULL
),
421 void SAL_CALL
PresenterSlideShowView::addMouseListener(
422 const Reference
<awt::XMouseListener
>& rxListener
)
423 throw (RuntimeException
)
426 maBroadcaster
.addListener(
427 getCppuType((Reference
<awt::XMouseListener
>*)NULL
),
431 void SAL_CALL
PresenterSlideShowView::removeMouseListener(
432 const Reference
<awt::XMouseListener
>& rxListener
)
433 throw (RuntimeException
)
436 maBroadcaster
.removeListener(
437 getCppuType((Reference
<awt::XMouseListener
>*)NULL
),
441 void SAL_CALL
PresenterSlideShowView::addMouseMotionListener(
442 const Reference
<awt::XMouseMotionListener
>& rxListener
)
443 throw (RuntimeException
)
446 maBroadcaster
.addListener(
447 getCppuType((Reference
<awt::XMouseMotionListener
>*)NULL
),
451 void SAL_CALL
PresenterSlideShowView::removeMouseMotionListener(
452 const Reference
<awt::XMouseMotionListener
>& rxListener
)
453 throw (RuntimeException
)
456 maBroadcaster
.removeListener(
457 getCppuType((Reference
<awt::XMouseMotionListener
>*)NULL
),
461 void SAL_CALL
PresenterSlideShowView::setMouseCursor(::sal_Int16 nPointerShape
)
462 throw (RuntimeException
)
466 // Create a pointer when it does not yet exist.
467 if ( ! mxPointer
.is())
469 mxPointer
= awt::Pointer::create(mxComponentContext
);
472 // Set the pointer to the given shape and the window(peer) to the
474 Reference
<awt::XWindowPeer
> xPeer (mxViewWindow
, UNO_QUERY
);
475 if (mxPointer
.is() && xPeer
.is())
477 mxPointer
->setType(nPointerShape
);
478 xPeer
->setPointer(mxPointer
);
482 awt::Rectangle SAL_CALL
PresenterSlideShowView::getCanvasArea( ) throw (RuntimeException
)
484 if( mxViewWindow
.is() && mxTopPane
.is() )
485 return mxPresenterHelper
->getWindowExtentsRelative( mxViewWindow
, mxTopPane
->getWindow() );
487 awt::Rectangle aRectangle
;
489 aRectangle
.X
= aRectangle
.Y
= aRectangle
.Width
= aRectangle
.Height
= 0;
494 //----- lang::XEventListener --------------------------------------------------
496 void SAL_CALL
PresenterSlideShowView::disposing (const lang::EventObject
& rEvent
)
497 throw (RuntimeException
)
499 if (rEvent
.Source
== mxViewWindow
)
501 else if (rEvent
.Source
== mxSlideShow
)
505 //----- XPaintListener --------------------------------------------------------
507 void SAL_CALL
PresenterSlideShowView::windowPaint (const awt::PaintEvent
& rEvent
)
508 throw (RuntimeException
)
510 // Deactivated views must not be painted.
511 if ( ! mbIsPresenterViewActive
)
514 awt::Rectangle
aViewWindowBox (mxViewWindow
->getPosSize());
515 if (aViewWindowBox
.Width
<= 0 || aViewWindowBox
.Height
<= 0)
518 if (rEvent
.Source
== mxWindow
)
519 PaintOuterWindow(rEvent
.UpdateRect
);
520 else if (mbIsEndSlideVisible
)
521 PaintEndSlide(rEvent
.UpdateRect
);
523 PaintInnerWindow(rEvent
);
526 //----- XMouseListener --------------------------------------------------------
528 void SAL_CALL
PresenterSlideShowView::mousePressed (const awt::MouseEvent
& rEvent
)
529 throw (RuntimeException
)
531 awt::MouseEvent
aEvent (rEvent
);
532 aEvent
.Source
= static_cast<XWeak
*>(this);
533 ::cppu::OInterfaceContainerHelper
* pIterator
534 = maBroadcaster
.getContainer(getCppuType((Reference
<awt::XMouseListener
>*)NULL
));
535 if (pIterator
!= NULL
)
537 pIterator
->notifyEach(&awt::XMouseListener::mousePressed
, aEvent
);
540 // Only when the end slide is displayed we forward the mouse event to
541 // the PresenterController so that it switches to the next slide and
542 // ends the presentation.
543 if (mbIsEndSlideVisible
)
544 if (mpPresenterController
.get() != NULL
)
545 mpPresenterController
->HandleMouseClick(rEvent
);
548 void SAL_CALL
PresenterSlideShowView::mouseReleased (const awt::MouseEvent
& rEvent
)
549 throw (RuntimeException
)
551 awt::MouseEvent
aEvent (rEvent
);
552 aEvent
.Source
= static_cast<XWeak
*>(this);
553 ::cppu::OInterfaceContainerHelper
* pIterator
554 = maBroadcaster
.getContainer(getCppuType((Reference
<awt::XMouseListener
>*)NULL
));
555 if (pIterator
!= NULL
)
557 pIterator
->notifyEach(&awt::XMouseListener::mouseReleased
, aEvent
);
561 void SAL_CALL
PresenterSlideShowView::mouseEntered (const awt::MouseEvent
& rEvent
)
562 throw (RuntimeException
)
564 awt::MouseEvent
aEvent (rEvent
);
565 aEvent
.Source
= static_cast<XWeak
*>(this);
566 ::cppu::OInterfaceContainerHelper
* pIterator
567 = maBroadcaster
.getContainer(getCppuType((Reference
<awt::XMouseListener
>*)NULL
));
568 if (pIterator
!= NULL
)
570 pIterator
->notifyEach(&awt::XMouseListener::mouseEntered
, aEvent
);
574 void SAL_CALL
PresenterSlideShowView::mouseExited (const awt::MouseEvent
& rEvent
)
575 throw (RuntimeException
)
577 awt::MouseEvent
aEvent (rEvent
);
578 aEvent
.Source
= static_cast<XWeak
*>(this);
579 ::cppu::OInterfaceContainerHelper
* pIterator
580 = maBroadcaster
.getContainer(getCppuType((Reference
<awt::XMouseListener
>*)NULL
));
581 if (pIterator
!= NULL
)
583 pIterator
->notifyEach(&awt::XMouseListener::mouseExited
, aEvent
);
587 //----- XMouseMotionListener --------------------------------------------------
589 void SAL_CALL
PresenterSlideShowView::mouseDragged (const awt::MouseEvent
& rEvent
)
590 throw (RuntimeException
)
592 awt::MouseEvent
aEvent (rEvent
);
593 aEvent
.Source
= static_cast<XWeak
*>(this);
594 ::cppu::OInterfaceContainerHelper
* pIterator
595 = maBroadcaster
.getContainer(getCppuType((Reference
<awt::XMouseMotionListener
>*)NULL
));
596 if (pIterator
!= NULL
)
598 pIterator
->notifyEach(&awt::XMouseMotionListener::mouseDragged
, aEvent
);
602 void SAL_CALL
PresenterSlideShowView::mouseMoved (const awt::MouseEvent
& rEvent
)
603 throw (RuntimeException
)
605 awt::MouseEvent
aEvent (rEvent
);
606 aEvent
.Source
= static_cast<XWeak
*>(this);
607 ::cppu::OInterfaceContainerHelper
* pIterator
608 = maBroadcaster
.getContainer(getCppuType((Reference
<awt::XMouseMotionListener
>*)NULL
));
609 if (pIterator
!= NULL
)
611 pIterator
->notifyEach(&awt::XMouseMotionListener::mouseMoved
, aEvent
);
615 //----- XWindowListener -------------------------------------------------------
617 void SAL_CALL
PresenterSlideShowView::windowResized (const awt::WindowEvent
& rEvent
)
618 throw (RuntimeException
)
623 ::osl::MutexGuard
aGuard (::osl::Mutex::getGlobalMutex());
628 void SAL_CALL
PresenterSlideShowView::windowMoved (const awt::WindowEvent
& rEvent
)
629 throw (RuntimeException
)
632 if ( ! mbIsPaintPending
)
633 mbIsForcedPaintPending
= true;
636 void SAL_CALL
PresenterSlideShowView::windowShown (const lang::EventObject
& rEvent
)
637 throw (RuntimeException
)
643 void SAL_CALL
PresenterSlideShowView::windowHidden (const lang::EventObject
& rEvent
)
644 throw (RuntimeException
)
649 //----- XView -----------------------------------------------------------------
651 Reference
<XResourceId
> SAL_CALL
PresenterSlideShowView::getResourceId (void)
652 throw(RuntimeException
)
657 sal_Bool SAL_CALL
PresenterSlideShowView::isAnchorOnly (void)
658 throw (RuntimeException
)
663 //----- CachablePresenterView -------------------------------------------------
665 void PresenterSlideShowView::ActivatePresenterView (void)
667 if (mxSlideShow
.is() && ! mbIsViewAdded
)
669 impl_addAndConfigureView();
670 mbIsViewAdded
= true;
674 void PresenterSlideShowView::DeactivatePresenterView (void)
676 if (mxSlideShow
.is() && mbIsViewAdded
)
678 mxSlideShow
->removeView(this);
679 mbIsViewAdded
= false;
683 //-----------------------------------------------------------------------------
685 void PresenterSlideShowView::PaintOuterWindow (const awt::Rectangle
& rRepaintBox
)
687 if ( ! mxCanvas
.is())
690 if (mpBackground
.get() == NULL
)
693 const rendering::ViewState
aViewState(
694 geometry::AffineMatrix2D(1,0,0, 0,1,0),
695 PresenterGeometryHelper::CreatePolygon(rRepaintBox
, mxCanvas
->getDevice()));
697 rendering::RenderState
aRenderState (
698 geometry::AffineMatrix2D(1,0,0, 0,1,0),
701 rendering::CompositeOperation::SOURCE
);
703 Reference
<rendering::XBitmap
> xBackgroundBitmap (mpBackground
->GetNormalBitmap());
704 if (xBackgroundBitmap
.is())
706 Sequence
<rendering::Texture
> aTextures (1);
707 const geometry::IntegerSize2D
aBitmapSize(xBackgroundBitmap
->getSize());
708 aTextures
[0] = rendering::Texture (
709 geometry::AffineMatrix2D(
710 aBitmapSize
.Width
,0,0,
711 0,aBitmapSize
.Height
,0),
717 rendering::StrokeAttributes(),
718 rendering::TexturingMode::REPEAT
,
719 rendering::TexturingMode::REPEAT
);
721 if (mxBackgroundPolygon1
.is())
722 mxCanvas
->fillTexturedPolyPolygon(
723 mxBackgroundPolygon1
,
727 if (mxBackgroundPolygon2
.is())
728 mxCanvas
->fillTexturedPolyPolygon(
729 mxBackgroundPolygon2
,
736 PresenterCanvasHelper::SetDeviceColor(aRenderState
, mpBackground
->maReplacementColor
);
738 if (mxBackgroundPolygon1
.is())
739 mxCanvas
->fillPolyPolygon(mxBackgroundPolygon1
, aViewState
, aRenderState
);
740 if (mxBackgroundPolygon2
.is())
741 mxCanvas
->fillPolyPolygon(mxBackgroundPolygon2
, aViewState
, aRenderState
);
745 void PresenterSlideShowView::PaintEndSlide (const awt::Rectangle
& rRepaintBox
)
747 if ( ! mxCanvas
.is())
750 const rendering::ViewState
aViewState(
751 geometry::AffineMatrix2D(1,0,0, 0,1,0),
752 PresenterGeometryHelper::CreatePolygon(rRepaintBox
, mxCanvas
->getDevice()));
754 rendering::RenderState
aRenderState (
755 geometry::AffineMatrix2D(1,0,0, 0,1,0),
758 rendering::CompositeOperation::SOURCE
);
759 PresenterCanvasHelper::SetDeviceColor(aRenderState
, util::Color(0x00000000));
760 mxCanvas
->fillPolyPolygon(
761 PresenterGeometryHelper::CreatePolygon(mxViewWindow
->getPosSize(), mxCanvas
->getDevice()),
767 if (mpPresenterController
.get() == NULL
)
769 ::boost::shared_ptr
<PresenterTheme
> pTheme (mpPresenterController
->GetTheme());
770 if (pTheme
.get() == NULL
)
773 const OUString
sViewStyle (pTheme
->GetStyleName(mxViewId
->getResourceURL()));
774 PresenterTheme::SharedFontDescriptor
pFont (pTheme
->GetFont(sViewStyle
));
775 if (pFont
.get() == NULL
)
778 /// this is responsible of the " presentation exit " text inside the slide windows
779 PresenterCanvasHelper::SetDeviceColor(aRenderState
, util::Color(0x00ffffff));
780 aRenderState
.AffineTransform
.m02
= 20;
781 aRenderState
.AffineTransform
.m12
= 40;
782 const rendering::StringContext
aContext (
783 msClickToExitPresentationText
, 0, msClickToExitPresentationText
.getLength());
784 pFont
->PrepareFont(mxCanvas
);
785 const Reference
<rendering::XTextLayout
> xLayout (
786 pFont
->mxFont
->createTextLayout(aContext
,rendering::TextDirection::WEAK_LEFT_TO_RIGHT
,0));
787 mxCanvas
->drawTextLayout(
794 // Finally, in double buffered environments, request the changes to be
796 Reference
<rendering::XSpriteCanvas
> mxSpriteCanvas (mxCanvas
, UNO_QUERY
);
797 if (mxSpriteCanvas
.is())
798 mxSpriteCanvas
->updateScreen(sal_True
);
801 void PresenterSlideShowView::PaintInnerWindow (const awt::PaintEvent
& rEvent
)
803 // Forward window paint to listeners.
804 awt::PaintEvent
aEvent (rEvent
);
805 aEvent
.Source
= static_cast<XWeak
*>(this);
806 ::cppu::OInterfaceContainerHelper
* pIterator
807 = maBroadcaster
.getContainer(getCppuType((Reference
<awt::XPaintListener
>*)NULL
));
808 if (pIterator
!= NULL
)
810 pIterator
->notifyEach(&awt::XPaintListener::windowPaint
, aEvent
);
813 if (mbIsForcedPaintPending
)
816 // Finally, in double buffered environments, request the changes to be
818 Reference
<rendering::XSpriteCanvas
> mxSpriteCanvas (mxCanvas
, UNO_QUERY
);
819 if (mxSpriteCanvas
.is())
820 mxSpriteCanvas
->updateScreen(sal_True
);
823 Reference
<awt::XWindow
> PresenterSlideShowView::CreateViewWindow (
824 const Reference
<awt::XWindow
>& rxParentWindow
) const
826 Reference
<awt::XWindow
> xViewWindow
;
829 Reference
<lang::XMultiComponentFactory
> xFactory (mxComponentContext
->getServiceManager());
830 if ( ! xFactory
.is())
833 Reference
<awt::XToolkit2
> xToolkit
= awt::Toolkit::create(mxComponentContext
);
834 awt::WindowDescriptor
aWindowDescriptor (
835 awt::WindowClass_CONTAINER
,
837 Reference
<awt::XWindowPeer
>(rxParentWindow
,UNO_QUERY_THROW
),
838 -1, // parent index not available
839 awt::Rectangle(0,0,10,10),
840 awt::WindowAttribute::SIZEABLE
841 | awt::WindowAttribute::MOVEABLE
842 | awt::WindowAttribute::NODECORATION
);
843 xViewWindow
= Reference
<awt::XWindow
>(
844 xToolkit
->createWindow(aWindowDescriptor
),UNO_QUERY_THROW
);
846 // Make the background transparent. The slide show paints its own background.
847 Reference
<awt::XWindowPeer
> xPeer (xViewWindow
, UNO_QUERY_THROW
);
850 xPeer
->setBackground(0xff000000);
853 xViewWindow
->setVisible(sal_True
);
855 catch (RuntimeException
&)
861 Reference
<rendering::XCanvas
> PresenterSlideShowView::CreateViewCanvas (
862 const Reference
<awt::XWindow
>& rxViewWindow
) const
864 // Create a canvas for the view window.
865 return mxPresenterHelper
->createSharedCanvas(
866 Reference
<rendering::XSpriteCanvas
>(mxTopPane
->getCanvas(), UNO_QUERY
),
867 mxTopPane
->getWindow(),
868 mxTopPane
->getCanvas(),
869 mxTopPane
->getWindow(),
873 void PresenterSlideShowView::Resize (void)
875 if ( ! mxWindow
.is() || ! mxViewWindow
.is())
878 const awt::Rectangle
aWindowBox (mxWindow
->getPosSize());
879 awt::Rectangle aViewWindowBox
;
880 if (aWindowBox
.Height
> 0)
882 const double nWindowAspectRatio (
883 double(aWindowBox
.Width
) / double(aWindowBox
.Height
));
884 if (nWindowAspectRatio
> mnPageAspectRatio
)
886 // Slides will be painted with the full parent window height.
887 aViewWindowBox
.Width
= sal_Int32(aWindowBox
.Height
* mnPageAspectRatio
+ 0.5);
888 aViewWindowBox
.Height
= aWindowBox
.Height
;
889 aViewWindowBox
.X
= (aWindowBox
.Width
- aViewWindowBox
.Width
) / 2;
890 aViewWindowBox
.Y
= 0;
894 // Slides will be painted with the full parent window width.
895 aViewWindowBox
.Width
= aWindowBox
.Width
;
896 aViewWindowBox
.Height
= sal_Int32(aWindowBox
.Width
/ mnPageAspectRatio
+ 0.5);
897 aViewWindowBox
.X
= 0;
898 aViewWindowBox
.Y
= (aWindowBox
.Height
- aViewWindowBox
.Height
) / 2;
900 mxViewWindow
->setPosSize(
903 aViewWindowBox
.Width
,
904 aViewWindowBox
.Height
,
905 awt::PosSize::POSSIZE
);
908 // Clear the background polygon so that on the next paint it is created
910 CreateBackgroundPolygons();
912 // Notify listeners that the transformation that maps the view into the
913 // window has changed.
914 lang::EventObject
aEvent (static_cast<XWeak
*>(this));
915 ::cppu::OInterfaceContainerHelper
* pIterator
916 = maBroadcaster
.getContainer(getCppuType((Reference
<util::XModifyListener
>*)NULL
));
917 if (pIterator
!= NULL
)
919 pIterator
->notifyEach(&util::XModifyListener::modified
, aEvent
);
922 // Due to constant aspect ratio resizing may lead a preview that changes
923 // its position but not its size. This invalidates the back buffer and
924 // we have to enforce a complete repaint.
925 if ( ! mbIsPaintPending
)
926 mbIsForcedPaintPending
= true;
929 void PresenterSlideShowView::ForceRepaint (void)
931 if (mxSlideShow
.is() && mbIsViewAdded
)
933 mxSlideShow
->removeView(this);
934 impl_addAndConfigureView();
938 void PresenterSlideShowView::CreateBackgroundPolygons (void)
940 const awt::Rectangle
aWindowBox (mxWindow
->getPosSize());
941 const awt::Rectangle
aViewWindowBox (mxViewWindow
->getPosSize());
942 if (aWindowBox
.Height
== aViewWindowBox
.Height
&& aWindowBox
.Width
== aViewWindowBox
.Width
)
944 mxBackgroundPolygon1
= NULL
;
945 mxBackgroundPolygon2
= NULL
;
947 else if (aWindowBox
.Height
== aViewWindowBox
.Height
)
949 // Paint two boxes to the left and right of the view window.
950 mxBackgroundPolygon1
= PresenterGeometryHelper::CreatePolygon(
956 mxCanvas
->getDevice());
957 mxBackgroundPolygon2
= PresenterGeometryHelper::CreatePolygon(
959 aViewWindowBox
.X
+ aViewWindowBox
.Width
,
961 aWindowBox
.Width
- aViewWindowBox
.X
- aViewWindowBox
.Width
,
963 mxCanvas
->getDevice());
967 // Paint two boxes above and below the view window.
968 mxBackgroundPolygon1
= PresenterGeometryHelper::CreatePolygon(
974 mxCanvas
->getDevice());
975 mxBackgroundPolygon2
= PresenterGeometryHelper::CreatePolygon(
978 aViewWindowBox
.Y
+ aViewWindowBox
.Height
,
980 aWindowBox
.Height
- aViewWindowBox
.Y
- aViewWindowBox
.Height
),
981 mxCanvas
->getDevice());
985 void PresenterSlideShowView::ThrowIfDisposed (void)
986 throw (::com::sun::star::lang::DisposedException
)
988 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
990 throw lang::DisposedException (
991 OUString("PresenterSlideShowView object has already been disposed"),
992 static_cast<uno::XWeak
*>(this));
996 void PresenterSlideShowView::impl_addAndConfigureView()
998 Reference
<presentation::XSlideShowView
> xView (this);
999 mxSlideShow
->addView(xView
);
1000 // Prevent embeded sounds being played twice at the same time by
1001 // disabling sound for the new slide show view.
1002 beans::PropertyValue aProperty
;
1003 aProperty
.Name
= "IsSoundEnabled";
1004 Sequence
<Any
> aValues (2);
1005 aValues
[0] <<= xView
;
1006 aValues
[1] <<= sal_False
;
1007 aProperty
.Value
<<= aValues
;
1008 mxSlideShow
->setProperty(aProperty
);
1011 } } // end of namespace ::sd::presenter
1013 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */