xref: /AOO41X/main/sd/source/ui/slideshow/slideshow.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //#include <com/sun/star/frame/XController.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
35*cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
40*cdf0e10cSrcweir #include <vos/mutex.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <vcl/svapp.hxx>
43*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
44*cdf0e10cSrcweir #include <svx/svdpool.hxx>
45*cdf0e10cSrcweir #include <svl/itemprop.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
50*cdf0e10cSrcweir #include <svx/unoprov.hxx>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx"
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #include "FrameView.hxx"
55*cdf0e10cSrcweir #include "unomodel.hxx"
56*cdf0e10cSrcweir #include "slideshow.hxx"
57*cdf0e10cSrcweir #include "slideshowimpl.hxx"
58*cdf0e10cSrcweir #include "sdattr.hrc"
59*cdf0e10cSrcweir #include "FactoryIds.hxx"
60*cdf0e10cSrcweir #include "ViewShell.hxx"
61*cdf0e10cSrcweir #include "SlideShowRestarter.hxx"
62*cdf0e10cSrcweir #include "DrawController.hxx"
63*cdf0e10cSrcweir #include <boost/bind.hpp>
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir using ::com::sun::star::presentation::XSlideShowController;
66*cdf0e10cSrcweir using ::com::sun::star::container::XIndexAccess;
67*cdf0e10cSrcweir using ::sd::framework::FrameworkHelper;
68*cdf0e10cSrcweir using ::rtl::OUString;
69*cdf0e10cSrcweir using ::com::sun::star::awt::XWindow;
70*cdf0e10cSrcweir using namespace ::sd;
71*cdf0e10cSrcweir using namespace ::cppu;
72*cdf0e10cSrcweir using namespace ::vos;
73*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
74*cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
75*cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
76*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
77*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
78*cdf0e10cSrcweir using namespace ::com::sun::star::animations;
79*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir extern String getUiNameFromPageApiNameImpl( const ::rtl::OUString& rApiName );
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir #define C2U(x) OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir namespace {
87*cdf0e10cSrcweir     /** This local version of the work window overloads DataChanged() so that it
88*cdf0e10cSrcweir         can restart the slide show when a display is added or removed.
89*cdf0e10cSrcweir     */
90*cdf0e10cSrcweir     class FullScreenWorkWindow : public WorkWindow
91*cdf0e10cSrcweir     {
92*cdf0e10cSrcweir     public:
93*cdf0e10cSrcweir         FullScreenWorkWindow (
94*cdf0e10cSrcweir             const ::rtl::Reference<SlideShow>& rpSlideShow,
95*cdf0e10cSrcweir             ViewShellBase* pViewShellBase)
96*cdf0e10cSrcweir             : WorkWindow(NULL, WB_HIDE | WB_CLIPCHILDREN),
97*cdf0e10cSrcweir               mpRestarter(new SlideShowRestarter(rpSlideShow, pViewShellBase))
98*cdf0e10cSrcweir         {}
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir         virtual void DataChanged (const DataChangedEvent& rEvent)
102*cdf0e10cSrcweir         {
103*cdf0e10cSrcweir             if (rEvent.GetType() == DATACHANGED_DISPLAY)
104*cdf0e10cSrcweir             {
105*cdf0e10cSrcweir                 mpRestarter->Restart();
106*cdf0e10cSrcweir             }
107*cdf0e10cSrcweir         }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     private:
110*cdf0e10cSrcweir         ::boost::shared_ptr<SlideShowRestarter> mpRestarter;
111*cdf0e10cSrcweir     };
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     /** Return the default display id (or -1 when that can not be
114*cdf0e10cSrcweir         determined.)
115*cdf0e10cSrcweir     */
116*cdf0e10cSrcweir     sal_Int32 GetDefaultDisplay (void)
117*cdf0e10cSrcweir     {
118*cdf0e10cSrcweir         try
119*cdf0e10cSrcweir         {
120*cdf0e10cSrcweir             Reference< XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
121*cdf0e10cSrcweir 			Reference< XPropertySet > xMonProps(xFactory->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.DisplayAccess" ) ) ), UNO_QUERY_THROW );
122*cdf0e10cSrcweir             const OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DefaultDisplay" ) );
123*cdf0e10cSrcweir             sal_Int32 nPrimaryIndex (-1);
124*cdf0e10cSrcweir             if (xMonProps->getPropertyValue( sPropertyName ) >>= nPrimaryIndex)
125*cdf0e10cSrcweir                 return nPrimaryIndex;
126*cdf0e10cSrcweir         }
127*cdf0e10cSrcweir         catch( Exception& )
128*cdf0e10cSrcweir         {
129*cdf0e10cSrcweir         }
130*cdf0e10cSrcweir         return -1;
131*cdf0e10cSrcweir     }
132*cdf0e10cSrcweir }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
136*cdf0e10cSrcweir // --------------------------------------------------------------------
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir const SfxItemPropertyMapEntry* ImplGetPresentationPropertyMap()
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir 	// NOTE: First member must be sorted
141*cdf0e10cSrcweir 	static const SfxItemPropertyMapEntry aPresentationPropertyMap_Impl[] =
142*cdf0e10cSrcweir 	{
143*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("AllowAnimations"),			ATTR_PRESENT_ANIMATION_ALLOWED,	&::getBooleanCppuType(),				0, 0 },
144*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("CustomShow"),				ATTR_PRESENT_CUSTOMSHOW,		&::getCppuType((const OUString*)0),		0, 0 },
145*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("Display"),					ATTR_PRESENT_DISPLAY,			&::getCppuType((const sal_Int32*)0),	0, 0 },
146*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("FirstPage"),				ATTR_PRESENT_DIANAME,			&::getCppuType((const OUString*)0),		0, 0 },
147*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsAlwaysOnTop"),			ATTR_PRESENT_ALWAYS_ON_TOP,		&::getBooleanCppuType(),				0, 0 },
148*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsAutomatic"),				ATTR_PRESENT_MANUEL,			&::getBooleanCppuType(),				0, 0 },
149*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsEndless"),				ATTR_PRESENT_ENDLESS,			&::getBooleanCppuType(),				0, 0 },
150*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsFullScreen"),				ATTR_PRESENT_FULLSCREEN,		&::getBooleanCppuType(),				0, 0 },
151*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsShowAll"),				ATTR_PRESENT_ALL,				&::getBooleanCppuType(),				0, 0 },
152*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsMouseVisible"),			ATTR_PRESENT_MOUSE,				&::getBooleanCppuType(),				0, 0 },
153*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsShowLogo"),				ATTR_PRESENT_SHOW_PAUSELOGO,	&::getBooleanCppuType(),				0, 0 },
154*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("IsTransitionOnClick"),		ATTR_PRESENT_CHANGE_PAGE,		&::getBooleanCppuType(),				0, 0 },
155*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("Pause"),					ATTR_PRESENT_PAUSE_TIMEOUT,		&::getCppuType((const sal_Int32*)0),	0, 0 },
156*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("StartWithNavigator"),		ATTR_PRESENT_NAVIGATOR,			&::getBooleanCppuType(),				0, 0 },
157*cdf0e10cSrcweir 		{ MAP_CHAR_LEN("UsePen"),					ATTR_PRESENT_PEN,				&::getBooleanCppuType(),				0, 0 },
158*cdf0e10cSrcweir 		{ 0,0,0,0,0,0}
159*cdf0e10cSrcweir 	};
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 	return aPresentationPropertyMap_Impl;
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir //SfxItemPropertyMap map_impl[] = { { 0,0,0,0,0,0 } };
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir // --------------------------------------------------------------------
167*cdf0e10cSrcweir // class SlideShow
168*cdf0e10cSrcweir // --------------------------------------------------------------------
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir SlideShow::SlideShow( SdDrawDocument* pDoc )
171*cdf0e10cSrcweir : SlideshowBase( m_aMutex )
172*cdf0e10cSrcweir , maPropSet(ImplGetPresentationPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool())
173*cdf0e10cSrcweir , mbIsInStartup(false)
174*cdf0e10cSrcweir , mpDoc( pDoc )
175*cdf0e10cSrcweir , mpCurrentViewShellBase( 0 )
176*cdf0e10cSrcweir , mpFullScreenViewShellBase( 0 )
177*cdf0e10cSrcweir , mpFullScreenFrameView( 0 )
178*cdf0e10cSrcweir , mnInPlaceConfigEvent( 0 )
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir }
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir // --------------------------------------------------------------------
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir void SlideShow::ThrowIfDisposed() throw (RuntimeException)
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir 	if( mpDoc == 0 )
187*cdf0e10cSrcweir 		throw DisposedException();
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir // --------------------------------------------------------------------
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir /// used by the model to create a slideshow for it
193*cdf0e10cSrcweir rtl::Reference< SlideShow > SlideShow::Create( SdDrawDocument* pDoc )
194*cdf0e10cSrcweir {
195*cdf0e10cSrcweir 	return new SlideShow( pDoc );
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir // --------------------------------------------------------------------
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir rtl::Reference< SlideShow > SlideShow::GetSlideShow( SdDrawDocument* pDocument )
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir 	rtl::Reference< SlideShow > xRet;
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	if( pDocument )
205*cdf0e10cSrcweir 		xRet = rtl::Reference< SlideShow >( dynamic_cast< SlideShow* >( pDocument->getPresentation().get() ) );
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	return xRet;
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir // --------------------------------------------------------------------
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir rtl::Reference< SlideShow > SlideShow::GetSlideShow( ViewShellBase& rBase )
213*cdf0e10cSrcweir {
214*cdf0e10cSrcweir 	return GetSlideShow( rBase.GetDocument() );
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir // --------------------------------------------------------------------
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XSlideShowController > SlideShow::GetSlideShowController(ViewShellBase& rBase )
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir 	rtl::Reference< SlideShow > xSlideShow( GetSlideShow( rBase ) );
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	Reference< XSlideShowController > xRet;
224*cdf0e10cSrcweir 	if( xSlideShow.is() )
225*cdf0e10cSrcweir 		xRet = xSlideShow->getController();
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	return xRet;
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir // --------------------------------------------------------------------
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir bool SlideShow::StartPreview( ViewShellBase& rBase,
233*cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage,
234*cdf0e10cSrcweir 	const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xAnimationNode,
235*cdf0e10cSrcweir 	::Window* pParent /* = 0 */ )
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir 	rtl::Reference< SlideShow > xSlideShow( GetSlideShow( rBase ) );
238*cdf0e10cSrcweir 	if( xSlideShow.is() )
239*cdf0e10cSrcweir 		return xSlideShow->startPreview( xDrawPage, xAnimationNode, pParent );
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 	return false;
242*cdf0e10cSrcweir }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir // --------------------------------------------------------------------
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir void SlideShow::Stop( ViewShellBase& rBase )
247*cdf0e10cSrcweir {
248*cdf0e10cSrcweir 	rtl::Reference< SlideShow > xSlideShow( GetSlideShow( rBase ) );
249*cdf0e10cSrcweir 	if( xSlideShow.is() )
250*cdf0e10cSrcweir 		xSlideShow->end();
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir // --------------------------------------------------------------------
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir bool SlideShow::IsRunning( ViewShellBase& rBase )
256*cdf0e10cSrcweir {
257*cdf0e10cSrcweir 	rtl::Reference< SlideShow > xSlideShow( GetSlideShow( rBase ) );
258*cdf0e10cSrcweir 	return xSlideShow.is() && xSlideShow->isRunning();
259*cdf0e10cSrcweir }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir // --------------------------------------------------------------------
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir bool SlideShow::IsRunning( ViewShell& rViewShell )
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir 	rtl::Reference< SlideShow > xSlideShow( GetSlideShow( rViewShell.GetViewShellBase() ) );
266*cdf0e10cSrcweir 	return xSlideShow.is() && xSlideShow->isRunning() && (xSlideShow->mxController->getViewShell() == &rViewShell);
267*cdf0e10cSrcweir }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir // --------------------------------------------------------------------
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir void SlideShow::CreateController(  ViewShell* pViewSh, ::sd::View* pView, ::Window* pParentWindow )
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir 	DBG_ASSERT( !mxController.is(), "sd::SlideShow::CreateController(), clean up old controller first!" );
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir 	Reference< XPresentation2 > xThis( this );
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir 	rtl::Reference<SlideshowImpl> xController (
278*cdf0e10cSrcweir         new SlideshowImpl(xThis, pViewSh, pView, mpDoc, pParentWindow));
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir     // Reset mbIsInStartup.  From here mxController.is() is used to prevent
281*cdf0e10cSrcweir     // multiple slide show instances for one document.
282*cdf0e10cSrcweir 	mxController = xController;
283*cdf0e10cSrcweir     mbIsInStartup = false;
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir // --------------------------------------------------------------------
287*cdf0e10cSrcweir // XServiceInfo
288*cdf0e10cSrcweir // --------------------------------------------------------------------
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir OUString SAL_CALL SlideShow::getImplementationName(  ) throw(RuntimeException)
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sd.SlideShow") );
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir // --------------------------------------------------------------------
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir sal_Bool SAL_CALL SlideShow::supportsService( const OUString& ServiceName ) throw(RuntimeException)
298*cdf0e10cSrcweir {
299*cdf0e10cSrcweir 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames(  ) );
300*cdf0e10cSrcweir }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir // --------------------------------------------------------------------
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir Sequence< OUString > SAL_CALL SlideShow::getSupportedServiceNames(  ) throw(RuntimeException)
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir 	OUString aService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.Presentation") );
307*cdf0e10cSrcweir 	Sequence< OUString > aSeq( &aService, 1 );
308*cdf0e10cSrcweir 	return aSeq;
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir // --------------------------------------------------------------------
312*cdf0e10cSrcweir // XPropertySet
313*cdf0e10cSrcweir // --------------------------------------------------------------------
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL SlideShow::getPropertySetInfo() throw(RuntimeException)
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
318*cdf0e10cSrcweir     static Reference< XPropertySetInfo > xInfo = maPropSet.getPropertySetInfo();
319*cdf0e10cSrcweir     return xInfo;
320*cdf0e10cSrcweir  }
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir // --------------------------------------------------------------------
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir void SAL_CALL SlideShow::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
327*cdf0e10cSrcweir 	ThrowIfDisposed();
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	sd::PresentationSettings& rPresSettings = mpDoc->getPresentationSettings();
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 	const SfxItemPropertySimpleEntry* pEntry = maPropSet.getPropertyMapEntry(aPropertyName);
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 	if( pEntry && ((pEntry->nFlags & PropertyAttribute::READONLY) != 0) )
334*cdf0e10cSrcweir 		throw PropertyVetoException();
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 	bool bValuesChanged = false;
337*cdf0e10cSrcweir 	bool bIllegalArgument = true;
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir 	switch( pEntry ? pEntry->nWID : -1 )
340*cdf0e10cSrcweir 	{
341*cdf0e10cSrcweir 	case ATTR_PRESENT_ALL:
342*cdf0e10cSrcweir 	{
343*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 		if( aValue >>= bVal )
346*cdf0e10cSrcweir 		{
347*cdf0e10cSrcweir 			bIllegalArgument = false;
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 			if( rPresSettings.mbAll != bVal )
350*cdf0e10cSrcweir 			{
351*cdf0e10cSrcweir 				rPresSettings.mbAll = bVal;
352*cdf0e10cSrcweir 				bValuesChanged = true;
353*cdf0e10cSrcweir 				if( bVal )
354*cdf0e10cSrcweir 					rPresSettings.mbCustomShow = sal_False;
355*cdf0e10cSrcweir 			}
356*cdf0e10cSrcweir 		}
357*cdf0e10cSrcweir 		break;
358*cdf0e10cSrcweir 	}
359*cdf0e10cSrcweir 	case ATTR_PRESENT_CHANGE_PAGE:
360*cdf0e10cSrcweir 	{
361*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 		if( aValue >>= bVal )
364*cdf0e10cSrcweir 		{
365*cdf0e10cSrcweir 			bIllegalArgument = false;
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 			if( bVal == rPresSettings.mbLockedPages )
368*cdf0e10cSrcweir 			{
369*cdf0e10cSrcweir 				bValuesChanged = true;
370*cdf0e10cSrcweir 				rPresSettings.mbLockedPages = !bVal;
371*cdf0e10cSrcweir 			}
372*cdf0e10cSrcweir 		}
373*cdf0e10cSrcweir 		break;
374*cdf0e10cSrcweir 	}
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 	case ATTR_PRESENT_ANIMATION_ALLOWED:
377*cdf0e10cSrcweir 	{
378*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 		if( aValue >>= bVal )
381*cdf0e10cSrcweir 		{
382*cdf0e10cSrcweir 			bIllegalArgument = false;
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 			if(rPresSettings.mbAnimationAllowed != bVal)
385*cdf0e10cSrcweir 			{
386*cdf0e10cSrcweir 				bValuesChanged = true;
387*cdf0e10cSrcweir 				rPresSettings.mbAnimationAllowed = bVal;
388*cdf0e10cSrcweir 			}
389*cdf0e10cSrcweir 		}
390*cdf0e10cSrcweir 		break;
391*cdf0e10cSrcweir 	}
392*cdf0e10cSrcweir 	case ATTR_PRESENT_CUSTOMSHOW:
393*cdf0e10cSrcweir 	{
394*cdf0e10cSrcweir 		OUString aShow;
395*cdf0e10cSrcweir 		if( aValue >>= aShow )
396*cdf0e10cSrcweir 		{
397*cdf0e10cSrcweir 			bIllegalArgument = false;
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 			const String aShowName( aShow );
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 			List* pCustomShowList = mpDoc->GetCustomShowList(sal_False);
402*cdf0e10cSrcweir 			if(pCustomShowList)
403*cdf0e10cSrcweir 			{
404*cdf0e10cSrcweir 				SdCustomShow* pCustomShow;
405*cdf0e10cSrcweir 				for( pCustomShow = (SdCustomShow*) pCustomShowList->First(); pCustomShow != NULL; pCustomShow = (SdCustomShow*) pCustomShowList->Next() )
406*cdf0e10cSrcweir 				{
407*cdf0e10cSrcweir 					if( pCustomShow->GetName() == aShowName )
408*cdf0e10cSrcweir 						break;
409*cdf0e10cSrcweir 				}
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 				rPresSettings.mbCustomShow = sal_True;
412*cdf0e10cSrcweir 				bValuesChanged = true;
413*cdf0e10cSrcweir 			}
414*cdf0e10cSrcweir 		}
415*cdf0e10cSrcweir 		break;
416*cdf0e10cSrcweir 	}
417*cdf0e10cSrcweir 	case ATTR_PRESENT_ENDLESS:
418*cdf0e10cSrcweir 	{
419*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir 		if( aValue >>= bVal )
422*cdf0e10cSrcweir 		{
423*cdf0e10cSrcweir 			bIllegalArgument = false;
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir 			if( rPresSettings.mbEndless != bVal)
426*cdf0e10cSrcweir 			{
427*cdf0e10cSrcweir 				bValuesChanged = true;
428*cdf0e10cSrcweir 				rPresSettings.mbEndless = bVal;
429*cdf0e10cSrcweir 			}
430*cdf0e10cSrcweir 		}
431*cdf0e10cSrcweir 		break;
432*cdf0e10cSrcweir 	}
433*cdf0e10cSrcweir 	case ATTR_PRESENT_FULLSCREEN:
434*cdf0e10cSrcweir 	{
435*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir 		if( aValue >>= bVal )
438*cdf0e10cSrcweir 		{
439*cdf0e10cSrcweir 			bIllegalArgument = false;
440*cdf0e10cSrcweir 			if( rPresSettings.mbFullScreen != bVal)
441*cdf0e10cSrcweir 			{
442*cdf0e10cSrcweir 				bValuesChanged = true;
443*cdf0e10cSrcweir 				rPresSettings.mbFullScreen = bVal;
444*cdf0e10cSrcweir 			}
445*cdf0e10cSrcweir 		}
446*cdf0e10cSrcweir 		break;
447*cdf0e10cSrcweir 	}
448*cdf0e10cSrcweir 	case ATTR_PRESENT_DIANAME:
449*cdf0e10cSrcweir 	{
450*cdf0e10cSrcweir 		OUString aPresPage;
451*cdf0e10cSrcweir 		aValue >>= aPresPage;
452*cdf0e10cSrcweir 		bIllegalArgument = false;
453*cdf0e10cSrcweir 		if( (rPresSettings.maPresPage != aPresPage) || !rPresSettings.mbCustomShow || !rPresSettings.mbAll )
454*cdf0e10cSrcweir 		{
455*cdf0e10cSrcweir 			bValuesChanged = true;
456*cdf0e10cSrcweir 			rPresSettings.maPresPage = getUiNameFromPageApiNameImpl(aPresPage);
457*cdf0e10cSrcweir 			rPresSettings.mbCustomShow = sal_False;
458*cdf0e10cSrcweir 			rPresSettings.mbAll = sal_False;
459*cdf0e10cSrcweir 		}
460*cdf0e10cSrcweir 		break;
461*cdf0e10cSrcweir 	}
462*cdf0e10cSrcweir 	case ATTR_PRESENT_MANUEL:
463*cdf0e10cSrcweir 	{
464*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir 		if( aValue >>= bVal )
467*cdf0e10cSrcweir 		{
468*cdf0e10cSrcweir 			bIllegalArgument = false;
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 			if( rPresSettings.mbManual != bVal)
471*cdf0e10cSrcweir 			{
472*cdf0e10cSrcweir 				bValuesChanged = true;
473*cdf0e10cSrcweir 				rPresSettings.mbManual = bVal;
474*cdf0e10cSrcweir 			}
475*cdf0e10cSrcweir 		}
476*cdf0e10cSrcweir 		break;
477*cdf0e10cSrcweir 	}
478*cdf0e10cSrcweir 	case ATTR_PRESENT_MOUSE:
479*cdf0e10cSrcweir 	{
480*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir 		if( aValue >>= bVal )
483*cdf0e10cSrcweir 		{
484*cdf0e10cSrcweir 			bIllegalArgument = false;
485*cdf0e10cSrcweir 			if( rPresSettings.mbMouseVisible != bVal)
486*cdf0e10cSrcweir 			{
487*cdf0e10cSrcweir 				bValuesChanged = true;
488*cdf0e10cSrcweir 				rPresSettings.mbMouseVisible = bVal;
489*cdf0e10cSrcweir 			}
490*cdf0e10cSrcweir 		}
491*cdf0e10cSrcweir 		break;
492*cdf0e10cSrcweir 	}
493*cdf0e10cSrcweir 	case ATTR_PRESENT_ALWAYS_ON_TOP:
494*cdf0e10cSrcweir 	{
495*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir 		if( aValue >>= bVal )
498*cdf0e10cSrcweir 		{
499*cdf0e10cSrcweir 			bIllegalArgument = false;
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir 			if( rPresSettings.mbAlwaysOnTop != bVal)
502*cdf0e10cSrcweir 			{
503*cdf0e10cSrcweir 				bValuesChanged = true;
504*cdf0e10cSrcweir 				rPresSettings.mbAlwaysOnTop = bVal;
505*cdf0e10cSrcweir 			}
506*cdf0e10cSrcweir 		}
507*cdf0e10cSrcweir 		break;
508*cdf0e10cSrcweir 	}
509*cdf0e10cSrcweir 	case ATTR_PRESENT_NAVIGATOR:
510*cdf0e10cSrcweir 	{
511*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 		if( aValue >>= bVal )
514*cdf0e10cSrcweir 		{
515*cdf0e10cSrcweir 			bIllegalArgument = false;
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir 			if( rPresSettings.mbStartWithNavigator != bVal)
518*cdf0e10cSrcweir 			{
519*cdf0e10cSrcweir 				bValuesChanged = true;
520*cdf0e10cSrcweir 				rPresSettings.mbStartWithNavigator = bVal;
521*cdf0e10cSrcweir 			}
522*cdf0e10cSrcweir 		}
523*cdf0e10cSrcweir 		break;
524*cdf0e10cSrcweir 	}
525*cdf0e10cSrcweir 	case ATTR_PRESENT_PEN:
526*cdf0e10cSrcweir 	{
527*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir 		if( aValue >>= bVal )
530*cdf0e10cSrcweir 		{
531*cdf0e10cSrcweir 			bIllegalArgument = false;
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir 			if(rPresSettings.mbMouseAsPen != bVal)
534*cdf0e10cSrcweir 			{
535*cdf0e10cSrcweir 				bValuesChanged = true;
536*cdf0e10cSrcweir 				rPresSettings.mbMouseAsPen = bVal;
537*cdf0e10cSrcweir 			}
538*cdf0e10cSrcweir 		}
539*cdf0e10cSrcweir 		break;
540*cdf0e10cSrcweir 	}
541*cdf0e10cSrcweir 	case ATTR_PRESENT_PAUSE_TIMEOUT:
542*cdf0e10cSrcweir 	{
543*cdf0e10cSrcweir 		sal_Int32 nValue = 0;
544*cdf0e10cSrcweir 		if( (aValue >>= nValue) && (nValue >= 0) )
545*cdf0e10cSrcweir 		{
546*cdf0e10cSrcweir 			bIllegalArgument = false;
547*cdf0e10cSrcweir 			if( rPresSettings.mnPauseTimeout != nValue )
548*cdf0e10cSrcweir 			{
549*cdf0e10cSrcweir 				bValuesChanged = true;
550*cdf0e10cSrcweir 				rPresSettings.mnPauseTimeout = nValue;
551*cdf0e10cSrcweir 			}
552*cdf0e10cSrcweir 		}
553*cdf0e10cSrcweir 		break;
554*cdf0e10cSrcweir 	}
555*cdf0e10cSrcweir 	case ATTR_PRESENT_SHOW_PAUSELOGO:
556*cdf0e10cSrcweir 	{
557*cdf0e10cSrcweir 		sal_Bool bVal = sal_False;
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir 		if( aValue >>= bVal )
560*cdf0e10cSrcweir 		{
561*cdf0e10cSrcweir 			bIllegalArgument = false;
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir 			if( rPresSettings.mbShowPauseLogo != bVal )
564*cdf0e10cSrcweir 			{
565*cdf0e10cSrcweir 				bValuesChanged = true;
566*cdf0e10cSrcweir 				rPresSettings.mbShowPauseLogo = bVal;
567*cdf0e10cSrcweir 			}
568*cdf0e10cSrcweir 		}
569*cdf0e10cSrcweir 		break;
570*cdf0e10cSrcweir 	}
571*cdf0e10cSrcweir 	case ATTR_PRESENT_DISPLAY:
572*cdf0e10cSrcweir 	{
573*cdf0e10cSrcweir 		sal_Int32 nDisplay = 0;
574*cdf0e10cSrcweir 		if( aValue >>= nDisplay )
575*cdf0e10cSrcweir 		{
576*cdf0e10cSrcweir             // Convert value to true display id.
577*cdf0e10cSrcweir             if (nDisplay == 0)
578*cdf0e10cSrcweir                 nDisplay = GetDefaultDisplay();
579*cdf0e10cSrcweir             else if (nDisplay < 0)
580*cdf0e10cSrcweir                 nDisplay = -1;
581*cdf0e10cSrcweir             else
582*cdf0e10cSrcweir                 --nDisplay;
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 			bIllegalArgument = false;
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 			SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
587*cdf0e10cSrcweir 			pOptions->SetDisplay( nDisplay );
588*cdf0e10cSrcweir 		}
589*cdf0e10cSrcweir 		break;
590*cdf0e10cSrcweir 	}
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir 	default:
593*cdf0e10cSrcweir 		throw UnknownPropertyException();
594*cdf0e10cSrcweir 	}
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir 	if( bIllegalArgument )
597*cdf0e10cSrcweir 		throw IllegalArgumentException();
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir 	if( bValuesChanged )
600*cdf0e10cSrcweir 		mpDoc->SetChanged( true );
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir // --------------------------------------------------------------------
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir Any SAL_CALL SlideShow::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
606*cdf0e10cSrcweir {
607*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
608*cdf0e10cSrcweir 	ThrowIfDisposed();
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir 	const sd::PresentationSettings& rPresSettings = mpDoc->getPresentationSettings();
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir 	const SfxItemPropertySimpleEntry* pEntry = maPropSet.getPropertyMapEntry(PropertyName);
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 	switch( pEntry ? pEntry->nWID : -1 )
615*cdf0e10cSrcweir 	{
616*cdf0e10cSrcweir 	case ATTR_PRESENT_ALL:
617*cdf0e10cSrcweir 		return Any( (sal_Bool) ( !rPresSettings.mbCustomShow && rPresSettings.mbAll ) );
618*cdf0e10cSrcweir 	case ATTR_PRESENT_CHANGE_PAGE:
619*cdf0e10cSrcweir 		return Any( (sal_Bool) !rPresSettings.mbLockedPages );
620*cdf0e10cSrcweir 	case ATTR_PRESENT_ANIMATION_ALLOWED:
621*cdf0e10cSrcweir 		return Any( rPresSettings.mbAnimationAllowed );
622*cdf0e10cSrcweir 	case ATTR_PRESENT_CUSTOMSHOW:
623*cdf0e10cSrcweir 		{
624*cdf0e10cSrcweir 			List* pList = mpDoc->GetCustomShowList(sal_False);
625*cdf0e10cSrcweir 			SdCustomShow* pShow = (pList && rPresSettings.mbCustomShow)?(SdCustomShow*)pList->GetCurObject():NULL;
626*cdf0e10cSrcweir 			OUString aShowName;
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir 			if(pShow)
629*cdf0e10cSrcweir 				aShowName = pShow->GetName();
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir 			return Any( aShowName );
632*cdf0e10cSrcweir 		}
633*cdf0e10cSrcweir 	case ATTR_PRESENT_ENDLESS:
634*cdf0e10cSrcweir 		return Any( rPresSettings.mbEndless );
635*cdf0e10cSrcweir 	case ATTR_PRESENT_FULLSCREEN:
636*cdf0e10cSrcweir 		return Any( rPresSettings.mbFullScreen );
637*cdf0e10cSrcweir 	case ATTR_PRESENT_DIANAME:
638*cdf0e10cSrcweir 		{
639*cdf0e10cSrcweir 			OUString aSlideName;
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir 			if( !rPresSettings.mbCustomShow && !rPresSettings.mbAll )
642*cdf0e10cSrcweir 				aSlideName = getPageApiNameFromUiName( rPresSettings.maPresPage );
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 			return Any( aSlideName );
645*cdf0e10cSrcweir 		}
646*cdf0e10cSrcweir 	case ATTR_PRESENT_MANUEL:
647*cdf0e10cSrcweir 		return Any( rPresSettings.mbManual );
648*cdf0e10cSrcweir 	case ATTR_PRESENT_MOUSE:
649*cdf0e10cSrcweir 		return Any( rPresSettings.mbMouseVisible );
650*cdf0e10cSrcweir 	case ATTR_PRESENT_ALWAYS_ON_TOP:
651*cdf0e10cSrcweir 		return Any( rPresSettings.mbAlwaysOnTop );
652*cdf0e10cSrcweir 	case ATTR_PRESENT_NAVIGATOR:
653*cdf0e10cSrcweir 		return Any( rPresSettings.mbStartWithNavigator );
654*cdf0e10cSrcweir 	case ATTR_PRESENT_PEN:
655*cdf0e10cSrcweir 		return Any( rPresSettings.mbMouseAsPen );
656*cdf0e10cSrcweir 	case ATTR_PRESENT_PAUSE_TIMEOUT:
657*cdf0e10cSrcweir 		return Any( rPresSettings.mnPauseTimeout );
658*cdf0e10cSrcweir 	case ATTR_PRESENT_SHOW_PAUSELOGO:
659*cdf0e10cSrcweir 		return Any( rPresSettings.mbShowPauseLogo );
660*cdf0e10cSrcweir 	case ATTR_PRESENT_DISPLAY:
661*cdf0e10cSrcweir 	{
662*cdf0e10cSrcweir 		SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
663*cdf0e10cSrcweir         const sal_Int32 nDisplay (pOptions->GetDisplay());
664*cdf0e10cSrcweir         // Convert true display id to the previously used schema.
665*cdf0e10cSrcweir         if (nDisplay == GetDefaultDisplay())
666*cdf0e10cSrcweir             return Any(sal_Int32(0));
667*cdf0e10cSrcweir         else if (nDisplay < 0)
668*cdf0e10cSrcweir             return Any(sal_Int32(-1));
669*cdf0e10cSrcweir         else
670*cdf0e10cSrcweir             return Any(nDisplay+1);
671*cdf0e10cSrcweir 	}
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir 	default:
674*cdf0e10cSrcweir 		throw UnknownPropertyException();
675*cdf0e10cSrcweir 	}
676*cdf0e10cSrcweir }
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir // --------------------------------------------------------------------
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir void SAL_CALL SlideShow::addPropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >&  ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
681*cdf0e10cSrcweir {
682*cdf0e10cSrcweir }
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir // --------------------------------------------------------------------
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir void SAL_CALL SlideShow::removePropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >&  ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
687*cdf0e10cSrcweir {
688*cdf0e10cSrcweir }
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir // --------------------------------------------------------------------
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir void SAL_CALL SlideShow::addVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >&  ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
693*cdf0e10cSrcweir {
694*cdf0e10cSrcweir }
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir // --------------------------------------------------------------------
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir void SAL_CALL SlideShow::removeVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >&  ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
699*cdf0e10cSrcweir {
700*cdf0e10cSrcweir }
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir // --------------------------------------------------------------------
703*cdf0e10cSrcweir // XPresentation
704*cdf0e10cSrcweir // --------------------------------------------------------------------
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir void SAL_CALL SlideShow::start() throw(RuntimeException)
707*cdf0e10cSrcweir {
708*cdf0e10cSrcweir 	const Sequence< PropertyValue > aArguments;
709*cdf0e10cSrcweir 	startWithArguments( aArguments );
710*cdf0e10cSrcweir }
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir // --------------------------------------------------------------------
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir void SAL_CALL SlideShow::end() throw(RuntimeException)
715*cdf0e10cSrcweir {
716*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir     // The mbIsInStartup flag should have been reset during the start of the
719*cdf0e10cSrcweir     // slide show.  Reset it here just in case that something has horribly
720*cdf0e10cSrcweir     // gone wrong.
721*cdf0e10cSrcweir     OSL_ASSERT(!mbIsInStartup);
722*cdf0e10cSrcweir     mbIsInStartup = false;
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir 	rtl::Reference< SlideshowImpl > xController( mxController );
725*cdf0e10cSrcweir 	if( xController.is() )
726*cdf0e10cSrcweir 	{
727*cdf0e10cSrcweir 		mxController.clear();
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir 		if( mpFullScreenFrameView )
730*cdf0e10cSrcweir 		{
731*cdf0e10cSrcweir 			delete mpFullScreenFrameView;
732*cdf0e10cSrcweir 			mpFullScreenFrameView = 0;
733*cdf0e10cSrcweir 		}
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 		ViewShellBase* pFullScreenViewShellBase = mpFullScreenViewShellBase;
736*cdf0e10cSrcweir 		mpFullScreenViewShellBase = 0;
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir 		if( pFullScreenViewShellBase )
739*cdf0e10cSrcweir 		{
740*cdf0e10cSrcweir 			PresentationViewShell* pShell = dynamic_cast<PresentationViewShell*>(pFullScreenViewShellBase->GetMainViewShell().get());
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir 			if( pShell && pShell->GetViewFrame() )
743*cdf0e10cSrcweir 			{
744*cdf0e10cSrcweir 				WorkWindow* pWorkWindow = dynamic_cast<WorkWindow*>(pShell->GetViewFrame()->GetTopFrame().GetWindow().GetParent());
745*cdf0e10cSrcweir 				if( pWorkWindow )
746*cdf0e10cSrcweir 				{
747*cdf0e10cSrcweir 					pWorkWindow->StartPresentationMode( sal_False, isAlwaysOnTop() );
748*cdf0e10cSrcweir 				}
749*cdf0e10cSrcweir 			}
750*cdf0e10cSrcweir 		}
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir 		xController->dispose();
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir 		if( pFullScreenViewShellBase )
755*cdf0e10cSrcweir 		{
756*cdf0e10cSrcweir 			PresentationViewShell* pShell = NULL;
757*cdf0e10cSrcweir             {
758*cdf0e10cSrcweir                 // Get the shell pointer in its own scope to be sure that
759*cdf0e10cSrcweir                 // the shared_ptr to the shell is released before DoClose()
760*cdf0e10cSrcweir                 // is called.
761*cdf0e10cSrcweir                 ::boost::shared_ptr<ViewShell> pSharedView (pFullScreenViewShellBase->GetMainViewShell());
762*cdf0e10cSrcweir                 pShell = dynamic_cast<PresentationViewShell*>(pSharedView.get());
763*cdf0e10cSrcweir             }
764*cdf0e10cSrcweir 			if( pShell && pShell->GetViewFrame() )
765*cdf0e10cSrcweir 				pShell->GetViewFrame()->DoClose();
766*cdf0e10cSrcweir 		}
767*cdf0e10cSrcweir 		else if( mpCurrentViewShellBase )
768*cdf0e10cSrcweir 		{
769*cdf0e10cSrcweir 			ViewShell* pViewShell = mpCurrentViewShellBase->GetMainViewShell().get();
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir 			if( pViewShell )
772*cdf0e10cSrcweir 			{
773*cdf0e10cSrcweir 				FrameView* pFrameView = pViewShell->GetFrameView();
774*cdf0e10cSrcweir 
775*cdf0e10cSrcweir 				if( pFrameView && (pFrameView->GetPresentationViewShellId() != SID_VIEWSHELL0) )
776*cdf0e10cSrcweir 				{
777*cdf0e10cSrcweir 					ViewShell::ShellType ePreviousType (pFrameView->GetPreviousViewShellType());
778*cdf0e10cSrcweir 					pFrameView->SetPreviousViewShellType(ViewShell::ST_NONE);
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir 					pFrameView->SetPresentationViewShellId(SID_VIEWSHELL0);
781*cdf0e10cSrcweir 					pFrameView->SetSlotId(SID_OBJECT_SELECT);
782*cdf0e10cSrcweir 					pFrameView->SetPreviousViewShellType(pViewShell->GetShellType());
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 					framework::FrameworkHelper::Instance(*mpCurrentViewShellBase)->RequestView(
785*cdf0e10cSrcweir 						framework::FrameworkHelper::GetViewURL(ePreviousType),
786*cdf0e10cSrcweir 						framework::FrameworkHelper::msCenterPaneURL);
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir 					pViewShell->GetViewFrame()->GetBindings().InvalidateAll( sal_True );
789*cdf0e10cSrcweir 				}
790*cdf0e10cSrcweir 			}
791*cdf0e10cSrcweir 		}
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir 		if( mpCurrentViewShellBase )
794*cdf0e10cSrcweir 		{
795*cdf0e10cSrcweir 			ViewShell* pViewShell = mpCurrentViewShellBase->GetMainViewShell().get();
796*cdf0e10cSrcweir 			if( pViewShell )
797*cdf0e10cSrcweir 			{
798*cdf0e10cSrcweir 				// invalidate the view shell so the presentation slot will be re-enabled
799*cdf0e10cSrcweir 				// and the rehersing will be updated
800*cdf0e10cSrcweir 				pViewShell->Invalidate();
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir 				if( xController->meAnimationMode ==ANIMATIONMODE_SHOW )
803*cdf0e10cSrcweir 				{
804*cdf0e10cSrcweir 					// switch to the previously visible Slide
805*cdf0e10cSrcweir 					DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>( pViewShell );
806*cdf0e10cSrcweir 					if( pDrawViewShell )
807*cdf0e10cSrcweir 						pDrawViewShell->SwitchPage( (sal_uInt16)xController->getRestoreSlide() );
808*cdf0e10cSrcweir                     else
809*cdf0e10cSrcweir                     {
810*cdf0e10cSrcweir                         Reference<XDrawView> xDrawView (
811*cdf0e10cSrcweir                             Reference<XWeak>(&mpCurrentViewShellBase->GetDrawController()), UNO_QUERY);
812*cdf0e10cSrcweir                         if (xDrawView.is())
813*cdf0e10cSrcweir                             xDrawView->setCurrentPage(
814*cdf0e10cSrcweir                                 Reference<XDrawPage>(
815*cdf0e10cSrcweir                                     mpDoc->GetSdPage(xController->getRestoreSlide(), PK_STANDARD)->getUnoPage(),
816*cdf0e10cSrcweir                                     UNO_QUERY));
817*cdf0e10cSrcweir                     }
818*cdf0e10cSrcweir 				}
819*cdf0e10cSrcweir 			}
820*cdf0e10cSrcweir 		}
821*cdf0e10cSrcweir 		mpCurrentViewShellBase = 0;
822*cdf0e10cSrcweir 	}
823*cdf0e10cSrcweir }
824*cdf0e10cSrcweir 
825*cdf0e10cSrcweir // --------------------------------------------------------------------
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir void SAL_CALL SlideShow::rehearseTimings() throw(RuntimeException)
828*cdf0e10cSrcweir {
829*cdf0e10cSrcweir 	Sequence< PropertyValue > aArguments(1);
830*cdf0e10cSrcweir 	aArguments[0].Name = C2U("RehearseTimings");
831*cdf0e10cSrcweir 	aArguments[0].Value <<= sal_True;
832*cdf0e10cSrcweir 	startWithArguments( aArguments );
833*cdf0e10cSrcweir }
834*cdf0e10cSrcweir 
835*cdf0e10cSrcweir // --------------------------------------------------------------------
836*cdf0e10cSrcweir // XPresentation2
837*cdf0e10cSrcweir // --------------------------------------------------------------------
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir void SAL_CALL SlideShow::startWithArguments( const Sequence< PropertyValue >& rArguments ) throw (RuntimeException)
840*cdf0e10cSrcweir {
841*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
842*cdf0e10cSrcweir 	ThrowIfDisposed();
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir     // Stop a running show before starting a new one.
845*cdf0e10cSrcweir 	if( mxController.is() )
846*cdf0e10cSrcweir     {
847*cdf0e10cSrcweir         OSL_ASSERT(!mbIsInStartup);
848*cdf0e10cSrcweir 		end();
849*cdf0e10cSrcweir     }
850*cdf0e10cSrcweir     else if (mbIsInStartup)
851*cdf0e10cSrcweir     {
852*cdf0e10cSrcweir         // We are already somewhere in process of starting a slide show but
853*cdf0e10cSrcweir         // have not yet got to the point where mxController is set.  There
854*cdf0e10cSrcweir         // is not yet a slide show to end so return silently.
855*cdf0e10cSrcweir         return;
856*cdf0e10cSrcweir     }
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir     // Prevent multiple instance of the SlideShow class for one document.
859*cdf0e10cSrcweir     mbIsInStartup = true;
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir 	mxCurrentSettings.reset( new PresentationSettingsEx( mpDoc->getPresentationSettings() ) );
862*cdf0e10cSrcweir 	mxCurrentSettings->SetArguments( rArguments );
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir 	// if there is no view shell base set, use the current one or the first using this document
865*cdf0e10cSrcweir 	if( mpCurrentViewShellBase == 0 )
866*cdf0e10cSrcweir 	{
867*cdf0e10cSrcweir 		// first check current
868*cdf0e10cSrcweir 		::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( SfxViewFrame::Current() );
869*cdf0e10cSrcweir 		if( pBase && pBase->GetDocument() == mpDoc )
870*cdf0e10cSrcweir 		{
871*cdf0e10cSrcweir 			mpCurrentViewShellBase = pBase;
872*cdf0e10cSrcweir 		}
873*cdf0e10cSrcweir 		else
874*cdf0e10cSrcweir 		{
875*cdf0e10cSrcweir 			// current is not ours, so get first from ours
876*cdf0e10cSrcweir 			mpCurrentViewShellBase = ::sd::ViewShellBase::GetViewShellBase( SfxViewFrame::GetFirst( mpDoc->GetDocSh() ) );
877*cdf0e10cSrcweir 		}
878*cdf0e10cSrcweir 	}
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir 	// Start either a full-screen or an in-place show.
881*cdf0e10cSrcweir 	if(mxCurrentSettings->mbFullScreen && !mxCurrentSettings->mbPreview)
882*cdf0e10cSrcweir 		StartFullscreenPresentation();
883*cdf0e10cSrcweir 	else
884*cdf0e10cSrcweir 		StartInPlacePresentation();
885*cdf0e10cSrcweir }
886*cdf0e10cSrcweir 
887*cdf0e10cSrcweir // --------------------------------------------------------------------
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir ::sal_Bool SAL_CALL SlideShow::isRunning(  ) throw (RuntimeException)
890*cdf0e10cSrcweir {
891*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
892*cdf0e10cSrcweir 	return mxController.is() && mxController->isRunning();
893*cdf0e10cSrcweir }
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir // --------------------------------------------------------------------
896*cdf0e10cSrcweir 
897*cdf0e10cSrcweir Reference< XSlideShowController > SAL_CALL SlideShow::getController(  ) throw (RuntimeException)
898*cdf0e10cSrcweir {
899*cdf0e10cSrcweir 	ThrowIfDisposed();
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir 	Reference< XSlideShowController > xController( mxController.get() );
902*cdf0e10cSrcweir 	return xController;
903*cdf0e10cSrcweir }
904*cdf0e10cSrcweir 
905*cdf0e10cSrcweir // --------------------------------------------------------------------
906*cdf0e10cSrcweir // XComponent
907*cdf0e10cSrcweir // --------------------------------------------------------------------
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir void SAL_CALL SlideShow::disposing (void)
910*cdf0e10cSrcweir {
911*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir 	if( mnInPlaceConfigEvent )
914*cdf0e10cSrcweir 	{
915*cdf0e10cSrcweir 		Application::RemoveUserEvent( mnInPlaceConfigEvent );
916*cdf0e10cSrcweir 		mnInPlaceConfigEvent = 0;
917*cdf0e10cSrcweir 	}
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir 	if( mxController.is() )
920*cdf0e10cSrcweir 	{
921*cdf0e10cSrcweir 		mxController->dispose();
922*cdf0e10cSrcweir 		mxController.clear();
923*cdf0e10cSrcweir 	}
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 	mpCurrentViewShellBase = 0;
926*cdf0e10cSrcweir 	mpFullScreenViewShellBase = 0;
927*cdf0e10cSrcweir 	mpDoc = 0;
928*cdf0e10cSrcweir }
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir // ---------------------------------------------------------
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir bool SlideShow::startPreview( const Reference< XDrawPage >& xDrawPage, const Reference< XAnimationNode >& xAnimationNode, ::Window* pParent )
933*cdf0e10cSrcweir {
934*cdf0e10cSrcweir 	Sequence< PropertyValue > aArguments(4);
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir 	aArguments[0].Name = C2U("Preview");
937*cdf0e10cSrcweir 	aArguments[0].Value <<= sal_True;
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 	aArguments[1].Name = C2U("FirstPage");
940*cdf0e10cSrcweir 	aArguments[1].Value <<= xDrawPage;
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir 	aArguments[2].Name = C2U("AnimationNode");
943*cdf0e10cSrcweir 	aArguments[2].Value <<= xAnimationNode;
944*cdf0e10cSrcweir 
945*cdf0e10cSrcweir 	Reference< XWindow > xParentWindow;
946*cdf0e10cSrcweir 	if( pParent )
947*cdf0e10cSrcweir 		xParentWindow = VCLUnoHelper::GetInterface( pParent );
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir 	aArguments[3].Name = C2U("ParentWindow");
950*cdf0e10cSrcweir 	aArguments[3].Value <<= xParentWindow;
951*cdf0e10cSrcweir 
952*cdf0e10cSrcweir 	startWithArguments( aArguments );
953*cdf0e10cSrcweir 
954*cdf0e10cSrcweir 	return true;
955*cdf0e10cSrcweir }
956*cdf0e10cSrcweir 
957*cdf0e10cSrcweir // ---------------------------------------------------------
958*cdf0e10cSrcweir 
959*cdf0e10cSrcweir ShowWindow* SlideShow::getShowWindow()
960*cdf0e10cSrcweir {
961*cdf0e10cSrcweir 	return mxController.is() ? mxController->mpShowWindow : 0;
962*cdf0e10cSrcweir }
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir // ---------------------------------------------------------
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir int SlideShow::getAnimationMode()
967*cdf0e10cSrcweir {
968*cdf0e10cSrcweir 	return mxController.is() ? mxController->meAnimationMode : ANIMATIONMODE_SHOW;
969*cdf0e10cSrcweir }
970*cdf0e10cSrcweir 
971*cdf0e10cSrcweir // ---------------------------------------------------------
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir void SlideShow::jumpToPageIndex( sal_Int32 nPageIndex )
974*cdf0e10cSrcweir {
975*cdf0e10cSrcweir 	if( mxController.is() )
976*cdf0e10cSrcweir 		mxController->displaySlideIndex( nPageIndex );
977*cdf0e10cSrcweir }
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir // ---------------------------------------------------------
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir void SlideShow::jumpToPageNumber( sal_Int32 nPageNumber )
982*cdf0e10cSrcweir {
983*cdf0e10cSrcweir 	if( mxController.is() )
984*cdf0e10cSrcweir 		mxController->displaySlideNumber( nPageNumber );
985*cdf0e10cSrcweir }
986*cdf0e10cSrcweir 
987*cdf0e10cSrcweir // ---------------------------------------------------------
988*cdf0e10cSrcweir 
989*cdf0e10cSrcweir sal_Int32 SlideShow::getCurrentPageNumber()
990*cdf0e10cSrcweir {
991*cdf0e10cSrcweir 	return mxController.is() ? mxController->getCurrentSlideNumber() : 0;
992*cdf0e10cSrcweir }
993*cdf0e10cSrcweir 
994*cdf0e10cSrcweir // ---------------------------------------------------------
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir void SlideShow::jumpToBookmark( const OUString& sBookmark )
997*cdf0e10cSrcweir {
998*cdf0e10cSrcweir 	if( mxController.is() )
999*cdf0e10cSrcweir 		mxController->jumpToBookmark( sBookmark );
1000*cdf0e10cSrcweir }
1001*cdf0e10cSrcweir 
1002*cdf0e10cSrcweir // ---------------------------------------------------------
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir bool SlideShow::isFullScreen()
1005*cdf0e10cSrcweir {
1006*cdf0e10cSrcweir 	return mxController.is() ? mxController->maPresSettings.mbFullScreen : false;
1007*cdf0e10cSrcweir }
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir // ---------------------------------------------------------
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir void SlideShow::resize( const Size &rSize )
1012*cdf0e10cSrcweir {
1013*cdf0e10cSrcweir 	if( mxController.is() )
1014*cdf0e10cSrcweir 		mxController->resize( rSize );
1015*cdf0e10cSrcweir }
1016*cdf0e10cSrcweir 
1017*cdf0e10cSrcweir // ---------------------------------------------------------
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir void SlideShow::activate( ViewShellBase& rBase )
1020*cdf0e10cSrcweir {
1021*cdf0e10cSrcweir 	if( (mpFullScreenViewShellBase == &rBase) && !mxController.is() )
1022*cdf0e10cSrcweir 	{
1023*cdf0e10cSrcweir 	    ::boost::shared_ptr<PresentationViewShell> pShell = ::boost::dynamic_pointer_cast<PresentationViewShell>(rBase.GetMainViewShell());
1024*cdf0e10cSrcweir 		if(pShell.get() != NULL)
1025*cdf0e10cSrcweir 		{
1026*cdf0e10cSrcweir 		    pShell->FinishInitialization( mpFullScreenFrameView );
1027*cdf0e10cSrcweir 			mpFullScreenFrameView = 0;
1028*cdf0e10cSrcweir 
1029*cdf0e10cSrcweir 			CreateController( pShell.get(), pShell->GetView(), rBase.GetViewWindow() );
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir 			if( mxController->startShow(mxCurrentSettings.get()) )
1032*cdf0e10cSrcweir 			{
1033*cdf0e10cSrcweir 				pShell->Resize();
1034*cdf0e10cSrcweir 			}
1035*cdf0e10cSrcweir 			else
1036*cdf0e10cSrcweir 			{
1037*cdf0e10cSrcweir 				end();
1038*cdf0e10cSrcweir 				return;
1039*cdf0e10cSrcweir 			}
1040*cdf0e10cSrcweir 		}
1041*cdf0e10cSrcweir 	}
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir 	if( mxController.is() )
1044*cdf0e10cSrcweir 		mxController->activate();
1045*cdf0e10cSrcweir }
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir // ---------------------------------------------------------
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir void SlideShow::deactivate( ViewShellBase& /*rBase*/ )
1050*cdf0e10cSrcweir {
1051*cdf0e10cSrcweir 	mxController->deactivate();
1052*cdf0e10cSrcweir }
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir // ---------------------------------------------------------
1055*cdf0e10cSrcweir 
1056*cdf0e10cSrcweir bool SlideShow::keyInput(const KeyEvent& rKEvt)
1057*cdf0e10cSrcweir {
1058*cdf0e10cSrcweir 	return mxController.is() ? mxController->keyInput(rKEvt) : false;
1059*cdf0e10cSrcweir }
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir // ---------------------------------------------------------
1062*cdf0e10cSrcweir 
1063*cdf0e10cSrcweir void SlideShow::paint( const Rectangle& rRect )
1064*cdf0e10cSrcweir {
1065*cdf0e10cSrcweir 	if( mxController.is() )
1066*cdf0e10cSrcweir 		mxController->paint( rRect );
1067*cdf0e10cSrcweir }
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir // ---------------------------------------------------------
1070*cdf0e10cSrcweir 
1071*cdf0e10cSrcweir bool SlideShow::isAlwaysOnTop()
1072*cdf0e10cSrcweir {
1073*cdf0e10cSrcweir 	return mxController.is() ? mxController->maPresSettings.mbAlwaysOnTop : false;
1074*cdf0e10cSrcweir }
1075*cdf0e10cSrcweir 
1076*cdf0e10cSrcweir // ---------------------------------------------------------
1077*cdf0e10cSrcweir 
1078*cdf0e10cSrcweir bool SlideShow::pause( bool bPause )
1079*cdf0e10cSrcweir {
1080*cdf0e10cSrcweir 	if( mxController.is() )
1081*cdf0e10cSrcweir 	{
1082*cdf0e10cSrcweir 		if( bPause )
1083*cdf0e10cSrcweir 			mxController->pause();
1084*cdf0e10cSrcweir 		else
1085*cdf0e10cSrcweir 			mxController->resume();
1086*cdf0e10cSrcweir 	}
1087*cdf0e10cSrcweir 	return true;
1088*cdf0e10cSrcweir }
1089*cdf0e10cSrcweir 
1090*cdf0e10cSrcweir // ---------------------------------------------------------
1091*cdf0e10cSrcweir 
1092*cdf0e10cSrcweir void SlideShow::receiveRequest(SfxRequest& rReq)
1093*cdf0e10cSrcweir {
1094*cdf0e10cSrcweir 	if( mxController.is() )
1095*cdf0e10cSrcweir 		mxController->receiveRequest( rReq );
1096*cdf0e10cSrcweir }
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir // ---------------------------------------------------------
1099*cdf0e10cSrcweir 
1100*cdf0e10cSrcweir sal_Int32 SlideShow::getFirstPageNumber()
1101*cdf0e10cSrcweir {
1102*cdf0e10cSrcweir 	return mxController.is() ? mxController->getFirstSlideNumber() : 0;
1103*cdf0e10cSrcweir }
1104*cdf0e10cSrcweir 
1105*cdf0e10cSrcweir // ---------------------------------------------------------
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir sal_Int32 SlideShow::getLastPageNumber()
1108*cdf0e10cSrcweir {
1109*cdf0e10cSrcweir 	return mxController.is() ? mxController->getLastSlideNumber() : 0;
1110*cdf0e10cSrcweir }
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir // ---------------------------------------------------------
1113*cdf0e10cSrcweir 
1114*cdf0e10cSrcweir bool SlideShow::isEndless()
1115*cdf0e10cSrcweir {
1116*cdf0e10cSrcweir 	return mxController.is() ? mxController->isEndless() : false;
1117*cdf0e10cSrcweir }
1118*cdf0e10cSrcweir 
1119*cdf0e10cSrcweir // ---------------------------------------------------------
1120*cdf0e10cSrcweir 
1121*cdf0e10cSrcweir bool SlideShow::isDrawingPossible()
1122*cdf0e10cSrcweir {
1123*cdf0e10cSrcweir 	return mxController.is() ? mxController->getUsePen() : false;
1124*cdf0e10cSrcweir }
1125*cdf0e10cSrcweir 
1126*cdf0e10cSrcweir // ---------------------------------------------------------
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir void SlideShow::StartInPlacePresentationConfigurationCallback()
1129*cdf0e10cSrcweir {
1130*cdf0e10cSrcweir 	if( mnInPlaceConfigEvent != 0 )
1131*cdf0e10cSrcweir 		Application::RemoveUserEvent( mnInPlaceConfigEvent );
1132*cdf0e10cSrcweir 
1133*cdf0e10cSrcweir 	mnInPlaceConfigEvent = Application::PostUserEvent( LINK( this, SlideShow, StartInPlacePresentationConfigurationHdl ) );
1134*cdf0e10cSrcweir }
1135*cdf0e10cSrcweir 
1136*cdf0e10cSrcweir // ---------------------------------------------------------
1137*cdf0e10cSrcweir 
1138*cdf0e10cSrcweir IMPL_LINK( SlideShow, StartInPlacePresentationConfigurationHdl, void *, EMPTYARG )
1139*cdf0e10cSrcweir {
1140*cdf0e10cSrcweir 	mnInPlaceConfigEvent = 0;
1141*cdf0e10cSrcweir 	StartInPlacePresentation();
1142*cdf0e10cSrcweir 	return 0;
1143*cdf0e10cSrcweir }
1144*cdf0e10cSrcweir 
1145*cdf0e10cSrcweir // ---------------------------------------------------------
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir void SlideShow::StartInPlacePresentation()
1148*cdf0e10cSrcweir {
1149*cdf0e10cSrcweir 	if( mpCurrentViewShellBase )
1150*cdf0e10cSrcweir 	{
1151*cdf0e10cSrcweir 		// Save the current view shell type so that it can be restored after the
1152*cdf0e10cSrcweir 		// show has ended.  If there already is a saved shell type then that is
1153*cdf0e10cSrcweir 		// not overwritten.
1154*cdf0e10cSrcweir 
1155*cdf0e10cSrcweir 		ViewShell::ShellType eShell = ViewShell::ST_NONE;
1156*cdf0e10cSrcweir 
1157*cdf0e10cSrcweir 		::boost::shared_ptr<FrameworkHelper> pHelper(FrameworkHelper::Instance(*mpCurrentViewShellBase));
1158*cdf0e10cSrcweir 		::boost::shared_ptr<ViewShell> pMainViewShell(pHelper->GetViewShell(FrameworkHelper::msCenterPaneURL));
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir 		if( pMainViewShell.get() )
1161*cdf0e10cSrcweir 			eShell = pMainViewShell->GetShellType();
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir 		if( eShell != ViewShell::ST_IMPRESS )
1164*cdf0e10cSrcweir 		{
1165*cdf0e10cSrcweir 			// Switch temporary to a DrawViewShell which supports the in-place presentation.
1166*cdf0e10cSrcweir 
1167*cdf0e10cSrcweir 			if( pMainViewShell.get() )
1168*cdf0e10cSrcweir 			{
1169*cdf0e10cSrcweir 	            FrameView* pFrameView = pMainViewShell->GetFrameView();
1170*cdf0e10cSrcweir 		        pFrameView->SetPresentationViewShellId(SID_VIEWSHELL1);
1171*cdf0e10cSrcweir 				pFrameView->SetPreviousViewShellType (pMainViewShell->GetShellType());
1172*cdf0e10cSrcweir 			    pFrameView->SetPageKind (PK_STANDARD);
1173*cdf0e10cSrcweir 			}
1174*cdf0e10cSrcweir 
1175*cdf0e10cSrcweir 			pHelper->RequestView( FrameworkHelper::msImpressViewURL, FrameworkHelper::msCenterPaneURL );
1176*cdf0e10cSrcweir 			pHelper->RunOnConfigurationEvent( FrameworkHelper::msConfigurationUpdateEndEvent, ::boost::bind(&SlideShow::StartInPlacePresentationConfigurationCallback, this) );
1177*cdf0e10cSrcweir 			return;
1178*cdf0e10cSrcweir 		}
1179*cdf0e10cSrcweir 		else
1180*cdf0e10cSrcweir 		{
1181*cdf0e10cSrcweir 			::Window* pParentWindow = mxCurrentSettings->mpParentWindow;
1182*cdf0e10cSrcweir 			if( pParentWindow == 0 )
1183*cdf0e10cSrcweir 				pParentWindow = mpCurrentViewShellBase->GetViewWindow();
1184*cdf0e10cSrcweir 
1185*cdf0e10cSrcweir 			CreateController( pMainViewShell.get(), pMainViewShell->GetView(), pParentWindow );
1186*cdf0e10cSrcweir 		}
1187*cdf0e10cSrcweir 	}
1188*cdf0e10cSrcweir 	else if( mxCurrentSettings->mpParentWindow )
1189*cdf0e10cSrcweir 	{
1190*cdf0e10cSrcweir 		// no current view shell, but parent window
1191*cdf0e10cSrcweir 		CreateController( 0, 0, mxCurrentSettings->mpParentWindow );
1192*cdf0e10cSrcweir 	}
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir 	if( mxController.is() )
1195*cdf0e10cSrcweir 	{
1196*cdf0e10cSrcweir 		sal_Bool bSuccess = sal_False;
1197*cdf0e10cSrcweir 		if( mxCurrentSettings.get() && mxCurrentSettings->mbPreview )
1198*cdf0e10cSrcweir 		{
1199*cdf0e10cSrcweir 			bSuccess = mxController->startPreview(mxCurrentSettings->mxStartPage, mxCurrentSettings->mxAnimationNode, mxCurrentSettings->mpParentWindow );
1200*cdf0e10cSrcweir 		}
1201*cdf0e10cSrcweir 		else
1202*cdf0e10cSrcweir 		{
1203*cdf0e10cSrcweir 			bSuccess = mxController->startShow(mxCurrentSettings.get());
1204*cdf0e10cSrcweir 		}
1205*cdf0e10cSrcweir 
1206*cdf0e10cSrcweir 		if( !bSuccess )
1207*cdf0e10cSrcweir 			end();
1208*cdf0e10cSrcweir 	}
1209*cdf0e10cSrcweir }
1210*cdf0e10cSrcweir 
1211*cdf0e10cSrcweir // ---------------------------------------------------------
1212*cdf0e10cSrcweir 
1213*cdf0e10cSrcweir void SlideShow::StartFullscreenPresentation( )
1214*cdf0e10cSrcweir {
1215*cdf0e10cSrcweir     // Create the top level window in which the PresentationViewShell(Base)
1216*cdf0e10cSrcweir     // will be created.  This is done here explicitly so that we can make it
1217*cdf0e10cSrcweir     // fullscreen.
1218*cdf0e10cSrcweir     const sal_Int32 nDisplay (GetDisplay());
1219*cdf0e10cSrcweir     WorkWindow* pWorkWindow = new FullScreenWorkWindow(this, mpCurrentViewShellBase);
1220*cdf0e10cSrcweir     pWorkWindow->SetBackground(Wallpaper(COL_BLACK));
1221*cdf0e10cSrcweir     pWorkWindow->StartPresentationMode( sal_True, mpDoc->getPresentationSettings().mbAlwaysOnTop ? PRESENTATION_HIDEALLAPPS : 0, nDisplay);
1222*cdf0e10cSrcweir     //    pWorkWindow->ShowFullScreenMode(sal_False, nDisplay);
1223*cdf0e10cSrcweir 
1224*cdf0e10cSrcweir     if (pWorkWindow->IsVisible())
1225*cdf0e10cSrcweir     {
1226*cdf0e10cSrcweir         // Initialize the new presentation view shell with a copy of the
1227*cdf0e10cSrcweir         // frame view of the current view shell.  This avoids that
1228*cdf0e10cSrcweir         // changes made by the presentation have an effect on the other
1229*cdf0e10cSrcweir         // view shells.
1230*cdf0e10cSrcweir 		FrameView* pOriginalFrameView = mpCurrentViewShellBase ? mpCurrentViewShellBase->GetMainViewShell()->GetFrameView() : 0;
1231*cdf0e10cSrcweir 
1232*cdf0e10cSrcweir 		if( mpFullScreenFrameView )
1233*cdf0e10cSrcweir 			delete mpFullScreenFrameView;
1234*cdf0e10cSrcweir         mpFullScreenFrameView = new FrameView(mpDoc, pOriginalFrameView);
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir //	    Reference<XController> xController;
1237*cdf0e10cSrcweir 
1238*cdf0e10cSrcweir 		// The new frame is created hidden.  To make it visible and activate the
1239*cdf0e10cSrcweir 	    // new view shell--a prerequisite to process slot calls and initialize
1240*cdf0e10cSrcweir 		// its panes--a GrabFocus() has to be called later on.
1241*cdf0e10cSrcweir 		SfxFrame* pNewFrame = SfxFrame::Create( *mpDoc->GetDocSh(), *pWorkWindow, PRESENTATION_FACTORY_ID, true );
1242*cdf0e10cSrcweir 		pNewFrame->SetPresentationMode(sal_True);
1243*cdf0e10cSrcweir 
1244*cdf0e10cSrcweir 		mpFullScreenViewShellBase = static_cast<ViewShellBase*>(pNewFrame->GetCurrentViewFrame()->GetViewShell());
1245*cdf0e10cSrcweir 		if(mpFullScreenViewShellBase != NULL)
1246*cdf0e10cSrcweir 		{
1247*cdf0e10cSrcweir 			// The following GrabFocus() is responsible for activating the
1248*cdf0e10cSrcweir 			// new view shell.  Without it the screen remains blank (under
1249*cdf0e10cSrcweir 			// Windows and some Linux variants.)
1250*cdf0e10cSrcweir 			mpFullScreenViewShellBase->GetWindow()->GrabFocus();
1251*cdf0e10cSrcweir 		}
1252*cdf0e10cSrcweir 	}
1253*cdf0e10cSrcweir }
1254*cdf0e10cSrcweir 
1255*cdf0e10cSrcweir // ---------------------------------------------------------
1256*cdf0e10cSrcweir 
1257*cdf0e10cSrcweir sal_Int32 SlideShow::GetDisplay()
1258*cdf0e10cSrcweir 
1259*cdf0e10cSrcweir {
1260*cdf0e10cSrcweir 	sal_Int32 nDisplay = 0;
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir 	SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
1263*cdf0e10cSrcweir 	if( pOptions )
1264*cdf0e10cSrcweir 		nDisplay = pOptions->GetDisplay();
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir     return nDisplay;
1267*cdf0e10cSrcweir }
1268*cdf0e10cSrcweir 
1269*cdf0e10cSrcweir // ---------------------------------------------------------
1270*cdf0e10cSrcweir 
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir bool SlideShow::dependsOn( ViewShellBase* pViewShellBase )
1273*cdf0e10cSrcweir {
1274*cdf0e10cSrcweir 	return mxController.is() && (pViewShellBase == mpCurrentViewShellBase) && mpFullScreenViewShellBase;
1275*cdf0e10cSrcweir }
1276*cdf0e10cSrcweir 
1277*cdf0e10cSrcweir // ---------------------------------------------------------
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir Reference< XPresentation2 > CreatePresentation( const SdDrawDocument& rDocument )
1280*cdf0e10cSrcweir {
1281*cdf0e10cSrcweir 	return Reference< XPresentation2 >( SlideShow::Create( const_cast< SdDrawDocument* >( &rDocument ) ).get() );
1282*cdf0e10cSrcweir }
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir // ---------------------------------------------------------
1285*cdf0e10cSrcweir 
1286