Bump version to 5.0-14
[LibreOffice.git] / sdext / source / presenter / PresenterScreen.hxx
blob44931fbbcfaf3d65c61b91245b6768de9e34a1c4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSCREEN_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSCREEN_HXX
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>
39 namespace sdext { namespace presenter {
41 class PresenterController;
43 namespace {
44 typedef ::cppu::WeakComponentImplHelper1 <
45 css::task::XJob
46 > PresenterScreenJobInterfaceBase;
47 typedef ::cppu::WeakComponentImplHelper1 <
48 css::lang::XEventListener
49 > PresenterScreenInterfaceBase;
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.
57 class PresenterScreenJob
58 : private ::boost::noncopyable,
59 private ::cppu::BaseMutex,
60 public PresenterScreenJobInterfaceBase
62 public:
63 static OUString getImplementationName_static();
64 static css::uno::Sequence< OUString > getSupportedServiceNames_static();
65 static css::uno::Reference<css::uno::XInterface> Create(
66 const css::uno::Reference<css::uno::XComponentContext>& rxContext);
68 virtual void SAL_CALL disposing() SAL_OVERRIDE;
70 // XJob
72 virtual css::uno::Any SAL_CALL execute(
73 const css::uno::Sequence<css::beans::NamedValue >& Arguments)
74 throw (css::lang::IllegalArgumentException,
75 css::uno::Exception,
76 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
78 private:
79 PresenterScreenJob (const css::uno::Reference<css::uno::XComponentContext>& rxContext);
80 virtual ~PresenterScreenJob();
82 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
85 /** This is the bootstrap class of the presenter screen. It is registered
86 as drawing framework startup service. That means that every drawing
87 framework instance creates an instance of this class.
89 <p>A PresenterScreen object registers itself as listener for drawing
90 framework configuration changes. It waits for the full screen marker (a
91 top level resource) to appear in the current configuration. When that
92 happens the actual presenter screen is initialized. A new
93 PresenterController is created and takes over the task of controlling
94 the presenter screen.</p>
96 class PresenterScreen
97 : private ::boost::noncopyable,
98 private ::cppu::BaseMutex,
99 public PresenterScreenInterfaceBase
101 public:
102 PresenterScreen (
103 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
104 const css::uno::Reference<css::frame::XModel2>& rxModel);
105 virtual ~PresenterScreen();
107 virtual void SAL_CALL disposing() SAL_OVERRIDE;
109 static bool isPresenterScreenEnabled(
110 const css::uno::Reference<css::uno::XComponentContext>& rxContext);
111 /** Make the presenter screen visible.
113 void InitializePresenterScreen();
115 /** Do not call ShutdownPresenterScreen() directly. Call
116 RequestShutdownPresenterScreen() instead. It will issue an
117 asynchronous call to ShutdownPresenterScreen() when that is safe.
119 void RequestShutdownPresenterScreen();
121 /** Switch / converse monitors between presenter view and slide output
123 void SwitchMonitors();
125 // XEventListener
127 virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 private:
130 css::uno::Reference<css::frame::XModel2 > mxModel;
131 css::uno::Reference<css::frame::XController> mxController;
132 css::uno::WeakReference<css::drawing::framework::XConfigurationController>
133 mxConfigurationControllerWeak;
134 css::uno::WeakReference<css::uno::XComponentContext> mxContextWeak;
135 css::uno::WeakReference<css::presentation::XSlideShowController> mxSlideShowControllerWeak;
136 ::rtl::Reference<PresenterController> mpPresenterController;
137 css::uno::Reference<css::drawing::framework::XResourceId> mxSlideShowViewId;
138 css::uno::Reference<css::drawing::framework::XConfiguration> mxSavedConfiguration;
139 ::rtl::Reference<PresenterPaneContainer> mpPaneContainer;
140 sal_Int32 mnComponentIndex;
141 css::uno::Reference<css::drawing::framework::XResourceFactory> mxPaneFactory;
142 css::uno::Reference<css::drawing::framework::XResourceFactory> mxViewFactory;
144 class ViewDescriptor
146 public:
147 OUString msTitle;
148 OUString msAccessibleTitle;
149 bool mbIsOpaque;
150 ViewDescriptor()
151 : mbIsOpaque(false)
155 typedef ::std::map<OUString,ViewDescriptor> ViewDescriptorContainer;
156 ViewDescriptorContainer maViewDescriptors;
158 void ShutdownPresenterScreen();
160 /** Create and initialize the factory for presenter view specific panes.
162 void SetupPaneFactory (
163 const css::uno::Reference<css::uno::XComponentContext>& rxContext);
165 /** Create and initialize the factory for presenter view specific views.
167 void SetupViewFactory (
168 const css::uno::Reference<css::uno::XComponentContext>& rxContext);
170 /** Read the current layout from the configuration and call
171 ProcessLayout to bring it on to the screen.
173 void SetupConfiguration (
174 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
175 const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
177 /** Read one layout from the configuration and make resource activation
178 requests to bring it on to the screen. When one layout references a
179 parent layout then this method calls itself recursively.
181 void ProcessLayout (
182 PresenterConfigurationAccess& rConfiguration,
183 const OUString& rsLayoutName,
184 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
185 const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
187 /** Called by ProcessLayout for a single entry of a Layouts
188 configuration list.
190 void ProcessComponent (
191 const OUString& rsKey,
192 const ::std::vector<css::uno::Any>& rValues,
193 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
194 const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId);
196 /** Read the view descriptions from the configuration.
198 void ProcessViewDescriptions (
199 PresenterConfigurationAccess& rConfiguration);
201 /** Called by ProcessViewDescriptions for a single entry.
203 void ProcessViewDescription (
204 const OUString& rsKey,
205 const ::std::vector<css::uno::Any>& rValues);
207 void SetupView (
208 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
209 const css::uno::Reference<css::drawing::framework::XResourceId>& rxAnchorId,
210 const OUString& rsPaneURL,
211 const OUString& rsViewURL,
212 const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization,
213 const double nLeft,
214 const double nTop,
215 const double nRight,
216 const double nBottom);
218 /** Return the built-in screen number on the presentation will normally
219 display the presenter console.
220 @return
221 Returns -1 when the presenter screen can or shall not be
222 displayed.
224 sal_Int32 GetPresenterScreenNumber (
225 const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const;
227 static sal_Int32 GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen );
229 /** Create a resource id for the full screen background pane so that it
230 is displayed on another screen than the full screen presentation.
232 css::uno::Reference<css::drawing::framework::XResourceId> GetMainPaneId (
233 const css::uno::Reference<css::presentation::XPresentation2>& rxPresentation) const;
238 #endif
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */