Bump version to 5.0-14
[LibreOffice.git] / sdext / source / presenter / PresenterScreen.cxx
blob11cae1cdffeb0328cf1985c6a9b9fdc04d7ddec7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "PresenterScreen.hxx"
21 #include "PresenterConfigurationAccess.hxx"
22 #include "PresenterController.hxx"
23 #include "PresenterFrameworkObserver.hxx"
24 #include "PresenterHelper.hxx"
25 #include "PresenterPaneContainer.hxx"
26 #include "PresenterPaneFactory.hxx"
27 #include "PresenterViewFactory.hxx"
28 #include "PresenterWindowManager.hxx"
29 #include <com/sun/star/frame/XController.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/drawing/framework/Configuration.hpp>
32 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
33 #include <com/sun/star/drawing/framework/ResourceId.hpp>
34 #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
35 #include <com/sun/star/presentation/XSlideShow.hpp>
36 #include <com/sun/star/presentation/XPresentation2.hpp>
37 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
38 #include <com/sun/star/document/XEventBroadcaster.hpp>
39 #include <boost/bind.hpp>
41 #include <com/sun/star/view/XSelectionSupplier.hpp>
42 #include <vcl/svapp.hxx>
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::lang;
47 using namespace ::com::sun::star::presentation;
48 using namespace ::com::sun::star::drawing::framework;
50 namespace sdext { namespace presenter {
52 namespace {
53 typedef ::cppu::WeakComponentImplHelper1 <
54 css::document::XEventListener
55 > PresenterScreenListenerInterfaceBase;
57 /** One instance of a PresenterScreenListener is registered per Impress
58 document and waits for the full screen slide show to start and to
59 end.
61 class PresenterScreenListener
62 : private ::boost::noncopyable,
63 private ::cppu::BaseMutex,
64 public PresenterScreenListenerInterfaceBase
66 public:
67 PresenterScreenListener (
68 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
69 const css::uno::Reference<css::frame::XModel2>& rxModel);
70 virtual ~PresenterScreenListener();
72 void Initialize();
73 virtual void SAL_CALL disposing() SAL_OVERRIDE;
75 // document::XEventListener
77 virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 // XEventListener
81 virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 private:
84 css::uno::Reference<css::frame::XModel2 > mxModel;
85 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
86 rtl::Reference<PresenterScreen> mpPresenterScreen;
88 void ThrowIfDisposed() const throw (::com::sun::star::lang::DisposedException);
92 //----- Service ---------------------------------------------------------------
94 OUString PresenterScreenJob::getImplementationName_static()
96 return OUString("org.libreoffice.comp.PresenterScreenJob");
99 Sequence<OUString> PresenterScreenJob::getSupportedServiceNames_static()
101 return Sequence<OUString>();
104 Reference<XInterface> PresenterScreenJob::Create (const Reference<uno::XComponentContext>& rxContext)
106 return Reference<XInterface>(static_cast<XWeak*>(new PresenterScreenJob(rxContext)));
109 //===== PresenterScreenJob ====================================================
111 PresenterScreenJob::PresenterScreenJob (const Reference<XComponentContext>& rxContext)
112 : PresenterScreenJobInterfaceBase(m_aMutex),
113 mxComponentContext(rxContext)
117 PresenterScreenJob::~PresenterScreenJob()
121 void SAL_CALL PresenterScreenJob::disposing()
123 mxComponentContext = NULL;
126 //----- XJob -----------------------------------------------------------
128 Any SAL_CALL PresenterScreenJob::execute(
129 const Sequence< beans::NamedValue >& Arguments )
130 throw (lang::IllegalArgumentException, Exception, RuntimeException, std::exception)
132 Sequence< beans::NamedValue > lEnv;
134 sal_Int32 i = 0;
135 sal_Int32 c = Arguments.getLength();
136 const beans::NamedValue* p = Arguments.getConstArray();
137 for (i=0; i<c; ++i)
139 if ( p[i].Name == "Environment" )
141 p[i].Value >>= lEnv;
142 break;
146 Reference<frame::XModel2> xModel;
147 c = lEnv.getLength();
148 p = lEnv.getConstArray();
149 for (i=0; i<c; ++i)
151 if ( p[i].Name == "Model" )
153 p[i].Value >>= xModel;
154 break;
158 Reference< XServiceInfo > xInfo( xModel, UNO_QUERY );
159 if( xInfo.is() && xInfo->supportsService("com.sun.star.presentation.PresentationDocument") )
161 // Create a new listener that waits for the full screen presentation
162 // to start and to end. It takes care of its own lifetime.
163 ::rtl::Reference<PresenterScreenListener> pListener (
164 new PresenterScreenListener(mxComponentContext, xModel));
165 pListener->Initialize();
168 return Any();
171 //===== PresenterScreenListener ===============================================
173 namespace {
175 PresenterScreenListener::PresenterScreenListener (
176 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
177 const css::uno::Reference<css::frame::XModel2>& rxModel)
178 : PresenterScreenListenerInterfaceBase(m_aMutex),
179 mxModel(rxModel),
180 mxComponentContext(rxContext),
181 mpPresenterScreen()
185 void PresenterScreenListener::Initialize()
187 Reference< document::XEventListener > xDocListener(
188 static_cast< document::XEventListener* >(this), UNO_QUERY);
189 Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
190 if( xDocBroadcaster.is() )
191 xDocBroadcaster->addEventListener(xDocListener);
194 PresenterScreenListener::~PresenterScreenListener()
198 void SAL_CALL PresenterScreenListener::disposing()
200 Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
201 if( xDocBroadcaster.is() )
202 xDocBroadcaster->removeEventListener(
203 Reference<document::XEventListener>(
204 static_cast<document::XEventListener*>(this), UNO_QUERY));
206 if (mpPresenterScreen.is())
208 mpPresenterScreen->RequestShutdownPresenterScreen();
209 mpPresenterScreen = NULL;
213 // document::XEventListener
215 void SAL_CALL PresenterScreenListener::notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException, std::exception)
217 ThrowIfDisposed();
219 if ( Event.EventName == "OnStartPresentation" )
221 mpPresenterScreen = new PresenterScreen(mxComponentContext, mxModel);
222 if(PresenterScreen::isPresenterScreenEnabled(mxComponentContext))
223 mpPresenterScreen->InitializePresenterScreen();
225 else if ( Event.EventName == "OnEndPresentation" )
227 if (mpPresenterScreen.is())
229 mpPresenterScreen->RequestShutdownPresenterScreen();
230 mpPresenterScreen = NULL;
235 // XEventListener
237 void SAL_CALL PresenterScreenListener::disposing (const css::lang::EventObject& rEvent)
238 throw (css::uno::RuntimeException, std::exception)
240 (void)rEvent;
242 if (mpPresenterScreen.is())
244 mpPresenterScreen->RequestShutdownPresenterScreen();
245 mpPresenterScreen = NULL;
249 void PresenterScreenListener::ThrowIfDisposed() const throw (
250 ::com::sun::star::lang::DisposedException)
252 if (rBHelper.bDisposed || rBHelper.bInDispose)
254 throw lang::DisposedException (
255 OUString(
256 "PresenterScreenListener object has already been disposed"),
257 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
261 } // end of anonymous namespace
263 //===== PresenterScreen =======================================================
265 PresenterScreen::PresenterScreen (
266 const Reference<XComponentContext>& rxContext,
267 const css::uno::Reference<css::frame::XModel2>& rxModel)
268 : PresenterScreenInterfaceBase(m_aMutex),
269 mxModel(rxModel),
270 mxController(),
271 mxConfigurationControllerWeak(),
272 mxContextWeak(rxContext),
273 mxSlideShowControllerWeak(),
274 mpPresenterController(),
275 mxSlideShowViewId(),
276 mxSavedConfiguration(),
277 mpPaneContainer(),
278 mnComponentIndex(0),
279 mxPaneFactory(),
280 mxViewFactory(),
281 maViewDescriptors()
285 PresenterScreen::~PresenterScreen()
289 bool PresenterScreen::isPresenterScreenEnabled(const css::uno::Reference<css::uno::XComponentContext>& rxContext)
291 bool dEnablePresenterScreen=true;
292 PresenterConfigurationAccess aConfiguration (
293 rxContext,
294 OUString("/org.openoffice.Office.Impress/"),
295 PresenterConfigurationAccess::READ_ONLY);
296 aConfiguration.GetConfigurationNode("Misc/Start/EnablePresenterScreen")
297 >>= dEnablePresenterScreen;
298 return dEnablePresenterScreen;
300 void SAL_CALL PresenterScreen::disposing()
302 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
303 if (xCC.is() && mxSavedConfiguration.is())
305 xCC->restoreConfiguration(mxSavedConfiguration);
307 mxConfigurationControllerWeak = Reference<XConfigurationController>(NULL);
309 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
310 if (xViewFactoryComponent.is())
311 xViewFactoryComponent->dispose();
312 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
313 if (xPaneFactoryComponent.is())
314 xPaneFactoryComponent->dispose();
316 mxModel = NULL;
319 //----- XEventListener --------------------------------------------------------
321 void SAL_CALL PresenterScreen::disposing (const lang::EventObject& /*rEvent*/)
322 throw (RuntimeException, std::exception)
324 mxSlideShowControllerWeak = WeakReference<presentation::XSlideShowController>();
325 RequestShutdownPresenterScreen();
330 void PresenterScreen::InitializePresenterScreen()
334 Reference<XComponentContext> xContext (mxContextWeak);
335 mpPaneContainer =
336 new PresenterPaneContainer(Reference<XComponentContext>(xContext));
338 Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
339 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
340 Reference<presentation::XSlideShowController> xSlideShowController( xPresentation->getController() );
341 mxSlideShowControllerWeak = xSlideShowController;
343 if( !xSlideShowController.is() || !xSlideShowController->isFullScreen() )
344 return;
346 // find first controller that is not the current controller (the one with the slideshow
347 mxController = mxModel->getCurrentController();
348 Reference< container::XEnumeration > xEnum( mxModel->getControllers() );
349 if( xEnum.is() )
351 while( xEnum->hasMoreElements() )
353 Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY );
354 if( xC.is() && (xC != mxController) )
356 mxController = xC;
357 break;
361 // Get the XController from the first argument.
362 Reference<XControllerManager> xCM(mxController, UNO_QUERY_THROW);
364 Reference<XConfigurationController> xCC( xCM->getConfigurationController());
365 mxConfigurationControllerWeak = xCC;
367 Reference<drawing::framework::XResourceId> xMainPaneId(
368 GetMainPaneId(xPresentation));
369 // An empty reference means that the presenter screen can
370 // not or must not be displayed.
371 if ( ! xMainPaneId.is())
372 return;
374 if (xCC.is() && xContext.is())
376 // Store the current configuration so that we can restore it when
377 // the presenter view is deactivated.
378 mxSavedConfiguration = xCC->getRequestedConfiguration();
379 xCC->lock();
383 // At the moment the presenter controller is displayed in its
384 // own full screen window that is controlled by the same
385 // configuration controller as the Impress document from
386 // which the presentation was started. Therefore the main
387 // pane is activated additionally to the already existing
388 // panes and does not replace them.
389 xCC->requestResourceActivation(
390 xMainPaneId,
391 ResourceActivationMode_ADD);
392 SetupConfiguration(xContext, xMainPaneId);
394 mpPresenterController = new PresenterController(
395 css::uno::WeakReference<css::lang::XEventListener>(this),
396 xContext,
397 mxController,
398 xSlideShowController,
399 mpPaneContainer,
400 xMainPaneId);
402 // Create pane and view factories and integrate them into the
403 // drawing framework.
404 SetupPaneFactory(xContext);
405 SetupViewFactory(xContext);
407 mpPresenterController->GetWindowManager()->RestoreViewMode();
409 catch (const RuntimeException&)
411 xCC->restoreConfiguration(mxSavedConfiguration);
413 xCC->unlock();
416 catch (const Exception&)
421 void PresenterScreen::SwitchMonitors()
423 try {
424 Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
425 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
427 // Get the existing presenter console screen, we want to switch the
428 // presentation to use that instead.
429 sal_Int32 nNewScreen = GetPresenterScreenNumber (xPresentation);
430 if (nNewScreen < 0)
431 return;
433 // Adapt that display number to be the 'default' setting of 0 if it matches
434 sal_Int32 nExternalDisplay = Application::GetDisplayExternalScreen();
436 if (nNewScreen == nExternalDisplay)
437 nNewScreen = 0; // screen zero is best == the primary display
438 else
439 nNewScreen++; // otherwise we store screens offset by one.
441 // Set the new presentation display
442 Reference<beans::XPropertySet> xProperties (xPresentation, UNO_QUERY_THROW);
443 uno::Any aDisplay;
444 aDisplay <<= nNewScreen;
445 xProperties->setPropertyValue("Display", aDisplay);
446 } catch (const uno::Exception &) {
451 * Return the real VCL screen number to show the presenter console
452 * on or -1 to not show anything.
454 sal_Int32 PresenterScreen::GetPresenterScreenNumber (
455 const Reference<presentation::XPresentation2>& rxPresentation) const
457 sal_Int32 nScreenNumber (0);
458 sal_Int32 nScreenCount (1);
461 Reference<beans::XPropertySet> xProperties (rxPresentation, UNO_QUERY);
462 if ( ! xProperties.is())
463 return -1;
465 // Determine the screen on which the full screen presentation is being
466 // displayed.
467 sal_Int32 nDisplayNumber (-1);
468 if ( ! (xProperties->getPropertyValue("Display") >>= nDisplayNumber))
469 return -1;
470 if (nDisplayNumber == -1)
472 // The special value -1 indicates that the slide show
473 // spans all available displays. That leaves no room for
474 // the presenter screen.
475 return -1;
478 SAL_INFO("sdext.presenter", "Display number is " << nDisplayNumber);
480 if (nDisplayNumber > 0)
482 nScreenNumber = nDisplayNumber - 1;
484 else if (nDisplayNumber == 0)
486 // A display number value of 0 indicates the primary screen.
487 // Find out which screen number that is.
488 if (nDisplayNumber <= 0)
489 nScreenNumber = Application::GetDisplayExternalScreen();
492 // We still have to determine the number of screens to decide
493 // whether the presenter screen may be shown at all.
494 nScreenCount = Application::GetScreenCount();
496 if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
498 // There is either only one screen or the full screen
499 // presentation spans all available screens. The presenter
500 // screen is shown only when a special flag in the configuration
501 // is set.
502 Reference<XComponentContext> xContext (mxContextWeak);
503 PresenterConfigurationAccess aConfiguration (
504 xContext,
505 OUString("/org.openoffice.Office.PresenterScreen/"),
506 PresenterConfigurationAccess::READ_ONLY);
507 bool bStartAlways (false);
508 if (aConfiguration.GetConfigurationNode(
509 OUString("Presenter/StartAlways")) >>= bStartAlways)
511 if (bStartAlways)
512 return GetPresenterScreenFromScreen(nScreenNumber);
514 return -1;
517 catch (const beans::UnknownPropertyException&)
519 OSL_ASSERT(false);
520 // For some reason we can not access the screen number. Use
521 // the default instead.
523 SAL_INFO("sdext.presenter", "Get presenter screen for screen " << nScreenNumber);
524 return GetPresenterScreenFromScreen(nScreenNumber);
527 sal_Int32 PresenterScreen::GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen )
529 // Setup the resource id of the full screen background pane so that
530 // it is displayed on another screen than the presentation.
531 sal_Int32 nPresenterScreenNumber (1);
532 switch (nPresentationScreen)
534 case 0:
535 nPresenterScreenNumber = 1;
536 break;
538 case 1:
539 nPresenterScreenNumber = 0;
540 break;
542 default:
543 SAL_INFO("sdext.presenter", "Warning unexpected, out of bound screen "
544 "mapped to 0" << nPresentationScreen);
545 // When the full screen presentation is displayed on a screen
546 // other than 0 or 1 then place the presenter on the first
547 // available screen.
548 nPresenterScreenNumber = 0;
549 break;
551 return nPresenterScreenNumber;
554 Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
555 const Reference<presentation::XPresentation2>& rxPresentation) const
557 // A negative value means that the presentation spans all available
558 // displays. That leaves no room for the presenter.
559 const sal_Int32 nScreen(GetPresenterScreenNumber(rxPresentation));
560 if (nScreen < 0)
561 return NULL;
563 return ResourceId::create(
564 Reference<XComponentContext>(mxContextWeak),
565 PresenterHelper::msFullScreenPaneURL
566 + "?FullScreen=true&ScreenNumber="
567 + OUString::number(nScreen));
570 void PresenterScreen::RequestShutdownPresenterScreen()
572 // Restore the configuration that was active before the presenter screen
573 // has been activated. Now, that the presenter screen is displayed in
574 // its own top level window this probably not necessary, but one never knows.
575 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
576 if (xCC.is() && mxSavedConfiguration.is())
578 xCC->restoreConfiguration(mxSavedConfiguration);
579 mxSavedConfiguration = NULL;
582 if (xCC.is())
584 // The actual restoration of the configuration takes place
585 // asynchronously. The view and pane factories can only by disposed
586 // after that. Therefore, set up a listener and wait for the
587 // restoration.
588 rtl::Reference<PresenterScreen> pSelf (this);
589 PresenterFrameworkObserver::RunOnUpdateEnd(
590 xCC,
591 ::boost::bind(&PresenterScreen::ShutdownPresenterScreen, pSelf));
592 xCC->update();
596 void PresenterScreen::ShutdownPresenterScreen()
598 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
599 if (xViewFactoryComponent.is())
600 xViewFactoryComponent->dispose();
601 mxViewFactory = NULL;
603 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
604 if (xPaneFactoryComponent.is())
605 xPaneFactoryComponent->dispose();
606 mxPaneFactory = NULL;
608 if (mpPresenterController.get() != NULL)
610 mpPresenterController->dispose();
611 mpPresenterController = rtl::Reference<PresenterController>();
613 mpPaneContainer = new PresenterPaneContainer(Reference<XComponentContext>(mxContextWeak));
616 void PresenterScreen::SetupPaneFactory (const Reference<XComponentContext>& rxContext)
620 if ( ! mxPaneFactory.is())
621 mxPaneFactory = PresenterPaneFactory::Create(
622 rxContext,
623 mxController,
624 mpPresenterController);
626 catch (const RuntimeException&)
628 OSL_ASSERT(false);
632 void PresenterScreen::SetupViewFactory (const Reference<XComponentContext>& rxContext)
636 if ( ! mxViewFactory.is())
637 mxViewFactory = PresenterViewFactory::Create(
638 rxContext,
639 mxController,
640 mpPresenterController);
642 catch (const RuntimeException&)
644 OSL_ASSERT(false);
648 void PresenterScreen::SetupConfiguration (
649 const Reference<XComponentContext>& rxContext,
650 const Reference<XResourceId>& rxAnchorId)
654 PresenterConfigurationAccess aConfiguration (
655 rxContext,
656 OUString("org.openoffice.Office.PresenterScreen"),
657 PresenterConfigurationAccess::READ_ONLY);
658 maViewDescriptors.clear();
659 ProcessViewDescriptions(aConfiguration);
660 OUString sLayoutName ("DefaultLayout");
661 aConfiguration.GetConfigurationNode(
662 OUString("Presenter/CurrentLayout")) >>= sLayoutName;
663 ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
665 catch (const RuntimeException&)
670 void PresenterScreen::ProcessLayout (
671 PresenterConfigurationAccess& rConfiguration,
672 const OUString& rsLayoutName,
673 const Reference<XComponentContext>& rxContext,
674 const Reference<XResourceId>& rxAnchorId)
678 Reference<container::XHierarchicalNameAccess> xLayoutNode (
679 rConfiguration.GetConfigurationNode(
680 "Presenter/Layouts/"+rsLayoutName),
681 UNO_QUERY_THROW);
683 // Read the parent layout first, if one is referenced.
684 OUString sParentLayout;
685 PresenterConfigurationAccess::GetConfigurationNode(
686 xLayoutNode,
687 OUString("ParentLayout")) >>= sParentLayout;
688 if (!sParentLayout.isEmpty())
690 // Prevent infinite recursion.
691 if (rsLayoutName != sParentLayout)
692 ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
695 // Process the actual layout list.
696 Reference<container::XNameAccess> xList (
697 PresenterConfigurationAccess::GetConfigurationNode(
698 xLayoutNode,
699 OUString("Layout")),
700 UNO_QUERY_THROW);
702 ::std::vector<OUString> aProperties (6);
703 aProperties[0] = "PaneURL";
704 aProperties[1] = "ViewURL";
705 aProperties[2] = "RelativeX";
706 aProperties[3] = "RelativeY";
707 aProperties[4] = "RelativeWidth";
708 aProperties[5] = "RelativeHeight";
709 mnComponentIndex = 1;
710 PresenterConfigurationAccess::ForAll(
711 xList,
712 aProperties,
713 ::boost::bind(&PresenterScreen::ProcessComponent, this,
716 rxContext,
717 rxAnchorId));
719 catch (const RuntimeException&)
724 void PresenterScreen::ProcessViewDescriptions (
725 PresenterConfigurationAccess& rConfiguration)
729 Reference<container::XNameAccess> xViewDescriptionsNode (
730 rConfiguration.GetConfigurationNode("Presenter/Views"),
731 UNO_QUERY_THROW);
733 ::std::vector<OUString> aProperties (4);
734 aProperties[0] = "ViewURL";
735 aProperties[1] = "Title";
736 aProperties[2] = "AccessibleTitle";
737 aProperties[3] = "IsOpaque";
738 mnComponentIndex = 1;
739 PresenterConfigurationAccess::ForAll(
740 xViewDescriptionsNode,
741 aProperties,
742 ::boost::bind(&PresenterScreen::ProcessViewDescription, this, _1, _2));
744 catch (const RuntimeException&)
746 OSL_ASSERT(false);
750 void PresenterScreen::ProcessComponent (
751 const OUString& rsKey,
752 const ::std::vector<Any>& rValues,
753 const Reference<XComponentContext>& rxContext,
754 const Reference<XResourceId>& rxAnchorId)
756 (void)rsKey;
758 if (rValues.size() != 6)
759 return;
763 OUString sPaneURL;
764 OUString sViewURL;
765 double nX = 0;
766 double nY = 0;
767 double nWidth = 0;
768 double nHeight = 0;
769 rValues[0] >>= sPaneURL;
770 rValues[1] >>= sViewURL;
771 rValues[2] >>= nX;
772 rValues[3] >>= nY;
773 rValues[4] >>= nWidth;
774 rValues[5] >>= nHeight;
776 if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)
778 SetupView(
779 rxContext,
780 rxAnchorId,
781 sPaneURL,
782 sViewURL,
783 PresenterPaneContainer::ViewInitializationFunction(),
786 nX+nWidth,
787 nY+nHeight);
790 catch (const Exception&)
792 OSL_ASSERT(false);
796 void PresenterScreen::ProcessViewDescription (
797 const OUString& rsKey,
798 const ::std::vector<Any>& rValues)
800 (void)rsKey;
802 if (rValues.size() != 4)
803 return;
807 ViewDescriptor aViewDescriptor;
808 OUString sViewURL;
809 rValues[0] >>= sViewURL;
810 rValues[1] >>= aViewDescriptor.msTitle;
811 rValues[2] >>= aViewDescriptor.msAccessibleTitle;
812 rValues[3] >>= aViewDescriptor.mbIsOpaque;
813 if (aViewDescriptor.msAccessibleTitle.isEmpty())
814 aViewDescriptor.msAccessibleTitle = aViewDescriptor.msTitle;
815 maViewDescriptors[sViewURL] = aViewDescriptor;
817 catch (const Exception&)
819 OSL_ASSERT(false);
823 void PresenterScreen::SetupView(
824 const Reference<XComponentContext>& rxContext,
825 const Reference<XResourceId>& rxAnchorId,
826 const OUString& rsPaneURL,
827 const OUString& rsViewURL,
828 const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization,
829 const double nLeft,
830 const double nTop,
831 const double nRight,
832 const double nBottom)
834 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
835 if (xCC.is())
837 Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
838 // Look up the view descriptor.
839 ViewDescriptor aViewDescriptor;
840 ViewDescriptorContainer::const_iterator iDescriptor (maViewDescriptors.find(rsViewURL));
841 if (iDescriptor != maViewDescriptors.end())
842 aViewDescriptor = iDescriptor->second;
844 // Prepare the pane.
845 OSL_ASSERT(mpPaneContainer.get() != NULL);
846 mpPaneContainer->PreparePane(
847 xPaneId,
848 rsViewURL,
849 aViewDescriptor.msTitle,
850 aViewDescriptor.msAccessibleTitle,
851 aViewDescriptor.mbIsOpaque,
852 rViewInitialization,
853 nLeft,
854 nTop,
855 nRight,
856 nBottom);
860 } } // end of namespace ::sdext::presenter
862 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */