1*c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c142477cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c142477cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c142477cSAndrew Rist  * distributed with this work for additional information
6*c142477cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c142477cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c142477cSAndrew Rist  * "License"); you may not use this file except in compliance
9*c142477cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c142477cSAndrew Rist  *
11*c142477cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c142477cSAndrew Rist  *
13*c142477cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c142477cSAndrew Rist  * software distributed under the License is distributed on an
15*c142477cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c142477cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c142477cSAndrew Rist  * specific language governing permissions and limitations
18*c142477cSAndrew Rist  * under the License.
19*c142477cSAndrew Rist  *
20*c142477cSAndrew Rist  *************************************************************/
21*c142477cSAndrew Rist 
22*c142477cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterScreen.hxx"
28cdf0e10cSrcweir #include "PresenterConfigurationAccess.hxx"
29cdf0e10cSrcweir #include "PresenterController.hxx"
30cdf0e10cSrcweir #include "PresenterFrameworkObserver.hxx"
31cdf0e10cSrcweir #include "PresenterHelper.hxx"
32cdf0e10cSrcweir #include "PresenterPaneContainer.hxx"
33cdf0e10cSrcweir #include "PresenterPaneFactory.hxx"
34cdf0e10cSrcweir #include "PresenterViewFactory.hxx"
35cdf0e10cSrcweir #include "PresenterWindowManager.hxx"
36cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
38cdf0e10cSrcweir #include <com/sun/star/drawing/framework/Configuration.hpp>
39cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
40cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceId.hpp>
41cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
42cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShow.hpp>
43cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentation2.hpp>
44cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentationSupplier.hpp>
45cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp>
46cdf0e10cSrcweir #include <boost/bind.hpp>
47cdf0e10cSrcweir #include <tools/debug.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir using namespace ::com::sun::star;
52cdf0e10cSrcweir using namespace ::com::sun::star::uno;
53cdf0e10cSrcweir using namespace ::com::sun::star::lang;
54cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
55cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
56cdf0e10cSrcweir using ::rtl::OUString;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #define A2S(s) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)))
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace sdext { namespace presenter {
61cdf0e10cSrcweir 
62cdf0e10cSrcweir namespace {
63cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper1 <
64cdf0e10cSrcweir 		css::document::XEventListener
65cdf0e10cSrcweir         > PresenterScreenListenerInterfaceBase;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     /** One instance of a PresenterScreenListener is registered per Impress
68cdf0e10cSrcweir         document and waits for the full screen slide show to start and to
69cdf0e10cSrcweir         end.
70cdf0e10cSrcweir     */
71cdf0e10cSrcweir     class PresenterScreenListener
72cdf0e10cSrcweir         : private ::boost::noncopyable,
73cdf0e10cSrcweir           private ::cppu::BaseMutex,
74cdf0e10cSrcweir           public PresenterScreenListenerInterfaceBase
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir     public:
77cdf0e10cSrcweir         PresenterScreenListener (
78cdf0e10cSrcweir             const css::uno::Reference<css::uno::XComponentContext>& rxContext,
79cdf0e10cSrcweir             const css::uno::Reference<css::frame::XModel2>& rxModel);
80cdf0e10cSrcweir         virtual ~PresenterScreenListener (void);
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         void Initialize (void);
83cdf0e10cSrcweir         virtual void SAL_CALL disposing (void);
84cdf0e10cSrcweir 
85cdf0e10cSrcweir         // document::XEventListener
86cdf0e10cSrcweir 
87cdf0e10cSrcweir         virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         // XEventListener
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) throw (css::uno::RuntimeException);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     private:
94cdf0e10cSrcweir         css::uno::Reference<css::frame::XModel2 > mxModel;
95cdf0e10cSrcweir         css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
96cdf0e10cSrcweir         rtl::Reference<PresenterScreen> mpPresenterScreen;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
99cdf0e10cSrcweir     };
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir //----- Service ---------------------------------------------------------------
104cdf0e10cSrcweir 
105cdf0e10cSrcweir OUString PresenterScreenJob::getImplementationName_static (void)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     return A2S("com.sun.star.comp.Draw.framework.PresenterScreenJob");
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 
113cdf0e10cSrcweir Sequence<OUString> PresenterScreenJob::getSupportedServiceNames_static (void)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	static const ::rtl::OUString sServiceName(
116cdf0e10cSrcweir         A2S("com.sun.star.drawing.framework.PresenterScreenJob"));
117cdf0e10cSrcweir 	return Sequence<rtl::OUString>(&sServiceName, 1);
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
123cdf0e10cSrcweir Reference<XInterface> PresenterScreenJob::Create (const Reference<uno::XComponentContext>& rxContext)
124cdf0e10cSrcweir     SAL_THROW((css::uno::Exception))
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     return Reference<XInterface>(static_cast<XWeak*>(new PresenterScreenJob(rxContext)));
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
132cdf0e10cSrcweir //===== PresenterScreenJob ====================================================
133cdf0e10cSrcweir 
134cdf0e10cSrcweir PresenterScreenJob::PresenterScreenJob (const Reference<XComponentContext>& rxContext)
135cdf0e10cSrcweir     : PresenterScreenJobInterfaceBase(m_aMutex),
136cdf0e10cSrcweir       mxComponentContext(rxContext)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 
143cdf0e10cSrcweir PresenterScreenJob::~PresenterScreenJob (void)
144cdf0e10cSrcweir {
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 
150cdf0e10cSrcweir void SAL_CALL PresenterScreenJob::disposing (void)
151cdf0e10cSrcweir {
152cdf0e10cSrcweir     mxComponentContext = NULL;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir //----- XJob -----------------------------------------------------------
159cdf0e10cSrcweir 
160cdf0e10cSrcweir Any SAL_CALL PresenterScreenJob::execute(
161cdf0e10cSrcweir     const Sequence< beans::NamedValue >& Arguments )
162cdf0e10cSrcweir     throw (lang::IllegalArgumentException, Exception, RuntimeException)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir 	Sequence< beans::NamedValue > lEnv;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     sal_Int32               i = 0;
167cdf0e10cSrcweir     sal_Int32               c = Arguments.getLength();
168cdf0e10cSrcweir     const beans::NamedValue* p = Arguments.getConstArray();
169cdf0e10cSrcweir     for (i=0; i<c; ++i)
170cdf0e10cSrcweir 	{
171cdf0e10cSrcweir         if (p[i].Name.equalsAscii("Environment"))
172cdf0e10cSrcweir         {
173cdf0e10cSrcweir             p[i].Value >>= lEnv;
174cdf0e10cSrcweir             break;
175cdf0e10cSrcweir         }
176cdf0e10cSrcweir 	}
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     Reference<frame::XModel2> xModel;
179cdf0e10cSrcweir     c = lEnv.getLength();
180cdf0e10cSrcweir     p = lEnv.getConstArray();
181cdf0e10cSrcweir     for (i=0; i<c; ++i)
182cdf0e10cSrcweir     {
183cdf0e10cSrcweir         if (p[i].Name.equalsAscii("Model"))
184cdf0e10cSrcweir         {
185cdf0e10cSrcweir             p[i].Value >>= xModel;
186cdf0e10cSrcweir             break;
187cdf0e10cSrcweir         }
188cdf0e10cSrcweir     }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	Reference< XServiceInfo > xInfo( xModel, UNO_QUERY );
191cdf0e10cSrcweir 	if( xInfo.is() && xInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) ) )
192cdf0e10cSrcweir 	{
193cdf0e10cSrcweir         // Create a new listener that waits for the full screen presentation
194cdf0e10cSrcweir         // to start and to end.  It takes care of its own lifetime.
195cdf0e10cSrcweir         ::rtl::Reference<PresenterScreenListener> pListener (
196cdf0e10cSrcweir             new PresenterScreenListener(mxComponentContext, xModel));
197cdf0e10cSrcweir         pListener->Initialize();
198cdf0e10cSrcweir 	}
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     return Any();
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 
206cdf0e10cSrcweir //===== PresenterScreenListener ===============================================
207cdf0e10cSrcweir 
208cdf0e10cSrcweir namespace {
209cdf0e10cSrcweir 
210cdf0e10cSrcweir PresenterScreenListener::PresenterScreenListener (
211cdf0e10cSrcweir     const css::uno::Reference<css::uno::XComponentContext>& rxContext,
212cdf0e10cSrcweir     const css::uno::Reference<css::frame::XModel2>& rxModel)
213cdf0e10cSrcweir     : PresenterScreenListenerInterfaceBase(m_aMutex),
214cdf0e10cSrcweir       mxModel(rxModel),
215cdf0e10cSrcweir       mxComponentContext(rxContext),
216cdf0e10cSrcweir       mpPresenterScreen()
217cdf0e10cSrcweir {
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 
223cdf0e10cSrcweir void PresenterScreenListener::Initialize (void)
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     Reference< document::XEventListener > xDocListener(
226cdf0e10cSrcweir         static_cast< document::XEventListener* >(this), UNO_QUERY);
227cdf0e10cSrcweir     Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
228cdf0e10cSrcweir     if( xDocBroadcaster.is() )
229cdf0e10cSrcweir         xDocBroadcaster->addEventListener(xDocListener);
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 
235cdf0e10cSrcweir PresenterScreenListener::~PresenterScreenListener (void)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 
242cdf0e10cSrcweir void SAL_CALL PresenterScreenListener::disposing (void)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
245cdf0e10cSrcweir     if( xDocBroadcaster.is() )
246cdf0e10cSrcweir         xDocBroadcaster->removeEventListener(
247cdf0e10cSrcweir             Reference<document::XEventListener>(
248cdf0e10cSrcweir                 static_cast<document::XEventListener*>(this), UNO_QUERY));
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     if (mpPresenterScreen.is())
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         mpPresenterScreen->RequestShutdownPresenterScreen();
253cdf0e10cSrcweir         mpPresenterScreen = NULL;
254cdf0e10cSrcweir     }
255cdf0e10cSrcweir }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 
260cdf0e10cSrcweir // document::XEventListener
261cdf0e10cSrcweir 
262cdf0e10cSrcweir void SAL_CALL PresenterScreenListener::notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir     ThrowIfDisposed();
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	if( Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnStartPresentation" ) ) )
267cdf0e10cSrcweir 	{
268cdf0e10cSrcweir 		mpPresenterScreen = new PresenterScreen(mxComponentContext, mxModel);
269cdf0e10cSrcweir         mpPresenterScreen->InitializePresenterScreen();
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir 	else if( Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnEndPresentation" ) ) )
272cdf0e10cSrcweir 	{
273cdf0e10cSrcweir         if (mpPresenterScreen.is())
274cdf0e10cSrcweir         {
275cdf0e10cSrcweir             mpPresenterScreen->RequestShutdownPresenterScreen();
276cdf0e10cSrcweir             mpPresenterScreen = NULL;
277cdf0e10cSrcweir         }
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 
284cdf0e10cSrcweir // XEventListener
285cdf0e10cSrcweir 
286cdf0e10cSrcweir void SAL_CALL PresenterScreenListener::disposing (const css::lang::EventObject& rEvent)
287cdf0e10cSrcweir     throw (css::uno::RuntimeException)
288cdf0e10cSrcweir {
289cdf0e10cSrcweir     (void)rEvent;
290cdf0e10cSrcweir 
291cdf0e10cSrcweir     if (mpPresenterScreen.is())
292cdf0e10cSrcweir     {
293cdf0e10cSrcweir         mpPresenterScreen->RequestShutdownPresenterScreen();
294cdf0e10cSrcweir         mpPresenterScreen = NULL;
295cdf0e10cSrcweir     }
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 
301cdf0e10cSrcweir void PresenterScreenListener::ThrowIfDisposed (void) const throw (
302cdf0e10cSrcweir     ::com::sun::star::lang::DisposedException)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
305cdf0e10cSrcweir 	{
306cdf0e10cSrcweir         throw lang::DisposedException (
307cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM(
308cdf0e10cSrcweir                 "PresenterScreenListener object has already been disposed")),
309cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
310cdf0e10cSrcweir     }
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir } // end of anonymous namespace
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 
318cdf0e10cSrcweir //===== PresenterScreen =======================================================
319cdf0e10cSrcweir 
320cdf0e10cSrcweir PresenterScreen::PresenterScreen (
321cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
322cdf0e10cSrcweir     const css::uno::Reference<css::frame::XModel2>& rxModel)
323cdf0e10cSrcweir     : PresenterScreenInterfaceBase(m_aMutex),
324cdf0e10cSrcweir 	  mxModel(rxModel),
325cdf0e10cSrcweir       mxController(),
326cdf0e10cSrcweir       mxConfigurationControllerWeak(),
327cdf0e10cSrcweir       mxContextWeak(rxContext),
328cdf0e10cSrcweir       mxSlideShowControllerWeak(),
329cdf0e10cSrcweir       mpPresenterController(),
330cdf0e10cSrcweir       mxSlideShowViewId(),
331cdf0e10cSrcweir       mxSavedConfiguration(),
332cdf0e10cSrcweir       mpPaneContainer(),
333cdf0e10cSrcweir       mnComponentIndex(0),
334cdf0e10cSrcweir       mxPaneFactory(),
335cdf0e10cSrcweir       mxViewFactory(),
336cdf0e10cSrcweir       maViewDescriptors()
337cdf0e10cSrcweir {
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 
343cdf0e10cSrcweir PresenterScreen::~PresenterScreen (void)
344cdf0e10cSrcweir {
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 
350cdf0e10cSrcweir void SAL_CALL PresenterScreen::disposing (void)
351cdf0e10cSrcweir {
352cdf0e10cSrcweir     Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
353cdf0e10cSrcweir     if (xCC.is() && mxSavedConfiguration.is())
354cdf0e10cSrcweir     {
355cdf0e10cSrcweir         xCC->restoreConfiguration(mxSavedConfiguration);
356cdf0e10cSrcweir     }
357cdf0e10cSrcweir     mxConfigurationControllerWeak = Reference<XConfigurationController>(NULL);
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
360cdf0e10cSrcweir     if (xViewFactoryComponent.is())
361cdf0e10cSrcweir        xViewFactoryComponent->dispose();
362cdf0e10cSrcweir     Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
363cdf0e10cSrcweir     if (xPaneFactoryComponent.is())
364cdf0e10cSrcweir         xPaneFactoryComponent->dispose();
365cdf0e10cSrcweir 
366cdf0e10cSrcweir     mxModel = NULL;
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 
372cdf0e10cSrcweir //----- XEventListener --------------------------------------------------------
373cdf0e10cSrcweir 
374cdf0e10cSrcweir void SAL_CALL PresenterScreen::disposing (const lang::EventObject& /*rEvent*/)
375cdf0e10cSrcweir     throw (RuntimeException)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir 	mxSlideShowControllerWeak = WeakReference<presentation::XSlideShowController>();
378cdf0e10cSrcweir 	RequestShutdownPresenterScreen();
379cdf0e10cSrcweir }
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 
384cdf0e10cSrcweir //-----------------------------------------------------------------------------
385cdf0e10cSrcweir 
386cdf0e10cSrcweir void PresenterScreen::InitializePresenterScreen (void)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir 	try
389cdf0e10cSrcweir 	{
390cdf0e10cSrcweir 		Reference<XComponentContext> xContext (mxContextWeak);
391cdf0e10cSrcweir         mpPaneContainer =
392cdf0e10cSrcweir             new PresenterPaneContainer(Reference<XComponentContext>(xContext));
393cdf0e10cSrcweir 
394cdf0e10cSrcweir         Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
395cdf0e10cSrcweir 		Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
396cdf0e10cSrcweir 		Reference<presentation::XSlideShowController> xSlideShowController( xPresentation->getController() );
397cdf0e10cSrcweir         mxSlideShowControllerWeak = xSlideShowController;
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 		if( !xSlideShowController.is() || !xSlideShowController->isFullScreen() )
400cdf0e10cSrcweir 			return;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 		// find first controller that is not the current controller (the one with the slideshow
403cdf0e10cSrcweir 		mxController = mxModel->getCurrentController();
404cdf0e10cSrcweir 		Reference< container::XEnumeration > xEnum( mxModel->getControllers() );
405cdf0e10cSrcweir 		if( xEnum.is() )
406cdf0e10cSrcweir 		{
407cdf0e10cSrcweir 			while( xEnum->hasMoreElements() )
408cdf0e10cSrcweir 			{
409cdf0e10cSrcweir 				Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY );
410cdf0e10cSrcweir 				if( xC.is() && (xC != mxController) )
411cdf0e10cSrcweir 				{
412cdf0e10cSrcweir 					mxController = xC;
413cdf0e10cSrcweir 					break;
414cdf0e10cSrcweir 				}
415cdf0e10cSrcweir 			}
416cdf0e10cSrcweir 		}
417cdf0e10cSrcweir 		// Get the XController from the first argument.
418cdf0e10cSrcweir 		Reference<XControllerManager> xCM(mxController, UNO_QUERY_THROW);
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 		Reference<XConfigurationController> xCC( xCM->getConfigurationController());
421cdf0e10cSrcweir 		mxConfigurationControllerWeak = xCC;
422cdf0e10cSrcweir 
423cdf0e10cSrcweir         Reference<drawing::framework::XResourceId> xMainPaneId(
424cdf0e10cSrcweir             GetMainPaneId(xPresentation));
425cdf0e10cSrcweir         // An empty reference means that the presenter screen can
426cdf0e10cSrcweir         // not or must not be displayed.
427cdf0e10cSrcweir         if ( ! xMainPaneId.is())
428cdf0e10cSrcweir             return;
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 		if (xCC.is() && xContext.is())
431cdf0e10cSrcweir 		{
432cdf0e10cSrcweir 			// Store the current configuration so that we can restore it when
433cdf0e10cSrcweir 			// the presenter view is deactivated.
434cdf0e10cSrcweir 			mxSavedConfiguration = xCC->getRequestedConfiguration();
435cdf0e10cSrcweir 			xCC->lock();
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 			try
438cdf0e10cSrcweir 			{
439cdf0e10cSrcweir                 // At the moment the presenter controller is displayed in its
440cdf0e10cSrcweir                 // own full screen window that is controlled by the same
441cdf0e10cSrcweir                 // configuration controller as the Impress document from
442cdf0e10cSrcweir                 // which the presentation was started.  Therefore the main
443cdf0e10cSrcweir                 // pane is actived additionally to the already existing
444cdf0e10cSrcweir                 // panes and does not replace them.
445cdf0e10cSrcweir 				xCC->requestResourceActivation(
446cdf0e10cSrcweir 					xMainPaneId,
447cdf0e10cSrcweir 					ResourceActivationMode_ADD);
448cdf0e10cSrcweir 				SetupConfiguration(xContext, xMainPaneId);
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 				mpPresenterController = new PresenterController(
451cdf0e10cSrcweir 					xContext,
452cdf0e10cSrcweir 					mxController,
453cdf0e10cSrcweir 					xSlideShowController,
454cdf0e10cSrcweir 					mpPaneContainer,
455cdf0e10cSrcweir 					xMainPaneId);
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 				// Create pane and view factories and integrate them into the
458cdf0e10cSrcweir 				// drawing framework.
459cdf0e10cSrcweir 				SetupPaneFactory(xContext);
460cdf0e10cSrcweir 				SetupViewFactory(xContext);
461cdf0e10cSrcweir 
462cdf0e10cSrcweir                 mpPresenterController->GetWindowManager()->RestoreViewMode();
463cdf0e10cSrcweir 			}
464cdf0e10cSrcweir 			catch (RuntimeException&)
465cdf0e10cSrcweir 			{
466cdf0e10cSrcweir 				xCC->restoreConfiguration(mxSavedConfiguration);
467cdf0e10cSrcweir 			}
468cdf0e10cSrcweir 			xCC->unlock();
469cdf0e10cSrcweir 		}
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir 	catch (Exception&)
472cdf0e10cSrcweir 	{
473cdf0e10cSrcweir 	}
474cdf0e10cSrcweir }
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 
479cdf0e10cSrcweir sal_Int32 PresenterScreen::GetScreenNumber (
480cdf0e10cSrcweir     const Reference<presentation::XPresentation2>& rxPresentation) const
481cdf0e10cSrcweir {
482cdf0e10cSrcweir     // Determine the screen on which the full screen presentation is being
483cdf0e10cSrcweir     // displayed.
484cdf0e10cSrcweir     sal_Int32 nScreenNumber (0);
485cdf0e10cSrcweir     sal_Int32 nScreenCount (1);
486cdf0e10cSrcweir     try
487cdf0e10cSrcweir     {
488cdf0e10cSrcweir         Reference<beans::XPropertySet> xProperties (rxPresentation, UNO_QUERY);
489cdf0e10cSrcweir         if ( ! xProperties.is())
490cdf0e10cSrcweir             return -1;
491cdf0e10cSrcweir 
492cdf0e10cSrcweir         sal_Int32 nDisplayNumber (-1);
493cdf0e10cSrcweir         if ( ! (xProperties->getPropertyValue(A2S("Display")) >>= nDisplayNumber))
494cdf0e10cSrcweir             return -1;
495cdf0e10cSrcweir         if (nDisplayNumber == -1)
496cdf0e10cSrcweir         {
497cdf0e10cSrcweir             // The special value -1 indicates that the slide show
498cdf0e10cSrcweir             // spans all available displays.  That leaves no room for
499cdf0e10cSrcweir             // the presenter screen.
500cdf0e10cSrcweir             return -1;
501cdf0e10cSrcweir         }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir         Reference<XComponentContext> xContext (mxContextWeak);
504cdf0e10cSrcweir         if ( ! xContext.is())
505cdf0e10cSrcweir             return -1;
506cdf0e10cSrcweir         Reference<lang::XMultiComponentFactory> xFactory (
507cdf0e10cSrcweir             xContext->getServiceManager(), UNO_QUERY);
508cdf0e10cSrcweir         if ( ! xFactory.is())
509cdf0e10cSrcweir             return -1;
510cdf0e10cSrcweir         Reference<beans::XPropertySet> xDisplayProperties (
511cdf0e10cSrcweir             xFactory->createInstanceWithContext(A2S("com.sun.star.awt.DisplayAccess"),xContext),
512cdf0e10cSrcweir             UNO_QUERY);
513cdf0e10cSrcweir         if  ( ! xDisplayProperties.is())
514cdf0e10cSrcweir             return -1;
515cdf0e10cSrcweir 
516cdf0e10cSrcweir         if (nDisplayNumber > 0)
517cdf0e10cSrcweir         {
518cdf0e10cSrcweir             nScreenNumber = nDisplayNumber - 1;
519cdf0e10cSrcweir         }
520cdf0e10cSrcweir         else if (nDisplayNumber == 0)
521cdf0e10cSrcweir         {
522cdf0e10cSrcweir             // A display number value of 0 indicates the primary screen.
523cdf0e10cSrcweir             // Instantiate the DisplayAccess service to find out which
524cdf0e10cSrcweir             // screen number that is.
525cdf0e10cSrcweir             if (nDisplayNumber <= 0 && xDisplayProperties.is())
526cdf0e10cSrcweir                 xDisplayProperties->getPropertyValue(A2S("DefaultDisplay")) >>= nScreenNumber;
527cdf0e10cSrcweir         }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir         // We still have to determine the number of screens to decide
530cdf0e10cSrcweir         // whether the presenter screen may be shown at all.
531cdf0e10cSrcweir         Reference<container::XIndexAccess> xIndexAccess (xDisplayProperties, UNO_QUERY);
532cdf0e10cSrcweir         if ( ! xIndexAccess.is())
533cdf0e10cSrcweir             return -1;
534cdf0e10cSrcweir         nScreenCount = xIndexAccess->getCount();
535cdf0e10cSrcweir 
536cdf0e10cSrcweir         if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
537cdf0e10cSrcweir         {
538cdf0e10cSrcweir             // There is either only one screen or the full screen
539cdf0e10cSrcweir             // presentation spans all available screens.  The presenter
540cdf0e10cSrcweir             // screen is shown only when a special flag in the configuration
541cdf0e10cSrcweir             // is set.
542cdf0e10cSrcweir             PresenterConfigurationAccess aConfiguration (
543cdf0e10cSrcweir                 xContext,
544cdf0e10cSrcweir                 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
545cdf0e10cSrcweir                 PresenterConfigurationAccess::READ_ONLY);
546cdf0e10cSrcweir             bool bStartAlways (false);
547cdf0e10cSrcweir             if (aConfiguration.GetConfigurationNode(
548cdf0e10cSrcweir                 OUString::createFromAscii("Presenter/StartAlways")) >>= bStartAlways)
549cdf0e10cSrcweir             {
550cdf0e10cSrcweir                 if (bStartAlways)
551cdf0e10cSrcweir                     return nScreenNumber;
552cdf0e10cSrcweir             }
553cdf0e10cSrcweir             return -1;
554cdf0e10cSrcweir         }
555cdf0e10cSrcweir     }
556cdf0e10cSrcweir     catch (beans::UnknownPropertyException&)
557cdf0e10cSrcweir     {
558cdf0e10cSrcweir         OSL_ASSERT(false);
559cdf0e10cSrcweir         // For some reason we can not access the screen number.  Use
560cdf0e10cSrcweir         // the default instead.
561cdf0e10cSrcweir     }
562cdf0e10cSrcweir 
563cdf0e10cSrcweir     return nScreenNumber;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 
569cdf0e10cSrcweir Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
570cdf0e10cSrcweir     const Reference<presentation::XPresentation2>& rxPresentation) const
571cdf0e10cSrcweir {
572cdf0e10cSrcweir     // A negative value means that the presentation spans all available
573cdf0e10cSrcweir     // displays.  That leaves no room for the presenter.
574cdf0e10cSrcweir     const sal_Int32 nScreenNumber(GetScreenNumber(rxPresentation));
575cdf0e10cSrcweir     if (nScreenNumber < 0)
576cdf0e10cSrcweir         return NULL;
577cdf0e10cSrcweir 
578cdf0e10cSrcweir     // Setup the resource id of the full screen background pane so that
579cdf0e10cSrcweir     // it is displayed on another screen than the presentation.
580cdf0e10cSrcweir     sal_Int32 nPresenterScreenNumber (1);
581cdf0e10cSrcweir     switch (nScreenNumber)
582cdf0e10cSrcweir     {
583cdf0e10cSrcweir         case 0:
584cdf0e10cSrcweir             nPresenterScreenNumber = 1;
585cdf0e10cSrcweir             break;
586cdf0e10cSrcweir 
587cdf0e10cSrcweir         case 1:
588cdf0e10cSrcweir             nPresenterScreenNumber = 0;
589cdf0e10cSrcweir             break;
590cdf0e10cSrcweir 
591cdf0e10cSrcweir         default:
592cdf0e10cSrcweir             // When the full screen presentation is displayed on a screen
593cdf0e10cSrcweir             // other than 0 or 1 then place the presenter on the first
594cdf0e10cSrcweir             // available screen.
595cdf0e10cSrcweir             nPresenterScreenNumber = 0;
596cdf0e10cSrcweir             break;
597cdf0e10cSrcweir     }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir     return ResourceId::create(
600cdf0e10cSrcweir         Reference<XComponentContext>(mxContextWeak),
601cdf0e10cSrcweir         PresenterHelper::msFullScreenPaneURL
602cdf0e10cSrcweir             +A2S("?FullScreen=true&ScreenNumber=")
603cdf0e10cSrcweir                 + OUString::valueOf(nPresenterScreenNumber));
604cdf0e10cSrcweir }
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 
609cdf0e10cSrcweir void PresenterScreen::RequestShutdownPresenterScreen (void)
610cdf0e10cSrcweir {
611cdf0e10cSrcweir     // Restore the configuration that was active before the presenter screen
612cdf0e10cSrcweir     // has been activated.  Now, that the presenter screen is displayed in
613cdf0e10cSrcweir     // its own top level window this probably not necessary, but one never knows.
614cdf0e10cSrcweir     Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
615cdf0e10cSrcweir     if (xCC.is() && mxSavedConfiguration.is())
616cdf0e10cSrcweir     {
617cdf0e10cSrcweir         xCC->restoreConfiguration(mxSavedConfiguration);
618cdf0e10cSrcweir         mxSavedConfiguration = NULL;
619cdf0e10cSrcweir     }
620cdf0e10cSrcweir 
621cdf0e10cSrcweir     if (xCC.is())
622cdf0e10cSrcweir     {
623cdf0e10cSrcweir         // The actual restoration of the configuration takes place
624cdf0e10cSrcweir         // asynchronously.  The view and pane factories can only by disposed
625cdf0e10cSrcweir         // after that.  Therefore, set up a listener and wait for the
626cdf0e10cSrcweir         // restoration.
627cdf0e10cSrcweir         rtl::Reference<PresenterScreen> pSelf (this);
628cdf0e10cSrcweir         PresenterFrameworkObserver::RunOnUpdateEnd(
629cdf0e10cSrcweir             xCC,
630cdf0e10cSrcweir             ::boost::bind(&PresenterScreen::ShutdownPresenterScreen, pSelf));
631cdf0e10cSrcweir         xCC->update();
632cdf0e10cSrcweir     }
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 
637cdf0e10cSrcweir 
638cdf0e10cSrcweir void PresenterScreen::ShutdownPresenterScreen (void)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir     Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
641cdf0e10cSrcweir     if (xViewFactoryComponent.is())
642cdf0e10cSrcweir         xViewFactoryComponent->dispose();
643cdf0e10cSrcweir     mxViewFactory = NULL;
644cdf0e10cSrcweir 
645cdf0e10cSrcweir     Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
646cdf0e10cSrcweir     if (xPaneFactoryComponent.is())
647cdf0e10cSrcweir         xPaneFactoryComponent->dispose();
648cdf0e10cSrcweir     mxPaneFactory = NULL;
649cdf0e10cSrcweir 
650cdf0e10cSrcweir     if (mpPresenterController.get() != NULL)
651cdf0e10cSrcweir     {
652cdf0e10cSrcweir         mpPresenterController->dispose();
653cdf0e10cSrcweir         mpPresenterController = rtl::Reference<PresenterController>();
654cdf0e10cSrcweir     }
655cdf0e10cSrcweir     mpPaneContainer = new PresenterPaneContainer(Reference<XComponentContext>(mxContextWeak));
656cdf0e10cSrcweir }
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 
661cdf0e10cSrcweir void PresenterScreen::SetupPaneFactory (const Reference<XComponentContext>& rxContext)
662cdf0e10cSrcweir {
663cdf0e10cSrcweir     try
664cdf0e10cSrcweir     {
665cdf0e10cSrcweir         if ( ! mxPaneFactory.is())
666cdf0e10cSrcweir             mxPaneFactory = PresenterPaneFactory::Create(
667cdf0e10cSrcweir                 rxContext,
668cdf0e10cSrcweir                 mxController,
669cdf0e10cSrcweir                 mpPresenterController);
670cdf0e10cSrcweir     }
671cdf0e10cSrcweir     catch (RuntimeException&)
672cdf0e10cSrcweir     {
673cdf0e10cSrcweir         OSL_ASSERT(false);
674cdf0e10cSrcweir     }
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 
679cdf0e10cSrcweir 
680cdf0e10cSrcweir void PresenterScreen::SetupViewFactory (const Reference<XComponentContext>& rxContext)
681cdf0e10cSrcweir {
682cdf0e10cSrcweir     try
683cdf0e10cSrcweir     {
684cdf0e10cSrcweir         if ( ! mxViewFactory.is())
685cdf0e10cSrcweir             mxViewFactory = PresenterViewFactory::Create(
686cdf0e10cSrcweir                 rxContext,
687cdf0e10cSrcweir                 mxController,
688cdf0e10cSrcweir                 mpPresenterController);
689cdf0e10cSrcweir     }
690cdf0e10cSrcweir     catch (RuntimeException&)
691cdf0e10cSrcweir     {
692cdf0e10cSrcweir         OSL_ASSERT(false);
693cdf0e10cSrcweir     }
694cdf0e10cSrcweir }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 
699cdf0e10cSrcweir void PresenterScreen::SetupConfiguration (
700cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
701cdf0e10cSrcweir     const Reference<XResourceId>& rxAnchorId)
702cdf0e10cSrcweir {
703cdf0e10cSrcweir     try
704cdf0e10cSrcweir     {
705cdf0e10cSrcweir         PresenterConfigurationAccess aConfiguration (
706cdf0e10cSrcweir             rxContext,
707cdf0e10cSrcweir             OUString::createFromAscii("org.openoffice.Office.extension.PresenterScreen"),
708cdf0e10cSrcweir             PresenterConfigurationAccess::READ_ONLY);
709cdf0e10cSrcweir         maViewDescriptors.clear();
710cdf0e10cSrcweir         ProcessViewDescriptions(aConfiguration);
711cdf0e10cSrcweir         OUString sLayoutName (OUString::createFromAscii("DefaultLayout"));
712cdf0e10cSrcweir         aConfiguration.GetConfigurationNode(
713cdf0e10cSrcweir             OUString::createFromAscii("Presenter/CurrentLayout")) >>= sLayoutName;
714cdf0e10cSrcweir         ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
715cdf0e10cSrcweir     }
716cdf0e10cSrcweir     catch (RuntimeException&)
717cdf0e10cSrcweir     {
718cdf0e10cSrcweir     }
719cdf0e10cSrcweir }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 
723cdf0e10cSrcweir 
724cdf0e10cSrcweir void PresenterScreen::ProcessLayout (
725cdf0e10cSrcweir     PresenterConfigurationAccess& rConfiguration,
726cdf0e10cSrcweir     const OUString& rsLayoutName,
727cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
728cdf0e10cSrcweir     const Reference<XResourceId>& rxAnchorId)
729cdf0e10cSrcweir {
730cdf0e10cSrcweir     try
731cdf0e10cSrcweir     {
732cdf0e10cSrcweir         Reference<container::XHierarchicalNameAccess> xLayoutNode (
733cdf0e10cSrcweir             rConfiguration.GetConfigurationNode(
734cdf0e10cSrcweir                 OUString::createFromAscii("Presenter/Layouts/")+rsLayoutName),
735cdf0e10cSrcweir             UNO_QUERY_THROW);
736cdf0e10cSrcweir 
737cdf0e10cSrcweir         // Read the parent layout first, if one is referenced.
738cdf0e10cSrcweir         OUString sParentLayout;
739cdf0e10cSrcweir         rConfiguration.GetConfigurationNode(
740cdf0e10cSrcweir             xLayoutNode,
741cdf0e10cSrcweir             OUString::createFromAscii("ParentLayout")) >>= sParentLayout;
742cdf0e10cSrcweir         if (sParentLayout.getLength() > 0)
743cdf0e10cSrcweir         {
744cdf0e10cSrcweir             // Prevent infinite recursion.
745cdf0e10cSrcweir             if (rsLayoutName != sParentLayout)
746cdf0e10cSrcweir                 ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
747cdf0e10cSrcweir         }
748cdf0e10cSrcweir 
749cdf0e10cSrcweir         // Process the actual layout list.
750cdf0e10cSrcweir         Reference<container::XNameAccess> xList (
751cdf0e10cSrcweir             rConfiguration.GetConfigurationNode(
752cdf0e10cSrcweir                 xLayoutNode,
753cdf0e10cSrcweir                 OUString::createFromAscii("Layout")),
754cdf0e10cSrcweir             UNO_QUERY_THROW);
755cdf0e10cSrcweir 
756cdf0e10cSrcweir         ::std::vector<rtl::OUString> aProperties (6);
757cdf0e10cSrcweir         aProperties[0] = OUString::createFromAscii("PaneURL");
758cdf0e10cSrcweir         aProperties[1] = OUString::createFromAscii("ViewURL");
759cdf0e10cSrcweir         aProperties[2] = OUString::createFromAscii("RelativeX");
760cdf0e10cSrcweir         aProperties[3] = OUString::createFromAscii("RelativeY");
761cdf0e10cSrcweir         aProperties[4] = OUString::createFromAscii("RelativeWidth");
762cdf0e10cSrcweir         aProperties[5] = OUString::createFromAscii("RelativeHeight");
763cdf0e10cSrcweir         mnComponentIndex = 1;
764cdf0e10cSrcweir         PresenterConfigurationAccess::ForAll(
765cdf0e10cSrcweir             xList,
766cdf0e10cSrcweir             aProperties,
767cdf0e10cSrcweir             ::boost::bind(&PresenterScreen::ProcessComponent, this,
768cdf0e10cSrcweir                 _1,
769cdf0e10cSrcweir                 _2,
770cdf0e10cSrcweir                 rxContext,
771cdf0e10cSrcweir                 rxAnchorId));
772cdf0e10cSrcweir     }
773cdf0e10cSrcweir     catch (RuntimeException&)
774cdf0e10cSrcweir     {
775cdf0e10cSrcweir     }
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 
781cdf0e10cSrcweir void PresenterScreen::ProcessViewDescriptions (
782cdf0e10cSrcweir     PresenterConfigurationAccess& rConfiguration)
783cdf0e10cSrcweir {
784cdf0e10cSrcweir     try
785cdf0e10cSrcweir     {
786cdf0e10cSrcweir         Reference<container::XNameAccess> xViewDescriptionsNode (
787cdf0e10cSrcweir             rConfiguration.GetConfigurationNode(A2S("Presenter/Views")),
788cdf0e10cSrcweir             UNO_QUERY_THROW);
789cdf0e10cSrcweir 
790cdf0e10cSrcweir         ::std::vector<rtl::OUString> aProperties (4);
791cdf0e10cSrcweir         aProperties[0] = OUString::createFromAscii("ViewURL");
792cdf0e10cSrcweir         aProperties[1] = OUString::createFromAscii("Title");
793cdf0e10cSrcweir         aProperties[2] = OUString::createFromAscii("AccessibleTitle");
794cdf0e10cSrcweir         aProperties[3] = OUString::createFromAscii("IsOpaque");
795cdf0e10cSrcweir         mnComponentIndex = 1;
796cdf0e10cSrcweir         PresenterConfigurationAccess::ForAll(
797cdf0e10cSrcweir             xViewDescriptionsNode,
798cdf0e10cSrcweir             aProperties,
799cdf0e10cSrcweir             ::boost::bind(&PresenterScreen::ProcessViewDescription, this, _1, _2));
800cdf0e10cSrcweir     }
801cdf0e10cSrcweir     catch (RuntimeException&)
802cdf0e10cSrcweir     {
803cdf0e10cSrcweir         OSL_ASSERT(false);
804cdf0e10cSrcweir     }
805cdf0e10cSrcweir }
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 
808cdf0e10cSrcweir 
809cdf0e10cSrcweir 
810cdf0e10cSrcweir void PresenterScreen::ProcessComponent (
811cdf0e10cSrcweir     const OUString& rsKey,
812cdf0e10cSrcweir     const ::std::vector<Any>& rValues,
813cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
814cdf0e10cSrcweir     const Reference<XResourceId>& rxAnchorId)
815cdf0e10cSrcweir {
816cdf0e10cSrcweir     (void)rsKey;
817cdf0e10cSrcweir 
818cdf0e10cSrcweir     if (rValues.size() != 6)
819cdf0e10cSrcweir         return;
820cdf0e10cSrcweir 
821cdf0e10cSrcweir     try
822cdf0e10cSrcweir     {
823cdf0e10cSrcweir         OUString sPaneURL;
824cdf0e10cSrcweir         OUString sViewURL;
825cdf0e10cSrcweir         double nX = 0;
826cdf0e10cSrcweir         double nY = 0;
827cdf0e10cSrcweir         double nWidth = 0;
828cdf0e10cSrcweir         double nHeight = 0;
829cdf0e10cSrcweir         rValues[0] >>= sPaneURL;
830cdf0e10cSrcweir         rValues[1] >>= sViewURL;
831cdf0e10cSrcweir         rValues[2] >>= nX;
832cdf0e10cSrcweir         rValues[3] >>= nY;
833cdf0e10cSrcweir         rValues[4] >>= nWidth;
834cdf0e10cSrcweir         rValues[5] >>= nHeight;
835cdf0e10cSrcweir 
836cdf0e10cSrcweir         if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)
837cdf0e10cSrcweir         {
838cdf0e10cSrcweir             SetupView(
839cdf0e10cSrcweir                 rxContext,
840cdf0e10cSrcweir                 rxAnchorId,
841cdf0e10cSrcweir                 sPaneURL,
842cdf0e10cSrcweir                 sViewURL,
843cdf0e10cSrcweir                 PresenterPaneContainer::ViewInitializationFunction(),
844cdf0e10cSrcweir                 nX,
845cdf0e10cSrcweir                 nY,
846cdf0e10cSrcweir                 nX+nWidth,
847cdf0e10cSrcweir                 nY+nHeight);
848cdf0e10cSrcweir         }
849cdf0e10cSrcweir    	}
850cdf0e10cSrcweir 	catch (Exception& e)
851cdf0e10cSrcweir 	{
852cdf0e10cSrcweir         (void)e;
853cdf0e10cSrcweir         OSL_ASSERT(false);
854cdf0e10cSrcweir 	}
855cdf0e10cSrcweir }
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 
860cdf0e10cSrcweir void PresenterScreen::ProcessViewDescription (
861cdf0e10cSrcweir     const OUString& rsKey,
862cdf0e10cSrcweir     const ::std::vector<Any>& rValues)
863cdf0e10cSrcweir {
864cdf0e10cSrcweir     (void)rsKey;
865cdf0e10cSrcweir 
866cdf0e10cSrcweir     if (rValues.size() != 4)
867cdf0e10cSrcweir         return;
868cdf0e10cSrcweir 
869cdf0e10cSrcweir     try
870cdf0e10cSrcweir     {
871cdf0e10cSrcweir         ViewDescriptor aViewDescriptor;
872cdf0e10cSrcweir         OUString sViewURL;
873cdf0e10cSrcweir         rValues[0] >>= sViewURL;
874cdf0e10cSrcweir         rValues[1] >>= aViewDescriptor.msTitle;
875cdf0e10cSrcweir         rValues[2] >>= aViewDescriptor.msAccessibleTitle;
876cdf0e10cSrcweir         rValues[3] >>= aViewDescriptor.mbIsOpaque;
877cdf0e10cSrcweir         if (aViewDescriptor.msAccessibleTitle.getLength()==0)
878cdf0e10cSrcweir             aViewDescriptor.msAccessibleTitle = aViewDescriptor.msTitle;
879cdf0e10cSrcweir         maViewDescriptors[sViewURL] = aViewDescriptor;
880cdf0e10cSrcweir    	}
881cdf0e10cSrcweir 	catch (Exception&)
882cdf0e10cSrcweir 	{
883cdf0e10cSrcweir         OSL_ASSERT(false);
884cdf0e10cSrcweir 	}
885cdf0e10cSrcweir }
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 
890cdf0e10cSrcweir void PresenterScreen::SetupView(
891cdf0e10cSrcweir     const Reference<XComponentContext>& rxContext,
892cdf0e10cSrcweir     const Reference<XResourceId>& rxAnchorId,
893cdf0e10cSrcweir     const OUString& rsPaneURL,
894cdf0e10cSrcweir     const OUString& rsViewURL,
895cdf0e10cSrcweir     const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization,
896cdf0e10cSrcweir     const double nLeft,
897cdf0e10cSrcweir     const double nTop,
898cdf0e10cSrcweir     const double nRight,
899cdf0e10cSrcweir     const double nBottom)
900cdf0e10cSrcweir {
901cdf0e10cSrcweir     Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
902cdf0e10cSrcweir     if (xCC.is())
903cdf0e10cSrcweir     {
904cdf0e10cSrcweir         Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
905cdf0e10cSrcweir         // Look up the view descriptor.
906cdf0e10cSrcweir         ViewDescriptor aViewDescriptor;
907cdf0e10cSrcweir         ViewDescriptorContainer::const_iterator iDescriptor (maViewDescriptors.find(rsViewURL));
908cdf0e10cSrcweir         if (iDescriptor != maViewDescriptors.end())
909cdf0e10cSrcweir             aViewDescriptor = iDescriptor->second;
910cdf0e10cSrcweir 
911cdf0e10cSrcweir         // Prepare the pane.
912cdf0e10cSrcweir         OSL_ASSERT(mpPaneContainer.get() != NULL);
913cdf0e10cSrcweir         mpPaneContainer->PreparePane(
914cdf0e10cSrcweir             xPaneId,
915cdf0e10cSrcweir             rsViewURL,
916cdf0e10cSrcweir             aViewDescriptor.msTitle,
917cdf0e10cSrcweir             aViewDescriptor.msAccessibleTitle,
918cdf0e10cSrcweir             aViewDescriptor.mbIsOpaque,
919cdf0e10cSrcweir             rViewInitialization,
920cdf0e10cSrcweir             nLeft,
921cdf0e10cSrcweir             nTop,
922cdf0e10cSrcweir             nRight,
923cdf0e10cSrcweir             nBottom);
924cdf0e10cSrcweir     }
925cdf0e10cSrcweir }
926cdf0e10cSrcweir 
927cdf0e10cSrcweir 
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 
930cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
931