1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: slideshow.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 //#include <com/sun/star/frame/XController.hpp>
35 #include <com/sun/star/beans/PropertyAttribute.hpp>
36 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
37 #include <com/sun/star/container/XIndexAccess.hpp>
38 #include <com/sun/star/frame/XDispatchProvider.hpp>
39 #include <com/sun/star/util/URL.hpp>
41 #include <cppuhelper/bootstrap.hxx>
43 #include <comphelper/processfactory.hxx>
44 #include <vos/mutex.hxx>
46 #include <vcl/svapp.hxx>
47 #include <vcl/wrkwin.hxx>
49 #include <svtools/itemprop.hxx>
51 #include <sfx2/topfrm.hxx>
52 #include <sfx2/viewfrm.hxx>
54 #include <toolkit/unohlp.hxx>
55 #include <svx/unoprov.hxx>
57 #include "framework/FrameworkHelper.hxx"
59 #include "FrameView.hxx"
60 #include "unomodel.hxx"
61 #include "slideshow.hxx"
62 #include "slideshowimpl.hxx"
64 #include "FactoryIds.hxx"
65 #include "ViewShell.hxx"
66 #include "SlideShowRestarter.hxx"
67 #include <boost/bind.hpp>
69 using ::com::sun::star::presentation::XSlideShowController
;
70 using ::com::sun::star::container::XIndexAccess
;
71 using ::sd::framework::FrameworkHelper
;
72 using ::rtl::OUString
;
73 using ::com::sun::star::awt::XWindow
;
75 using namespace ::cppu
;
76 using namespace ::vos
;
77 using namespace ::com::sun::star
;
78 using namespace ::com::sun::star::uno
;
79 using namespace ::com::sun::star::presentation
;
80 using namespace ::com::sun::star::drawing
;
81 using namespace ::com::sun::star::beans
;
82 using namespace ::com::sun::star::lang
;
83 using namespace ::com::sun::star::animations
;
84 using namespace ::com::sun::star::drawing::framework
;
86 extern String
getUiNameFromPageApiNameImpl( const ::rtl::OUString
& rApiName
);
88 #define C2U(x) OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
92 /** This local version of the work window overloads DataChanged() so that it
93 can restart the slide show when a displau is added or removed.
95 class FullScreenWorkWindow
: public WorkWindow
98 FullScreenWorkWindow (
99 const ::rtl::Reference
<SlideShow
>& rpSlideShow
,
100 ViewShellBase
* pViewShellBase
)
101 : WorkWindow(NULL
, WB_HIDE
| WB_CLIPCHILDREN
),
102 mpRestarter(new SlideShowRestarter(rpSlideShow
, pViewShellBase
))
106 virtual void DataChanged (const DataChangedEvent
& rEvent
)
108 if (rEvent
.GetType() == DATACHANGED_DISPLAY
)
110 mpRestarter
->Restart();
115 ::boost::shared_ptr
<SlideShowRestarter
> mpRestarter
;
120 //////////////////////////////////////////////////////////////////////////////
121 // --------------------------------------------------------------------
123 const SfxItemPropertyMapEntry
* ImplGetPresentationPropertyMap()
125 // NOTE: First member must be sorted
126 static const SfxItemPropertyMapEntry aPresentationPropertyMap_Impl
[] =
128 { MAP_CHAR_LEN("AllowAnimations"), ATTR_PRESENT_ANIMATION_ALLOWED
, &::getBooleanCppuType(), 0, 0 },
129 { MAP_CHAR_LEN("CustomShow"), ATTR_PRESENT_CUSTOMSHOW
, &::getCppuType((const OUString
*)0), 0, 0 },
130 { MAP_CHAR_LEN("Display"), ATTR_PRESENT_DISPLAY
, &::getCppuType((const sal_Int32
*)0), 0, 0 },
131 { MAP_CHAR_LEN("FirstPage"), ATTR_PRESENT_DIANAME
, &::getCppuType((const OUString
*)0), 0, 0 },
132 { MAP_CHAR_LEN("IsAlwaysOnTop"), ATTR_PRESENT_ALWAYS_ON_TOP
, &::getBooleanCppuType(), 0, 0 },
133 { MAP_CHAR_LEN("IsAutomatic"), ATTR_PRESENT_MANUEL
, &::getBooleanCppuType(), 0, 0 },
134 { MAP_CHAR_LEN("IsEndless"), ATTR_PRESENT_ENDLESS
, &::getBooleanCppuType(), 0, 0 },
135 { MAP_CHAR_LEN("IsFullScreen"), ATTR_PRESENT_FULLSCREEN
, &::getBooleanCppuType(), 0, 0 },
136 { MAP_CHAR_LEN("IsShowAll"), ATTR_PRESENT_ALL
, &::getBooleanCppuType(), 0, 0 },
137 { MAP_CHAR_LEN("IsMouseVisible"), ATTR_PRESENT_MOUSE
, &::getBooleanCppuType(), 0, 0 },
138 { MAP_CHAR_LEN("IsShowLogo"), ATTR_PRESENT_SHOW_PAUSELOGO
, &::getBooleanCppuType(), 0, 0 },
139 { MAP_CHAR_LEN("IsTransitionOnClick"), ATTR_PRESENT_CHANGE_PAGE
, &::getBooleanCppuType(), 0, 0 },
140 { MAP_CHAR_LEN("Pause"), ATTR_PRESENT_PAUSE_TIMEOUT
, &::getCppuType((const sal_Int32
*)0), 0, 0 },
141 { MAP_CHAR_LEN("StartWithNavigator"), ATTR_PRESENT_NAVIGATOR
, &::getBooleanCppuType(), 0, 0 },
142 { MAP_CHAR_LEN("UsePen"), ATTR_PRESENT_PEN
, &::getBooleanCppuType(), 0, 0 },
146 return aPresentationPropertyMap_Impl
;
149 //SfxItemPropertyMap map_impl[] = { { 0,0,0,0,0,0 } };
151 // --------------------------------------------------------------------
153 // --------------------------------------------------------------------
155 SlideShow::SlideShow( SdDrawDocument
* pDoc
)
156 : SlideshowBase( m_aMutex
)
157 , maPropSet(ImplGetPresentationPropertyMap())
158 , mbIsInStartup(false)
160 , mpCurrentViewShellBase( 0 )
161 , mpFullScreenViewShellBase( 0 )
162 , mpFullScreenFrameView( 0 )
163 , mnInPlaceConfigEvent( 0 )
167 // --------------------------------------------------------------------
169 void SlideShow::ThrowIfDisposed() throw (RuntimeException
)
172 throw DisposedException();
175 // --------------------------------------------------------------------
177 /// used by the model to create a slideshow for it
178 rtl::Reference
< SlideShow
> SlideShow::Create( SdDrawDocument
* pDoc
)
180 return new SlideShow( pDoc
);
183 // --------------------------------------------------------------------
185 rtl::Reference
< SlideShow
> SlideShow::GetSlideShow( SdDrawDocument
* pDocument
)
187 rtl::Reference
< SlideShow
> xRet
;
190 xRet
= rtl::Reference
< SlideShow
>( dynamic_cast< SlideShow
* >( pDocument
->getPresentation().get() ) );
195 // --------------------------------------------------------------------
197 rtl::Reference
< SlideShow
> SlideShow::GetSlideShow( ViewShellBase
& rBase
)
199 return GetSlideShow( rBase
.GetDocument() );
202 // --------------------------------------------------------------------
204 ::com::sun::star::uno::Reference
< ::com::sun::star::presentation::XSlideShowController
> SlideShow::GetSlideShowController(ViewShellBase
& rBase
)
206 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
208 Reference
< XSlideShowController
> xRet
;
209 if( xSlideShow
.is() )
210 xRet
= xSlideShow
->getController();
215 // --------------------------------------------------------------------
217 bool SlideShow::StartPreview( ViewShellBase
& rBase
,
218 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& xDrawPage
,
219 const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xAnimationNode
,
220 ::Window
* pParent
/* = 0 */ )
222 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
223 if( xSlideShow
.is() )
224 return xSlideShow
->startPreview( xDrawPage
, xAnimationNode
, pParent
);
229 // --------------------------------------------------------------------
231 void SlideShow::Stop( ViewShellBase
& rBase
)
233 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
234 if( xSlideShow
.is() )
238 // --------------------------------------------------------------------
240 bool SlideShow::IsRunning( ViewShellBase
& rBase
)
242 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
243 return xSlideShow
.is() && xSlideShow
->isRunning();
246 // --------------------------------------------------------------------
248 bool SlideShow::IsRunning( ViewShell
& rViewShell
)
250 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rViewShell
.GetViewShellBase() ) );
251 return xSlideShow
.is() && xSlideShow
->isRunning() && (xSlideShow
->mxController
->getViewShell() == &rViewShell
);
254 // --------------------------------------------------------------------
256 void SlideShow::CreateController( ViewShell
* pViewSh
, ::sd::View
* pView
, ::Window
* pParentWindow
)
258 DBG_ASSERT( !mxController
.is(), "sd::SlideShow::CreateController(), clean up old controller first!" );
260 Reference
< XPresentation2
> xThis( this );
262 rtl::Reference
<SlideshowImpl
> xController (
263 new SlideshowImpl(xThis
, pViewSh
, pView
, mpDoc
, pParentWindow
));
265 // Reset mbIsInStartup. From here mxController.is() is used to prevent
266 // multiple slide show instances for one document.
267 mxController
= xController
;
268 mbIsInStartup
= false;
271 // --------------------------------------------------------------------
273 // --------------------------------------------------------------------
275 OUString SAL_CALL
SlideShow::getImplementationName( ) throw(RuntimeException
)
277 return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SlideShow") );
280 // --------------------------------------------------------------------
282 sal_Bool SAL_CALL
SlideShow::supportsService( const OUString
& ServiceName
) throw(RuntimeException
)
284 return SvxServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames( ) );
287 // --------------------------------------------------------------------
289 Sequence
< OUString
> SAL_CALL
SlideShow::getSupportedServiceNames( ) throw(RuntimeException
)
291 OUString
aService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.Presentation") );
292 Sequence
< OUString
> aSeq( &aService
, 1 );
296 // --------------------------------------------------------------------
298 // --------------------------------------------------------------------
300 Reference
< XPropertySetInfo
> SAL_CALL
SlideShow::getPropertySetInfo() throw(RuntimeException
)
302 OGuard
aGuard( Application::GetSolarMutex() );
303 static Reference
< XPropertySetInfo
> xInfo
= maPropSet
.getPropertySetInfo();
307 // --------------------------------------------------------------------
309 void SAL_CALL
SlideShow::setPropertyValue( const OUString
& aPropertyName
, const Any
& aValue
) throw(UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
311 OGuard
aGuard( Application::GetSolarMutex() );
314 sd::PresentationSettings
& rPresSettings
= mpDoc
->getPresentationSettings();
316 const SfxItemPropertySimpleEntry
* pEntry
= maPropSet
.getPropertyMapEntry(aPropertyName
);
318 if( pEntry
&& ((pEntry
->nFlags
& PropertyAttribute::READONLY
) != 0) )
319 throw PropertyVetoException();
321 bool bValuesChanged
= false;
322 bool bIllegalArgument
= true;
324 switch( pEntry
? pEntry
->nWID
: -1 )
326 case ATTR_PRESENT_ALL
:
328 sal_Bool bVal
= sal_False
;
330 if( aValue
>>= bVal
)
332 bIllegalArgument
= false;
334 if( rPresSettings
.mbAll
!= bVal
)
336 rPresSettings
.mbAll
= bVal
;
337 bValuesChanged
= true;
339 rPresSettings
.mbCustomShow
= sal_False
;
344 case ATTR_PRESENT_CHANGE_PAGE
:
346 sal_Bool bVal
= sal_False
;
348 if( aValue
>>= bVal
)
350 bIllegalArgument
= false;
352 if( bVal
== rPresSettings
.mbLockedPages
)
354 bValuesChanged
= true;
355 rPresSettings
.mbLockedPages
= !bVal
;
361 case ATTR_PRESENT_ANIMATION_ALLOWED
:
363 sal_Bool bVal
= sal_False
;
365 if( aValue
>>= bVal
)
367 bIllegalArgument
= false;
369 if(rPresSettings
.mbAnimationAllowed
!= bVal
)
371 bValuesChanged
= true;
372 rPresSettings
.mbAnimationAllowed
= bVal
;
377 case ATTR_PRESENT_CUSTOMSHOW
:
380 if( aValue
>>= aShow
)
382 bIllegalArgument
= false;
384 const String
aShowName( aShow
);
386 List
* pCustomShowList
= mpDoc
->GetCustomShowList(sal_False
);
389 SdCustomShow
* pCustomShow
;
390 for( pCustomShow
= (SdCustomShow
*) pCustomShowList
->First(); pCustomShow
!= NULL
; pCustomShow
= (SdCustomShow
*) pCustomShowList
->Next() )
392 if( pCustomShow
->GetName() == aShowName
)
396 rPresSettings
.mbCustomShow
= sal_True
;
397 bValuesChanged
= true;
402 case ATTR_PRESENT_ENDLESS
:
404 sal_Bool bVal
= sal_False
;
406 if( aValue
>>= bVal
)
408 bIllegalArgument
= false;
410 if( rPresSettings
.mbEndless
!= bVal
)
412 bValuesChanged
= true;
413 rPresSettings
.mbEndless
= bVal
;
418 case ATTR_PRESENT_FULLSCREEN
:
420 sal_Bool bVal
= sal_False
;
422 if( aValue
>>= bVal
)
424 bIllegalArgument
= false;
425 if( rPresSettings
.mbFullScreen
!= bVal
)
427 bValuesChanged
= true;
428 rPresSettings
.mbFullScreen
= bVal
;
433 case ATTR_PRESENT_DIANAME
:
436 aValue
>>= aPresPage
;
437 bIllegalArgument
= false;
438 if( (rPresSettings
.maPresPage
!= aPresPage
) || !rPresSettings
.mbCustomShow
|| !rPresSettings
.mbAll
)
440 bValuesChanged
= true;
441 rPresSettings
.maPresPage
= getUiNameFromPageApiNameImpl(aPresPage
);
442 rPresSettings
.mbCustomShow
= sal_False
;
443 rPresSettings
.mbAll
= sal_False
;
447 case ATTR_PRESENT_MANUEL
:
449 sal_Bool bVal
= sal_False
;
451 if( aValue
>>= bVal
)
453 bIllegalArgument
= false;
455 if( rPresSettings
.mbManual
!= bVal
)
457 bValuesChanged
= true;
458 rPresSettings
.mbManual
= bVal
;
463 case ATTR_PRESENT_MOUSE
:
465 sal_Bool bVal
= sal_False
;
467 if( aValue
>>= bVal
)
469 bIllegalArgument
= false;
470 if( rPresSettings
.mbMouseVisible
!= bVal
)
472 bValuesChanged
= true;
473 rPresSettings
.mbMouseVisible
= bVal
;
478 case ATTR_PRESENT_ALWAYS_ON_TOP
:
480 sal_Bool bVal
= sal_False
;
482 if( aValue
>>= bVal
)
484 bIllegalArgument
= false;
486 if( rPresSettings
.mbAlwaysOnTop
!= bVal
)
488 bValuesChanged
= true;
489 rPresSettings
.mbAlwaysOnTop
= bVal
;
494 case ATTR_PRESENT_NAVIGATOR
:
496 sal_Bool bVal
= sal_False
;
498 if( aValue
>>= bVal
)
500 bIllegalArgument
= false;
502 if( rPresSettings
.mbStartWithNavigator
!= bVal
)
504 bValuesChanged
= true;
505 rPresSettings
.mbStartWithNavigator
= bVal
;
510 case ATTR_PRESENT_PEN
:
512 sal_Bool bVal
= sal_False
;
514 if( aValue
>>= bVal
)
516 bIllegalArgument
= false;
518 if(rPresSettings
.mbMouseAsPen
!= bVal
)
520 bValuesChanged
= true;
521 rPresSettings
.mbMouseAsPen
= bVal
;
526 case ATTR_PRESENT_PAUSE_TIMEOUT
:
528 sal_Int32 nValue
= 0;
529 if( (aValue
>>= nValue
) && (nValue
>= 0) )
531 bIllegalArgument
= false;
532 if( rPresSettings
.mnPauseTimeout
!= nValue
)
534 bValuesChanged
= true;
535 rPresSettings
.mnPauseTimeout
= nValue
;
540 case ATTR_PRESENT_SHOW_PAUSELOGO
:
542 sal_Bool bVal
= sal_False
;
544 if( aValue
>>= bVal
)
546 bIllegalArgument
= false;
548 if( rPresSettings
.mbShowPauseLogo
!= bVal
)
550 bValuesChanged
= true;
551 rPresSettings
.mbShowPauseLogo
= bVal
;
556 case ATTR_PRESENT_DISPLAY
:
558 sal_Int32 nDisplay
= 0;
559 if( aValue
>>= nDisplay
)
561 bIllegalArgument
= false;
563 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
564 pOptions
->SetDisplay( nDisplay
);
570 throw UnknownPropertyException();
573 if( bIllegalArgument
)
574 throw IllegalArgumentException();
577 mpDoc
->SetChanged( true );
580 // --------------------------------------------------------------------
582 Any SAL_CALL
SlideShow::getPropertyValue( const OUString
& PropertyName
) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
584 OGuard
aGuard( Application::GetSolarMutex() );
587 const sd::PresentationSettings
& rPresSettings
= mpDoc
->getPresentationSettings();
589 const SfxItemPropertySimpleEntry
* pEntry
= maPropSet
.getPropertyMapEntry(PropertyName
);
591 switch( pEntry
? pEntry
->nWID
: -1 )
593 case ATTR_PRESENT_ALL
:
594 return Any( (sal_Bool
) ( !rPresSettings
.mbCustomShow
&& rPresSettings
.mbAll
) );
595 case ATTR_PRESENT_CHANGE_PAGE
:
596 return Any( (sal_Bool
) !rPresSettings
.mbLockedPages
);
597 case ATTR_PRESENT_ANIMATION_ALLOWED
:
598 return Any( rPresSettings
.mbAnimationAllowed
);
599 case ATTR_PRESENT_CUSTOMSHOW
:
601 List
* pList
= mpDoc
->GetCustomShowList(sal_False
);
602 SdCustomShow
* pShow
= (pList
&& rPresSettings
.mbCustomShow
)?(SdCustomShow
*)pList
->GetCurObject():NULL
;
606 aShowName
= pShow
->GetName();
608 return Any( aShowName
);
610 case ATTR_PRESENT_ENDLESS
:
611 return Any( rPresSettings
.mbEndless
);
612 case ATTR_PRESENT_FULLSCREEN
:
613 return Any( rPresSettings
.mbFullScreen
);
614 case ATTR_PRESENT_DIANAME
:
618 if( !rPresSettings
.mbCustomShow
&& !rPresSettings
.mbAll
)
619 aSlideName
= getPageApiNameFromUiName( rPresSettings
.maPresPage
);
621 return Any( aSlideName
);
623 case ATTR_PRESENT_MANUEL
:
624 return Any( rPresSettings
.mbManual
);
625 case ATTR_PRESENT_MOUSE
:
626 return Any( rPresSettings
.mbMouseVisible
);
627 case ATTR_PRESENT_ALWAYS_ON_TOP
:
628 return Any( rPresSettings
.mbAlwaysOnTop
);
629 case ATTR_PRESENT_NAVIGATOR
:
630 return Any( rPresSettings
.mbStartWithNavigator
);
631 case ATTR_PRESENT_PEN
:
632 return Any( rPresSettings
.mbMouseAsPen
);
633 case ATTR_PRESENT_PAUSE_TIMEOUT
:
634 return Any( rPresSettings
.mnPauseTimeout
);
635 case ATTR_PRESENT_SHOW_PAUSELOGO
:
636 return Any( rPresSettings
.mbShowPauseLogo
);
637 case ATTR_PRESENT_DISPLAY
:
639 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
640 return Any( pOptions
->GetDisplay() );
644 throw UnknownPropertyException();
648 // --------------------------------------------------------------------
650 void SAL_CALL
SlideShow::addPropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
654 // --------------------------------------------------------------------
656 void SAL_CALL
SlideShow::removePropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
660 // --------------------------------------------------------------------
662 void SAL_CALL
SlideShow::addVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
666 // --------------------------------------------------------------------
668 void SAL_CALL
SlideShow::removeVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
672 // --------------------------------------------------------------------
674 // --------------------------------------------------------------------
676 void SAL_CALL
SlideShow::start() throw(RuntimeException
)
678 const Sequence
< PropertyValue
> aArguments
;
679 startWithArguments( aArguments
);
682 // --------------------------------------------------------------------
684 void SAL_CALL
SlideShow::end() throw(RuntimeException
)
686 OGuard
aGuard( Application::GetSolarMutex() );
688 // The mbIsInStartup flag should have been reset during the start of the
689 // slide show. Reset it here just in case that something has horribly
691 OSL_ASSERT(!mbIsInStartup
);
692 mbIsInStartup
= false;
694 rtl::Reference
< SlideshowImpl
> xController( mxController
);
695 if( xController
.is() )
697 mxController
.clear();
699 if( mpFullScreenFrameView
)
701 delete mpFullScreenFrameView
;
702 mpFullScreenFrameView
= 0;
705 ViewShellBase
* pFullScreenViewShellBase
= mpFullScreenViewShellBase
;
706 mpFullScreenViewShellBase
= 0;
708 // dispose before fullscreen window changes screens
709 // (potentially). If this needs to be moved behind
710 // pWorkWindow->StartPresentationMode() again, read issue
711 // pWorkWindow->i94007 & implement the solution outlined
713 xController
->dispose();
715 if( pFullScreenViewShellBase
)
717 PresentationViewShell
* pShell
= dynamic_cast<PresentationViewShell
*>(pFullScreenViewShellBase
->GetMainViewShell().get());
719 if( pShell
&& pShell
->GetViewFrame() && pShell
->GetViewFrame()->GetTopFrame() )
721 WorkWindow
* pWorkWindow
= dynamic_cast<WorkWindow
*>(pShell
->GetViewFrame()->GetTopFrame()->GetWindow().GetParent());
724 pWorkWindow
->StartPresentationMode( FALSE
, isAlwaysOnTop() );
729 if( pFullScreenViewShellBase
)
731 PresentationViewShell
* pShell
= NULL
;
733 // Get the shell pointer in its own scope to be sure that
734 // the shared_ptr to the shell is released before DoClose()
736 ::boost::shared_ptr
<ViewShell
> pSharedView (pFullScreenViewShellBase
->GetMainViewShell());
737 pShell
= dynamic_cast<PresentationViewShell
*>(pSharedView
.get());
739 if( pShell
&& pShell
->GetViewFrame() )
740 pShell
->GetViewFrame()->DoClose();
742 else if( mpCurrentViewShellBase
)
744 ViewShell
* pViewShell
= mpCurrentViewShellBase
->GetMainViewShell().get();
748 FrameView
* pFrameView
= pViewShell
->GetFrameView();
750 if( pFrameView
&& (pFrameView
->GetPresentationViewShellId() != SID_VIEWSHELL0
) )
752 ViewShell::ShellType
ePreviousType (pFrameView
->GetPreviousViewShellType());
753 pFrameView
->SetPreviousViewShellType(ViewShell::ST_NONE
);
755 pFrameView
->SetPresentationViewShellId(SID_VIEWSHELL0
);
756 pFrameView
->SetSlotId(SID_OBJECT_SELECT
);
757 pFrameView
->SetPreviousViewShellType(pViewShell
->GetShellType());
759 framework::FrameworkHelper::Instance(*mpCurrentViewShellBase
)->RequestView(
760 framework::FrameworkHelper::GetViewURL(ePreviousType
),
761 framework::FrameworkHelper::msCenterPaneURL
);
763 pViewShell
->GetViewFrame()->GetBindings().InvalidateAll( TRUE
);
768 if( mpCurrentViewShellBase
)
770 ViewShell
* pViewShell
= mpCurrentViewShellBase
->GetMainViewShell().get();
773 // invalidate the view shell so the presentation slot will be re-enabled
774 // and the rehersing will be updated
775 pViewShell
->Invalidate();
777 if( xController
->meAnimationMode
==ANIMATIONMODE_SHOW
)
779 // switch to the previously visible Slide
780 DrawViewShell
* pDrawViewShell
= dynamic_cast<DrawViewShell
*>( pViewShell
);
782 pDrawViewShell
->SwitchPage( (USHORT
)xController
->getRestoreSlide() );
785 if( pViewShell
->GetDoc()->IsStartWithPresentation() )
787 pViewShell
->GetDoc()->SetStartWithPresentation( false );
789 Reference
<frame::XDispatchProvider
> xProvider(pViewShell
->GetViewShellBase().GetController()->getFrame(),
794 aURL
.Complete
= ::rtl::OUString::createFromAscii(".uno:CloseFrame");
796 uno::Reference
< frame::XDispatch
> xDispatch(
797 xProvider
->queryDispatch(
798 aURL
, ::rtl::OUString(), 0));
801 xDispatch
->dispatch(aURL
,
802 uno::Sequence
< beans::PropertyValue
>());
808 mpCurrentViewShellBase
= 0;
812 // --------------------------------------------------------------------
814 void SAL_CALL
SlideShow::rehearseTimings() throw(RuntimeException
)
816 Sequence
< PropertyValue
> aArguments(1);
817 aArguments
[0].Name
= C2U("RehearseTimings");
818 aArguments
[0].Value
<<= sal_True
;
819 startWithArguments( aArguments
);
822 // --------------------------------------------------------------------
824 // --------------------------------------------------------------------
826 void SAL_CALL
SlideShow::startWithArguments( const Sequence
< PropertyValue
>& rArguments
) throw (RuntimeException
)
828 OGuard
aGuard( Application::GetSolarMutex() );
831 // Stop a running show before starting a new one.
832 if( mxController
.is() )
834 OSL_ASSERT(!mbIsInStartup
);
837 else if (mbIsInStartup
)
839 // We are already somewhere in process of starting a slide show but
840 // have not yet got to the point where mxController is set. There
841 // is not yet a slide show to end so return silently.
845 // Prevent multiple instance of the SlideShow class for one document.
846 mbIsInStartup
= true;
848 mxCurrentSettings
.reset( new PresentationSettingsEx( mpDoc
->getPresentationSettings() ) );
849 mxCurrentSettings
->SetArguments( rArguments
);
851 // if there is no view shell base set, use the current one or the first using this document
852 if( mpCurrentViewShellBase
== 0 )
854 // first check current
855 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( SfxViewFrame::Current() );
856 if( pBase
&& pBase
->GetDocument() == mpDoc
)
858 mpCurrentViewShellBase
= pBase
;
862 // current is not ours, so get first from ours
863 mpCurrentViewShellBase
= ::sd::ViewShellBase::GetViewShellBase( SfxViewFrame::GetFirst( mpDoc
->GetDocSh() ) );
867 // Start either a full-screen or an in-place show.
868 if(mxCurrentSettings
->mbFullScreen
&& !mxCurrentSettings
->mbPreview
)
869 StartFullscreenPresentation();
871 StartInPlacePresentation();
874 // --------------------------------------------------------------------
876 ::sal_Bool SAL_CALL
SlideShow::isRunning( ) throw (RuntimeException
)
878 OGuard
aGuard( Application::GetSolarMutex() );
879 return mxController
.is() && mxController
->isRunning();
882 // --------------------------------------------------------------------
884 Reference
< XSlideShowController
> SAL_CALL
SlideShow::getController( ) throw (RuntimeException
)
888 Reference
< XSlideShowController
> xController( mxController
.get() );
892 // --------------------------------------------------------------------
894 // --------------------------------------------------------------------
896 void SAL_CALL
SlideShow::disposing (void)
898 OGuard
aGuard( Application::GetSolarMutex() );
900 if( mnInPlaceConfigEvent
)
902 Application::RemoveUserEvent( mnInPlaceConfigEvent
);
903 mnInPlaceConfigEvent
= 0;
906 if( mxController
.is() )
908 mxController
->dispose();
909 mxController
.clear();
912 mpCurrentViewShellBase
= 0;
913 mpFullScreenViewShellBase
= 0;
917 // ---------------------------------------------------------
919 bool SlideShow::startPreview( const Reference
< XDrawPage
>& xDrawPage
, const Reference
< XAnimationNode
>& xAnimationNode
, ::Window
* pParent
)
921 Sequence
< PropertyValue
> aArguments(4);
923 aArguments
[0].Name
= C2U("Preview");
924 aArguments
[0].Value
<<= sal_True
;
926 aArguments
[1].Name
= C2U("FirstPage");
927 aArguments
[1].Value
<<= xDrawPage
;
929 aArguments
[2].Name
= C2U("AnimationNode");
930 aArguments
[2].Value
<<= xAnimationNode
;
932 Reference
< XWindow
> xParentWindow
;
934 xParentWindow
= VCLUnoHelper::GetInterface( pParent
);
936 aArguments
[3].Name
= C2U("ParentWindow");
937 aArguments
[3].Value
<<= xParentWindow
;
939 startWithArguments( aArguments
);
944 // ---------------------------------------------------------
946 ShowWindow
* SlideShow::getShowWindow()
948 return mxController
.is() ? mxController
->mpShowWindow
: 0;
951 // ---------------------------------------------------------
953 int SlideShow::getAnimationMode()
955 return mxController
.is() ? mxController
->meAnimationMode
: ANIMATIONMODE_SHOW
;
958 // ---------------------------------------------------------
960 void SlideShow::jumpToPageIndex( sal_Int32 nPageIndex
)
962 if( mxController
.is() )
963 mxController
->displaySlideIndex( nPageIndex
);
966 // ---------------------------------------------------------
968 void SlideShow::jumpToPageNumber( sal_Int32 nPageNumber
)
970 if( mxController
.is() )
971 mxController
->displaySlideNumber( nPageNumber
);
974 // ---------------------------------------------------------
976 sal_Int32
SlideShow::getCurrentPageNumber()
978 return mxController
.is() ? mxController
->getCurrentSlideNumber() : 0;
981 // ---------------------------------------------------------
983 sal_Int32
SlideShow::getCurrentPageIndex()
985 return mxController
.is() ? mxController
->getCurrentSlideIndex() : 0;
988 // ---------------------------------------------------------
990 void SlideShow::jumpToBookmark( const OUString
& sBookmark
)
992 if( mxController
.is() )
993 mxController
->jumpToBookmark( sBookmark
);
996 // ---------------------------------------------------------
998 bool SlideShow::isFullScreen()
1000 return mxController
.is() ? mxController
->maPresSettings
.mbFullScreen
: false;
1003 // ---------------------------------------------------------
1005 void SlideShow::resize( const Size
&rSize
)
1007 if( mxController
.is() )
1008 mxController
->resize( rSize
);
1011 // ---------------------------------------------------------
1013 void SlideShow::activate( ViewShellBase
& rBase
)
1015 if( (mpFullScreenViewShellBase
== &rBase
) && !mxController
.is() )
1017 ::boost::shared_ptr
<PresentationViewShell
> pShell
= ::boost::dynamic_pointer_cast
<PresentationViewShell
>(rBase
.GetMainViewShell());
1018 if(pShell
.get() != NULL
)
1020 pShell
->FinishInitialization( mpFullScreenFrameView
);
1021 mpFullScreenFrameView
= 0;
1023 CreateController( pShell
.get(), pShell
->GetView(), rBase
.GetViewWindow() );
1025 if( mxController
->startShow(mxCurrentSettings
.get()) )
1037 if( mxController
.is() )
1038 mxController
->activate();
1041 // ---------------------------------------------------------
1043 void SlideShow::deactivate( ViewShellBase
& /*rBase*/ )
1045 mxController
->deactivate();
1048 // ---------------------------------------------------------
1050 bool SlideShow::keyInput(const KeyEvent
& rKEvt
)
1052 return mxController
.is() ? mxController
->keyInput(rKEvt
) : false;
1055 // ---------------------------------------------------------
1057 void SlideShow::paint( const Rectangle
& rRect
)
1059 if( mxController
.is() )
1060 mxController
->paint( rRect
);
1063 // ---------------------------------------------------------
1065 bool SlideShow::isAlwaysOnTop()
1067 return mxController
.is() ? mxController
->maPresSettings
.mbAlwaysOnTop
: false;
1070 // ---------------------------------------------------------
1072 bool SlideShow::pause( bool bPause
)
1074 if( mxController
.is() )
1077 mxController
->pause();
1079 mxController
->resume();
1084 // ---------------------------------------------------------
1086 void SlideShow::receiveRequest(SfxRequest
& rReq
)
1088 if( mxController
.is() )
1089 mxController
->receiveRequest( rReq
);
1092 // ---------------------------------------------------------
1094 sal_Int32
SlideShow::getFirstPageNumber()
1096 return mxController
.is() ? mxController
->getFirstSlideNumber() : 0;
1099 // ---------------------------------------------------------
1101 sal_Int32
SlideShow::getLastPageNumber()
1103 return mxController
.is() ? mxController
->getLastSlideNumber() : 0;
1106 // ---------------------------------------------------------
1108 bool SlideShow::isEndless()
1110 return mxController
.is() ? mxController
->isEndless() : false;
1113 // ---------------------------------------------------------
1115 bool SlideShow::isDrawingPossible()
1117 return mxController
.is() ? mxController
->getUsePen() : false;
1120 // ---------------------------------------------------------
1122 void SlideShow::StartInPlacePresentationConfigurationCallback()
1124 if( mnInPlaceConfigEvent
!= 0 )
1125 Application::RemoveUserEvent( mnInPlaceConfigEvent
);
1127 mnInPlaceConfigEvent
= Application::PostUserEvent( LINK( this, SlideShow
, StartInPlacePresentationConfigurationHdl
) );
1130 // ---------------------------------------------------------
1132 IMPL_LINK( SlideShow
, StartInPlacePresentationConfigurationHdl
, void *, EMPTYARG
)
1134 mnInPlaceConfigEvent
= 0;
1135 StartInPlacePresentation();
1139 // ---------------------------------------------------------
1141 void SlideShow::StartInPlacePresentation()
1143 if( mpCurrentViewShellBase
)
1145 // Save the current view shell type so that it can be restored after the
1146 // show has ended. If there already is a saved shell type then that is
1149 ViewShell::ShellType eShell
= ViewShell::ST_NONE
;
1151 ::boost::shared_ptr
<FrameworkHelper
> pHelper(FrameworkHelper::Instance(*mpCurrentViewShellBase
));
1152 ::boost::shared_ptr
<ViewShell
> pMainViewShell(pHelper
->GetViewShell(FrameworkHelper::msCenterPaneURL
));
1154 if( pMainViewShell
.get() )
1155 eShell
= pMainViewShell
->GetShellType();
1157 if( eShell
!= ViewShell::ST_IMPRESS
)
1159 // Switch temporary to a DrawViewShell which supports the in-place presentation.
1161 if( pMainViewShell
.get() )
1163 FrameView
* pFrameView
= pMainViewShell
->GetFrameView();
1164 pFrameView
->SetPresentationViewShellId(SID_VIEWSHELL1
);
1165 pFrameView
->SetPreviousViewShellType (pMainViewShell
->GetShellType());
1166 pFrameView
->SetPageKind (PK_STANDARD
);
1169 pHelper
->RequestView( FrameworkHelper::msImpressViewURL
, FrameworkHelper::msCenterPaneURL
);
1170 pHelper
->RunOnConfigurationEvent( FrameworkHelper::msConfigurationUpdateEndEvent
, ::boost::bind(&SlideShow::StartInPlacePresentationConfigurationCallback
, this) );
1175 ::Window
* pParentWindow
= mxCurrentSettings
->mpParentWindow
;
1176 if( pParentWindow
== 0 )
1177 pParentWindow
= mpCurrentViewShellBase
->GetViewWindow();
1179 CreateController( pMainViewShell
.get(), pMainViewShell
->GetView(), pParentWindow
);
1182 else if( mxCurrentSettings
->mpParentWindow
)
1184 // no current view shell, but parent window
1185 CreateController( 0, 0, mxCurrentSettings
->mpParentWindow
);
1188 if( mxController
.is() )
1190 sal_Bool bSuccess
= sal_False
;
1191 if( mxCurrentSettings
.get() && mxCurrentSettings
->mbPreview
)
1193 bSuccess
= mxController
->startPreview(mxCurrentSettings
->mxStartPage
, mxCurrentSettings
->mxAnimationNode
, mxCurrentSettings
->mpParentWindow
);
1197 bSuccess
= mxController
->startShow(mxCurrentSettings
.get());
1205 // ---------------------------------------------------------
1207 void SlideShow::StartFullscreenPresentation( )
1209 // Create the top level window in which the PresentationViewShell(Base)
1210 // will be created. This is done here explicitly so that we can make it
1212 const sal_Int32
nDisplay (GetDisplay());
1213 WorkWindow
* pWorkWindow
= new FullScreenWorkWindow(this, mpCurrentViewShellBase
);
1214 pWorkWindow
->StartPresentationMode( TRUE
, mpDoc
->getPresentationSettings().mbAlwaysOnTop
? PRESENTATION_HIDEALLAPPS
: 0, nDisplay
);
1215 // pWorkWindow->ShowFullScreenMode(FALSE, nDisplay);
1216 pWorkWindow
->SetBackground(Wallpaper(COL_BLACK
));
1218 if (pWorkWindow
->IsVisible())
1220 // Initialize the new presentation view shell with a copy of the
1221 // frame view of the current view shell. This avoids that
1222 // changes made by the presentation have an effect on the other
1224 FrameView
* pOriginalFrameView
= mpCurrentViewShellBase
? mpCurrentViewShellBase
->GetMainViewShell()->GetFrameView() : 0;
1226 if( mpFullScreenFrameView
)
1227 delete mpFullScreenFrameView
;
1228 mpFullScreenFrameView
= new FrameView(mpDoc
, pOriginalFrameView
);
1230 // Reference<XController> xController;
1232 // The new frame is created hidden. To make it visible and activate the
1233 // new view shell--a prerequisite to process slot calls and initialize
1234 // its panes--a GrabFocus() has to be called later on.
1235 SfxTopFrame
* pNewFrame
= SfxTopFrame::Create( mpDoc
->GetDocSh(), pWorkWindow
, PRESENTATION_FACTORY_ID
, TRUE
);
1236 pNewFrame
->SetPresentationMode(TRUE
);
1238 mpFullScreenViewShellBase
= static_cast<ViewShellBase
*>(pNewFrame
->GetCurrentViewFrame()->GetViewShell());
1239 if(mpFullScreenViewShellBase
!= NULL
)
1241 // The following GrabFocus() is responsible for activating the
1242 // new view shell. Without it the screen remains blank (under
1243 // Windows and some Linux variants.)
1244 mpFullScreenViewShellBase
->GetWindow()->GrabFocus();
1249 // ---------------------------------------------------------
1251 sal_Int32
SlideShow::GetDisplay()
1254 sal_Int32 nDisplay
= 0;
1256 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
1258 nDisplay
= pOptions
->GetDisplay();
1264 Reference
<XMultiServiceFactory
> xFactory(
1265 ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW
);
1266 Reference
<XPropertySet
> xMonitorProperties(
1267 xFactory
->createInstance(
1268 OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess"))),
1270 const OUString
sPropertyName (RTL_CONSTASCII_USTRINGPARAM("DefaultDisplay"));
1271 xMonitorProperties
->getPropertyValue(sPropertyName
) >>= nDisplay
;
1285 // ---------------------------------------------------------
1288 bool SlideShow::dependsOn( ViewShellBase
* pViewShellBase
)
1290 return mxController
.is() && (pViewShellBase
== mpCurrentViewShellBase
) && mpFullScreenViewShellBase
;
1293 // ---------------------------------------------------------
1295 Reference
< XPresentation2
> CreatePresentation( const SdDrawDocument
& rDocument
)
1297 return Reference
< XPresentation2
>( SlideShow::Create( const_cast< SdDrawDocument
* >( &rDocument
) ).get() );
1300 // ---------------------------------------------------------