1c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c45d927aSAndrew Rist  * distributed with this work for additional information
6c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10c45d927aSAndrew Rist  *
11c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12c45d927aSAndrew Rist  *
13c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17c45d927aSAndrew Rist  * specific language governing permissions and limitations
18c45d927aSAndrew Rist  * under the License.
19c45d927aSAndrew Rist  *
20c45d927aSAndrew Rist  *************************************************************/
21c45d927aSAndrew Rist 
22c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "slideshow.hxx"
27cdf0e10cSrcweir #include "ViewShellBase.hxx"
28cdf0e10cSrcweir #include <rtl/ref.hxx>
29cdf0e10cSrcweir #include <tools/link.hxx>
30cdf0e10cSrcweir #include <boost/enable_shared_from_this.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace sd {
33cdf0e10cSrcweir 
34cdf0e10cSrcweir /** This class is used when a display is removed or added to restart the
35cdf0e10cSrcweir     slide show.  This is necessary at least with DirectX because
36cdf0e10cSrcweir     deactivating a display invalidates DirectX resources.  Accessing those
37cdf0e10cSrcweir     leads to a crash.
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     During a restart a possibly installed presenter extension is given the
40*86e1cf34SPedro Giffuni     opportunity to show or hide depending on the number of available displays.
41cdf0e10cSrcweir */
42cdf0e10cSrcweir class SlideShowRestarter
43cdf0e10cSrcweir     : public boost::enable_shared_from_this<SlideShowRestarter>
44cdf0e10cSrcweir {
45cdf0e10cSrcweir public:
46cdf0e10cSrcweir     /** Create a new SlideShowRestarter object.
47cdf0e10cSrcweir         @param rpSlideShow
48cdf0e10cSrcweir             The slide show is used to determine the current slide, which is
49cdf0e10cSrcweir             restored after the restart, and of course to stop and start the
50cdf0e10cSrcweir             slide show.
51cdf0e10cSrcweir         @param pViewShellBase
52cdf0e10cSrcweir             Used to get access to a slot dispatcher.
53cdf0e10cSrcweir     */
54cdf0e10cSrcweir     SlideShowRestarter (
55cdf0e10cSrcweir         const ::rtl::Reference<SlideShow>& rpSlideShow,
56cdf0e10cSrcweir         ViewShellBase* pViewShellBase);
57cdf0e10cSrcweir     virtual ~SlideShowRestarter (void);
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     /** Restarting the slide show is an asynchronous multi step process
60cdf0e10cSrcweir         which is started by calling this method.
61cdf0e10cSrcweir     */
62cdf0e10cSrcweir     void Restart (void);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir private:
65cdf0e10cSrcweir     sal_Int32 mnEventId;
66cdf0e10cSrcweir     ::rtl::Reference<SlideShow> mpSlideShow;
67cdf0e10cSrcweir     ViewShellBase* mpViewShellBase;
68cdf0e10cSrcweir     ::boost::shared_ptr<SlideShowRestarter> mpSelf;
69cdf0e10cSrcweir     sal_Int32 mnDisplayCount;
70cdf0e10cSrcweir     SfxDispatcher* mpDispatcher;
71cdf0e10cSrcweir     sal_Int32 mnCurrentSlideNumber;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     /** The display count is used to determine whether the number of
74cdf0e10cSrcweir         displays has changed and thus whether restarting the slide show is
75cdf0e10cSrcweir         really necessary.
76cdf0e10cSrcweir     */
77cdf0e10cSrcweir     sal_Int32 GetDisplayCount (void);
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     DECL_LINK(EndPresentation, void*);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     /** Restart the presentation on the slide last shown before the restart
82cdf0e10cSrcweir         was initiated.
83cdf0e10cSrcweir     */
84cdf0e10cSrcweir     void StartPresentation (void);
85cdf0e10cSrcweir };
86cdf0e10cSrcweir 
87cdf0e10cSrcweir } // end of namespace sd
88