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