Update ooo320-m1
[ooovba.git] / sdext / source / presenter / PresenterWindowManager.cxx
blobaf3c37de90032478ca38b7513edb69473212178b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterWindowManager.cxx,v $
11 * $Revision: 1.7 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #undef ENABLE_PANE_RESIZING
36 //#define ENABLE_PANE_RESIZING
38 #include "PresenterWindowManager.hxx"
39 #include "PresenterAnimation.hxx"
40 #include "PresenterAnimator.hxx"
41 #include "PresenterController.hxx"
42 #include "PresenterGeometryHelper.hxx"
43 #include "PresenterHelper.hxx"
44 #include "PresenterPaintManager.hxx"
45 #include "PresenterPaneBase.hxx"
46 #include "PresenterPaneBorderManager.hxx"
47 #include "PresenterPaneBorderPainter.hxx"
48 #include "PresenterPaneContainer.hxx"
49 #include "PresenterPaneFactory.hxx"
50 #include "PresenterSprite.hxx"
51 #include "PresenterToolBar.hxx"
52 #include "PresenterViewFactory.hxx"
53 #include "PresenterTheme.hxx"
54 #include <com/sun/star/awt/InvalidateStyle.hpp>
55 #include <com/sun/star/awt/PosSize.hpp>
56 #include <com/sun/star/awt/SystemPointer.hpp>
57 #include <com/sun/star/awt/XDevice.hpp>
58 #include <com/sun/star/awt/XWindow2.hpp>
59 #include <com/sun/star/awt/XWindowPeer.hpp>
60 #include <com/sun/star/awt/WindowAttribute.hpp>
61 #include <com/sun/star/container/XChild.hpp>
62 #include <com/sun/star/drawing/framework/ResourceId.hpp>
63 #include <com/sun/star/rendering/CompositeOperation.hpp>
64 #include <com/sun/star/rendering/FillRule.hpp>
65 #include <com/sun/star/rendering/PathCapType.hpp>
66 #include <com/sun/star/rendering/PathJoinType.hpp>
67 #include <com/sun/star/rendering/Texture.hpp>
68 #include <com/sun/star/rendering/TexturingMode.hpp>
69 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
70 #include <boost/bind.hpp>
71 #include <boost/bind/protect.hpp>
72 #include <math.h>
74 using namespace ::com::sun::star;
75 using namespace ::com::sun::star::uno;
76 using namespace ::com::sun::star::drawing::framework;
77 using ::rtl::OUString;
79 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
81 namespace sdext { namespace presenter {
83 namespace {
85 typedef ::cppu::WeakComponentImplHelper1<
86 css::drawing::framework::XConfigurationChangeListener
87 > ModeChangeAnimationStarterInterfaceBase;
89 class ModeChangeAnimationStarter
90 : protected ::cppu::BaseMutex,
91 public ModeChangeAnimationStarterInterfaceBase
93 public:
94 ModeChangeAnimationStarter (
95 const Reference<drawing::framework::XConfigurationController>& rxConfigurationController,
96 const Reference<awt::XWindow>& rxWindow,
97 const Reference<rendering::XSpriteCanvas>& rxCanvas,
98 const ::boost::shared_ptr<PresenterAnimator>& rpAnimator);
99 virtual ~ModeChangeAnimationStarter (void);
100 virtual void SAL_CALL disposing (void);
102 // XConfigurationChangeListener
104 virtual void SAL_CALL notifyConfigurationChange (
105 const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
106 throw (com::sun::star::uno::RuntimeException);
109 // XEventListener
111 virtual void SAL_CALL disposing (
112 const com::sun::star::lang::EventObject& rEvent)
113 throw (com::sun::star::uno::RuntimeException);
115 private:
116 Reference<drawing::framework::XConfigurationController> mxConfigurationController;
117 ::boost::shared_ptr<PresenterAnimator> mpAnimator;
118 ::boost::shared_ptr<PresenterSprite> mpSprite;
119 Reference<rendering::XSpriteCanvas> mxCanvas;
127 //===== PresenterWindowManager ================================================
129 PresenterWindowManager::PresenterWindowManager (
130 const Reference<XComponentContext>& rxContext,
131 const ::rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
132 const ::rtl::Reference<PresenterController>& rpPresenterController)
133 : PresenterWindowManagerInterfaceBase(m_aMutex),
134 mxComponentContext(rxContext),
135 mpPresenterController(rpPresenterController),
136 mxParentWindow(),
137 mxParentCanvas(),
138 mxPaneBorderManager(),
139 mpPaneBorderPainter(),
140 mpPaneContainer(rpPaneContainer),
141 mbIsLayoutPending(true),
142 mbIsLayouting(false),
143 mpTheme(),
144 mpBackgroundBitmap(),
145 mxScaledBackgroundBitmap(),
146 maPaneBackgroundColor(),
147 mxClipPolygon(),
148 meLayoutMode(LM_Generic),
149 mbIsSlideSorterActive(false),
150 mbIsHelpViewActive(false),
151 maLayoutListeners(),
152 mbIsMouseClickPending(false)
154 UpdateWindowList();
160 PresenterWindowManager::~PresenterWindowManager (void)
167 void SAL_CALL PresenterWindowManager::disposing (void)
169 NotifyDisposing();
171 SetParentPane(NULL);
173 Reference<lang::XComponent> xComponent (mxPaneBorderManager, UNO_QUERY);
174 if (xComponent.is())
175 xComponent->dispose();
176 mxPaneBorderManager = NULL;
178 PresenterPaneContainer::PaneList::const_iterator iPane;
179 PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
180 for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
182 if ((*iPane)->mxBorderWindow.is())
184 (*iPane)->mxBorderWindow->removeWindowListener(this);
185 (*iPane)->mxBorderWindow->removeFocusListener(this);
186 #ifndef ENABLE_PANE_RESIZING
187 (*iPane)->mxBorderWindow->removeMouseListener(this);
188 #endif
196 void PresenterWindowManager::SetParentPane (
197 const Reference<drawing::framework::XPane>& rxPane)
199 if (mxParentWindow.is())
201 mxParentWindow->removeWindowListener(this);
202 mxParentWindow->removePaintListener(this);
203 mxParentWindow->removeMouseListener(this);
204 mxParentWindow->removeFocusListener(this);
206 mxParentWindow = NULL;
207 mxParentCanvas = NULL;
209 if (rxPane.is())
211 mxParentWindow = rxPane->getWindow();
212 mxParentCanvas = rxPane->getCanvas();
214 else
216 mxParentWindow = NULL;
219 if (mxParentWindow.is())
221 mxParentWindow->addWindowListener(this);
222 mxParentWindow->addPaintListener(this);
223 mxParentWindow->addMouseListener(this);
224 mxParentWindow->addFocusListener(this);
226 // We paint our own background, make that of the parent window transparent.
227 Reference<awt::XWindowPeer> xPeer (mxParentWindow, UNO_QUERY);
228 if (xPeer.is())
229 xPeer->setBackground(util::Color(0xff000000));
236 void PresenterWindowManager::SetTheme (const ::boost::shared_ptr<PresenterTheme>& rpTheme)
238 mpTheme = rpTheme;
240 // Get background bitmap or background color from the theme.
242 if (mpTheme.get() != NULL)
244 mpBackgroundBitmap = mpTheme->GetBitmap(OUString(), A2S("Background"));
251 void PresenterWindowManager::NotifyPaneCreation (
252 const PresenterPaneContainer::SharedPaneDescriptor& rpDescriptor)
254 if (rpDescriptor.get()==NULL)
256 OSL_ASSERT(rpDescriptor.get()!=NULL);
257 return;
259 if ( ! rpDescriptor->mxContentWindow.is())
261 OSL_ASSERT(rpDescriptor->mxContentWindow.is());
262 return;
265 mbIsLayoutPending = true;
267 Reference<awt::XWindow> xBorderWindow (rpDescriptor->mxBorderWindow);
268 OSL_ASSERT(xBorderWindow.is());
269 if (xBorderWindow.is() && ! rpDescriptor->mbIsSprite)
271 Invalidate();
273 xBorderWindow->addWindowListener(this);
274 xBorderWindow->addFocusListener(this);
275 #ifndef ENABLE_PANE_RESIZING
276 xBorderWindow->addMouseListener(this);
277 #endif
280 UpdateWindowList();
281 Layout();
287 void PresenterWindowManager::NotifyViewCreation (const Reference<XView>& rxView)
289 PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
290 mpPaneContainer->FindPaneId(rxView->getResourceId()->getAnchor()));
291 OSL_ASSERT(pDescriptor.get() != NULL);
292 if (pDescriptor.get() != NULL)
294 Layout();
296 mpPresenterController->GetPaintManager()->Invalidate(
297 pDescriptor->mxContentWindow,
298 (sal_Int16)(awt::InvalidateStyle::TRANSPARENT
299 | awt::InvalidateStyle::CHILDREN));
306 void PresenterWindowManager::SetPanePosSizeRelative (
307 const Reference<XResourceId>& rxPaneId,
308 const double nRelativeX,
309 const double nRelativeY,
310 const double nRelativeWidth,
311 const double nRelativeHeight)
313 PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
314 mpPaneContainer->FindPaneId(rxPaneId));
315 if (pDescriptor.get() != NULL)
317 pDescriptor->mnLeft = nRelativeX;
318 pDescriptor->mnTop = nRelativeY;
319 pDescriptor->mnRight = nRelativeX + nRelativeWidth;
320 pDescriptor->mnBottom = nRelativeY + nRelativeHeight;
322 mpPaneContainer->ToTop(pDescriptor);
329 void PresenterWindowManager::SetPanePosSizeAbsolute (
330 const OUString& rsPaneURL,
331 const double nX,
332 const double nY,
333 const double nWidth,
334 const double nHeight)
336 PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
337 mpPaneContainer->FindPaneURL(rsPaneURL));
338 if (pDescriptor.get() != NULL)
340 awt::Rectangle aParentBox = mxParentWindow->getPosSize();
341 if (aParentBox.Width > 0 && aParentBox.Height > 0)
343 pDescriptor->mnLeft = nX / aParentBox.Width;
344 pDescriptor->mnTop = nY / aParentBox.Height;
345 pDescriptor->mnRight = (nX + nWidth) / aParentBox.Width;
346 pDescriptor->mnBottom = (nY + nHeight) / aParentBox.Height;
348 if (pDescriptor->mxBorderWindow.is())
349 pDescriptor->mxBorderWindow->setPosSize(
350 ::sal::static_int_cast<sal_Int32>(nX),
351 ::sal::static_int_cast<sal_Int32>(nY),
352 ::sal::static_int_cast<sal_Int32>(nWidth),
353 ::sal::static_int_cast<sal_Int32>(nHeight),
354 awt::PosSize::POSSIZE);
361 void PresenterWindowManager::SetPaneBorderPainter (
362 const ::rtl::Reference<PresenterPaneBorderPainter>& rPainter)
364 mpPaneBorderPainter = rPainter;
370 //----- XWindowListener -------------------------------------------------------
372 void SAL_CALL PresenterWindowManager::windowResized (const awt::WindowEvent& rEvent)
373 throw (RuntimeException)
375 ThrowIfDisposed();
376 if (rEvent.Source == mxParentWindow)
378 Layout();
380 else
382 Reference<awt::XWindow> xWindow (rEvent.Source,UNO_QUERY);
383 if (xWindow.is())
385 UpdateWindowSize(xWindow);
387 // Make sure the background of a transparent window is painted.
388 mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow);
396 void SAL_CALL PresenterWindowManager::windowMoved (const awt::WindowEvent& rEvent)
397 throw (RuntimeException)
399 ThrowIfDisposed();
400 if (rEvent.Source != mxParentWindow)
402 Reference<awt::XWindow> xWindow (rEvent.Source,UNO_QUERY);
403 UpdateWindowSize(xWindow);
405 // Make sure the background of a transparent window is painted.
406 mpPresenterController->GetPaintManager()->Invalidate(xWindow);
413 void SAL_CALL PresenterWindowManager::windowShown (const lang::EventObject& rEvent)
414 throw (RuntimeException)
416 (void)rEvent;
422 void SAL_CALL PresenterWindowManager::windowHidden (const lang::EventObject& rEvent)
423 throw (RuntimeException)
425 (void)rEvent;
431 //----- XPaintListener --------------------------------------------------------
433 void SAL_CALL PresenterWindowManager::windowPaint (const awt::PaintEvent& rEvent)
434 throw (RuntimeException)
436 ThrowIfDisposed();
438 if ( ! mxParentWindow.is())
439 return;
440 if ( ! mxParentCanvas.is())
441 return;
443 if (mpTheme.get()!=NULL)
447 if (mbIsLayoutPending)
448 Layout();
449 PaintBackground(rEvent.UpdateRect);
450 if ( ! PaintChildren(rEvent))
452 Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxParentCanvas, UNO_QUERY);
453 // if (xSpriteCanvas.is())
454 // xSpriteCanvas->updateScreen(sal_False);
457 catch (RuntimeException&)
459 OSL_ASSERT(FALSE);
467 //----- XMouseListener --------------------------------------------------------
469 void SAL_CALL PresenterWindowManager::mousePressed (const css::awt::MouseEvent& rEvent)
470 throw(css::uno::RuntimeException)
472 (void)rEvent;
473 mbIsMouseClickPending = true;
479 void SAL_CALL PresenterWindowManager::mouseReleased (const css::awt::MouseEvent& rEvent)
480 throw(css::uno::RuntimeException)
482 #ifndef ENABLE_PANE_RESIZING
483 if (mbIsMouseClickPending)
485 mbIsMouseClickPending = false;
486 mpPresenterController->HandleMouseClick(rEvent);
488 #else
489 (void)rEvent;
490 #endif
496 void SAL_CALL PresenterWindowManager::mouseEntered (const css::awt::MouseEvent& rEvent)
497 throw(css::uno::RuntimeException)
499 (void)rEvent;
500 mbIsMouseClickPending = false;
506 void SAL_CALL PresenterWindowManager::mouseExited (const css::awt::MouseEvent& rEvent)
507 throw(css::uno::RuntimeException)
509 (void)rEvent;
510 mbIsMouseClickPending = false;
516 //----- XFocusListener --------------------------------------------------------
518 void SAL_CALL PresenterWindowManager::focusGained (const css::awt::FocusEvent& rEvent)
519 throw (css::uno::RuntimeException)
521 ThrowIfDisposed();
522 (void)rEvent;
523 OSL_TRACE("PresenterWindowManager::focusGained window %x\n",
524 rEvent.Source.get());
530 void SAL_CALL PresenterWindowManager::focusLost (const css::awt::FocusEvent& rEvent)
531 throw (css::uno::RuntimeException)
533 ThrowIfDisposed();
534 (void)rEvent;
540 //----- XEventListener --------------------------------------------------------
542 void SAL_CALL PresenterWindowManager::disposing (const lang::EventObject& rEvent)
543 throw (RuntimeException)
545 if (rEvent.Source == mxParentWindow)
546 mxParentWindow = NULL;
547 else
549 Reference<awt::XWindow> xWindow (rEvent.Source, UNO_QUERY);
556 //-----------------------------------------------------------------------------
558 bool PresenterWindowManager::PaintChildren (const awt::PaintEvent& rEvent) const
560 bool bChildInvalidated (false);
562 // Call windowPaint on all children that lie in or touch the
563 // update rectangle.
564 PresenterPaneContainer::PaneList::const_iterator iPane;
565 PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
566 for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
570 // Make sure that the pane shall and can be painted.
571 if ( ! (*iPane)->mbIsActive)
572 continue;
573 if ((*iPane)->mbIsSprite)
574 continue;
575 if ( ! (*iPane)->mxPane.is())
576 continue;
577 if ( ! (*iPane)->mxBorderWindow.is())
578 continue;
579 Reference<awt::XWindow> xBorderWindow ((*iPane)->mxBorderWindow);
580 if ( ! xBorderWindow.is())
581 continue;
583 // Get the area in which the border of the pane has to be painted.
584 const awt::Rectangle aBorderBox (xBorderWindow->getPosSize());
585 const awt::Rectangle aBorderUpdateBox(
586 PresenterGeometryHelper::Intersection(
587 rEvent.UpdateRect,
588 aBorderBox));
589 if (aBorderUpdateBox.Width<=0 || aBorderUpdateBox.Height<=0)
590 continue;
592 const awt::Rectangle aLocalBorderUpdateBox(
593 PresenterGeometryHelper::TranslateRectangle(
594 aBorderUpdateBox,
595 -aBorderBox.X,
596 -aBorderBox.Y));
598 // Invalidate the area of the content window.
599 mpPresenterController->GetPaintManager()->Invalidate(
600 xBorderWindow,
601 aLocalBorderUpdateBox,
602 sal_Int16(awt::InvalidateStyle::CHILDREN
603 | awt::InvalidateStyle::NOTRANSPARENT));
605 catch (RuntimeException&)
607 OSL_ASSERT(FALSE);
611 return bChildInvalidated;
617 void PresenterWindowManager::SetLayoutMode (const LayoutMode eMode)
619 OSL_ASSERT(mpPresenterController.get() != NULL);
621 if (meLayoutMode != eMode
622 || mbIsSlideSorterActive
623 || mbIsHelpViewActive)
625 meLayoutMode = eMode;
626 mbIsSlideSorterActive = false;
627 mbIsHelpViewActive = false;
629 mpPresenterController->RequestViews(
630 mbIsSlideSorterActive,
631 meLayoutMode==LM_Notes,
632 mbIsHelpViewActive);
633 Layout();
634 NotifyLayoutModeChange();
641 PresenterWindowManager::LayoutMode PresenterWindowManager::GetLayoutMode (void) const
643 return meLayoutMode;
649 void PresenterWindowManager::SetSlideSorterState (bool bIsActive)
651 if (mbIsSlideSorterActive != bIsActive)
653 mbIsSlideSorterActive = bIsActive;
654 if (mbIsSlideSorterActive)
655 mbIsHelpViewActive = false;
656 StoreViewMode(GetViewMode());
658 mpPresenterController->RequestViews(
659 mbIsSlideSorterActive,
660 meLayoutMode==LM_Notes,
661 mbIsHelpViewActive);
662 Layout();
663 NotifyLayoutModeChange();
670 bool PresenterWindowManager::IsSlideSorterActive (void) const
672 return mbIsSlideSorterActive;
678 void PresenterWindowManager::SetHelpViewState (bool bIsActive)
680 if (mbIsHelpViewActive != bIsActive)
682 mbIsHelpViewActive = bIsActive;
683 if (mbIsHelpViewActive)
684 mbIsSlideSorterActive = false;
685 StoreViewMode(GetViewMode());
687 mpPresenterController->RequestViews(
688 mbIsSlideSorterActive,
689 meLayoutMode==LM_Notes,
690 mbIsHelpViewActive);
691 Layout();
692 NotifyLayoutModeChange();
699 bool PresenterWindowManager::IsHelpViewActive (void) const
701 return mbIsHelpViewActive;
707 void PresenterWindowManager::SetViewMode (const ViewMode eMode)
709 switch (eMode)
711 case VM_Standard:
712 SetSlideSorterState(false);
713 SetHelpViewState(false);
714 SetLayoutMode(LM_Standard);
715 break;
717 case VM_Notes:
718 SetSlideSorterState(false);
719 SetHelpViewState(false);
720 SetLayoutMode(LM_Notes);
721 break;
723 case VM_SlideOverview:
724 SetHelpViewState(false);
725 SetSlideSorterState(true);
726 break;
728 case VM_Help:
729 SetHelpViewState(true);
730 SetSlideSorterState(false);
731 break;
734 StoreViewMode(eMode);
740 PresenterWindowManager::ViewMode PresenterWindowManager::GetViewMode (void) const
742 if (mbIsHelpViewActive)
743 return VM_Help;
744 else if (mbIsSlideSorterActive)
745 return VM_SlideOverview;
746 else if (meLayoutMode == LM_Notes)
747 return VM_Notes;
748 else
749 return VM_Standard;
755 void PresenterWindowManager::RestoreViewMode (void)
757 sal_Int32 nMode (0);
758 PresenterConfigurationAccess aConfiguration (
759 mxComponentContext,
760 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
761 PresenterConfigurationAccess::READ_ONLY);
762 aConfiguration.GetConfigurationNode(A2S("Presenter/InitialViewMode")) >>= nMode;
763 switch (nMode)
765 default:
766 case 0:
767 SetViewMode(VM_Standard);
768 break;
770 case 1:
771 SetViewMode(VM_Notes);
772 break;
774 case 2:
775 SetViewMode(VM_SlideOverview);
776 break;
783 void PresenterWindowManager::StoreViewMode (const ViewMode eViewMode)
787 PresenterConfigurationAccess aConfiguration (
788 mxComponentContext,
789 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
790 PresenterConfigurationAccess::READ_WRITE);
791 aConfiguration.GoToChild(A2S("Presenter"));
792 Any aValue;
793 switch (eViewMode)
795 default:
796 case VM_Standard:
797 aValue = Any(sal_Int32(0));
798 break;
800 case VM_Notes:
801 aValue = Any(sal_Int32(1));
802 break;
804 case VM_SlideOverview:
805 aValue = Any(sal_Int32(2));
806 break;
809 aConfiguration.SetProperty (A2S("InitialViewMode"), aValue);
810 aConfiguration.CommitChanges();
812 catch (Exception&)
820 void PresenterWindowManager::AddLayoutListener (
821 const Reference<document::XEventListener>& rxListener)
823 maLayoutListeners.push_back(rxListener);
829 void PresenterWindowManager::RemoveLayoutListener (
830 const Reference<document::XEventListener>& rxListener)
832 LayoutListenerContainer::iterator iListener (maLayoutListeners.begin());
833 LayoutListenerContainer::iterator iEnd (maLayoutListeners.end());
834 for ( ; iListener!=iEnd; ++iListener)
836 if (*iListener == rxListener)
838 maLayoutListeners.erase(iListener);
839 // Assume that there are no multiple entries.
840 break;
848 void PresenterWindowManager::Layout (void)
850 if (mxParentWindow.is() && ! mbIsLayouting)
852 mbIsLayoutPending = false;
853 mbIsLayouting = true;
854 mxScaledBackgroundBitmap = NULL;
855 mxClipPolygon = NULL;
859 if (mbIsSlideSorterActive)
860 LayoutSlideSorterMode();
861 else if (mbIsHelpViewActive)
862 LayoutHelpMode();
863 else
864 switch (meLayoutMode)
866 case LM_Standard:
867 default:
868 LayoutStandardMode();
869 break;
871 case LM_Notes:
872 LayoutNotesMode();
873 break;
876 catch (Exception&)
878 OSL_ASSERT(false);
879 throw;
882 mbIsLayouting = false;
889 void PresenterWindowManager::LayoutStandardMode (void)
891 awt::Rectangle aBox = mxParentWindow->getPosSize();
893 const double nGoldenRatio ((1 + sqrt(5.0)) / 2);
894 const double nGap (20);
895 const double nHorizontalSlideDivide (aBox.Width / nGoldenRatio);
896 double nSlidePreviewTop (0);
898 // For the current slide view calculate the outer height from the outer
899 // width. This takes into acount the slide aspect ratio and thus has to
900 // go over the inner pane size.
901 PresenterPaneContainer::SharedPaneDescriptor pPane (
902 mpPaneContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL));
903 if (pPane.get() != NULL)
905 const awt::Size aCurrentSlideOuterBox(CalculatePaneSize(
906 nHorizontalSlideDivide - 1.5*nGap,
907 PresenterPaneFactory::msCurrentSlidePreviewPaneURL));
908 nSlidePreviewTop = (aBox.Height - aCurrentSlideOuterBox.Height) / 2;
909 SetPanePosSizeAbsolute (
910 PresenterPaneFactory::msCurrentSlidePreviewPaneURL,
911 nGap,
912 nSlidePreviewTop,
913 aCurrentSlideOuterBox.Width,
914 aCurrentSlideOuterBox.Height);
918 // For the next slide view calculate the outer height from the outer
919 // width. This takes into acount the slide aspect ratio and thus has to
920 // go over the inner pane size.
921 pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msNextSlidePreviewPaneURL);
922 if (pPane.get() != NULL)
924 const awt::Size aNextSlideOuterBox (CalculatePaneSize(
925 aBox.Width - nHorizontalSlideDivide - 1.5*nGap,
926 PresenterPaneFactory::msNextSlidePreviewPaneURL));
927 SetPanePosSizeAbsolute (
928 PresenterPaneFactory::msNextSlidePreviewPaneURL,
929 aBox.Width - aNextSlideOuterBox.Width - nGap,
930 nSlidePreviewTop,
931 aNextSlideOuterBox.Width,
932 aNextSlideOuterBox.Height);
935 LayoutToolBar();
941 void PresenterWindowManager::LayoutNotesMode (void)
943 awt::Rectangle aBox = mxParentWindow->getPosSize();
945 const geometry::RealRectangle2D aToolBarBox (LayoutToolBar());
947 const double nGoldenRatio ((1 + sqrt(5.0)) / 2);
948 const double nGap (20);
949 const double nPrimaryWidth (aBox.Width / nGoldenRatio);
950 const double nSecondaryWidth (aBox.Width - nPrimaryWidth);
951 const double nTertiaryWidth (nSecondaryWidth / nGoldenRatio);
952 double nSlidePreviewTop (0);
953 double nNotesViewBottom (aToolBarBox.Y1 - nGap);
955 // The notes view has no fixed aspect ratio.
956 PresenterPaneContainer::SharedPaneDescriptor pPane (
957 mpPaneContainer->FindPaneURL(PresenterPaneFactory::msNotesPaneURL));
958 if (pPane.get() != NULL)
960 const geometry::RealSize2D aNotesViewOuterSize(
961 nPrimaryWidth - 1.5*nGap + 0.5,
962 nNotesViewBottom);
963 nSlidePreviewTop = (aBox.Height
964 - aToolBarBox.Y2 + aToolBarBox.Y1 - aNotesViewOuterSize.Height) / 2;
965 SetPanePosSizeAbsolute (
966 PresenterPaneFactory::msNotesPaneURL,
967 aBox.Width - aNotesViewOuterSize.Width - nGap,
968 nSlidePreviewTop,
969 aNotesViewOuterSize.Width,
970 aNotesViewOuterSize.Height);
971 nNotesViewBottom = nSlidePreviewTop + aNotesViewOuterSize.Height;
974 // For the current slide view calculate the outer height from the outer
975 // width. This takes into acount the slide aspect ratio and thus has to
976 // go over the inner pane size.
977 pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL);
978 if (pPane.get() != NULL)
980 const awt::Size aCurrentSlideOuterBox(CalculatePaneSize(
981 nSecondaryWidth - 1.5*nGap,
982 PresenterPaneFactory::msCurrentSlidePreviewPaneURL));
983 SetPanePosSizeAbsolute (
984 PresenterPaneFactory::msCurrentSlidePreviewPaneURL,
985 nGap,
986 nSlidePreviewTop,
987 aCurrentSlideOuterBox.Width,
988 aCurrentSlideOuterBox.Height);
992 // For the next slide view calculate the outer height from the outer
993 // width. This takes into acount the slide aspect ratio and thus has to
994 // go over the inner pane size.
995 pPane = mpPaneContainer->FindPaneURL(PresenterPaneFactory::msNextSlidePreviewPaneURL);
996 if (pPane.get() != NULL)
998 const awt::Size aNextSlideOuterBox (CalculatePaneSize(
999 nTertiaryWidth,
1000 PresenterPaneFactory::msNextSlidePreviewPaneURL));
1001 SetPanePosSizeAbsolute (
1002 PresenterPaneFactory::msNextSlidePreviewPaneURL,
1003 nGap,
1004 nNotesViewBottom - aNextSlideOuterBox.Height,
1005 aNextSlideOuterBox.Width,
1006 aNextSlideOuterBox.Height);
1013 void PresenterWindowManager::LayoutSlideSorterMode (void)
1015 const geometry::RealRectangle2D aToolBarBox (LayoutToolBar());
1017 awt::Rectangle aWindowBox = mxParentWindow->getPosSize();
1018 const double nGap (20);
1019 SetPanePosSizeAbsolute(
1020 mpPaneContainer->GetPaneURLForViewURL(PresenterViewFactory::msSlideSorterURL),
1021 nGap,
1022 nGap,
1023 aWindowBox.Width - 2*nGap,
1024 aToolBarBox.Y1 - 2*nGap);
1030 void PresenterWindowManager::LayoutHelpMode (void)
1032 const geometry::RealRectangle2D aToolBarBox (LayoutToolBar());
1034 awt::Rectangle aWindowBox = mxParentWindow->getPosSize();
1035 const double nGap (20);
1036 const double nGoldenRatio ((1 + sqrt(5.0)) / 2);
1037 const double nWidth = ::std::min(aWindowBox.Width - 2*nGap, aWindowBox.Width/nGoldenRatio);
1038 SetPanePosSizeAbsolute(
1039 mpPaneContainer->GetPaneURLForViewURL(PresenterViewFactory::msHelpViewURL),
1040 (aWindowBox.Width - nWidth)/2,
1041 nGap,
1042 nWidth,
1043 aToolBarBox.Y1 - 2*nGap);
1049 geometry::RealRectangle2D PresenterWindowManager::LayoutToolBar (void)
1051 double nToolBarWidth (400);
1052 double nToolBarHeight (80);
1054 // Get access to the tool bar.
1055 PresenterPaneContainer::SharedPaneDescriptor pDescriptor(
1056 mpPaneContainer->FindPaneURL(PresenterPaneFactory::msToolBarPaneURL));
1057 if (pDescriptor.get() != NULL)
1059 PresenterToolBarView* pToolBarView
1060 = dynamic_cast<PresenterToolBarView*>(pDescriptor->mxView.get());
1061 if (pToolBarView != NULL && pToolBarView->GetPresenterToolBar().is())
1063 geometry::RealSize2D aSize (pToolBarView->GetPresenterToolBar()->GetMinimalSize());
1065 if (mpPaneBorderPainter.is())
1067 const awt::Rectangle aBox (mpPaneBorderPainter->addBorder (
1068 PresenterPaneFactory::msToolBarPaneURL,
1069 awt::Rectangle(
1072 PresenterGeometryHelper::Round(aSize.Width),
1073 PresenterGeometryHelper::Round(aSize.Height)),
1074 css::drawing::framework::BorderType_TOTAL_BORDER));
1076 nToolBarWidth = aBox.Width;
1077 nToolBarHeight = aBox.Height;
1079 else
1081 nToolBarWidth = aSize.Width + 20;
1082 nToolBarHeight = aSize.Height + 10;
1087 const awt::Rectangle aBox = mxParentWindow->getPosSize();
1088 const double nToolBarX ((aBox.Width - nToolBarWidth) / 2);
1089 const double nToolBarY (aBox.Height - nToolBarHeight);
1090 SetPanePosSizeAbsolute(
1091 PresenterPaneFactory::msToolBarPaneURL,
1092 nToolBarX,
1093 nToolBarY,
1094 nToolBarWidth,
1095 nToolBarHeight);
1097 return geometry::RealRectangle2D(
1098 nToolBarX,
1099 nToolBarY,
1100 nToolBarX + nToolBarWidth - 1,
1101 nToolBarY + nToolBarHeight - 1);
1107 awt::Size PresenterWindowManager::CalculatePaneSize (
1108 const double nOuterWidth,
1109 const OUString& rsPaneURL)
1111 // Calculate the inner width by removing the pane border.
1112 awt::Rectangle aInnerBox (mpPaneBorderPainter->RemoveBorder (
1113 rsPaneURL,
1114 awt::Rectangle(0,0,
1115 sal_Int32(nOuterWidth+0.5),sal_Int32(nOuterWidth)),
1116 drawing::framework::BorderType_TOTAL_BORDER));
1118 // Calculate the inner height with the help of the slide aspect ratio.
1119 const double nCurrentSlideInnerHeight (
1120 aInnerBox.Width / mpPresenterController->GetSlideAspectRatio());
1122 // Add the pane border to get the outer box.
1123 awt::Rectangle aOuterBox (mpPaneBorderPainter->AddBorder (
1124 rsPaneURL,
1125 awt::Rectangle(0,0,
1126 aInnerBox.Width,sal_Int32(nCurrentSlideInnerHeight+0.5)),
1127 drawing::framework::BorderType_TOTAL_BORDER));
1129 return awt::Size(aOuterBox.Width, aOuterBox.Height);
1135 void PresenterWindowManager::NotifyLayoutModeChange (void)
1137 document::EventObject aEvent;
1138 aEvent.Source = Reference<XInterface>(static_cast<XWeak*>(this));
1140 LayoutListenerContainer aContainerCopy (maLayoutListeners);
1141 LayoutListenerContainer::iterator iListener (aContainerCopy.begin());
1142 LayoutListenerContainer::iterator iEnd (aContainerCopy.end());
1143 for ( ; iListener!=iEnd; ++iListener)
1145 if (iListener->is())
1149 (*iListener)->notifyEvent(aEvent);
1151 catch (lang::DisposedException&)
1153 RemoveLayoutListener(*iListener);
1155 catch (RuntimeException&)
1165 void PresenterWindowManager::NotifyDisposing (void)
1167 lang::EventObject aEvent;
1168 aEvent.Source = static_cast<XWeak*>(this);
1170 LayoutListenerContainer aContainer;
1171 aContainer.swap(maLayoutListeners);
1172 LayoutListenerContainer::iterator iListener (aContainer.begin());
1173 LayoutListenerContainer::iterator iEnd (aContainer.end());
1174 for ( ; iListener!=iEnd; ++iListener)
1176 if (iListener->is())
1180 (*iListener)->disposing(aEvent);
1182 catch (lang::DisposedException&)
1185 catch (RuntimeException&)
1195 void PresenterWindowManager::LayoutUnknownMode (void)
1197 awt::Rectangle aBox = mxParentWindow->getPosSize();
1199 PresenterPaneContainer::PaneList::const_iterator iPane;
1200 PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
1201 for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
1203 const PresenterPaneContainer::SharedPaneDescriptor& pDescriptor (*iPane);
1204 if ( ! pDescriptor->mxBorderWindow.is())
1205 continue;
1207 // Layout the border window.
1208 const sal_Int32 nX = (sal_Int32)(pDescriptor->mnLeft * aBox.Width);
1209 const sal_Int32 nY = (sal_Int32)(pDescriptor->mnTop * aBox.Height);
1210 const sal_Int32 nWidth = (sal_Int32)(pDescriptor->mnRight * aBox.Width) - nX;
1211 const sal_Int32 nHeight = (sal_Int32)(pDescriptor->mnBottom * aBox.Height) - nY;
1213 pDescriptor->mxBorderWindow->setPosSize(
1214 nX,nY,nWidth,nHeight,
1215 awt::PosSize::POSSIZE);
1222 void PresenterWindowManager::UpdateWindowSize (const Reference<awt::XWindow>& rxBorderWindow)
1224 PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
1225 mpPaneContainer->FindBorderWindow(rxBorderWindow));
1226 if (pDescriptor.get() != NULL)
1228 mxClipPolygon = NULL;
1230 awt::Rectangle aParentBox = mxParentWindow->getPosSize();
1231 awt::Rectangle aBorderBox (pDescriptor->mxBorderWindow->getPosSize());
1233 if ( ! mbIsLayouting)
1235 const double nWidth (aParentBox.Width);
1236 const double nHeight (aParentBox.Height);
1237 pDescriptor->mnLeft = double(aBorderBox.X) / nWidth;
1238 pDescriptor->mnTop = double(aBorderBox.Y) / nHeight;
1239 pDescriptor->mnRight = double(aBorderBox.X + aBorderBox.Width) / nWidth;
1240 pDescriptor->mnBottom = double(aBorderBox.Y + aBorderBox.Height) / nHeight;
1242 else
1244 // This update of the window size was initiated by
1245 // Layout(). Therefore the window size does not have to be
1246 // updated.
1249 // ToTop is called last because it may invalidate the iterator.
1250 if ( ! mbIsLayouting)
1251 mpPaneContainer->ToTop(pDescriptor);
1258 void PresenterWindowManager::PaintBackground (const awt::Rectangle& rUpdateBox)
1260 (void)rUpdateBox;
1261 if ( ! mxParentWindow.is())
1262 return;
1264 Reference<rendering::XGraphicDevice> xDevice (mxParentCanvas->getDevice());
1265 if ( ! xDevice.is())
1266 return;
1268 // Create a polygon for the background and for clipping.
1269 Reference<rendering::XPolyPolygon2D> xBackgroundPolygon (
1270 PresenterGeometryHelper::CreatePolygon(mxParentWindow->getPosSize(), xDevice));
1271 if ( ! mxClipPolygon.is())
1272 mxClipPolygon = CreateClipPolyPolygon();
1274 // Create View- and RenderState structs.
1275 const rendering::ViewState aViewState(
1276 geometry::AffineMatrix2D(1,0,0, 0,1,0),
1277 PresenterGeometryHelper::CreatePolygon(rUpdateBox, xDevice));
1278 rendering::RenderState aRenderState (
1279 geometry::AffineMatrix2D(1,0,0, 0,1,0),
1280 mxClipPolygon,
1281 Sequence<double>(4),
1282 rendering::CompositeOperation::SOURCE);
1284 // Paint the background.
1285 if (mpBackgroundBitmap.get() != NULL)
1287 ProvideBackgroundBitmap();
1289 if (mxScaledBackgroundBitmap.is())
1291 Sequence<rendering::Texture> aTextures (1);
1292 const geometry::IntegerSize2D aBitmapSize(mxScaledBackgroundBitmap->getSize());
1293 aTextures[0] = rendering::Texture (
1294 geometry::AffineMatrix2D(
1295 aBitmapSize.Width,0,0,
1296 0,aBitmapSize.Height,0),
1299 mxScaledBackgroundBitmap,
1300 NULL,
1301 NULL,
1302 rendering::StrokeAttributes(),
1303 rendering::TexturingMode::REPEAT,
1304 rendering::TexturingMode::REPEAT);
1306 mxParentCanvas->fillTexturedPolyPolygon(
1307 xBackgroundPolygon,
1308 aViewState,
1309 aRenderState,
1310 aTextures);
1312 else
1314 const util::Color aBackgroundColor (mpBackgroundBitmap->maReplacementColor);
1315 aRenderState.DeviceColor[0] = ((aBackgroundColor >> 16) & 0x0ff) / 255.0;
1316 aRenderState.DeviceColor[1] = ((aBackgroundColor >> 8) & 0x0ff) / 255.0;
1317 aRenderState.DeviceColor[2] = ((aBackgroundColor >> 0) & 0x0ff) / 255.0;
1318 aRenderState.DeviceColor[3] = ((aBackgroundColor >> 24) & 0x0ff) / 255.0;
1319 mxParentCanvas->fillPolyPolygon(
1320 xBackgroundPolygon,
1321 aViewState,
1322 aRenderState);
1330 void PresenterWindowManager::ProvideBackgroundBitmap (void)
1332 if ( ! mxScaledBackgroundBitmap.is())
1334 Reference<rendering::XBitmap> xBitmap (mpBackgroundBitmap->GetNormalBitmap());
1335 if (xBitmap.is())
1337 const bool bStretchVertical (mpBackgroundBitmap->meVerticalTexturingMode
1338 == PresenterBitmapDescriptor::Stretch);
1339 const bool bStretchHorizontal (mpBackgroundBitmap->meHorizontalTexturingMode
1340 == PresenterBitmapDescriptor::Stretch);
1341 if (bStretchHorizontal || bStretchVertical)
1343 geometry::RealSize2D aSize;
1344 if (bStretchVertical)
1345 aSize.Height = mxParentWindow->getPosSize().Height;
1346 else
1347 aSize.Height = xBitmap->getSize().Height;
1348 if (bStretchHorizontal)
1349 aSize.Width = mxParentWindow->getPosSize().Width;
1350 else
1351 aSize.Width = xBitmap->getSize().Width;
1352 mxScaledBackgroundBitmap = xBitmap->getScaledBitmap(aSize, sal_False);
1354 else
1356 mxScaledBackgroundBitmap
1357 = Reference<rendering::XBitmap>(xBitmap, UNO_QUERY);
1366 Reference<rendering::XPolyPolygon2D> PresenterWindowManager::CreateClipPolyPolygon (void) const
1368 // Create a clip polygon that includes the whole update area but has the
1369 // content windows as holes.
1370 const sal_Int32 nPaneCount (mpPaneContainer->maPanes.size());
1371 ::std::vector<awt::Rectangle> aRectangles;
1372 aRectangles.reserve(1+nPaneCount);
1373 aRectangles.push_back(mxParentWindow->getPosSize());
1374 PresenterPaneContainer::PaneList::const_iterator iPane;
1375 PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
1376 for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
1378 PresenterPaneContainer::SharedPaneDescriptor pDescriptor (*iPane);
1379 if ( ! pDescriptor->mbIsActive)
1380 continue;
1381 if ( ! pDescriptor->mbIsOpaque)
1382 continue;
1383 if ( ! pDescriptor->mxBorderWindow.is() || ! pDescriptor->mxContentWindow.is())
1384 continue;
1385 Reference<awt::XWindow2> xWindow (pDescriptor->mxBorderWindow, UNO_QUERY);
1386 if (xWindow.is() && ! xWindow->isVisible())
1387 continue;
1389 const awt::Rectangle aOuterBorderBox (pDescriptor->mxBorderWindow->getPosSize());
1390 awt::Rectangle aInnerBorderBox (pDescriptor->mxContentWindow->getPosSize());
1391 aInnerBorderBox.X += aOuterBorderBox.X;
1392 aInnerBorderBox.Y += aOuterBorderBox.Y;
1393 aRectangles.push_back(aInnerBorderBox);
1395 Reference<rendering::XPolyPolygon2D> xPolyPolygon (
1396 PresenterGeometryHelper::CreatePolygon(
1397 aRectangles,
1398 mxParentCanvas->getDevice()));
1399 if (xPolyPolygon.is())
1400 xPolyPolygon->setFillRule(rendering::FillRule_EVEN_ODD);
1401 return xPolyPolygon;
1407 void PresenterWindowManager::UpdateWindowList (void)
1409 #ifdef ENABLE_PANE_RESIZING
1412 OSL_ASSERT(mxComponentContext.is());
1414 Reference<lang::XComponent> xComponent (mxPaneBorderManager, UNO_QUERY);
1415 if (xComponent.is())
1416 xComponent->dispose();
1418 Reference<lang::XMultiComponentFactory> xFactory (mxComponentContext->getServiceManager());
1419 if (xFactory.is())
1421 Sequence<Any> aArguments (1 + mpPaneContainer->maPanes.size()*2);
1422 sal_Int32 nIndex (0);
1423 aArguments[nIndex++] = Any(mxParentWindow);
1424 for (sal_uInt32 nPaneIndex=0; nPaneIndex<mpPaneContainer->maPanes.size(); ++nPaneIndex)
1426 if ( ! mpPaneContainer->maPanes[nPaneIndex]->mbIsActive)
1427 continue;
1429 const Reference<awt::XWindow> xBorderWindow (
1430 mpPaneContainer->maPanes[nPaneIndex]->mxBorderWindow);
1431 const Reference<awt::XWindow> xContentWindow (
1432 mpPaneContainer->maPanes[nPaneIndex]->mxContentWindow);
1433 const Reference<awt::XWindow2> xBorderWindow2(xBorderWindow, UNO_QUERY);
1434 if (xBorderWindow.is()
1435 && xContentWindow.is()
1436 && ( ! xBorderWindow2.is() || xBorderWindow2->isVisible()))
1438 aArguments[nIndex++] = Any(xBorderWindow);
1439 aArguments[nIndex++] = Any(xContentWindow);
1443 aArguments.realloc(nIndex);
1444 rtl::Reference<PresenterPaneBorderManager> pManager (
1445 new PresenterPaneBorderManager (
1446 mxComponentContext,
1447 mpPresenterController));
1448 pManager->initialize(aArguments);
1449 mxPaneBorderManager = Reference<XInterface>(static_cast<XWeak*>(pManager.get()));
1452 catch (RuntimeException&)
1455 #endif
1461 void PresenterWindowManager::Invalidate (void)
1463 mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow);
1469 Reference<awt::XWindow> PresenterWindowManager::GetParentWindow (void) const
1471 return mxParentWindow;
1477 Reference<rendering::XCanvas> PresenterWindowManager::GetParentCanvas (void) const
1479 return mxParentCanvas;
1485 void PresenterWindowManager::Update (void)
1487 mxClipPolygon = NULL;
1488 mbIsLayoutPending = true;
1490 UpdateWindowList();
1491 Invalidate();
1497 void PresenterWindowManager::ThrowIfDisposed (void) const
1498 throw (::com::sun::star::lang::DisposedException)
1500 if (rBHelper.bDisposed || rBHelper.bInDispose)
1502 throw lang::DisposedException (
1503 OUString(RTL_CONSTASCII_USTRINGPARAM(
1504 "PresenterWindowManager has already been disposed")),
1505 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1511 namespace {
1513 //===== ModeChangeAnimation ===================================================
1515 class ModeChangeAnimation : public PresenterAnimation
1517 public:
1518 ModeChangeAnimation (
1519 const ::boost::shared_ptr<PresenterSprite>& rpSprite,
1520 const Reference<rendering::XSpriteCanvas>& rxCanvas)
1521 : PresenterAnimation (0, 1000, 20),
1522 mpSprite(rpSprite),
1523 mxCanvas(rxCanvas)
1527 virtual void Run (const double nProgress, const sal_uInt64 nCurrentTime)
1529 (void)nCurrentTime;
1530 mpSprite->SetAlpha(1.0 - nProgress);
1531 mxCanvas->updateScreen(sal_False);
1534 private:
1535 ::boost::shared_ptr<PresenterSprite> mpSprite;
1536 Reference<rendering::XSpriteCanvas> mxCanvas;
1542 ModeChangeAnimationStarter::ModeChangeAnimationStarter (
1543 const Reference<drawing::framework::XConfigurationController>& rxConfigurationController,
1544 const Reference<awt::XWindow>& rxWindow,
1545 const Reference<rendering::XSpriteCanvas>& rxCanvas,
1546 const ::boost::shared_ptr<PresenterAnimator>& rpAnimator)
1547 : ModeChangeAnimationStarterInterfaceBase(m_aMutex),
1548 mxConfigurationController(rxConfigurationController),
1549 mpAnimator(rpAnimator),
1550 mpSprite(new PresenterSprite()),
1551 mxCanvas(rxCanvas)
1553 OSL_ASSERT(rxWindow.is());
1554 OSL_ASSERT(rxCanvas.is());
1556 // Get the bitmap of the background.
1557 Reference<rendering::XBitmap> xBackgroundBitmap (rxCanvas, UNO_QUERY);
1558 if ( ! xBackgroundBitmap.is())
1559 return;
1561 // Create the sprite.
1562 const awt::Rectangle aWindowSize (rxWindow->getPosSize());
1563 mpSprite->SetFactory(rxCanvas);
1564 mpSprite->Resize(geometry::RealSize2D(aWindowSize.Width, aWindowSize.Height));
1565 mpSprite->SetPriority(10);
1567 // Fill it with the background inside the bounding box.
1568 const rendering::ViewState aViewState (
1569 geometry::AffineMatrix2D(1,0,0, 0,1,0),
1570 NULL);
1571 const rendering::RenderState aRenderState (
1572 geometry::AffineMatrix2D(1,0,0, 0,1,0),
1573 NULL,
1574 Sequence<double>(4),
1575 rendering::CompositeOperation::SOURCE);
1576 Reference<rendering::XCanvas> xSpriteCanvas (mpSprite->GetCanvas());
1577 if (xSpriteCanvas.is())
1579 xSpriteCanvas->drawBitmap(xBackgroundBitmap, aViewState, aRenderState);
1580 mpSprite->Show();
1583 // Register as listener to be notified when the new panes are visible
1584 // and the sprite can be faded out.
1585 mxConfigurationController->addConfigurationChangeListener(
1586 this,
1587 A2S("ConfigurationUpdateEnd"),
1588 Any());
1594 ModeChangeAnimationStarter::~ModeChangeAnimationStarter (void)
1601 void SAL_CALL ModeChangeAnimationStarter::disposing (void)
1603 mxConfigurationController = NULL;
1604 mpAnimator.reset();
1605 mpSprite.reset();
1611 // XConfigurationChangeListener
1613 void SAL_CALL ModeChangeAnimationStarter::notifyConfigurationChange (
1614 const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
1615 throw (com::sun::star::uno::RuntimeException)
1617 (void)rEvent;
1619 // Start the actual animation.
1620 mpAnimator->AddAnimation(SharedPresenterAnimation(new ModeChangeAnimation(
1621 mpSprite,
1622 mxCanvas)));
1624 mxConfigurationController->removeConfigurationChangeListener(this);
1630 // XEventListener
1632 void SAL_CALL ModeChangeAnimationStarter::disposing (
1633 const com::sun::star::lang::EventObject& rEvent)
1634 throw (com::sun::star::uno::RuntimeException)
1636 if (rEvent.Source == mxConfigurationController)
1637 mxConfigurationController = NULL;
1642 } // end of anonymous namespace
1645 } } // end of namespace ::sdext::presenter