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