Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSCREEN_HXX
21 : #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSCREEN_HXX
22 :
23 : #include "PresenterConfigurationAccess.hxx"
24 : #include "PresenterPaneContainer.hxx"
25 : #include <cppuhelper/compbase1.hxx>
26 : #include <cppuhelper/basemutex.hxx>
27 : #include <com/sun/star/lang/XInitialization.hpp>
28 : #include <com/sun/star/frame/XController.hpp>
29 : #include <com/sun/star/frame/XModel2.hpp>
30 : #include <com/sun/star/task/XJob.hpp>
31 : #include <com/sun/star/document/XEventListener.hpp>
32 : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
33 : #include <com/sun/star/drawing/framework/XView.hpp>
34 : #include <com/sun/star/presentation/XSlideShowController.hpp>
35 : #include <com/sun/star/presentation/XPresentation2.hpp>
36 : #include <rtl/ref.hxx>
37 : #include <boost/noncopyable.hpp>
38 :
39 : namespace sdext { namespace presenter {
40 :
41 : class PresenterController;
42 :
43 : namespace {
44 : typedef ::cppu::WeakComponentImplHelper1 <
45 : css::task::XJob
46 : > PresenterScreenJobInterfaceBase;
47 : typedef ::cppu::WeakComponentImplHelper1 <
48 : css::lang::XEventListener
49 : > PresenterScreenInterfaceBase;
50 : }
51 :
52 : /** The PresenterScreenJob service is instantiated every time a document is
53 : created or loaded. In its execute() method it then filters out all
54 : non-Impress documents and creates and registers a new PresenterScreen
55 : object.
56 : */
57 : class PresenterScreenJob
58 : : private ::boost::noncopyable,
59 : private ::cppu::BaseMutex,
60 : public PresenterScreenJobInterfaceBase
61 : {
62 : public:
63 : static OUString getImplementationName_static (void);
64 : static css::uno::Sequence< OUString > getSupportedServiceNames_static (void);
65 : static css::uno::Reference<css::uno::XInterface> Create(
66 : const css::uno::Reference<css::uno::XComponentContext>& rxContext)
67 : SAL_THROW((css::uno::Exception));
68 :
69 : virtual void SAL_CALL disposing (void) SAL_OVERRIDE;
70 :
71 : // XJob
72 :
73 : virtual css::uno::Any SAL_CALL execute(
74 : const css::uno::Sequence<css::beans::NamedValue >& Arguments)
75 : throw (css::lang::IllegalArgumentException,
76 : css::uno::Exception,
77 : css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
78 :
79 : private:
80 : PresenterScreenJob (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
81 : virtual ~PresenterScreenJob (void);
82 :
83 : css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
84 : };
85 :
86 : /** This is the bootstrap class of the presenter screen. It is registered
87 : as drawing framework startup service. That means that every drawing
88 : framework instance creates an instance of this class.
89 :
90 : <p>A PresenterScreen object registers itself as listener for drawing
91 : framework configuration changes. It waits for the full screen marker (a
92 : top level resource) to appear in the current configuration. When that
93 : happens the actual presenter screen is initialized. A new
94 : PresenterController is created and takes over the task of controlling
95 : the presenter screen.</p>
96 : */
97 : class PresenterScreen
98 : : private ::boost::noncopyable,
99 : private ::cppu::BaseMutex,
100 : public PresenterScreenInterfaceBase
101 : {
102 : public:
103 : PresenterScreen (
104 : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
105 : const css::uno::Reference<css::frame::XModel2>& rxModel);
106 : virtual ~PresenterScreen (void);
107 :
108 : virtual void SAL_CALL disposing (void) SAL_OVERRIDE;
109 :
110 : bool isPresenterScreenEnabled(
111 : const css::uno::Reference<css::uno::XComponentContext>& rxContext);
112 : /** Make the presenter screen visible.
113 : */
114 : void InitializePresenterScreen (void);
115 :
116 : /** Do not call ShutdownPresenterScreen() directly. Call
117 : RequestShutdownPresenterScreen() instead. It will issue an
118 : asynchronous call to ShutdownPresenterScreen() when that is safe.
119 : */
120 : void RequestShutdownPresenterScreen (void);
121 :
122 : /** Switch / converse monitors between presenter view and slide output
123 : */
124 : void SwitchMonitors (void);
125 :
126 : // XEventListener
127 :
128 : virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 :
130 : private:
131 : css::uno::Reference<css::frame::XModel2 > mxModel;
132 : css::uno::Reference<css::frame::XController> mxController;
133 : css::uno::WeakReference<css::drawing::framework::XConfigurationController>
134 : mxConfigurationControllerWeak;
135 : css::uno::WeakReference<css::uno::XComponentContext> mxContextWeak;
136 : css::uno::WeakReference<css::presentation::XSlideShowController> mxSlideShowControllerWeak;
137 : ::rtl::Reference<PresenterController> mpPresenterController;
138 : css::uno::Reference<css::drawing::framework::XResourceId> mxSlideShowViewId;
139 : css::uno::Reference<css::drawing::framework::XConfiguration> mxSavedConfiguration;
140 : ::rtl::Reference<PresenterPaneContainer> mpPaneContainer;
141 : sal_Int32 mnComponentIndex;
142 : css::uno::Reference<css::drawing::framework::XResourceFactory> mxPaneFactory;
143 : css::uno::Reference<css::drawing::framework::XResourceFactory> mxViewFactory;
144 :
145 0 : class ViewDescriptor
146 : {
147 : public:
148 : OUString msTitle;
149 : OUString msAccessibleTitle;
150 : bool mbIsOpaque;
151 0 : ViewDescriptor()
152 0 : : mbIsOpaque(false)
153 : {
154 0 : }
155 : };
156 : typedef ::std::map<OUString,ViewDescriptor> ViewDescriptorContainer;
157 : ViewDescriptorContainer maViewDescriptors;
158 :
159 : void ShutdownPresenterScreen (void);
160 :
161 : /** Create and initialize the factory for presenter view specific panes.
162 : */
163 : void SetupPaneFactory (
164 : const css::uno::Reference<css::uno::XComponentContext>& rxContext);
165 :
166 : /** Create and initialize the factory for presenter view specific views.
167 : */
168 : void SetupViewFactory (
169 : const css::uno::Reference<css::uno::XComponentContext>& rxContext);
170 :
171 : /** Read the current layout from the configuration and call
172 : ProcessLayout to bring it on to the screen.
173 : */
174 : void SetupConfiguration (
175 : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
176 : const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
177 :
178 : /** Read one layout from the configuration and make resource activation
179 : requests to bring it on to the screen. When one layout references a
180 : parent layout then this method calls itself recursively.
181 : */
182 : void ProcessLayout (
183 : PresenterConfigurationAccess& rConfiguration,
184 : const OUString& rsLayoutName,
185 : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
186 : const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
187 :
188 : /** Called by ProcessLayout for a single entry of a Layouts
189 : configuration list.
190 : */
191 : void ProcessComponent (
192 : const OUString& rsKey,
193 : const ::std::vector<css::uno::Any>& rValues,
194 : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
195 : const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
196 :
197 : /** Read the view descriptions from the configuration.
198 : */
199 : void ProcessViewDescriptions (
200 : PresenterConfigurationAccess& rConfiguration);
201 :
202 : /** Called by ProcessViewDescriptions for a single entry.
203 : */
204 : void ProcessViewDescription (
205 : const OUString& rsKey,
206 : const ::std::vector<css::uno::Any>& rValues);
207 :
208 : void SetupView (
209 : const css::uno::Reference<css::uno::XComponentContext>& rxContext,
210 : const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId,
211 : const OUString& rsPaneURL,
212 : const OUString& rsViewURL,
213 : const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization,
214 : const double nLeft,
215 : const double nTop,
216 : const double nRight,
217 : const double nBottom);
218 :
219 : /** Return the built-in screen number on the presentation will normally
220 : display the presenter console.
221 : @return
222 : Returns -1 when the presenter screen can or shall not be
223 : displayed.
224 : */
225 : sal_Int32 GetPresenterScreenNumber (
226 : const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const;
227 :
228 : sal_Int32 GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen ) 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 :
241 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|