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