1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/beans/PropertyAttribute.hpp>
21 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
22 #include <com/sun/star/container/XIndexAccess.hpp>
23 #include <com/sun/star/frame/XDispatchProvider.hpp>
24 #include <com/sun/star/util/URL.hpp>
26 #include <cppuhelper/bootstrap.hxx>
27 #include <cppuhelper/supportsservice.hxx>
29 #include <osl/mutex.hxx>
31 #include <vcl/svapp.hxx>
32 #include <vcl/wrkwin.hxx>
33 #include <svx/svdpool.hxx>
34 #include <svl/itemprop.hxx>
36 #include <sfx2/viewfrm.hxx>
38 #include <toolkit/helper/vclunohelper.hxx>
39 #include <svx/unoprov.hxx>
41 #include "framework/FrameworkHelper.hxx"
43 #include "FrameView.hxx"
44 #include "createpresentation.hxx"
45 #include "unomodel.hxx"
46 #include "slideshow.hxx"
47 #include "slideshowimpl.hxx"
49 #include "FactoryIds.hxx"
50 #include "ViewShell.hxx"
51 #include "SlideShowRestarter.hxx"
52 #include "DrawController.hxx"
53 #include "customshowlist.hxx"
54 #include <boost/bind.hpp>
55 #include "unopage.hxx"
57 using ::com::sun::star::presentation::XSlideShowController
;
58 using ::com::sun::star::container::XIndexAccess
;
59 using ::sd::framework::FrameworkHelper
;
60 using ::com::sun::star::awt::XWindow
;
62 using namespace ::cppu
;
63 using namespace ::com::sun::star
;
64 using namespace ::com::sun::star::uno
;
65 using namespace ::com::sun::star::drawing
;
66 using namespace ::com::sun::star::beans
;
67 using namespace ::com::sun::star::lang
;
68 using namespace ::com::sun::star::animations
;
69 using namespace ::com::sun::star::drawing::framework
;
72 /** This local version of the work window overrides DataChanged() so that it
73 can restart the slide show when a display is added or removed.
75 class FullScreenWorkWindow
: public WorkWindow
78 FullScreenWorkWindow (
79 const ::rtl::Reference
<SlideShow
>& rpSlideShow
,
80 ViewShellBase
* pViewShellBase
)
81 : WorkWindow(NULL
, WB_HIDE
| WB_CLIPCHILDREN
),
82 mpRestarter(new SlideShowRestarter(rpSlideShow
, pViewShellBase
))
85 void Restart(bool bForce
)
87 mpRestarter
->Restart(bForce
);
90 virtual void DataChanged (const DataChangedEvent
& rEvent
) SAL_OVERRIDE
92 if (rEvent
.GetType() == DataChangedEventType::DISPLAY
)
97 ::boost::shared_ptr
<SlideShowRestarter
> mpRestarter
;
101 const SfxItemPropertyMapEntry
* ImplGetPresentationPropertyMap()
103 // NOTE: First member must be sorted
104 static const SfxItemPropertyMapEntry aPresentationPropertyMap_Impl
[] =
106 { OUString("AllowAnimations"), ATTR_PRESENT_ANIMATION_ALLOWED
, cppu::UnoType
<bool>::get(), 0, 0 },
107 { OUString("CustomShow"), ATTR_PRESENT_CUSTOMSHOW
, ::cppu::UnoType
<OUString
>::get(), 0, 0 },
108 { OUString("Display"), ATTR_PRESENT_DISPLAY
, ::cppu::UnoType
<sal_Int32
>::get(), 0, 0 },
109 { OUString("FirstPage"), ATTR_PRESENT_DIANAME
, ::cppu::UnoType
<OUString
>::get(), 0, 0 },
110 { OUString("IsAlwaysOnTop"), ATTR_PRESENT_ALWAYS_ON_TOP
, cppu::UnoType
<bool>::get(), 0, 0 },
111 { OUString("IsAutomatic"), ATTR_PRESENT_MANUEL
, cppu::UnoType
<bool>::get(), 0, 0 },
112 { OUString("IsEndless"), ATTR_PRESENT_ENDLESS
, cppu::UnoType
<bool>::get(), 0, 0 },
113 { OUString("IsFullScreen"), ATTR_PRESENT_FULLSCREEN
, cppu::UnoType
<bool>::get(), 0, 0 },
114 { OUString("IsShowAll"), ATTR_PRESENT_ALL
, cppu::UnoType
<bool>::get(), 0, 0 },
115 { OUString("IsMouseVisible"), ATTR_PRESENT_MOUSE
, cppu::UnoType
<bool>::get(), 0, 0 },
116 { OUString("IsShowLogo"), ATTR_PRESENT_SHOW_PAUSELOGO
, cppu::UnoType
<bool>::get(), 0, 0 },
117 { OUString("IsTransitionOnClick"), ATTR_PRESENT_CHANGE_PAGE
, cppu::UnoType
<bool>::get(), 0, 0 },
118 { OUString("Pause"), ATTR_PRESENT_PAUSE_TIMEOUT
, ::cppu::UnoType
<sal_Int32
>::get(), 0, 0 },
119 { OUString("StartWithNavigator"), ATTR_PRESENT_NAVIGATOR
, cppu::UnoType
<bool>::get(), 0, 0 },
120 { OUString("UsePen"), ATTR_PRESENT_PEN
, cppu::UnoType
<bool>::get(), 0, 0 },
121 { OUString(), 0, css::uno::Type(), 0, 0 }
124 return aPresentationPropertyMap_Impl
;
129 SlideShow::SlideShow( SdDrawDocument
* pDoc
)
130 : SlideshowBase( m_aMutex
)
131 , maPropSet(ImplGetPresentationPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool())
132 , mbIsInStartup(false)
134 , mpCurrentViewShellBase( 0 )
135 , mpFullScreenViewShellBase( 0 )
136 , mpFullScreenFrameView( 0 )
137 , mnInPlaceConfigEvent( 0 )
141 void SlideShow::ThrowIfDisposed() const throw (RuntimeException
)
144 throw DisposedException();
147 /// used by the model to create a slideshow for it
148 rtl::Reference
< SlideShow
> SlideShow::Create( SdDrawDocument
* pDoc
)
150 return new SlideShow( pDoc
);
153 rtl::Reference
< SlideShow
> SlideShow::GetSlideShow( SdDrawDocument
* pDocument
)
155 rtl::Reference
< SlideShow
> xRet
;
158 xRet
= GetSlideShow( *pDocument
);
163 rtl::Reference
< SlideShow
> SlideShow::GetSlideShow( SdDrawDocument
& rDocument
)
165 return rtl::Reference
< SlideShow
>(
166 dynamic_cast< SlideShow
* >( rDocument
.getPresentation().get() ) );
169 rtl::Reference
< SlideShow
> SlideShow::GetSlideShow( ViewShellBase
& rBase
)
171 return GetSlideShow( rBase
.GetDocument() );
174 ::com::sun::star::uno::Reference
< ::com::sun::star::presentation::XSlideShowController
> SlideShow::GetSlideShowController(ViewShellBase
& rBase
)
176 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
178 Reference
< XSlideShowController
> xRet
;
179 if( xSlideShow
.is() )
180 xRet
= xSlideShow
->getController();
185 bool SlideShow::StartPreview( ViewShellBase
& rBase
,
186 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& xDrawPage
,
187 const ::com::sun::star::uno::Reference
< ::com::sun::star::animations::XAnimationNode
>& xAnimationNode
,
188 vcl::Window
* pParent
/* = 0 */ )
190 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
191 if( xSlideShow
.is() )
192 return xSlideShow
->startPreview( xDrawPage
, xAnimationNode
, pParent
);
197 void SlideShow::Stop( ViewShellBase
& rBase
)
199 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
200 if( xSlideShow
.is() )
204 bool SlideShow::IsRunning( ViewShellBase
& rBase
)
206 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rBase
) );
207 return xSlideShow
.is() && xSlideShow
->isRunning();
210 bool SlideShow::IsRunning( ViewShell
& rViewShell
)
212 rtl::Reference
< SlideShow
> xSlideShow( GetSlideShow( rViewShell
.GetViewShellBase() ) );
213 return xSlideShow
.is() && xSlideShow
->isRunning() && (xSlideShow
->mxController
->getViewShell() == &rViewShell
);
216 void SlideShow::CreateController( ViewShell
* pViewSh
, ::sd::View
* pView
, vcl::Window
* pParentWindow
)
218 DBG_ASSERT( !mxController
.is(), "sd::SlideShow::CreateController(), clean up old controller first!" );
220 Reference
< XPresentation2
> xThis( this );
222 rtl::Reference
<SlideshowImpl
> xController (
223 new SlideshowImpl(xThis
, pViewSh
, pView
, mpDoc
, pParentWindow
));
225 // Reset mbIsInStartup. From here mxController.is() is used to prevent
226 // multiple slide show instances for one document.
227 mxController
= xController
;
228 mbIsInStartup
= false;
233 OUString SAL_CALL
SlideShow::getImplementationName( ) throw(RuntimeException
, std::exception
)
235 return OUString( "com.sun.star.comp.sd.SlideShow" );
238 sal_Bool SAL_CALL
SlideShow::supportsService( const OUString
& ServiceName
) throw(RuntimeException
, std::exception
)
240 return cppu::supportsService( this, ServiceName
);
243 Sequence
< OUString
> SAL_CALL
SlideShow::getSupportedServiceNames( ) throw(RuntimeException
, std::exception
)
245 OUString
aService( "com.sun.star.presentation.Presentation" );
246 Sequence
< OUString
> aSeq( &aService
, 1 );
251 Reference
< XPropertySetInfo
> SAL_CALL
SlideShow::getPropertySetInfo() throw(RuntimeException
, std::exception
)
253 SolarMutexGuard aGuard
;
254 static Reference
< XPropertySetInfo
> xInfo
= maPropSet
.getPropertySetInfo();
258 void SAL_CALL
SlideShow::setPropertyValue( const OUString
& aPropertyName
, const Any
& aValue
) throw(UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
, std::exception
)
260 SolarMutexGuard aGuard
;
263 sd::PresentationSettings
& rPresSettings
= mpDoc
->getPresentationSettings();
265 const SfxItemPropertySimpleEntry
* pEntry
= maPropSet
.getPropertyMapEntry(aPropertyName
);
267 if( pEntry
&& ((pEntry
->nFlags
& PropertyAttribute::READONLY
) != 0) )
268 throw PropertyVetoException();
270 bool bValuesChanged
= false;
271 bool bIllegalArgument
= true;
273 switch( pEntry
? pEntry
->nWID
: -1 )
275 case ATTR_PRESENT_ALL
:
279 if( aValue
>>= bVal
)
281 bIllegalArgument
= false;
283 if( rPresSettings
.mbAll
!= bVal
)
285 rPresSettings
.mbAll
= bVal
;
286 bValuesChanged
= true;
288 rPresSettings
.mbCustomShow
= false;
293 case ATTR_PRESENT_CHANGE_PAGE
:
297 if( aValue
>>= bVal
)
299 bIllegalArgument
= false;
301 if( bVal
== rPresSettings
.mbLockedPages
)
303 bValuesChanged
= true;
304 rPresSettings
.mbLockedPages
= !bVal
;
310 case ATTR_PRESENT_ANIMATION_ALLOWED
:
314 if( aValue
>>= bVal
)
316 bIllegalArgument
= false;
318 if(rPresSettings
.mbAnimationAllowed
!= bVal
)
320 bValuesChanged
= true;
321 rPresSettings
.mbAnimationAllowed
= bVal
;
326 case ATTR_PRESENT_CUSTOMSHOW
:
329 if( aValue
>>= aShow
)
331 bIllegalArgument
= false;
333 const OUString
aShowName( aShow
);
335 SdCustomShowList
* pCustomShowList
= mpDoc
->GetCustomShowList(false);
338 SdCustomShow
* pCustomShow
;
339 for( pCustomShow
= pCustomShowList
->First(); pCustomShow
!= NULL
; pCustomShow
= pCustomShowList
->Next() )
341 if( pCustomShow
->GetName() == aShowName
)
345 rPresSettings
.mbCustomShow
= true;
346 bValuesChanged
= true;
351 case ATTR_PRESENT_ENDLESS
:
355 if( aValue
>>= bVal
)
357 bIllegalArgument
= false;
359 if( rPresSettings
.mbEndless
!= bVal
)
361 bValuesChanged
= true;
362 rPresSettings
.mbEndless
= bVal
;
367 case ATTR_PRESENT_FULLSCREEN
:
371 if( aValue
>>= bVal
)
373 bIllegalArgument
= false;
374 if( rPresSettings
.mbFullScreen
!= bVal
)
376 bValuesChanged
= true;
377 rPresSettings
.mbFullScreen
= bVal
;
382 case ATTR_PRESENT_DIANAME
:
385 aValue
>>= aPresPage
;
386 bIllegalArgument
= false;
387 if( (rPresSettings
.maPresPage
!= aPresPage
) || !rPresSettings
.mbCustomShow
|| !rPresSettings
.mbAll
)
389 bValuesChanged
= true;
390 rPresSettings
.maPresPage
= getUiNameFromPageApiNameImpl(aPresPage
);
391 rPresSettings
.mbCustomShow
= false;
392 rPresSettings
.mbAll
= false;
396 case ATTR_PRESENT_MANUEL
:
400 if( aValue
>>= bVal
)
402 bIllegalArgument
= false;
404 if( rPresSettings
.mbManual
!= bVal
)
406 bValuesChanged
= true;
407 rPresSettings
.mbManual
= bVal
;
412 case ATTR_PRESENT_MOUSE
:
416 if( aValue
>>= bVal
)
418 bIllegalArgument
= false;
419 if( rPresSettings
.mbMouseVisible
!= bVal
)
421 bValuesChanged
= true;
422 rPresSettings
.mbMouseVisible
= bVal
;
427 case ATTR_PRESENT_ALWAYS_ON_TOP
:
431 if( aValue
>>= bVal
)
433 bIllegalArgument
= false;
435 if( rPresSettings
.mbAlwaysOnTop
!= bVal
)
437 bValuesChanged
= true;
438 rPresSettings
.mbAlwaysOnTop
= bVal
;
443 case ATTR_PRESENT_NAVIGATOR
:
447 if( aValue
>>= bVal
)
449 bIllegalArgument
= false;
451 if( rPresSettings
.mbStartWithNavigator
!= bVal
)
453 bValuesChanged
= true;
454 rPresSettings
.mbStartWithNavigator
= bVal
;
459 case ATTR_PRESENT_PEN
:
463 if( aValue
>>= bVal
)
465 bIllegalArgument
= false;
467 if(rPresSettings
.mbMouseAsPen
!= bVal
)
469 bValuesChanged
= true;
470 rPresSettings
.mbMouseAsPen
= bVal
;
475 case ATTR_PRESENT_PAUSE_TIMEOUT
:
477 sal_Int32 nValue
= 0;
478 if( (aValue
>>= nValue
) && (nValue
>= 0) )
480 bIllegalArgument
= false;
481 if( rPresSettings
.mnPauseTimeout
!= nValue
)
483 bValuesChanged
= true;
484 rPresSettings
.mnPauseTimeout
= nValue
;
489 case ATTR_PRESENT_SHOW_PAUSELOGO
:
493 if( aValue
>>= bVal
)
495 bIllegalArgument
= false;
497 if( rPresSettings
.mbShowPauseLogo
!= bVal
)
499 bValuesChanged
= true;
500 rPresSettings
.mbShowPauseLogo
= bVal
;
505 case ATTR_PRESENT_DISPLAY
:
507 sal_Int32 nDisplay
= 0;
508 if( aValue
>>= nDisplay
)
510 bIllegalArgument
= false;
512 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
513 pOptions
->SetDisplay( nDisplay
);
515 FullScreenWorkWindow
*pWin
= dynamic_cast<FullScreenWorkWindow
*>(GetWorkWindow());
524 throw UnknownPropertyException();
527 if( bIllegalArgument
)
528 throw IllegalArgumentException();
531 mpDoc
->SetChanged( true );
534 Any SAL_CALL
SlideShow::getPropertyValue( const OUString
& PropertyName
) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
536 SolarMutexGuard aGuard
;
539 const sd::PresentationSettings
& rPresSettings
= mpDoc
->getPresentationSettings();
541 const SfxItemPropertySimpleEntry
* pEntry
= maPropSet
.getPropertyMapEntry(PropertyName
);
543 switch( pEntry
? pEntry
->nWID
: -1 )
545 case ATTR_PRESENT_ALL
:
546 return Any( !rPresSettings
.mbCustomShow
&& rPresSettings
.mbAll
);
547 case ATTR_PRESENT_CHANGE_PAGE
:
548 return Any( !rPresSettings
.mbLockedPages
);
549 case ATTR_PRESENT_ANIMATION_ALLOWED
:
550 return Any( rPresSettings
.mbAnimationAllowed
);
551 case ATTR_PRESENT_CUSTOMSHOW
:
553 SdCustomShowList
* pList
= mpDoc
->GetCustomShowList(false);
554 SdCustomShow
* pShow
= (pList
&& rPresSettings
.mbCustomShow
) ? pList
->GetCurObject() : NULL
;
558 aShowName
= pShow
->GetName();
560 return Any( aShowName
);
562 case ATTR_PRESENT_ENDLESS
:
563 return Any( rPresSettings
.mbEndless
);
564 case ATTR_PRESENT_FULLSCREEN
:
565 return Any( rPresSettings
.mbFullScreen
);
566 case ATTR_PRESENT_DIANAME
:
570 if( !rPresSettings
.mbCustomShow
&& !rPresSettings
.mbAll
)
571 aSlideName
= getPageApiNameFromUiName( rPresSettings
.maPresPage
);
573 return Any( aSlideName
);
575 case ATTR_PRESENT_MANUEL
:
576 return Any( rPresSettings
.mbManual
);
577 case ATTR_PRESENT_MOUSE
:
578 return Any( rPresSettings
.mbMouseVisible
);
579 case ATTR_PRESENT_ALWAYS_ON_TOP
:
580 return Any( rPresSettings
.mbAlwaysOnTop
);
581 case ATTR_PRESENT_NAVIGATOR
:
582 return Any( rPresSettings
.mbStartWithNavigator
);
583 case ATTR_PRESENT_PEN
:
584 return Any( rPresSettings
.mbMouseAsPen
);
585 case ATTR_PRESENT_PAUSE_TIMEOUT
:
586 return Any( rPresSettings
.mnPauseTimeout
);
587 case ATTR_PRESENT_SHOW_PAUSELOGO
:
588 return Any( rPresSettings
.mbShowPauseLogo
);
589 case ATTR_PRESENT_DISPLAY
:
591 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
592 return Any(pOptions
->GetDisplay());
596 throw UnknownPropertyException();
600 void SAL_CALL
SlideShow::addPropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
604 void SAL_CALL
SlideShow::removePropertyChangeListener( const OUString
& , const Reference
< XPropertyChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
608 void SAL_CALL
SlideShow::addVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
612 void SAL_CALL
SlideShow::removeVetoableChangeListener( const OUString
& , const Reference
< XVetoableChangeListener
>& ) throw(UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
618 void SAL_CALL
SlideShow::start() throw(RuntimeException
, std::exception
)
620 const Sequence
< PropertyValue
> aArguments
;
621 startWithArguments( aArguments
);
624 WorkWindow
*SlideShow::GetWorkWindow()
626 if( !mpFullScreenViewShellBase
)
629 PresentationViewShell
* pShell
= dynamic_cast<PresentationViewShell
*>(mpFullScreenViewShellBase
->GetMainViewShell().get());
631 if( !pShell
|| !pShell
->GetViewFrame() )
634 return dynamic_cast<WorkWindow
*>(pShell
->GetViewFrame()->GetTopFrame().GetWindow().GetParent());
637 bool SlideShow::IsExitAfterPresenting() const
639 SolarMutexGuard aGuard
;
641 return mpDoc
->IsExitAfterPresenting();
644 void SlideShow::SetExitAfterPresenting(bool bExit
)
646 SolarMutexGuard aGuard
;
648 mpDoc
->SetExitAfterPresenting(bExit
);
651 void SAL_CALL
SlideShow::end()
652 throw (RuntimeException
, std::exception
)
654 SolarMutexGuard aGuard
;
656 // The mbIsInStartup flag should have been reset during the start of the
657 // slide show. Reset it here just in case that something has horribly
659 OSL_ASSERT(!mbIsInStartup
);
660 mbIsInStartup
= false;
662 rtl::Reference
< SlideshowImpl
> xController( mxController
);
663 if( xController
.is() )
665 mxController
.clear();
667 if( mpFullScreenFrameView
)
669 delete mpFullScreenFrameView
;
670 mpFullScreenFrameView
= 0;
673 ViewShellBase
* pFullScreenViewShellBase
= mpFullScreenViewShellBase
;
674 mpFullScreenViewShellBase
= 0;
676 // dispose before fullscreen window changes screens
677 // (potentially). If this needs to be moved behind
678 // pWorkWindow->StartPresentationMode() again, read issue
679 // pWorkWindow->i94007 & implement the solution outlined
681 xController
->dispose();
683 if( pFullScreenViewShellBase
)
685 PresentationViewShell
* pShell
= dynamic_cast<PresentationViewShell
*>(pFullScreenViewShellBase
->GetMainViewShell().get());
687 if( pShell
&& pShell
->GetViewFrame() )
689 WorkWindow
* pWorkWindow
= dynamic_cast<WorkWindow
*>(pShell
->GetViewFrame()->GetTopFrame().GetWindow().GetParent());
692 pWorkWindow
->StartPresentationMode( false, isAlwaysOnTop() ? PRESENTATION_HIDEALLAPPS
: 0 );
697 if( pFullScreenViewShellBase
)
699 PresentationViewShell
* pShell
= NULL
;
701 // Get the shell pointer in its own scope to be sure that
702 // the shared_ptr to the shell is released before DoClose()
704 ::boost::shared_ptr
<ViewShell
> pSharedView (pFullScreenViewShellBase
->GetMainViewShell());
705 pShell
= dynamic_cast<PresentationViewShell
*>(pSharedView
.get());
707 if( pShell
&& pShell
->GetViewFrame() )
708 pShell
->GetViewFrame()->DoClose();
710 else if( mpCurrentViewShellBase
)
712 ViewShell
* pViewShell
= mpCurrentViewShellBase
->GetMainViewShell().get();
716 FrameView
* pFrameView
= pViewShell
->GetFrameView();
718 if( pFrameView
&& (pFrameView
->GetPresentationViewShellId() != SID_VIEWSHELL0
) )
720 ViewShell::ShellType
ePreviousType (pFrameView
->GetPreviousViewShellType());
721 pFrameView
->SetPreviousViewShellType(ViewShell::ST_NONE
);
723 pFrameView
->SetPresentationViewShellId(SID_VIEWSHELL0
);
724 pFrameView
->SetSlotId(SID_OBJECT_SELECT
);
725 pFrameView
->SetPreviousViewShellType(pViewShell
->GetShellType());
727 framework::FrameworkHelper::Instance(*mpCurrentViewShellBase
)->RequestView(
728 framework::FrameworkHelper::GetViewURL(ePreviousType
),
729 framework::FrameworkHelper::msCenterPaneURL
);
731 pViewShell
->GetViewFrame()->GetBindings().InvalidateAll( true );
736 if( mpCurrentViewShellBase
)
738 ViewShell
* pViewShell
= mpCurrentViewShellBase
->GetMainViewShell().get();
741 // invalidate the view shell so the presentation slot will be re-enabled
742 // and the rehersing will be updated
743 pViewShell
->Invalidate();
745 if( xController
->meAnimationMode
==ANIMATIONMODE_SHOW
)
747 // switch to the previously visible Slide
748 DrawViewShell
* pDrawViewShell
= dynamic_cast<DrawViewShell
*>( pViewShell
);
750 pDrawViewShell
->SwitchPage( (sal_uInt16
)xController
->getRestoreSlide() );
753 Reference
<XDrawView
> xDrawView (
754 Reference
<XWeak
>(&mpCurrentViewShellBase
->GetDrawController()), UNO_QUERY
);
756 xDrawView
->setCurrentPage(
757 Reference
<XDrawPage
>(
758 mpDoc
->GetSdPage(xController
->getRestoreSlide(), PK_STANDARD
)->getUnoPage(),
763 if( pViewShell
->GetDoc()->IsExitAfterPresenting() )
765 pViewShell
->GetDoc()->SetExitAfterPresenting( false );
767 Reference
<frame::XDispatchProvider
> xProvider(pViewShell
->GetViewShellBase().GetController()->getFrame(),
772 aURL
.Complete
= ".uno:CloseFrame";
774 uno::Reference
< frame::XDispatch
> xDispatch(
775 xProvider
->queryDispatch(
776 aURL
, OUString(), 0));
779 xDispatch
->dispatch(aURL
,
780 uno::Sequence
< beans::PropertyValue
>());
785 //Fire the acc focus event when focus is switched back. The above method mpCurrentViewShellBase->GetWindow()->GrabFocus() will
786 //set focus to WorkWindow instead of the sd::window, so here call Shell's method to fire the focus event
788 pViewShell
->SwitchActiveViewFireFocus();
790 mpCurrentViewShellBase
= 0;
794 void SAL_CALL
SlideShow::rehearseTimings() throw(RuntimeException
, std::exception
)
796 Sequence
< PropertyValue
> aArguments(1);
797 aArguments
[0].Name
= "RehearseTimings";
798 aArguments
[0].Value
<<= sal_True
;
799 startWithArguments( aArguments
);
804 void SAL_CALL
SlideShow::startWithArguments(const Sequence
< PropertyValue
>& rArguments
)
805 throw (RuntimeException
, std::exception
)
807 SolarMutexGuard aGuard
;
810 // Stop a running show before starting a new one.
811 if( mxController
.is() )
813 OSL_ASSERT(!mbIsInStartup
);
816 else if (mbIsInStartup
)
818 // We are already somewhere in process of starting a slide show but
819 // have not yet got to the point where mxController is set. There
820 // is not yet a slide show to end so return silently.
824 // Prevent multiple instance of the SlideShow class for one document.
825 mbIsInStartup
= true;
827 mxCurrentSettings
.reset( new PresentationSettingsEx( mpDoc
->getPresentationSettings() ) );
828 mxCurrentSettings
->SetArguments( rArguments
);
830 // if there is no view shell base set, use the current one or the first using this document
831 if( mpCurrentViewShellBase
== 0 )
833 // first check current
834 ::sd::ViewShellBase
* pBase
= ::sd::ViewShellBase::GetViewShellBase( SfxViewFrame::Current() );
835 if( pBase
&& pBase
->GetDocument() == mpDoc
)
837 mpCurrentViewShellBase
= pBase
;
841 // current is not ours, so get first from ours
842 mpCurrentViewShellBase
= ::sd::ViewShellBase::GetViewShellBase( SfxViewFrame::GetFirst( mpDoc
->GetDocSh() ) );
846 // #i118456# make sure TextEdit changes get pushed to model.
847 // mpDrawView is tested against NULL above already.
848 if(mpCurrentViewShellBase
)
850 ViewShell
* pViewShell
= mpCurrentViewShellBase
->GetMainViewShell().get();
852 if(pViewShell
&& pViewShell
->GetView())
854 pViewShell
->GetView()->SdrEndTextEdit();
858 // Start either a full-screen or an in-place show.
859 if(mxCurrentSettings
->mbFullScreen
&& !mxCurrentSettings
->mbPreview
)
860 StartFullscreenPresentation();
862 StartInPlacePresentation();
866 sal_Bool SAL_CALL
SlideShow::isRunning( ) throw (RuntimeException
, std::exception
)
868 SolarMutexGuard aGuard
;
869 return mxController
.is() && mxController
->isRunning();
872 Reference
< XSlideShowController
> SAL_CALL
SlideShow::getController( ) throw (RuntimeException
, std::exception
)
876 Reference
< XSlideShowController
> xController( mxController
.get() );
882 void SAL_CALL
SlideShow::disposing()
884 SolarMutexGuard aGuard
;
886 if( mnInPlaceConfigEvent
)
888 Application::RemoveUserEvent( mnInPlaceConfigEvent
);
889 mnInPlaceConfigEvent
= 0;
892 if( mxController
.is() )
894 mxController
->dispose();
895 mxController
.clear();
898 mpCurrentViewShellBase
= 0;
899 mpFullScreenViewShellBase
= 0;
903 bool SlideShow::startPreview( const Reference
< XDrawPage
>& xDrawPage
, const Reference
< XAnimationNode
>& xAnimationNode
, vcl::Window
* pParent
)
905 Sequence
< PropertyValue
> aArguments(4);
907 aArguments
[0].Name
= "Preview";
908 aArguments
[0].Value
<<= sal_True
;
910 aArguments
[1].Name
= "FirstPage";
911 aArguments
[1].Value
<<= xDrawPage
;
913 aArguments
[2].Name
= "AnimationNode";
914 aArguments
[2].Value
<<= xAnimationNode
;
916 Reference
< XWindow
> xParentWindow
;
918 xParentWindow
= VCLUnoHelper::GetInterface( pParent
);
920 aArguments
[3].Name
= "ParentWindow";
921 aArguments
[3].Value
<<= xParentWindow
;
923 startWithArguments( aArguments
);
928 OutputDevice
* SlideShow::getShowWindow()
930 return mxController
.is() ? mxController
->mpShowWindow
.get() : 0;
933 int SlideShow::getAnimationMode()
935 return mxController
.is() ? mxController
->meAnimationMode
: ANIMATIONMODE_SHOW
;
938 void SlideShow::jumpToPageIndex( sal_Int32 nPageIndex
)
940 if( mxController
.is() )
941 mxController
->displaySlideIndex( nPageIndex
);
944 void SlideShow::jumpToPageNumber( sal_Int32 nPageNumber
)
946 if( mxController
.is() )
947 mxController
->displaySlideNumber( nPageNumber
);
950 sal_Int32
SlideShow::getCurrentPageNumber()
952 return mxController
.is() ? mxController
->getCurrentSlideNumber() : 0;
955 void SlideShow::jumpToBookmark( const OUString
& sBookmark
)
957 if( mxController
.is() )
958 mxController
->jumpToBookmark( sBookmark
);
961 bool SlideShow::isFullScreen()
963 return mxController
.is() && mxController
->maPresSettings
.mbFullScreen
;
966 void SlideShow::resize( const Size
&rSize
)
968 if( mxController
.is() )
969 mxController
->resize( rSize
);
972 void SlideShow::activate( ViewShellBase
& rBase
)
974 if( (mpFullScreenViewShellBase
== &rBase
) && !mxController
.is() )
976 ::boost::shared_ptr
<PresentationViewShell
> pShell
= ::boost::dynamic_pointer_cast
<PresentationViewShell
>(rBase
.GetMainViewShell());
977 if(pShell
.get() != NULL
)
979 pShell
->FinishInitialization( mpFullScreenFrameView
);
980 mpFullScreenFrameView
= 0;
982 CreateController( pShell
.get(), pShell
->GetView(), rBase
.GetViewWindow() );
984 if( mxController
->startShow(mxCurrentSettings
.get()) )
987 // Defer the sd::ShowWindow's GrabFocus to here. so that the accessible event can be fired correctly.
988 pShell
->GetActiveWindow()->GrabFocus();
998 if( mxController
.is() )
999 mxController
->activate();
1003 void SlideShow::deactivate( ViewShellBase
& /*rBase*/ )
1005 mxController
->deactivate();
1008 bool SlideShow::keyInput(const KeyEvent
& rKEvt
)
1010 return mxController
.is() && mxController
->keyInput(rKEvt
);
1013 void SlideShow::paint( const Rectangle
& rRect
)
1015 if( mxController
.is() )
1016 mxController
->paint( rRect
);
1019 bool SlideShow::isAlwaysOnTop()
1021 return mxController
.is() && mxController
->maPresSettings
.mbAlwaysOnTop
;
1024 bool SlideShow::pause( bool bPause
)
1026 if( mxController
.is() )
1029 mxController
->pause();
1031 mxController
->resume();
1036 void SlideShow::receiveRequest(SfxRequest
& rReq
)
1038 if( mxController
.is() )
1039 mxController
->receiveRequest( rReq
);
1042 sal_Int32
SlideShow::getFirstPageNumber()
1044 return mxController
.is() ? mxController
->getFirstSlideNumber() : 0;
1047 sal_Int32
SlideShow::getLastPageNumber()
1049 return mxController
.is() ? mxController
->getLastSlideNumber() : 0;
1052 bool SlideShow::isEndless()
1054 return mxController
.is() && mxController
->isEndless();
1057 bool SlideShow::isDrawingPossible()
1059 return mxController
.is() && mxController
->getUsePen();
1062 bool SlideShow::swipe(const CommandSwipeData
& rSwipeData
)
1064 return mxController
.is() && mxController
->swipe(rSwipeData
);
1067 bool SlideShow::longpress(const CommandLongPressData
& rLongPressData
)
1069 return mxController
.is() && mxController
->longpress(rLongPressData
);
1072 void SlideShow::StartInPlacePresentationConfigurationCallback()
1074 if( mnInPlaceConfigEvent
!= 0 )
1075 Application::RemoveUserEvent( mnInPlaceConfigEvent
);
1077 mnInPlaceConfigEvent
= Application::PostUserEvent( LINK( this, SlideShow
, StartInPlacePresentationConfigurationHdl
) );
1080 IMPL_LINK_NOARG(SlideShow
, StartInPlacePresentationConfigurationHdl
)
1082 mnInPlaceConfigEvent
= 0;
1083 StartInPlacePresentation();
1087 void SlideShow::StartInPlacePresentation()
1089 if( mpCurrentViewShellBase
)
1091 // Save the current view shell type so that it can be restored after the
1092 // show has ended. If there already is a saved shell type then that is
1095 ViewShell::ShellType eShell
= ViewShell::ST_NONE
;
1097 ::boost::shared_ptr
<FrameworkHelper
> pHelper(FrameworkHelper::Instance(*mpCurrentViewShellBase
));
1098 ::boost::shared_ptr
<ViewShell
> pMainViewShell(pHelper
->GetViewShell(FrameworkHelper::msCenterPaneURL
));
1100 if( pMainViewShell
.get() )
1101 eShell
= pMainViewShell
->GetShellType();
1103 if( eShell
!= ViewShell::ST_IMPRESS
)
1105 // Switch temporary to a DrawViewShell which supports the in-place presentation.
1107 if( pMainViewShell
.get() )
1109 FrameView
* pFrameView
= pMainViewShell
->GetFrameView();
1110 pFrameView
->SetPresentationViewShellId(SID_VIEWSHELL1
);
1111 pFrameView
->SetPreviousViewShellType (pMainViewShell
->GetShellType());
1112 pFrameView
->SetPageKind (PK_STANDARD
);
1115 pHelper
->RequestView( FrameworkHelper::msImpressViewURL
, FrameworkHelper::msCenterPaneURL
);
1116 pHelper
->RunOnConfigurationEvent( FrameworkHelper::msConfigurationUpdateEndEvent
, ::boost::bind(&SlideShow::StartInPlacePresentationConfigurationCallback
, this) );
1121 vcl::Window
* pParentWindow
= mxCurrentSettings
->mpParentWindow
;
1122 if( pParentWindow
== 0 )
1123 pParentWindow
= mpCurrentViewShellBase
->GetViewWindow();
1125 CreateController( pMainViewShell
.get(), pMainViewShell
->GetView(), pParentWindow
);
1128 else if( mxCurrentSettings
->mpParentWindow
)
1130 // no current view shell, but parent window
1131 CreateController( 0, 0, mxCurrentSettings
->mpParentWindow
);
1134 if( mxController
.is() )
1136 bool bSuccess
= false;
1137 if( mxCurrentSettings
.get() && mxCurrentSettings
->mbPreview
)
1139 bSuccess
= mxController
->startPreview(mxCurrentSettings
->mxStartPage
, mxCurrentSettings
->mxAnimationNode
, mxCurrentSettings
->mpParentWindow
);
1143 bSuccess
= mxController
->startShow(mxCurrentSettings
.get());
1150 if(mpCurrentViewShellBase
)
1151 mpCurrentViewShellBase
->GetWindow()->GrabFocus();
1156 void SlideShow::StartFullscreenPresentation( )
1158 // Create the top level window in which the PresentationViewShell(Base)
1159 // will be created. This is done here explicitly so that we can make it
1161 const sal_Int32
nDisplay (GetDisplay());
1162 VclPtr
<WorkWindow
> pWorkWindow
= VclPtr
<FullScreenWorkWindow
>::Create(this, mpCurrentViewShellBase
);
1163 pWorkWindow
->SetBackground(Wallpaper(COL_BLACK
));
1164 pWorkWindow
->StartPresentationMode( true, mpDoc
->getPresentationSettings().mbAlwaysOnTop
? PRESENTATION_HIDEALLAPPS
: 0, nDisplay
);
1165 // pWorkWindow->ShowFullScreenMode(sal_False, nDisplay);
1167 if (pWorkWindow
->IsVisible())
1169 // Initialize the new presentation view shell with a copy of the
1170 // frame view of the current view shell. This avoids that
1171 // changes made by the presentation have an effect on the other
1173 FrameView
* pOriginalFrameView
= 0;
1174 ::boost::shared_ptr
<ViewShell
> xShell(mpCurrentViewShellBase
->GetMainViewShell());
1176 pOriginalFrameView
= xShell
->GetFrameView();
1178 delete mpFullScreenFrameView
;
1179 mpFullScreenFrameView
= new FrameView(mpDoc
, pOriginalFrameView
);
1181 // The new frame is created hidden. To make it visible and activate the
1182 // new view shell--a prerequisite to process slot calls and initialize
1183 // its panes--a GrabFocus() has to be called later on.
1184 SfxFrame
* pNewFrame
= SfxFrame::Create( *mpDoc
->GetDocSh(), *pWorkWindow
, PRESENTATION_FACTORY_ID
, true );
1185 pNewFrame
->SetPresentationMode(true);
1187 mpFullScreenViewShellBase
= static_cast<ViewShellBase
*>(pNewFrame
->GetCurrentViewFrame()->GetViewShell());
1188 if(mpFullScreenViewShellBase
!= NULL
)
1190 // The following GrabFocus() is responsible for activating the
1191 // new view shell. Without it the screen remains blank (under
1192 // Windows and some Linux variants.)
1193 mpFullScreenViewShellBase
->GetWindow()->GrabFocus();
1198 /// convert configuration setting display concept to real screens
1199 sal_Int32
SlideShow::GetDisplay()
1201 sal_Int32 nDisplay
= 0;
1203 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS
);
1205 nDisplay
= pOptions
->GetDisplay();
1209 else if( nDisplay
== 0)
1210 nDisplay
= (sal_Int32
)Application::GetDisplayExternalScreen();
1214 SAL_INFO("sd", "Presenting on real screen " << nDisplay
);
1219 bool SlideShow::dependsOn( ViewShellBase
* pViewShellBase
)
1221 return mxController
.is() && (pViewShellBase
== mpCurrentViewShellBase
) && mpFullScreenViewShellBase
;
1224 Reference
< presentation::XPresentation2
> CreatePresentation( const SdDrawDocument
& rDocument
)
1226 return Reference
< presentation::XPresentation2
>( SlideShow::Create( const_cast< SdDrawDocument
* >( &rDocument
) ).get() );
1229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */