1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterScreen.hxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SDEXT_PRESENTER_PRESENTER_SCREEN_HXX
33 #define SDEXT_PRESENTER_PRESENTER_SCREEN_HXX
35 #include "PresenterConfigurationAccess.hxx"
36 #include "PresenterPaneContainer.hxx"
37 #include <cppuhelper/compbase1.hxx>
38 #include <cppuhelper/basemutex.hxx>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <com/sun/star/frame/XController.hpp>
41 #include <com/sun/star/frame/XModel2.hpp>
42 #include <com/sun/star/task/XJob.hpp>
43 #include <com/sun/star/document/XEventListener.hpp>
44 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
45 #include <com/sun/star/drawing/framework/XView.hpp>
46 #include <com/sun/star/presentation/XSlideShowController.hpp>
47 #include <com/sun/star/presentation/XPresentation2.hpp>
48 #include <rtl/ref.hxx>
49 #include <boost/noncopyable.hpp>
50 #include <boost/shared_ptr.hpp>
51 #include <boost/scoped_ptr.hpp>
53 namespace css
= ::com::sun::star
;
55 namespace sdext
{ namespace presenter
{
57 class PresenterWindowManager
;
58 class PresenterController
;
61 typedef ::cppu::WeakComponentImplHelper1
<
63 > PresenterScreenJobInterfaceBase
;
64 typedef ::cppu::WeakComponentImplHelper1
<
65 css::lang::XEventListener
66 > PresenterScreenInterfaceBase
;
72 /** The PresenterScreenJob service is instantiated every time a document is
73 created or loaded. In its execute() method it then filters out all
74 non-Impress documents and creates and registers a new PresenterScreen
77 class PresenterScreenJob
78 : private ::boost::noncopyable
,
79 private ::cppu::BaseMutex
,
80 public PresenterScreenJobInterfaceBase
83 static ::rtl::OUString
getImplementationName_static (void);
84 static css::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_static (void);
85 static css::uno::Reference
<css::uno::XInterface
> Create(
86 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
)
87 SAL_THROW((css::uno::Exception
));
89 virtual void SAL_CALL
disposing (void);
93 virtual css::uno::Any SAL_CALL
execute(
94 const css::uno::Sequence
<css::beans::NamedValue
>& Arguments
)
95 throw (css::lang::IllegalArgumentException
,
97 css::uno::RuntimeException
);
100 PresenterScreenJob (const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
);
101 virtual ~PresenterScreenJob (void);
103 css::uno::Reference
<css::uno::XComponentContext
> mxComponentContext
;
109 /** This is the bootstrap class of the presenter screen. It is registered
110 as drawing framework startup service. That means that every drawing
111 framework instance creates an instance of this class.
113 <p>A PresenterScreen object registers itself as listener for drawing
114 framework configuration changes. It waits for the full screen marker (a
115 top level resource) to appear in the current configuration. When that
116 happens the actual presenter screen is initialized. A new
117 PresenterController is created and takes over the task of controlling
118 the presenter screen.</p>
120 class PresenterScreen
121 : private ::boost::noncopyable
,
122 private ::cppu::BaseMutex
,
123 public PresenterScreenInterfaceBase
127 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
128 const css::uno::Reference
<css::frame::XModel2
>& rxModel
);
129 virtual ~PresenterScreen (void);
131 virtual void SAL_CALL
disposing (void);
133 /** Make the presenter screen visible.
135 void InitializePresenterScreen (void);
137 /** Do not call ShutdownPresenterScreen() directly. Call
138 RequestShutdownPresenterScreen() instead. It will issue an
139 asynchronous call to ShutdownPresenterScreen() when that is safe.
141 void RequestShutdownPresenterScreen (void);
146 virtual void SAL_CALL
disposing ( const css::lang::EventObject
& rEvent
) throw (css::uno::RuntimeException
);
149 css::uno::Reference
<css::frame::XModel2
> mxModel
;
150 css::uno::Reference
<css::frame::XController
> mxController
;
151 css::uno::WeakReference
<css::drawing::framework::XConfigurationController
>
152 mxConfigurationControllerWeak
;
153 css::uno::WeakReference
<css::uno::XComponentContext
> mxContextWeak
;
154 css::uno::WeakReference
<css::presentation::XSlideShowController
> mxSlideShowControllerWeak
;
155 ::rtl::Reference
<PresenterController
> mpPresenterController
;
156 css::uno::Reference
<css::drawing::framework::XResourceId
> mxSlideShowViewId
;
157 css::uno::Reference
<css::drawing::framework::XConfiguration
> mxSavedConfiguration
;
158 ::rtl::Reference
<PresenterPaneContainer
> mpPaneContainer
;
159 sal_Int32 mnComponentIndex
;
160 css::uno::Reference
<css::drawing::framework::XResourceFactory
> mxPaneFactory
;
161 css::uno::Reference
<css::drawing::framework::XResourceFactory
> mxViewFactory
;
166 ::rtl::OUString msTitle
;
169 typedef ::std::map
<rtl::OUString
,ViewDescriptor
> ViewDescriptorContainer
;
170 ViewDescriptorContainer maViewDescriptors
;
173 void ShutdownPresenterScreen (void);
175 /** Create and initialize the factory for presenter view specific panes.
177 void SetupPaneFactory (
178 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
);
180 /** Create and initialize the factory for presenter view specific views.
182 void SetupViewFactory (
183 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
);
185 /** Read the current layout from the configuration and call
186 ProcessLayout to bring it on to the screen.
188 void SetupConfiguration (
189 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
190 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
);
192 /** Read one layout from the configuration and make resource activation
193 requests to bring it on to the screen. When one layout references a
194 parent layout then this method calls itself recursively.
197 PresenterConfigurationAccess
& rConfiguration
,
198 const ::rtl::OUString
& rsLayoutName
,
199 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
200 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
);
202 /** Called by ProcessLayout for a single entry of a Layouts
205 void ProcessComponent (
206 const ::rtl::OUString
& rsKey
,
207 const ::std::vector
<css::uno::Any
>& rValues
,
208 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
209 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
);
211 /** Read the view descriptions from the configuration.
213 void ProcessViewDescriptions (
214 PresenterConfigurationAccess
& rConfiguration
);
216 /** Called by ProcessViewDescriptions for a single entry.
218 void ProcessViewDescription (
219 const ::rtl::OUString
& rsKey
,
220 const ::std::vector
<css::uno::Any
>& rValues
);
223 const css::uno::Reference
<css::uno::XComponentContext
>& rxContext
,
224 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxAnchorId
,
225 const ::rtl::OUString
& rsPaneURL
,
226 const ::rtl::OUString
& rsViewURL
,
227 const PresenterPaneContainer::ViewInitializationFunction
& rViewInitialization
,
231 const double nBottom
);
233 /** Return the screen number on which to display the presenter screen.
235 Returns -1 when the presenter screen can or shall not be
238 sal_Int32
GetScreenNumber (
239 const css::uno::Reference
<css::presentation::XPresentation2
>& rxPresentation
) const;
241 /** Create a resource id for the full screen background pane so that it
242 is displayed on another screen than the full screen presentation.
244 css::uno::Reference
<css::drawing::framework::XResourceId
> GetMainPaneId (
245 const css::uno::Reference
<css::presentation::XPresentation2
>& rxPresentation
) const;