xref: /trunk/main/sdext/source/presenter/PresenterScreen.hxx (revision 45c5a00162811bd03b87fcb4fe9996782f2b59ec)
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 #ifndef SDEXT_PRESENTER_PRESENTER_SCREEN_HXX
25 #define SDEXT_PRESENTER_PRESENTER_SCREEN_HXX
26 
27 #include "PresenterConfigurationAccess.hxx"
28 #include "PresenterPaneContainer.hxx"
29 #include <cppuhelper/compbase1.hxx>
30 #include <cppuhelper/basemutex.hxx>
31 #include <com/sun/star/lang/XInitialization.hpp>
32 #include <com/sun/star/frame/XController.hpp>
33 #include <com/sun/star/frame/XModel2.hpp>
34 #include <com/sun/star/task/XJob.hpp>
35 #include <com/sun/star/document/XEventListener.hpp>
36 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
37 #include <com/sun/star/drawing/framework/XView.hpp>
38 #include <com/sun/star/presentation/XSlideShowController.hpp>
39 #include <com/sun/star/presentation/XPresentation2.hpp>
40 #include <rtl/ref.hxx>
41 #include <boost/noncopyable.hpp>
42 #include <boost/shared_ptr.hpp>
43 #include <boost/scoped_ptr.hpp>
44 
45 namespace css = ::com::sun::star;
46 
47 namespace sdext { namespace presenter {
48 
49 class PresenterWindowManager;
50 class PresenterController;
51 
52 namespace {
53     typedef ::cppu::WeakComponentImplHelper1 <
54         css::task::XJob
55         > PresenterScreenJobInterfaceBase;
56     typedef ::cppu::WeakComponentImplHelper1 <
57         css::lang::XEventListener
58         > PresenterScreenInterfaceBase;
59 }
60 
61 
62 
63 
64 /** The PresenterScreenJob service is instantiated every time a document is
65     created or loaded.  In its execute() method it then filters out all
66     non-Impress documents and creates and registers a new PresenterScreen
67     object.
68 */
69 class PresenterScreenJob
70     : private ::boost::noncopyable,
71       private ::cppu::BaseMutex,
72       public PresenterScreenJobInterfaceBase
73 {
74 public:
75     static ::rtl::OUString getImplementationName_static (void);
76     static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void);
77     static css::uno::Reference<css::uno::XInterface> Create(
78         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
79 
80     virtual void SAL_CALL disposing (void);
81 
82     // XJob
83 
84     virtual css::uno::Any SAL_CALL execute(
85         const css::uno::Sequence<css::beans::NamedValue >& Arguments);
86 
87 private:
88     PresenterScreenJob (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
89     virtual ~PresenterScreenJob (void);
90 
91     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
92 };
93 
94 
95 
96 
97 /** This is the bootstrap class of the presenter screen.  It is registered
98     as drawing framework startup service.  That means that every drawing
99     framework instance creates an instance of this class.
100 
101     <p>A PresenterScreen object registers itself as listener for drawing
102     framework configuration changes.  It waits for the full screen marker (a
103     top level resource) to appear in the current configuration.  When that
104     happens the actual presenter screen is initialized.  A new
105     PresenterController is created and takes over the task of controlling
106     the presenter screen.</p>
107 */
108 class PresenterScreen
109     : private ::boost::noncopyable,
110       private ::cppu::BaseMutex,
111       public PresenterScreenInterfaceBase
112 {
113 public:
114     PresenterScreen (
115         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
116         const css::uno::Reference<css::frame::XModel2>& rxModel);
117     virtual ~PresenterScreen (void);
118 
119     virtual void SAL_CALL disposing (void);
120 
121     /** Make the presenter screen visible.
122     */
123     void InitializePresenterScreen (void);
124 
125     /** Do not call ShutdownPresenterScreen() directly.  Call
126         RequestShutdownPresenterScreen() instead.  It will issue an
127         asynchronous call to ShutdownPresenterScreen() when that is safe.
128     */
129     void RequestShutdownPresenterScreen (void);
130 
131 
132     // XEventListener
133 
134     virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent);
135 
136 private:
137     css::uno::Reference<css::frame::XModel2 > mxModel;
138     css::uno::Reference<css::frame::XController> mxController;
139     css::uno::WeakReference<css::drawing::framework::XConfigurationController>
140         mxConfigurationControllerWeak;
141     css::uno::WeakReference<css::uno::XComponentContext> mxContextWeak;
142     css::uno::WeakReference<css::presentation::XSlideShowController> mxSlideShowControllerWeak;
143     ::rtl::Reference<PresenterController> mpPresenterController;
144     css::uno::Reference<css::drawing::framework::XResourceId> mxSlideShowViewId;
145     css::uno::Reference<css::drawing::framework::XConfiguration> mxSavedConfiguration;
146     ::rtl::Reference<PresenterPaneContainer> mpPaneContainer;
147     sal_Int32 mnComponentIndex;
148     css::uno::Reference<css::drawing::framework::XResourceFactory> mxPaneFactory;
149     css::uno::Reference<css::drawing::framework::XResourceFactory> mxViewFactory;
150 
151     class ViewDescriptor
152     {
153     public:
154         ::rtl::OUString msTitle;
155         ::rtl::OUString msAccessibleTitle;
156         bool mbIsOpaque;
157     };
158     typedef ::std::map<rtl::OUString,ViewDescriptor> ViewDescriptorContainer;
159     ViewDescriptorContainer maViewDescriptors;
160 
161 
162     void ShutdownPresenterScreen (void);
163 
164     /** Create and initialize the factory for presenter view specific panes.
165     */
166     void SetupPaneFactory (
167         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
168 
169     /** Create and initialize the factory for presenter view specific views.
170     */
171     void SetupViewFactory (
172         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
173 
174     /** Read the current layout from the configuration and call
175         ProcessLayout to bring it on to the screen.
176     */
177     void SetupConfiguration (
178         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
179         const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
180 
181     /** Read one layout from the configuration and make resource activation
182         requests to bring it on to the screen.  When one layout references a
183         parent layout then this method calls itself recursively.
184     */
185     void ProcessLayout (
186         PresenterConfigurationAccess& rConfiguration,
187         const ::rtl::OUString& rsLayoutName,
188         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
189         const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
190 
191     /** Called by ProcessLayout for a single entry of a Layouts
192         configuration list.
193     */
194     void ProcessComponent (
195         const ::rtl::OUString& rsKey,
196         const ::std::vector<css::uno::Any>& rValues,
197         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
198         const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
199 
200     /** Read the view descriptions from the configuration.
201     */
202     void ProcessViewDescriptions (
203         PresenterConfigurationAccess& rConfiguration);
204 
205     /** Called by ProcessViewDescriptions for a single entry.
206     */
207     void ProcessViewDescription (
208         const ::rtl::OUString& rsKey,
209         const ::std::vector<css::uno::Any>& rValues);
210 
211     void SetupView (
212         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
213         const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId,
214         const ::rtl::OUString& rsPaneURL,
215         const ::rtl::OUString& rsViewURL,
216         const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization,
217         const double nLeft,
218         const double nTop,
219         const double nRight,
220         const double nBottom);
221 
222     /** Return the screen number on which to display the presenter screen.
223         @return
224             Returns -1 when the presenter screen can or shall not be
225             displayed.
226     */
227     sal_Int32 GetScreenNumber (
228         const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const;
229 
230     /** Create a resource id for the full screen background pane so that it
231         is displayed on another screen than the full screen presentation.
232     */
233     css::uno::Reference<css::drawing::framework::XResourceId> GetMainPaneId (
234         const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const;
235 };
236 
237 } }
238 
239 #endif
240