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