xref: /trunk/main/sd/source/ui/slideshow/SlideShowRestarter.hxx (revision ffd38472365e95f6a578737bc9a5eb0fac624a86)
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 #include "precompiled_sd.hxx"
23 
24 #include "slideshow.hxx"
25 #include "ViewShellBase.hxx"
26 #include <rtl/ref.hxx>
27 #include <tools/link.hxx>
28 #include <boost/enable_shared_from_this.hpp>
29 
30 namespace sd {
31 
32 /** This class is used when a display is removed or added to restart the
33     slide show. This is necessary at least with DirectX because
34     deactivating a display invalidates DirectX resources. Accessing those
35     leads to a crash.
36 
37     During a restart a possibly installed presenter extension is given the
38     opportunity to show or hide depending on the number of available displays.
39 */
40 class SlideShowRestarter
41     : public boost::enable_shared_from_this<SlideShowRestarter>
42 {
43 public:
44     /** Create a new SlideShowRestarter object.
45         @param rpSlideShow
46             The slide show is used to determine the current slide, which is
47             restored after the restart, and of course to stop and start the
48             slide show.
49         @param pViewShellBase
50             Used to get access to a slot dispatcher.
51     */
52     SlideShowRestarter (
53         const ::rtl::Reference<SlideShow>& rpSlideShow,
54         ViewShellBase* pViewShellBase);
55     virtual ~SlideShowRestarter (void);
56 
57     /** Restarting the slide show is an asynchronous multi step process
58         which is started by calling this method.
59     */
60     void Restart (void);
61 
62 private:
63     sal_Int32 mnEventId;
64     ::rtl::Reference<SlideShow> mpSlideShow;
65     ViewShellBase* mpViewShellBase;
66     ::boost::shared_ptr<SlideShowRestarter> mpSelf;
67     sal_Int32 mnDisplayCount;
68     SfxDispatcher* mpDispatcher;
69     sal_Int32 mnCurrentSlideNumber;
70 
71     /** The display count is used to determine whether the number of
72         displays has changed and thus whether restarting the slide show is
73         really necessary.
74     */
75     sal_Int32 GetDisplayCount (void);
76 
77     DECL_LINK(EndPresentation, void*);
78 
79     /** Restart the presentation on the slide last shown before the restart
80         was initiated.
81     */
82     void StartPresentation (void);
83 };
84 
85 } // end of namespace sd
86 
87 /* vim: set noet sw=4 ts=4: */
88