1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
31 //#include <com/sun/star/frame/XController.hpp>
32 #include <com/sun/star/beans/PropertyAttribute.hpp>
33 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
34 #include <com/sun/star/container/XIndexAccess.hpp>
35 #include <comphelper/serviceinfohelper.hxx>
37 #include <cppuhelper/bootstrap.hxx>
39 #include <comphelper/processfactory.hxx>
40 #include <vos/mutex.hxx>
42 #include <vcl/svapp.hxx>
43 #include <vcl/wrkwin.hxx>
44 #include <svx/svdpool.hxx>
45 #include <svl/itemprop.hxx>
47 #include <sfx2/viewfrm.hxx>
49 #include <toolkit/unohlp.hxx>
50 #include <svx/unoprov.hxx>
52 #include "framework/FrameworkHelper.hxx"
54 #include "FrameView.hxx"
55 #include "unomodel.hxx"
56 #include "slideshow.hxx"
57 #include "slideshowimpl.hxx"
59 #include "FactoryIds.hxx"
60 #include "ViewShell.hxx"
61 #include "SlideShowRestarter.hxx"
62 #include "DrawController.hxx"
63 #include <boost/bind.hpp>
65 using ::com::sun::star::presentation::XSlideShowController
;
66 using ::com::sun::star::container::XIndexAccess
;
67 using ::sd::framework::FrameworkHelper
;
68 using ::rtl::OUString
;
69 using ::com::sun::star::awt::XWindow
;
71 using namespace ::cppu
;
72 using namespace ::vos
;
73 using namespace ::com::sun::star::uno
;
74 using namespace ::com::sun::star::presentation
;
75 using namespace ::com::sun::star::drawing
;
76 using namespace ::com::sun::star::beans
;
77 using namespace ::com::sun::star::lang
;
78 using namespace ::com::sun::star::animations
;
79 using namespace ::com::sun::star::drawing::framework
;
81 extern String
getUiNameFromPageApiNameImpl( const ::rtl::OUString
& rApiName
);
83 #define C2U(x) OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
87 /** This local version of the work window overloads DataChanged() so that it
88 can restart the slide show when a display is added or removed.
90 class FullScreenWorkWindow
: public WorkWindow
93 FullScreenWorkWindow (
94 const ::rtl::Reference
<SlideShow
>& rpSlideShow
,
95 ViewShellBase
* pViewShellBase
)
96 : WorkWindow(NULL
, WB_HIDE
| WB_CLIPCHILDREN
),
97 mpRestarter(new SlideShowRestarter(rpSlideShow
, pViewShellBase
))
101 virtual void DataChanged (const DataChangedEvent
& rEvent
)
103 if (rEvent
.GetType() == DATACHANGED_DISPLAY
)
105 mpRestarter
->Restart();
110 ::boost::shared_ptr
<SlideShowRestarter
> mpRestarter
;
115 //////////////////////////////////////////////////////////////////////////////
116 // --------------------------------------------------------------------
118 const SfxItemPropertyMapEntry
* ImplGetPresentationPropertyMap()
120 // NOTE: First member must be sorted
121 static const SfxItemPropertyMapEntry aPresentationPropertyMap_Impl
[] =
123 { MAP_CHAR_LEN("AllowAnimations"), ATTR_PRESENT_ANIMATION_ALLOWED
, &::getBooleanCppuType(), 0, 0 },
124 { MAP_CHAR_LEN("CustomShow"), ATTR_PRESENT_CUSTOMSHOW
, &::getCppuType((const OUString
*)0), 0, 0 },
125 { MAP_CHAR_LEN("Display"), ATTR_PRESENT_DISPLAY
, &::getCppuType((const sal_Int32
*)0), 0, 0 },
126 { MAP_CHAR_LEN("FirstPage"), ATTR_PRESENT_DIANAME
, &::getCppuType((const OUString
*)0), 0, 0 },
127 { MAP_CHAR_LEN("IsAlwaysOnTop"), ATTR_PRESENT_ALWAYS_ON_TOP
, &::getBooleanCppuType(), 0, 0 },
128 { MAP_CHAR_LEN("IsAutomatic"), ATTR_PRESENT_MANUEL
, &::getBooleanCppuType(), 0, 0 },
129 { MAP_CHAR_LEN("IsEndless"), ATTR_PRESENT_ENDLESS
, &::getBooleanCppuType(), 0, 0 },
130 { MAP_CHAR_LEN("IsFullScreen"), ATTR_PRESENT_FULLSCREEN
, &::getBooleanCppuType(), 0, 0 },
131 { MAP_CHAR_LEN("IsShowAll"), ATTR_PRESENT_ALL
, &::getBooleanCppuType(), 0, 0 },
132 { MAP_CHAR_LEN("IsMouseVisible"), ATTR_PRESENT_MOUSE
, &::getBooleanCppuType(), 0, 0 },
133 { MAP_CHAR_LEN("IsShowLogo"), ATTR_PRESENT_SHOW_PAUSELOGO
, &::getBooleanCppuType(), 0, 0 },
134 { MAP_CHAR_LEN("IsTransitionOnClick"), ATTR_PRESENT_CHANGE_PAGE
, &::getBooleanCppuType(), 0, 0 },
135 { MAP_CHAR_LEN("Pause"), ATTR_PRESENT_PAUSE_TIMEOUT
, &::getCppuType((const sal_Int32
*)0), 0, 0 },
136 { MAP_CHAR_LEN("StartWithNavigator"), ATTR_PRESENT_NAVIGATOR
, &::getBooleanCppuType(), 0, 0 },
137 { MAP_CHAR_LEN("UsePen"), ATTR_PRESENT_PEN
, &::getBooleanCppuType(), 0, 0 },
141 return aPresentationPropertyMap_Impl
;
144 //SfxItemPropertyMap map_impl[] = { { 0,0,0,0,0,0 } };
146 // --------------------------------------------------------------------
148 // --------------------------------------------------------------------
150 SlideShow::SlideShow( SdDrawDocument
* pDoc
)
151 : SlideshowBase( m_aMutex
)
152 , maPropSet(ImplGetPresentationPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool())
153 , mbIsInStartup(false)
155 , mpCurrentViewShellBase( 0 )
156 , mpFullScreenViewShellBase( 0 )
157 , mpFullScreenFrameView( 0 )
158 , mnInPlaceConfigEvent( 0 )
162 // --------------------------------------------------------------------
164 void SlideShow::ThrowIfDisposed() throw (RuntimeException
)
167 throw DisposedException();
170 // --------------------------------------------------------------------
172 /// used by the model to create a slideshow for it
173 rtl::Reference
< SlideShow
> SlideShow::Create( SdDrawDocument
* pDoc
)
175 return new SlideShow( pDoc
);
178 // --------------------------------------------------------------------
180 rtl::Reference
< SlideShow
> SlideShow::GetSlideShow( SdDrawDocument
* pDocument
)
182 rtl::Reference
< SlideShow
> xRet
;
185 xRet
= rtl::Reference
< SlideShow
>( dynamic_cast< SlideShow
* >( pDocument
->getPresentation().get() ) );
190 // --------------------------------------------------------------------
192 rtl::Reference
< SlideShow
> SlideShow::GetSlideShow( ViewShellBase
& rBase
)
194 return GetSlideShow( rBase
.GetDocument() );
197 // --------------------------------------------------------------------
199 ::com::sun::star::uno::Reference
< ::com::sun::star::presentation::XSlideShowController
> SlideShow::GetSlideShowController(ViewShellBase
& rBase
)
201 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
203 Reference
< XSlideShowController
> xRet
;
204 if( xSlideShow
.is() )
205 xRet
= xSlideShow
->getController();
210 // --------------------------------------------------------------------
212 bool SlideShow::StartPreview( ViewShellBase
& rBase
,
213 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& xDrawPage
,
214 const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xAnimationNode
,
215 ::Window
* pParent
/* = 0 */ )
217 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
218 if( xSlideShow
.is() )
219 return xSlideShow
->startPreview( xDrawPage
, xAnimationNode
, pParent
);
224 // --------------------------------------------------------------------
226 void SlideShow::Stop( ViewShellBase
& rBase
)
228 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
229 if( xSlideShow
.is() )
233 // --------------------------------------------------------------------
235 bool SlideShow::IsRunning( ViewShellBase
& rBase
)
237 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
238 return xSlideShow
.is() && xSlideShow
->isRunning();
241 // --------------------------------------------------------------------
243 bool SlideShow::IsRunning( ViewShell
& rViewShell
)
245 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rViewShell
.GetViewShellBase() ) );
246 return xSlideShow
.is() && xSlideShow
->isRunning() && (xSlideShow
->mxController
->getViewShell() == &rViewShell
);
249 // --------------------------------------------------------------------
251 void SlideShow::CreateController( ViewShell
* pViewSh
, ::sd::View
* pView
, ::Window
* pParentWindow
)
253 DBG_ASSERT( !mxController
.is(), "sd::SlideShow::CreateController(), clean up old controller first!" );
255 Reference
< XPresentation2
> xThis( this );
257 rtl::Reference
<SlideshowImpl
> xController (
258 new SlideshowImpl(xThis
, pViewSh
, pView
, mpDoc
, pParentWindow
));
260 // Reset mbIsInStartup. From here mxController.is() is used to prevent
261 // multiple slide show instances for one document.
262 mxController
= xController
;
263 mbIsInStartup
= false;
266 // --------------------------------------------------------------------
268 // --------------------------------------------------------------------
270 OUString SAL_CALL
SlideShow::getImplementationName( ) throw(RuntimeException
)
272 return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SlideShow") );
275 // --------------------------------------------------------------------
277 sal_Bool SAL_CALL
SlideShow::supportsService( const OUString
& ServiceName
) throw(RuntimeException
)
279 return comphelper::ServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames( ) );
282 // --------------------------------------------------------------------
284 Sequence
< OUString
> SAL_CALL
SlideShow::getSupportedServiceNames( ) throw(RuntimeException
)
286 OUString
aService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.Presentation") );
287 Sequence
< OUString
> aSeq( &aService
, 1 );
291 // --------------------------------------------------------------------
293 // --------------------------------------------------------------------
295 Reference
< XPropertySetInfo
> SAL_CALL
SlideShow::getPropertySetInfo() throw(RuntimeException
)
297 OGuard
aGuard( Application::GetSolarMutex() );
298 static Reference
< XPropertySetInfo
> xInfo
= maPropSet
.getPropertySetInfo();
302 // --------------------------------------------------------------------
304 void SAL_CALL
SlideShow::setPropertyValue( const OUString
& aPropertyName
, const Any
& aValue
) throw(UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
306 OGuard
aGuard( Application::GetSolarMutex() );
309 sd::PresentationSettings
& rPresSettings
= mpDoc
->getPresentationSettings();
311 const SfxItemPropertySimpleEntry
* pEntry
= maPropSet
.getPropertyMapEntry(aPropertyName
);
313 if( pEntry
&& ((pEntry
->nFlags
& PropertyAttribute::READONLY
) != 0) )
314 throw PropertyVetoException();
316 bool bValuesChanged
= false;
317 bool bIllegalArgument
= true;
319 switch( pEntry
? pEntry
->nWID
: -1 )
321 case ATTR_PRESENT_ALL
:
323 sal_Bool bVal
= sal_False
;
325 if( aValue
>>= bVal
)
327 bIllegalArgument
= false;
329 if( rPresSettings
.mbAll
!= bVal
)
331 rPresSettings
.mbAll
= bVal
;
332 bValuesChanged
= true;
334 rPresSettings
.mbCustomShow
= sal_False
;
339 case ATTR_PRESENT_CHANGE_PAGE
:
341 sal_Bool bVal
= sal_False
;
343 if( aValue
>>= bVal
)
345 bIllegalArgument
= false;
347 if( bVal
== rPresSettings
.mbLockedPages
)
349 bValuesChanged
= true;
350 rPresSettings
.mbLockedPages
= !bVal
;
356 case ATTR_PRESENT_ANIMATION_ALLOWED
:
358 sal_Bool bVal
= sal_False
;
360 if( aValue
>>= bVal
)
362 bIllegalArgument
= false;
364 if(rPresSettings
.mbAnimationAllowed
!= bVal
)
366 bValuesChanged
= true;
367 rPresSettings
.mbAnimationAllowed
= bVal
;
372 case ATTR_PRESENT_CUSTOMSHOW
:
375 if( aValue
>>= aShow
)
377 bIllegalArgument
= false;
379 const String
aShowName( aShow
);
381 List
* pCustomShowList
= mpDoc
->GetCustomShowList(sal_False
);
384 SdCustomShow
* pCustomShow
;
385 for( pCustomShow
= (SdCustomShow
*) pCustomShowList
->First(); pCustomShow
!= NULL
; pCustomShow
= (SdCustomShow
*) pCustomShowList
->Next() )
387 if( pCustomShow
->GetName() == aShowName
)
391 rPresSettings
.mbCustomShow
= sal_True
;
392 bValuesChanged
= true;
397 case ATTR_PRESENT_ENDLESS
:
399 sal_Bool bVal
= sal_False
;
401 if( aValue
>>= bVal
)
403 bIllegalArgument
= false;
405 if( rPresSettings
.mbEndless
!= bVal
)
407 bValuesChanged
= true;
408 rPresSettings
.mbEndless
= bVal
;
413 case ATTR_PRESENT_FULLSCREEN
:
415 sal_Bool bVal
= sal_False
;
417 if( aValue
>>= bVal
)
419 bIllegalArgument
= false;
420 if( rPresSettings
.mbFullScreen
!= bVal
)
422 bValuesChanged
= true;
423 rPresSettings
.mbFullScreen
= bVal
;
428 case ATTR_PRESENT_DIANAME
:
431 aValue
>>= aPresPage
;
432 bIllegalArgument
= false;
433 if( (rPresSettings
.maPresPage
!= aPresPage
) || !rPresSettings
.mbCustomShow
|| !rPresSettings
.mbAll
)
435 bValuesChanged
= true;
436 rPresSettings
.maPresPage
= getUiNameFromPageApiNameImpl(aPresPage
);
437 rPresSettings
.mbCustomShow
= sal_False
;
438 rPresSettings
.mbAll
= sal_False
;
442 case ATTR_PRESENT_MANUEL
:
444 sal_Bool bVal
= sal_False
;
446 if( aValue
>>= bVal
)
448 bIllegalArgument
= false;
450 if( rPresSettings
.mbManual
!= bVal
)
452 bValuesChanged
= true;
453 rPresSettings
.mbManual
= bVal
;
458 case ATTR_PRESENT_MOUSE
:
460 sal_Bool bVal
= sal_False
;
462 if( aValue
>>= bVal
)
464 bIllegalArgument
= false;
465 if( rPresSettings
.mbMouseVisible
!= bVal
)
467 bValuesChanged
= true;
468 rPresSettings
.mbMouseVisible
= bVal
;
473 case ATTR_PRESENT_ALWAYS_ON_TOP
:
475 sal_Bool bVal
= sal_False
;
477 if( aValue
>>= bVal
)
479 bIllegalArgument
= false;
481 if( rPresSettings
.mbAlwaysOnTop
!= bVal
)
483 bValuesChanged
= true;
484 rPresSettings
.mbAlwaysOnTop
= bVal
;
489 case ATTR_PRESENT_NAVIGATOR
:
491 sal_Bool bVal
= sal_False
;
493 if( aValue
>>= bVal
)
495 bIllegalArgument
= false;
497 if( rPresSettings
.mbStartWithNavigator
!= bVal
)
499 bValuesChanged
= true;
500 rPresSettings
.mbStartWithNavigator
= bVal
;
505 case ATTR_PRESENT_PEN
:
507 sal_Bool bVal
= sal_False
;
509 if( aValue
>>= bVal
)
511 bIllegalArgument
= false;
513 if(rPresSettings
.mbMouseAsPen
!= bVal
)
515 bValuesChanged
= true;
516 rPresSettings
.mbMouseAsPen
= bVal
;
521 case ATTR_PRESENT_PAUSE_TIMEOUT
:
523 sal_Int32 nValue
= 0;
524 if( (aValue
>>= nValue
) && (nValue
>= 0) )
526 bIllegalArgument
= false;
527 if( rPresSettings
.mnPauseTimeout
!= nValue
)
529 bValuesChanged
= true;
530 rPresSettings
.mnPauseTimeout
= nValue
;
535 case ATTR_PRESENT_SHOW_PAUSELOGO
:
537 sal_Bool bVal
= sal_False
;
539 if( aValue
>>= bVal
)
541 bIllegalArgument
= false;
543 if( rPresSettings
.mbShowPauseLogo
!= bVal
)
545 bValuesChanged
= true;
546 rPresSettings
.mbShowPauseLogo
= bVal
;
551 case ATTR_PRESENT_DISPLAY
:
553 sal_Int32 nDisplay
= 0;
554 if( aValue
>>= nDisplay
)
556 bIllegalArgument
= false;
558 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
559 pOptions
->SetDisplay( nDisplay
);
565 throw UnknownPropertyException();
568 if( bIllegalArgument
)
569 throw IllegalArgumentException();
572 mpDoc
->SetChanged( true );
575 // --------------------------------------------------------------------
577 Any SAL_CALL
SlideShow::getPropertyValue( const OUString
& PropertyName
) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
579 OGuard
aGuard( Application::GetSolarMutex() );
582 const sd::PresentationSettings
& rPresSettings
= mpDoc
->getPresentationSettings();
584 const SfxItemPropertySimpleEntry
* pEntry
= maPropSet
.getPropertyMapEntry(PropertyName
);
586 switch( pEntry
? pEntry
->nWID
: -1 )
588 case ATTR_PRESENT_ALL
:
589 return Any( (sal_Bool
) ( !rPresSettings
.mbCustomShow
&& rPresSettings
.mbAll
) );
590 case ATTR_PRESENT_CHANGE_PAGE
:
591 return Any( (sal_Bool
) !rPresSettings
.mbLockedPages
);
592 case ATTR_PRESENT_ANIMATION_ALLOWED
:
593 return Any( rPresSettings
.mbAnimationAllowed
);
594 case ATTR_PRESENT_CUSTOMSHOW
:
596 List
* pList
= mpDoc
->GetCustomShowList(sal_False
);
597 SdCustomShow
* pShow
= (pList
&& rPresSettings
.mbCustomShow
)?(SdCustomShow
*)pList
->GetCurObject():NULL
;
601 aShowName
= pShow
->GetName();
603 return Any( aShowName
);
605 case ATTR_PRESENT_ENDLESS
:
606 return Any( rPresSettings
.mbEndless
);
607 case ATTR_PRESENT_FULLSCREEN
:
608 return Any( rPresSettings
.mbFullScreen
);
609 case ATTR_PRESENT_DIANAME
:
613 if( !rPresSettings
.mbCustomShow
&& !rPresSettings
.mbAll
)
614 aSlideName
= getPageApiNameFromUiName( rPresSettings
.maPresPage
);
616 return Any( aSlideName
);
618 case ATTR_PRESENT_MANUEL
:
619 return Any( rPresSettings
.mbManual
);
620 case ATTR_PRESENT_MOUSE
:
621 return Any( rPresSettings
.mbMouseVisible
);
622 case ATTR_PRESENT_ALWAYS_ON_TOP
:
623 return Any( rPresSettings
.mbAlwaysOnTop
);
624 case ATTR_PRESENT_NAVIGATOR
:
625 return Any( rPresSettings
.mbStartWithNavigator
);
626 case ATTR_PRESENT_PEN
:
627 return Any( rPresSettings
.mbMouseAsPen
);
628 case ATTR_PRESENT_PAUSE_TIMEOUT
:
629 return Any( rPresSettings
.mnPauseTimeout
);
630 case ATTR_PRESENT_SHOW_PAUSELOGO
:
631 return Any( rPresSettings
.mbShowPauseLogo
);
632 case ATTR_PRESENT_DISPLAY
:
634 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
635 return Any( pOptions
->GetDisplay() );
639 throw UnknownPropertyException();
643 // --------------------------------------------------------------------
645 void SAL_CALL
SlideShow::addPropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
649 // --------------------------------------------------------------------
651 void SAL_CALL
SlideShow::removePropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
655 // --------------------------------------------------------------------
657 void SAL_CALL
SlideShow::addVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
661 // --------------------------------------------------------------------
663 void SAL_CALL
SlideShow::removeVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
667 // --------------------------------------------------------------------
669 // --------------------------------------------------------------------
671 void SAL_CALL
SlideShow::start() throw(RuntimeException
)
673 const Sequence
< PropertyValue
> aArguments
;
674 startWithArguments( aArguments
);
677 // --------------------------------------------------------------------
679 void SAL_CALL
SlideShow::end() throw(RuntimeException
)
681 OGuard
aGuard( Application::GetSolarMutex() );
683 // The mbIsInStartup flag should have been reset during the start of the
684 // slide show. Reset it here just in case that something has horribly
686 OSL_ASSERT(!mbIsInStartup
);
687 mbIsInStartup
= false;
689 rtl::Reference
< SlideshowImpl
> xController( mxController
);
690 if( xController
.is() )
692 mxController
.clear();
694 if( mpFullScreenFrameView
)
696 delete mpFullScreenFrameView
;
697 mpFullScreenFrameView
= 0;
700 ViewShellBase
* pFullScreenViewShellBase
= mpFullScreenViewShellBase
;
701 mpFullScreenViewShellBase
= 0;
703 if( pFullScreenViewShellBase
)
705 PresentationViewShell
* pShell
= dynamic_cast<PresentationViewShell
*>(pFullScreenViewShellBase
->GetMainViewShell().get());
707 if( pShell
&& pShell
->GetViewFrame() )
709 WorkWindow
* pWorkWindow
= dynamic_cast<WorkWindow
*>(pShell
->GetViewFrame()->GetTopFrame().GetWindow().GetParent());
712 pWorkWindow
->StartPresentationMode( sal_False
, isAlwaysOnTop() );
717 xController
->dispose();
719 if( pFullScreenViewShellBase
)
721 PresentationViewShell
* pShell
= NULL
;
723 // Get the shell pointer in its own scope to be sure that
724 // the shared_ptr to the shell is released before DoClose()
726 ::boost::shared_ptr
<ViewShell
> pSharedView (pFullScreenViewShellBase
->GetMainViewShell());
727 pShell
= dynamic_cast<PresentationViewShell
*>(pSharedView
.get());
729 if( pShell
&& pShell
->GetViewFrame() )
730 pShell
->GetViewFrame()->DoClose();
732 else if( mpCurrentViewShellBase
)
734 ViewShell
* pViewShell
= mpCurrentViewShellBase
->GetMainViewShell().get();
738 FrameView
* pFrameView
= pViewShell
->GetFrameView();
740 if( pFrameView
&& (pFrameView
->GetPresentationViewShellId() != SID_VIEWSHELL0
) )
742 ViewShell::ShellType
ePreviousType (pFrameView
->GetPreviousViewShellType());
743 pFrameView
->SetPreviousViewShellType(ViewShell::ST_NONE
);
745 pFrameView
->SetPresentationViewShellId(SID_VIEWSHELL0
);
746 pFrameView
->SetSlotId(SID_OBJECT_SELECT
);
747 pFrameView
->SetPreviousViewShellType(pViewShell
->GetShellType());
749 framework::FrameworkHelper::Instance(*mpCurrentViewShellBase
)->RequestView(
750 framework::FrameworkHelper::GetViewURL(ePreviousType
),
751 framework::FrameworkHelper::msCenterPaneURL
);
753 pViewShell
->GetViewFrame()->GetBindings().InvalidateAll( sal_True
);
758 if( mpCurrentViewShellBase
)
760 ViewShell
* pViewShell
= mpCurrentViewShellBase
->GetMainViewShell().get();
763 // invalidate the view shell so the presentation slot will be re-enabled
764 // and the rehersing will be updated
765 pViewShell
->Invalidate();
767 if( xController
->meAnimationMode
==ANIMATIONMODE_SHOW
)
769 // switch to the previously visible Slide
770 DrawViewShell
* pDrawViewShell
= dynamic_cast<DrawViewShell
*>( pViewShell
);
772 pDrawViewShell
->SwitchPage( (sal_uInt16
)xController
->getRestoreSlide() );
775 Reference
<XDrawView
> xDrawView (
776 Reference
<XWeak
>(&mpCurrentViewShellBase
->GetDrawController()), UNO_QUERY
);
778 xDrawView
->setCurrentPage(
779 Reference
<XDrawPage
>(
780 mpDoc
->GetSdPage(xController
->getRestoreSlide(), PK_STANDARD
)->getUnoPage(),
786 mpCurrentViewShellBase
= 0;
790 // --------------------------------------------------------------------
792 void SAL_CALL
SlideShow::rehearseTimings() throw(RuntimeException
)
794 Sequence
< PropertyValue
> aArguments(1);
795 aArguments
[0].Name
= C2U("RehearseTimings");
796 aArguments
[0].Value
<<= sal_True
;
797 startWithArguments( aArguments
);
800 // --------------------------------------------------------------------
802 // --------------------------------------------------------------------
804 void SAL_CALL
SlideShow::startWithArguments( const Sequence
< PropertyValue
>& rArguments
) throw (RuntimeException
)
806 OGuard
aGuard( Application::GetSolarMutex() );
809 // Stop a running show before starting a new one.
810 if( mxController
.is() )
812 OSL_ASSERT(!mbIsInStartup
);
815 else if (mbIsInStartup
)
817 // We are already somewhere in process of starting a slide show but
818 // have not yet got to the point where mxController is set. There
819 // is not yet a slide show to end so return silently.
823 // Prevent multiple instance of the SlideShow class for one document.
824 mbIsInStartup
= true;
826 mxCurrentSettings
.reset( new PresentationSettingsEx( mpDoc
->getPresentationSettings() ) );
827 mxCurrentSettings
->SetArguments( rArguments
);
829 // if there is no view shell base set, use the current one or the first using this document
830 if( mpCurrentViewShellBase
== 0 )
832 // first check current
833 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( SfxViewFrame::Current() );
834 if( pBase
&& pBase
->GetDocument() == mpDoc
)
836 mpCurrentViewShellBase
= pBase
;
840 // current is not ours, so get first from ours
841 mpCurrentViewShellBase
= ::sd::ViewShellBase::GetViewShellBase( SfxViewFrame::GetFirst( mpDoc
->GetDocSh() ) );
845 // Start either a full-screen or an in-place show.
846 if(mxCurrentSettings
->mbFullScreen
&& !mxCurrentSettings
->mbPreview
)
847 StartFullscreenPresentation();
849 StartInPlacePresentation();
852 // --------------------------------------------------------------------
854 ::sal_Bool SAL_CALL
SlideShow::isRunning( ) throw (RuntimeException
)
856 OGuard
aGuard( Application::GetSolarMutex() );
857 return mxController
.is() && mxController
->isRunning();
860 // --------------------------------------------------------------------
862 Reference
< XSlideShowController
> SAL_CALL
SlideShow::getController( ) throw (RuntimeException
)
866 Reference
< XSlideShowController
> xController( mxController
.get() );
870 // --------------------------------------------------------------------
872 // --------------------------------------------------------------------
874 void SAL_CALL
SlideShow::disposing (void)
876 OGuard
aGuard( Application::GetSolarMutex() );
878 if( mnInPlaceConfigEvent
)
880 Application::RemoveUserEvent( mnInPlaceConfigEvent
);
881 mnInPlaceConfigEvent
= 0;
884 if( mxController
.is() )
886 mxController
->dispose();
887 mxController
.clear();
890 mpCurrentViewShellBase
= 0;
891 mpFullScreenViewShellBase
= 0;
895 // ---------------------------------------------------------
897 bool SlideShow::startPreview( const Reference
< XDrawPage
>& xDrawPage
, const Reference
< XAnimationNode
>& xAnimationNode
, ::Window
* pParent
)
899 Sequence
< PropertyValue
> aArguments(4);
901 aArguments
[0].Name
= C2U("Preview");
902 aArguments
[0].Value
<<= sal_True
;
904 aArguments
[1].Name
= C2U("FirstPage");
905 aArguments
[1].Value
<<= xDrawPage
;
907 aArguments
[2].Name
= C2U("AnimationNode");
908 aArguments
[2].Value
<<= xAnimationNode
;
910 Reference
< XWindow
> xParentWindow
;
912 xParentWindow
= VCLUnoHelper::GetInterface( pParent
);
914 aArguments
[3].Name
= C2U("ParentWindow");
915 aArguments
[3].Value
<<= xParentWindow
;
917 startWithArguments( aArguments
);
922 // ---------------------------------------------------------
924 ShowWindow
* SlideShow::getShowWindow()
926 return mxController
.is() ? mxController
->mpShowWindow
: 0;
929 // ---------------------------------------------------------
931 int SlideShow::getAnimationMode()
933 return mxController
.is() ? mxController
->meAnimationMode
: ANIMATIONMODE_SHOW
;
936 // ---------------------------------------------------------
938 void SlideShow::jumpToPageIndex( sal_Int32 nPageIndex
)
940 if( mxController
.is() )
941 mxController
->displaySlideIndex( nPageIndex
);
944 // ---------------------------------------------------------
946 void SlideShow::jumpToPageNumber( sal_Int32 nPageNumber
)
948 if( mxController
.is() )
949 mxController
->displaySlideNumber( nPageNumber
);
952 // ---------------------------------------------------------
954 sal_Int32
SlideShow::getCurrentPageNumber()
956 return mxController
.is() ? mxController
->getCurrentSlideNumber() : 0;
959 // ---------------------------------------------------------
961 void SlideShow::jumpToBookmark( const OUString
& sBookmark
)
963 if( mxController
.is() )
964 mxController
->jumpToBookmark( sBookmark
);
967 // ---------------------------------------------------------
969 bool SlideShow::isFullScreen()
971 return mxController
.is() ? mxController
->maPresSettings
.mbFullScreen
: false;
974 // ---------------------------------------------------------
976 void SlideShow::resize( const Size
&rSize
)
978 if( mxController
.is() )
979 mxController
->resize( rSize
);
982 // ---------------------------------------------------------
984 void SlideShow::activate( ViewShellBase
& rBase
)
986 if( (mpFullScreenViewShellBase
== &rBase
) && !mxController
.is() )
988 ::boost::shared_ptr
<PresentationViewShell
> pShell
= ::boost::dynamic_pointer_cast
<PresentationViewShell
>(rBase
.GetMainViewShell());
989 if(pShell
.get() != NULL
)
991 pShell
->FinishInitialization( mpFullScreenFrameView
);
992 mpFullScreenFrameView
= 0;
994 CreateController( pShell
.get(), pShell
->GetView(), rBase
.GetViewWindow() );
996 if( mxController
->startShow(mxCurrentSettings
.get()) )
1008 if( mxController
.is() )
1009 mxController
->activate();
1012 // ---------------------------------------------------------
1014 void SlideShow::deactivate( ViewShellBase
& /*rBase*/ )
1016 mxController
->deactivate();
1019 // ---------------------------------------------------------
1021 bool SlideShow::keyInput(const KeyEvent
& rKEvt
)
1023 return mxController
.is() ? mxController
->keyInput(rKEvt
) : false;
1026 // ---------------------------------------------------------
1028 void SlideShow::paint( const Rectangle
& rRect
)
1030 if( mxController
.is() )
1031 mxController
->paint( rRect
);
1034 // ---------------------------------------------------------
1036 bool SlideShow::isAlwaysOnTop()
1038 return mxController
.is() ? mxController
->maPresSettings
.mbAlwaysOnTop
: false;
1041 // ---------------------------------------------------------
1043 bool SlideShow::pause( bool bPause
)
1045 if( mxController
.is() )
1048 mxController
->pause();
1050 mxController
->resume();
1055 // ---------------------------------------------------------
1057 void SlideShow::receiveRequest(SfxRequest
& rReq
)
1059 if( mxController
.is() )
1060 mxController
->receiveRequest( rReq
);
1063 // ---------------------------------------------------------
1065 sal_Int32
SlideShow::getFirstPageNumber()
1067 return mxController
.is() ? mxController
->getFirstSlideNumber() : 0;
1070 // ---------------------------------------------------------
1072 sal_Int32
SlideShow::getLastPageNumber()
1074 return mxController
.is() ? mxController
->getLastSlideNumber() : 0;
1077 // ---------------------------------------------------------
1079 bool SlideShow::isEndless()
1081 return mxController
.is() ? mxController
->isEndless() : false;
1084 // ---------------------------------------------------------
1086 bool SlideShow::isDrawingPossible()
1088 return mxController
.is() ? mxController
->getUsePen() : false;
1091 // ---------------------------------------------------------
1093 void SlideShow::StartInPlacePresentationConfigurationCallback()
1095 if( mnInPlaceConfigEvent
!= 0 )
1096 Application::RemoveUserEvent( mnInPlaceConfigEvent
);
1098 mnInPlaceConfigEvent
= Application::PostUserEvent( LINK( this, SlideShow
, StartInPlacePresentationConfigurationHdl
) );
1101 // ---------------------------------------------------------
1103 IMPL_LINK( SlideShow
, StartInPlacePresentationConfigurationHdl
, void *, EMPTYARG
)
1105 mnInPlaceConfigEvent
= 0;
1106 StartInPlacePresentation();
1110 // ---------------------------------------------------------
1112 void SlideShow::StartInPlacePresentation()
1114 if( mpCurrentViewShellBase
)
1116 // Save the current view shell type so that it can be restored after the
1117 // show has ended. If there already is a saved shell type then that is
1120 ViewShell::ShellType eShell
= ViewShell::ST_NONE
;
1122 ::boost::shared_ptr
<FrameworkHelper
> pHelper(FrameworkHelper::Instance(*mpCurrentViewShellBase
));
1123 ::boost::shared_ptr
<ViewShell
> pMainViewShell(pHelper
->GetViewShell(FrameworkHelper::msCenterPaneURL
));
1125 if( pMainViewShell
.get() )
1126 eShell
= pMainViewShell
->GetShellType();
1128 if( eShell
!= ViewShell::ST_IMPRESS
)
1130 // Switch temporary to a DrawViewShell which supports the in-place presentation.
1132 if( pMainViewShell
.get() )
1134 FrameView
* pFrameView
= pMainViewShell
->GetFrameView();
1135 pFrameView
->SetPresentationViewShellId(SID_VIEWSHELL1
);
1136 pFrameView
->SetPreviousViewShellType (pMainViewShell
->GetShellType());
1137 pFrameView
->SetPageKind (PK_STANDARD
);
1140 pHelper
->RequestView( FrameworkHelper::msImpressViewURL
, FrameworkHelper::msCenterPaneURL
);
1141 pHelper
->RunOnConfigurationEvent( FrameworkHelper::msConfigurationUpdateEndEvent
, ::boost::bind(&SlideShow::StartInPlacePresentationConfigurationCallback
, this) );
1146 ::Window
* pParentWindow
= mxCurrentSettings
->mpParentWindow
;
1147 if( pParentWindow
== 0 )
1148 pParentWindow
= mpCurrentViewShellBase
->GetViewWindow();
1150 CreateController( pMainViewShell
.get(), pMainViewShell
->GetView(), pParentWindow
);
1153 else if( mxCurrentSettings
->mpParentWindow
)
1155 // no current view shell, but parent window
1156 CreateController( 0, 0, mxCurrentSettings
->mpParentWindow
);
1159 if( mxController
.is() )
1161 sal_Bool bSuccess
= sal_False
;
1162 if( mxCurrentSettings
.get() && mxCurrentSettings
->mbPreview
)
1164 bSuccess
= mxController
->startPreview(mxCurrentSettings
->mxStartPage
, mxCurrentSettings
->mxAnimationNode
, mxCurrentSettings
->mpParentWindow
);
1168 bSuccess
= mxController
->startShow(mxCurrentSettings
.get());
1176 // ---------------------------------------------------------
1178 void SlideShow::StartFullscreenPresentation( )
1180 // Create the top level window in which the PresentationViewShell(Base)
1181 // will be created. This is done here explicitly so that we can make it
1183 const sal_Int32
nDisplay (GetDisplay());
1184 WorkWindow
* pWorkWindow
= new FullScreenWorkWindow(this, mpCurrentViewShellBase
);
1185 pWorkWindow
->SetBackground(Wallpaper(COL_BLACK
));
1186 pWorkWindow
->StartPresentationMode( sal_True
, mpDoc
->getPresentationSettings().mbAlwaysOnTop
? PRESENTATION_HIDEALLAPPS
: 0, nDisplay
);
1187 // pWorkWindow->ShowFullScreenMode(sal_False, nDisplay);
1189 if (pWorkWindow
->IsVisible())
1191 // Initialize the new presentation view shell with a copy of the
1192 // frame view of the current view shell. This avoids that
1193 // changes made by the presentation have an effect on the other
1195 FrameView
* pOriginalFrameView
= mpCurrentViewShellBase
? mpCurrentViewShellBase
->GetMainViewShell()->GetFrameView() : 0;
1197 if( mpFullScreenFrameView
)
1198 delete mpFullScreenFrameView
;
1199 mpFullScreenFrameView
= new FrameView(mpDoc
, pOriginalFrameView
);
1201 // Reference<XController> xController;
1203 // The new frame is created hidden. To make it visible and activate the
1204 // new view shell--a prerequisite to process slot calls and initialize
1205 // its panes--a GrabFocus() has to be called later on.
1206 SfxFrame
* pNewFrame
= SfxFrame::Create( *mpDoc
->GetDocSh(), *pWorkWindow
, PRESENTATION_FACTORY_ID
, true );
1207 pNewFrame
->SetPresentationMode(sal_True
);
1209 mpFullScreenViewShellBase
= static_cast<ViewShellBase
*>(pNewFrame
->GetCurrentViewFrame()->GetViewShell());
1210 if(mpFullScreenViewShellBase
!= NULL
)
1212 // The following GrabFocus() is responsible for activating the
1213 // new view shell. Without it the screen remains blank (under
1214 // Windows and some Linux variants.)
1215 mpFullScreenViewShellBase
->GetWindow()->GrabFocus();
1220 // ---------------------------------------------------------
1222 sal_Int32
SlideShow::GetDisplay()
1225 sal_Int32 nDisplay
= 0;
1227 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
1229 nDisplay
= pOptions
->GetDisplay();
1235 Reference
<XMultiServiceFactory
> xFactory(
1236 ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW
);
1237 Reference
<XPropertySet
> xMonitorProperties(
1238 xFactory
->createInstance(
1239 OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess"))),
1241 const OUString
sPropertyName (RTL_CONSTASCII_USTRINGPARAM("DefaultDisplay"));
1242 xMonitorProperties
->getPropertyValue(sPropertyName
) >>= nDisplay
;
1256 // ---------------------------------------------------------
1259 bool SlideShow::dependsOn( ViewShellBase
* pViewShellBase
)
1261 return mxController
.is() && (pViewShellBase
== mpCurrentViewShellBase
) && mpFullScreenViewShellBase
;
1264 // ---------------------------------------------------------
1266 Reference
< XPresentation2
> CreatePresentation( const SdDrawDocument
& rDocument
)
1268 return Reference
< XPresentation2
>( SlideShow::Create( const_cast< SdDrawDocument
* >( &rDocument
) ).get() );
1271 // ---------------------------------------------------------