1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 SDEXT_PRESENTER_PRESENTER_SCREEN_HXX
21 #define SDEXT_PRESENTER_PRESENTER_SCREEN_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>
38 #include <boost/shared_ptr.hpp>
39 #include <boost/scoped_ptr.hpp>
41 namespace sdext
{ namespace presenter
{
43 class PresenterController
;
46 typedef ::cppu::WeakComponentImplHelper1
<
48 > PresenterScreenJobInterfaceBase
;
49 typedef ::cppu::WeakComponentImplHelper1
<
50 css::lang::XEventListener
51 > PresenterScreenInterfaceBase
;
54 /** The PresenterScreenJob service is instantiated every time a document is
55 created or loaded. In its execute() method it then filters out all
56 non-Impress documents and creates and registers a new PresenterScreen
59 class PresenterScreenJob
60 : private ::boost::noncopyable
,
61 private ::cppu::BaseMutex
,
62 public PresenterScreenJobInterfaceBase
65 static OUString
getImplementationName_static (void);
66 static css::uno::Sequence
< OUString
> getSupportedServiceNames_static (void);
67 static css::uno::Reference
<css::uno::XInterface
> Create(
68 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
)
69 SAL_THROW((css::uno::Exception
));
71 virtual void SAL_CALL
disposing (void);
75 virtual css::uno::Any SAL_CALL
execute(
76 const css::uno::Sequence
<css::beans::NamedValue
>& Arguments
)
77 throw (css::lang::IllegalArgumentException
,
79 css::uno::RuntimeException
);
82 PresenterScreenJob (const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
);
83 virtual ~PresenterScreenJob (void);
85 css::uno::Reference
<css::uno::XComponentContext
> mxComponentContext
;
88 /** This is the bootstrap class of the presenter screen. It is registered
89 as drawing framework startup service. That means that every drawing
90 framework instance creates an instance of this class.
92 <p>A PresenterScreen object registers itself as listener for drawing
93 framework configuration changes. It waits for the full screen marker (a
94 top level resource) to appear in the current configuration. When that
95 happens the actual presenter screen is initialized. A new
96 PresenterController is created and takes over the task of controlling
97 the presenter screen.</p>
100 : private ::boost::noncopyable
,
101 private ::cppu::BaseMutex
,
102 public PresenterScreenInterfaceBase
106 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
107 const css::uno::Reference
<css::frame::XModel2
>& rxModel
);
108 virtual ~PresenterScreen (void);
110 virtual void SAL_CALL
disposing (void);
112 bool isPresenterScreenEnabled(
113 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
);
114 /** Make the presenter screen visible.
116 void InitializePresenterScreen (void);
118 /** Do not call ShutdownPresenterScreen() directly. Call
119 RequestShutdownPresenterScreen() instead. It will issue an
120 asynchronous call to ShutdownPresenterScreen() when that is safe.
122 void RequestShutdownPresenterScreen (void);
124 /** Switch / converse monitors between presenter view and slide output
126 void SwitchMonitors (void);
130 virtual void SAL_CALL
disposing ( const css::lang::EventObject
& rEvent
) throw (css::uno::RuntimeException
);
133 css::uno::Reference
<css::frame::XModel2
> mxModel
;
134 css::uno::Reference
<css::frame::XController
> mxController
;
135 css::uno::WeakReference
<css::drawing::framework::XConfigurationController
>
136 mxConfigurationControllerWeak
;
137 css::uno::WeakReference
<css::uno::XComponentContext
> mxContextWeak
;
138 css::uno::WeakReference
<css::presentation::XSlideShowController
> mxSlideShowControllerWeak
;
139 ::rtl::Reference
<PresenterController
> mpPresenterController
;
140 css::uno::Reference
<css::drawing::framework::XResourceId
> mxSlideShowViewId
;
141 css::uno::Reference
<css::drawing::framework::XConfiguration
> mxSavedConfiguration
;
142 ::rtl::Reference
<PresenterPaneContainer
> mpPaneContainer
;
143 sal_Int32 mnComponentIndex
;
144 css::uno::Reference
<css::drawing::framework::XResourceFactory
> mxPaneFactory
;
145 css::uno::Reference
<css::drawing::framework::XResourceFactory
> mxViewFactory
;
151 OUString msAccessibleTitle
;
158 typedef ::std::map
<OUString
,ViewDescriptor
> ViewDescriptorContainer
;
159 ViewDescriptorContainer maViewDescriptors
;
161 void ShutdownPresenterScreen (void);
163 /** Create and initialize the factory for presenter view specific panes.
165 void SetupPaneFactory (
166 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
);
168 /** Create and initialize the factory for presenter view specific views.
170 void SetupViewFactory (
171 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
);
173 /** Read the current layout from the configuration and call
174 ProcessLayout to bring it on to the screen.
176 void SetupConfiguration (
177 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
178 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
);
180 /** Read one layout from the configuration and make resource activation
181 requests to bring it on to the screen. When one layout references a
182 parent layout then this method calls itself recursively.
185 PresenterConfigurationAccess
& rConfiguration
,
186 const OUString
& rsLayoutName
,
187 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
188 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
);
190 /** Called by ProcessLayout for a single entry of a Layouts
193 void ProcessComponent (
194 const OUString
& rsKey
,
195 const ::std::vector
<css::uno::Any
>& rValues
,
196 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
197 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
);
199 /** Read the view descriptions from the configuration.
201 void ProcessViewDescriptions (
202 PresenterConfigurationAccess
& rConfiguration
);
204 /** Called by ProcessViewDescriptions for a single entry.
206 void ProcessViewDescription (
207 const OUString
& rsKey
,
208 const ::std::vector
<css::uno::Any
>& rValues
);
211 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
212 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
,
213 const OUString
& rsPaneURL
,
214 const OUString
& rsViewURL
,
215 const PresenterPaneContainer::ViewInitializationFunction
& rViewInitialization
,
219 const double nBottom
);
221 /** Return the built-in screen number on the presentation will normally
222 display the presenter console.
224 Returns -1 when the presenter screen can or shall not be
227 sal_Int32
GetPresenterScreenNumber (
228 const css::uno::Reference
<css::presentation::XPresentation2
>& rxPresentation
) const;
230 sal_Int32
GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen
) const;
232 /** Create a resource id for the full screen background pane so that it
233 is displayed on another screen than the full screen presentation.
235 css::uno::Reference
<css::drawing::framework::XResourceId
> GetMainPaneId (
236 const css::uno::Reference
<css::presentation::XPresentation2
>& rxPresentation
) const;
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */