Updated core
[LibreOffice.git] / sdext / source / presenter / PresenterScreen.cxx
blobf986944931587829694c51355b04e3f12fee1b07
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 (void);
72 void Initialize (void);
73 virtual void SAL_CALL disposing (void);
75 // document::XEventListener
77 virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException);
79 // XEventListener
81 virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) throw (css::uno::RuntimeException);
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 (void) const throw (::com::sun::star::lang::DisposedException);
92 //----- Service ---------------------------------------------------------------
94 OUString PresenterScreenJob::getImplementationName_static (void)
96 return OUString("org.libreoffice.comp.PresenterScreenJob");
99 Sequence<OUString> PresenterScreenJob::getSupportedServiceNames_static (void)
101 return Sequence<OUString>();
104 Reference<XInterface> PresenterScreenJob::Create (const Reference<uno::XComponentContext>& rxContext)
105 SAL_THROW((css::uno::Exception))
107 return Reference<XInterface>(static_cast<XWeak*>(new PresenterScreenJob(rxContext)));
110 //===== PresenterScreenJob ====================================================
112 PresenterScreenJob::PresenterScreenJob (const Reference<XComponentContext>& rxContext)
113 : PresenterScreenJobInterfaceBase(m_aMutex),
114 mxComponentContext(rxContext)
118 PresenterScreenJob::~PresenterScreenJob (void)
122 void SAL_CALL PresenterScreenJob::disposing (void)
124 mxComponentContext = NULL;
127 //----- XJob -----------------------------------------------------------
129 Any SAL_CALL PresenterScreenJob::execute(
130 const Sequence< beans::NamedValue >& Arguments )
131 throw (lang::IllegalArgumentException, Exception, RuntimeException)
133 Sequence< beans::NamedValue > lEnv;
135 sal_Int32 i = 0;
136 sal_Int32 c = Arguments.getLength();
137 const beans::NamedValue* p = Arguments.getConstArray();
138 for (i=0; i<c; ++i)
140 if ( p[i].Name == "Environment" )
142 p[i].Value >>= lEnv;
143 break;
147 Reference<frame::XModel2> xModel;
148 c = lEnv.getLength();
149 p = lEnv.getConstArray();
150 for (i=0; i<c; ++i)
152 if ( p[i].Name == "Model" )
154 p[i].Value >>= xModel;
155 break;
159 Reference< XServiceInfo > xInfo( xModel, UNO_QUERY );
160 if( xInfo.is() && xInfo->supportsService( OUString( "com.sun.star.presentation.PresentationDocument" ) ) )
162 // Create a new listener that waits for the full screen presentation
163 // to start and to end. It takes care of its own lifetime.
164 ::rtl::Reference<PresenterScreenListener> pListener (
165 new PresenterScreenListener(mxComponentContext, xModel));
166 pListener->Initialize();
169 return Any();
172 //===== PresenterScreenListener ===============================================
174 namespace {
176 PresenterScreenListener::PresenterScreenListener (
177 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
178 const css::uno::Reference<css::frame::XModel2>& rxModel)
179 : PresenterScreenListenerInterfaceBase(m_aMutex),
180 mxModel(rxModel),
181 mxComponentContext(rxContext),
182 mpPresenterScreen()
186 void PresenterScreenListener::Initialize (void)
188 Reference< document::XEventListener > xDocListener(
189 static_cast< document::XEventListener* >(this), UNO_QUERY);
190 Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
191 if( xDocBroadcaster.is() )
192 xDocBroadcaster->addEventListener(xDocListener);
195 PresenterScreenListener::~PresenterScreenListener (void)
199 void SAL_CALL PresenterScreenListener::disposing (void)
201 Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
202 if( xDocBroadcaster.is() )
203 xDocBroadcaster->removeEventListener(
204 Reference<document::XEventListener>(
205 static_cast<document::XEventListener*>(this), UNO_QUERY));
207 if (mpPresenterScreen.is())
209 mpPresenterScreen->RequestShutdownPresenterScreen();
210 mpPresenterScreen = NULL;
214 // document::XEventListener
216 void SAL_CALL PresenterScreenListener::notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException)
218 ThrowIfDisposed();
220 if ( Event.EventName == "OnStartPresentation" )
222 mpPresenterScreen = new PresenterScreen(mxComponentContext, mxModel);
223 if(mpPresenterScreen->isPresenterScreenEnabled(mxComponentContext))
224 mpPresenterScreen->InitializePresenterScreen();
226 else if ( Event.EventName == "OnEndPresentation" )
228 if (mpPresenterScreen.is())
230 mpPresenterScreen->RequestShutdownPresenterScreen();
231 mpPresenterScreen = NULL;
236 // XEventListener
238 void SAL_CALL PresenterScreenListener::disposing (const css::lang::EventObject& rEvent)
239 throw (css::uno::RuntimeException)
241 (void)rEvent;
243 if (mpPresenterScreen.is())
245 mpPresenterScreen->RequestShutdownPresenterScreen();
246 mpPresenterScreen = NULL;
250 void PresenterScreenListener::ThrowIfDisposed (void) const throw (
251 ::com::sun::star::lang::DisposedException)
253 if (rBHelper.bDisposed || rBHelper.bInDispose)
255 throw lang::DisposedException (
256 OUString(
257 "PresenterScreenListener object has already been disposed"),
258 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
262 } // end of anonymous namespace
264 //===== PresenterScreen =======================================================
266 PresenterScreen::PresenterScreen (
267 const Reference<XComponentContext>& rxContext,
268 const css::uno::Reference<css::frame::XModel2>& rxModel)
269 : PresenterScreenInterfaceBase(m_aMutex),
270 mxModel(rxModel),
271 mxController(),
272 mxConfigurationControllerWeak(),
273 mxContextWeak(rxContext),
274 mxSlideShowControllerWeak(),
275 mpPresenterController(),
276 mxSlideShowViewId(),
277 mxSavedConfiguration(),
278 mpPaneContainer(),
279 mnComponentIndex(0),
280 mxPaneFactory(),
281 mxViewFactory(),
282 maViewDescriptors()
286 PresenterScreen::~PresenterScreen (void)
290 bool PresenterScreen::isPresenterScreenEnabled(const css::uno::Reference<css::uno::XComponentContext>& rxContext)
292 bool dEnablePresenterScreen=true;
293 PresenterConfigurationAccess aConfiguration (
294 rxContext,
295 OUString("/org.openoffice.Office.Impress/"),
296 PresenterConfigurationAccess::READ_ONLY);
297 aConfiguration.GetConfigurationNode("Misc/Start/EnablePresenterScreen")
298 >>= dEnablePresenterScreen;
299 return dEnablePresenterScreen;
301 void SAL_CALL PresenterScreen::disposing (void)
303 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
304 if (xCC.is() && mxSavedConfiguration.is())
306 xCC->restoreConfiguration(mxSavedConfiguration);
308 mxConfigurationControllerWeak = Reference<XConfigurationController>(NULL);
310 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
311 if (xViewFactoryComponent.is())
312 xViewFactoryComponent->dispose();
313 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
314 if (xPaneFactoryComponent.is())
315 xPaneFactoryComponent->dispose();
317 mxModel = NULL;
320 //----- XEventListener --------------------------------------------------------
322 void SAL_CALL PresenterScreen::disposing (const lang::EventObject& /*rEvent*/)
323 throw (RuntimeException)
325 mxSlideShowControllerWeak = WeakReference<presentation::XSlideShowController>();
326 RequestShutdownPresenterScreen();
329 //-----------------------------------------------------------------------------
331 void PresenterScreen::InitializePresenterScreen (void)
335 Reference<XComponentContext> xContext (mxContextWeak);
336 mpPaneContainer =
337 new PresenterPaneContainer(Reference<XComponentContext>(xContext));
339 Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
340 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
341 Reference<presentation::XSlideShowController> xSlideShowController( xPresentation->getController() );
342 mxSlideShowControllerWeak = xSlideShowController;
344 if( !xSlideShowController.is() || !xSlideShowController->isFullScreen() )
345 return;
347 // find first controller that is not the current controller (the one with the slideshow
348 mxController = mxModel->getCurrentController();
349 Reference< container::XEnumeration > xEnum( mxModel->getControllers() );
350 if( xEnum.is() )
352 while( xEnum->hasMoreElements() )
354 Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY );
355 if( xC.is() && (xC != mxController) )
357 mxController = xC;
358 break;
362 // Get the XController from the first argument.
363 Reference<XControllerManager> xCM(mxController, UNO_QUERY_THROW);
365 Reference<XConfigurationController> xCC( xCM->getConfigurationController());
366 mxConfigurationControllerWeak = xCC;
368 Reference<drawing::framework::XResourceId> xMainPaneId(
369 GetMainPaneId(xPresentation));
370 // An empty reference means that the presenter screen can
371 // not or must not be displayed.
372 if ( ! xMainPaneId.is())
373 return;
375 if (xCC.is() && xContext.is())
377 // Store the current configuration so that we can restore it when
378 // the presenter view is deactivated.
379 mxSavedConfiguration = xCC->getRequestedConfiguration();
380 xCC->lock();
384 // At the moment the presenter controller is displayed in its
385 // own full screen window that is controlled by the same
386 // configuration controller as the Impress document from
387 // which the presentation was started. Therefore the main
388 // pane is actived additionally to the already existing
389 // panes and does not replace them.
390 xCC->requestResourceActivation(
391 xMainPaneId,
392 ResourceActivationMode_ADD);
393 SetupConfiguration(xContext, xMainPaneId);
395 mpPresenterController = new PresenterController(
396 css::uno::WeakReference<css::lang::XEventListener>(this),
397 xContext,
398 mxController,
399 xSlideShowController,
400 mpPaneContainer,
401 xMainPaneId);
403 // Create pane and view factories and integrate them into the
404 // drawing framework.
405 SetupPaneFactory(xContext);
406 SetupViewFactory(xContext);
408 mpPresenterController->GetWindowManager()->RestoreViewMode();
410 catch (const RuntimeException&)
412 xCC->restoreConfiguration(mxSavedConfiguration);
414 xCC->unlock();
417 catch (const Exception&)
422 void PresenterScreen::SwitchMonitors()
424 try {
425 Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
426 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
428 // Get the existing presenter console screen, we want to switch the
429 // presentation to use that instead.
430 sal_Int32 nNewScreen = GetPresenterScreenNumber (xPresentation);
431 if (nNewScreen < 0)
432 return;
434 // Adapt that display number to be the 'default' setting of 0 if it matches
435 sal_Int32 nExternalDisplay = Application::GetDisplayExternalScreen();
437 if (nNewScreen == nExternalDisplay)
438 nNewScreen = 0; // screen zero is best == the primary display
439 else
440 nNewScreen++; // otherwise we store screens offset by one.
442 // Set the new presentation display
443 Reference<beans::XPropertySet> xProperties (xPresentation, UNO_QUERY_THROW);
444 uno::Any aDisplay;
445 aDisplay <<= nNewScreen;
446 xProperties->setPropertyValue("Display", aDisplay);
447 } catch (const uno::Exception &) {
452 * Return the real VCL screen number to show the presenter console
453 * on or -1 to not show anything.
455 sal_Int32 PresenterScreen::GetPresenterScreenNumber (
456 const Reference<presentation::XPresentation2>& rxPresentation) const
458 sal_Int32 nScreenNumber (0);
459 sal_Int32 nScreenCount (1);
462 Reference<beans::XPropertySet> xProperties (rxPresentation, UNO_QUERY);
463 if ( ! xProperties.is())
464 return -1;
466 // Determine the screen on which the full screen presentation is being
467 // displayed.
468 sal_Int32 nDisplayNumber (-1);
469 if ( ! (xProperties->getPropertyValue("Display") >>= nDisplayNumber))
470 return -1;
471 if (nDisplayNumber == -1)
473 // The special value -1 indicates that the slide show
474 // spans all available displays. That leaves no room for
475 // the presenter screen.
476 return -1;
479 SAL_INFO("sdext.presenter", "Display number is " << nDisplayNumber);
481 if (nDisplayNumber > 0)
483 nScreenNumber = nDisplayNumber - 1;
485 else if (nDisplayNumber == 0)
487 // A display number value of 0 indicates the primary screen.
488 // Find out which screen number that is.
489 if (nDisplayNumber <= 0)
490 nScreenNumber = Application::GetDisplayExternalScreen();
493 // We still have to determine the number of screens to decide
494 // whether the presenter screen may be shown at all.
495 nScreenCount = Application::GetScreenCount();
497 if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
499 // There is either only one screen or the full screen
500 // presentation spans all available screens. The presenter
501 // screen is shown only when a special flag in the configuration
502 // is set.
503 Reference<XComponentContext> xContext (mxContextWeak);
504 PresenterConfigurationAccess aConfiguration (
505 xContext,
506 OUString("/org.openoffice.Office.PresenterScreen/"),
507 PresenterConfigurationAccess::READ_ONLY);
508 bool bStartAlways (false);
509 if (aConfiguration.GetConfigurationNode(
510 OUString("Presenter/StartAlways")) >>= bStartAlways)
512 if (bStartAlways)
513 return GetPresenterScreenFromScreen(nScreenNumber);
515 return -1;
518 catch (const beans::UnknownPropertyException&)
520 OSL_ASSERT(false);
521 // For some reason we can not access the screen number. Use
522 // the default instead.
524 SAL_INFO("sdext.presenter", "Get presenter screen for screen " << nScreenNumber);
525 return GetPresenterScreenFromScreen(nScreenNumber);
528 sal_Int32 PresenterScreen::GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen ) const
530 // Setup the resource id of the full screen background pane so that
531 // it is displayed on another screen than the presentation.
532 sal_Int32 nPresenterScreenNumber (1);
533 switch (nPresentationScreen)
535 case 0:
536 nPresenterScreenNumber = 1;
537 break;
539 case 1:
540 nPresenterScreenNumber = 0;
541 break;
543 default:
544 SAL_INFO("sdext.presenter", "Warning unexpected, out of bound screen "
545 "mapped to 0" << nPresentationScreen);
546 // When the full screen presentation is displayed on a screen
547 // other than 0 or 1 then place the presenter on the first
548 // available screen.
549 nPresenterScreenNumber = 0;
550 break;
552 return nPresenterScreenNumber;
555 Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
556 const Reference<presentation::XPresentation2>& rxPresentation) const
558 // A negative value means that the presentation spans all available
559 // displays. That leaves no room for the presenter.
560 const sal_Int32 nScreen(GetPresenterScreenNumber(rxPresentation));
561 if (nScreen < 0)
562 return NULL;
564 return ResourceId::create(
565 Reference<XComponentContext>(mxContextWeak),
566 PresenterHelper::msFullScreenPaneURL
567 + "?FullScreen=true&ScreenNumber="
568 + OUString::valueOf(nScreen));
571 void PresenterScreen::RequestShutdownPresenterScreen (void)
573 // Restore the configuration that was active before the presenter screen
574 // has been activated. Now, that the presenter screen is displayed in
575 // its own top level window this probably not necessary, but one never knows.
576 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
577 if (xCC.is() && mxSavedConfiguration.is())
579 xCC->restoreConfiguration(mxSavedConfiguration);
580 mxSavedConfiguration = NULL;
583 if (xCC.is())
585 // The actual restoration of the configuration takes place
586 // asynchronously. The view and pane factories can only by disposed
587 // after that. Therefore, set up a listener and wait for the
588 // restoration.
589 rtl::Reference<PresenterScreen> pSelf (this);
590 PresenterFrameworkObserver::RunOnUpdateEnd(
591 xCC,
592 ::boost::bind(&PresenterScreen::ShutdownPresenterScreen, pSelf));
593 xCC->update();
597 void PresenterScreen::ShutdownPresenterScreen (void)
599 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
600 if (xViewFactoryComponent.is())
601 xViewFactoryComponent->dispose();
602 mxViewFactory = NULL;
604 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
605 if (xPaneFactoryComponent.is())
606 xPaneFactoryComponent->dispose();
607 mxPaneFactory = NULL;
609 if (mpPresenterController.get() != NULL)
611 mpPresenterController->dispose();
612 mpPresenterController = rtl::Reference<PresenterController>();
614 mpPaneContainer = new PresenterPaneContainer(Reference<XComponentContext>(mxContextWeak));
617 void PresenterScreen::SetupPaneFactory (const Reference<XComponentContext>& rxContext)
621 if ( ! mxPaneFactory.is())
622 mxPaneFactory = PresenterPaneFactory::Create(
623 rxContext,
624 mxController,
625 mpPresenterController);
627 catch (const RuntimeException&)
629 OSL_ASSERT(false);
633 void PresenterScreen::SetupViewFactory (const Reference<XComponentContext>& rxContext)
637 if ( ! mxViewFactory.is())
638 mxViewFactory = PresenterViewFactory::Create(
639 rxContext,
640 mxController,
641 mpPresenterController);
643 catch (const RuntimeException&)
645 OSL_ASSERT(false);
649 void PresenterScreen::SetupConfiguration (
650 const Reference<XComponentContext>& rxContext,
651 const Reference<XResourceId>& rxAnchorId)
655 PresenterConfigurationAccess aConfiguration (
656 rxContext,
657 OUString("org.openoffice.Office.PresenterScreen"),
658 PresenterConfigurationAccess::READ_ONLY);
659 maViewDescriptors.clear();
660 ProcessViewDescriptions(aConfiguration);
661 OUString sLayoutName ("DefaultLayout");
662 aConfiguration.GetConfigurationNode(
663 OUString("Presenter/CurrentLayout")) >>= sLayoutName;
664 ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
666 catch (const RuntimeException&)
671 void PresenterScreen::ProcessLayout (
672 PresenterConfigurationAccess& rConfiguration,
673 const OUString& rsLayoutName,
674 const Reference<XComponentContext>& rxContext,
675 const Reference<XResourceId>& rxAnchorId)
679 Reference<container::XHierarchicalNameAccess> xLayoutNode (
680 rConfiguration.GetConfigurationNode(
681 OUString("Presenter/Layouts/")+rsLayoutName),
682 UNO_QUERY_THROW);
684 // Read the parent layout first, if one is referenced.
685 OUString sParentLayout;
686 rConfiguration.GetConfigurationNode(
687 xLayoutNode,
688 OUString("ParentLayout")) >>= sParentLayout;
689 if (!sParentLayout.isEmpty())
691 // Prevent infinite recursion.
692 if (rsLayoutName != sParentLayout)
693 ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
696 // Process the actual layout list.
697 Reference<container::XNameAccess> xList (
698 rConfiguration.GetConfigurationNode(
699 xLayoutNode,
700 OUString("Layout")),
701 UNO_QUERY_THROW);
703 ::std::vector<OUString> aProperties (6);
704 aProperties[0] = OUString("PaneURL");
705 aProperties[1] = OUString("ViewURL");
706 aProperties[2] = OUString("RelativeX");
707 aProperties[3] = OUString("RelativeY");
708 aProperties[4] = OUString("RelativeWidth");
709 aProperties[5] = OUString("RelativeHeight");
710 mnComponentIndex = 1;
711 PresenterConfigurationAccess::ForAll(
712 xList,
713 aProperties,
714 ::boost::bind(&PresenterScreen::ProcessComponent, this,
717 rxContext,
718 rxAnchorId));
720 catch (const RuntimeException&)
725 void PresenterScreen::ProcessViewDescriptions (
726 PresenterConfigurationAccess& rConfiguration)
730 Reference<container::XNameAccess> xViewDescriptionsNode (
731 rConfiguration.GetConfigurationNode("Presenter/Views"),
732 UNO_QUERY_THROW);
734 ::std::vector<OUString> aProperties (4);
735 aProperties[0] = OUString("ViewURL");
736 aProperties[1] = OUString("Title");
737 aProperties[2] = OUString("AccessibleTitle");
738 aProperties[3] = OUString("IsOpaque");
739 mnComponentIndex = 1;
740 PresenterConfigurationAccess::ForAll(
741 xViewDescriptionsNode,
742 aProperties,
743 ::boost::bind(&PresenterScreen::ProcessViewDescription, this, _1, _2));
745 catch (const RuntimeException&)
747 OSL_ASSERT(false);
751 void PresenterScreen::ProcessComponent (
752 const OUString& rsKey,
753 const ::std::vector<Any>& rValues,
754 const Reference<XComponentContext>& rxContext,
755 const Reference<XResourceId>& rxAnchorId)
757 (void)rsKey;
759 if (rValues.size() != 6)
760 return;
764 OUString sPaneURL;
765 OUString sViewURL;
766 double nX = 0;
767 double nY = 0;
768 double nWidth = 0;
769 double nHeight = 0;
770 rValues[0] >>= sPaneURL;
771 rValues[1] >>= sViewURL;
772 rValues[2] >>= nX;
773 rValues[3] >>= nY;
774 rValues[4] >>= nWidth;
775 rValues[5] >>= nHeight;
777 if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)
779 SetupView(
780 rxContext,
781 rxAnchorId,
782 sPaneURL,
783 sViewURL,
784 PresenterPaneContainer::ViewInitializationFunction(),
787 nX+nWidth,
788 nY+nHeight);
791 catch (const Exception&)
793 OSL_ASSERT(false);
797 void PresenterScreen::ProcessViewDescription (
798 const OUString& rsKey,
799 const ::std::vector<Any>& rValues)
801 (void)rsKey;
803 if (rValues.size() != 4)
804 return;
808 ViewDescriptor aViewDescriptor;
809 OUString sViewURL;
810 rValues[0] >>= sViewURL;
811 rValues[1] >>= aViewDescriptor.msTitle;
812 rValues[2] >>= aViewDescriptor.msAccessibleTitle;
813 rValues[3] >>= aViewDescriptor.mbIsOpaque;
814 if (aViewDescriptor.msAccessibleTitle.isEmpty())
815 aViewDescriptor.msAccessibleTitle = aViewDescriptor.msTitle;
816 maViewDescriptors[sViewURL] = aViewDescriptor;
818 catch (const Exception&)
820 OSL_ASSERT(false);
824 void PresenterScreen::SetupView(
825 const Reference<XComponentContext>& rxContext,
826 const Reference<XResourceId>& rxAnchorId,
827 const OUString& rsPaneURL,
828 const OUString& rsViewURL,
829 const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization,
830 const double nLeft,
831 const double nTop,
832 const double nRight,
833 const double nBottom)
835 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
836 if (xCC.is())
838 Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
839 // Look up the view descriptor.
840 ViewDescriptor aViewDescriptor;
841 ViewDescriptorContainer::const_iterator iDescriptor (maViewDescriptors.find(rsViewURL));
842 if (iDescriptor != maViewDescriptors.end())
843 aViewDescriptor = iDescriptor->second;
845 // Prepare the pane.
846 OSL_ASSERT(mpPaneContainer.get() != NULL);
847 mpPaneContainer->PreparePane(
848 xPaneId,
849 rsViewURL,
850 aViewDescriptor.msTitle,
851 aViewDescriptor.msAccessibleTitle,
852 aViewDescriptor.mbIsOpaque,
853 rViewInitialization,
854 nLeft,
855 nTop,
856 nRight,
857 nBottom);
861 } } // end of namespace ::sdext::presenter
863 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */