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