update dev300-m58
[ooovba.git] / sdext / source / presenter / PresenterScreen.cxx
blobd3f676e759b641f3bbb1e2394f05f36ef30461c6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterScreen.cxx,v $
11 * $Revision: 1.5 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "PresenterScreen.hxx"
36 #include "PresenterConfigurationAccess.hxx"
37 #include "PresenterController.hxx"
38 #include "PresenterFrameworkObserver.hxx"
39 #include "PresenterHelper.hxx"
40 #include "PresenterPaneContainer.hxx"
41 #include "PresenterPaneFactory.hxx"
42 #include "PresenterViewFactory.hxx"
43 #include "PresenterWindowManager.hxx"
44 #include <com/sun/star/frame/XController.hpp>
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #include <com/sun/star/drawing/framework/Configuration.hpp>
47 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
48 #include <com/sun/star/drawing/framework/ResourceId.hpp>
49 #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
50 #include <com/sun/star/presentation/XSlideShow.hpp>
51 #include <com/sun/star/presentation/XPresentation2.hpp>
52 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
53 #include <com/sun/star/document/XEventBroadcaster.hpp>
54 #include <boost/bind.hpp>
55 #include <tools/debug.hxx>
57 #include <com/sun/star/view/XSelectionSupplier.hpp>
59 using namespace ::com::sun::star;
60 using namespace ::com::sun::star::uno;
61 using namespace ::com::sun::star::lang;
62 using namespace ::com::sun::star::presentation;
63 using namespace ::com::sun::star::drawing::framework;
64 using ::rtl::OUString;
66 #define A2S(s) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)))
68 namespace sdext { namespace presenter {
70 namespace {
71 typedef ::cppu::WeakComponentImplHelper1 <
72 css::document::XEventListener
73 > PresenterScreenListenerInterfaceBase;
75 /** One instance of a PresenterScreenListener is registered per Impress
76 document and waits for the full screen slide show to start and to
77 end.
79 class PresenterScreenListener
80 : private ::boost::noncopyable,
81 private ::cppu::BaseMutex,
82 public PresenterScreenListenerInterfaceBase
84 public:
85 PresenterScreenListener (
86 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
87 const css::uno::Reference<css::frame::XModel2>& rxModel);
88 virtual ~PresenterScreenListener (void);
90 void Initialize (void);
91 virtual void SAL_CALL disposing (void);
93 // document::XEventListener
95 virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException);
97 // XEventListener
99 virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) throw (css::uno::RuntimeException);
101 private:
102 css::uno::Reference<css::frame::XModel2 > mxModel;
103 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
104 rtl::Reference<PresenterScreen> mpPresenterScreen;
106 void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
111 //----- Service ---------------------------------------------------------------
113 OUString PresenterScreenJob::getImplementationName_static (void)
115 return A2S("com.sun.star.comp.Draw.framework.PresenterScreenJob");
121 Sequence<OUString> PresenterScreenJob::getSupportedServiceNames_static (void)
123 static const ::rtl::OUString sServiceName(
124 A2S("com.sun.star.drawing.framework.PresenterScreenJob"));
125 return Sequence<rtl::OUString>(&sServiceName, 1);
131 Reference<XInterface> PresenterScreenJob::Create (const Reference<uno::XComponentContext>& rxContext)
132 SAL_THROW((css::uno::Exception))
134 return Reference<XInterface>(static_cast<XWeak*>(new PresenterScreenJob(rxContext)));
140 //===== PresenterScreenJob ====================================================
142 PresenterScreenJob::PresenterScreenJob (const Reference<XComponentContext>& rxContext)
143 : PresenterScreenJobInterfaceBase(m_aMutex),
144 mxComponentContext(rxContext)
151 PresenterScreenJob::~PresenterScreenJob (void)
158 void SAL_CALL PresenterScreenJob::disposing (void)
160 mxComponentContext = NULL;
166 //----- XJob -----------------------------------------------------------
168 Any SAL_CALL PresenterScreenJob::execute(
169 const Sequence< beans::NamedValue >& Arguments )
170 throw (lang::IllegalArgumentException, Exception, RuntimeException)
172 Sequence< beans::NamedValue > lEnv;
174 sal_Int32 i = 0;
175 sal_Int32 c = Arguments.getLength();
176 const beans::NamedValue* p = Arguments.getConstArray();
177 for (i=0; i<c; ++i)
179 if (p[i].Name.equalsAscii("Environment"))
181 p[i].Value >>= lEnv;
182 break;
186 Reference<frame::XModel2> xModel;
187 c = lEnv.getLength();
188 p = lEnv.getConstArray();
189 for (i=0; i<c; ++i)
191 if (p[i].Name.equalsAscii("Model"))
193 p[i].Value >>= xModel;
194 break;
198 Reference< XServiceInfo > xInfo( xModel, UNO_QUERY );
199 if( xInfo.is() && xInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) ) )
201 // Create a new listener that waits for the full screen presentation
202 // to start and to end. It takes care of its own lifetime.
203 ::rtl::Reference<PresenterScreenListener> pListener (
204 new PresenterScreenListener(mxComponentContext, xModel));
205 pListener->Initialize();
208 return Any();
214 //===== PresenterScreenListener ===============================================
216 namespace {
218 PresenterScreenListener::PresenterScreenListener (
219 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
220 const css::uno::Reference<css::frame::XModel2>& rxModel)
221 : PresenterScreenListenerInterfaceBase(m_aMutex),
222 mxModel(rxModel),
223 mxComponentContext(rxContext),
224 mpPresenterScreen()
231 void PresenterScreenListener::Initialize (void)
233 Reference< document::XEventListener > xDocListener(
234 static_cast< document::XEventListener* >(this), UNO_QUERY);
235 Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
236 if( xDocBroadcaster.is() )
237 xDocBroadcaster->addEventListener(xDocListener);
243 PresenterScreenListener::~PresenterScreenListener (void)
250 void SAL_CALL PresenterScreenListener::disposing (void)
252 Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
253 if( xDocBroadcaster.is() )
254 xDocBroadcaster->removeEventListener(
255 Reference<document::XEventListener>(
256 static_cast<document::XEventListener*>(this), UNO_QUERY));
258 if (mpPresenterScreen.is())
260 mpPresenterScreen->RequestShutdownPresenterScreen();
261 mpPresenterScreen = NULL;
268 // document::XEventListener
270 void SAL_CALL PresenterScreenListener::notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException)
272 ThrowIfDisposed();
274 if( Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnStartPresentation" ) ) )
276 mpPresenterScreen = new PresenterScreen(mxComponentContext, mxModel);
277 mpPresenterScreen->InitializePresenterScreen();
279 else if( Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnEndPresentation" ) ) )
281 if (mpPresenterScreen.is())
283 mpPresenterScreen->RequestShutdownPresenterScreen();
284 mpPresenterScreen = NULL;
292 // XEventListener
294 void SAL_CALL PresenterScreenListener::disposing (const css::lang::EventObject& rEvent)
295 throw (css::uno::RuntimeException)
297 (void)rEvent;
299 if (mpPresenterScreen.is())
301 mpPresenterScreen->RequestShutdownPresenterScreen();
302 mpPresenterScreen = NULL;
309 void PresenterScreenListener::ThrowIfDisposed (void) const throw (
310 ::com::sun::star::lang::DisposedException)
312 if (rBHelper.bDisposed || rBHelper.bInDispose)
314 throw lang::DisposedException (
315 OUString(RTL_CONSTASCII_USTRINGPARAM(
316 "PresenterScreenListener object has already been disposed")),
317 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
321 } // end of anonymous namespace
326 //===== PresenterScreen =======================================================
328 PresenterScreen::PresenterScreen (
329 const Reference<XComponentContext>& rxContext,
330 const css::uno::Reference<css::frame::XModel2>& rxModel)
331 : PresenterScreenInterfaceBase(m_aMutex),
332 mxModel(rxModel),
333 mxController(),
334 mxConfigurationControllerWeak(),
335 mxContextWeak(rxContext),
336 mxSlideShowControllerWeak(),
337 mpPresenterController(),
338 mxSlideShowViewId(),
339 mxSavedConfiguration(),
340 mpPaneContainer(),
341 mnComponentIndex(0),
342 mxPaneFactory(),
343 mxViewFactory(),
344 maViewDescriptors()
351 PresenterScreen::~PresenterScreen (void)
358 void SAL_CALL PresenterScreen::disposing (void)
360 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
361 if (xCC.is() && mxSavedConfiguration.is())
363 xCC->restoreConfiguration(mxSavedConfiguration);
365 mxConfigurationControllerWeak = Reference<XConfigurationController>(NULL);
367 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
368 if (xViewFactoryComponent.is())
369 xViewFactoryComponent->dispose();
370 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
371 if (xPaneFactoryComponent.is())
372 xPaneFactoryComponent->dispose();
374 mxModel = NULL;
380 //----- XEventListener --------------------------------------------------------
382 void SAL_CALL PresenterScreen::disposing (const lang::EventObject& /*rEvent*/)
383 throw (RuntimeException)
385 mxSlideShowControllerWeak = WeakReference<presentation::XSlideShowController>();
386 RequestShutdownPresenterScreen();
392 //-----------------------------------------------------------------------------
394 void PresenterScreen::InitializePresenterScreen (void)
398 Reference<XComponentContext> xContext (mxContextWeak);
399 mpPaneContainer =
400 new PresenterPaneContainer(Reference<XComponentContext>(xContext));
402 Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
403 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
404 Reference<presentation::XSlideShowController> xSlideShowController( xPresentation->getController() );
405 mxSlideShowControllerWeak = xSlideShowController;
407 if( !xSlideShowController.is() || !xSlideShowController->isFullScreen() )
408 return;
410 // find first controller that is not the current controller (the one with the slideshow
411 mxController = mxModel->getCurrentController();
412 Reference< container::XEnumeration > xEnum( mxModel->getControllers() );
413 if( xEnum.is() )
415 while( xEnum->hasMoreElements() )
417 Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY );
418 if( xC.is() && (xC != mxController) )
420 mxController = xC;
421 break;
425 // Get the XController from the first argument.
426 Reference<XControllerManager> xCM(mxController, UNO_QUERY_THROW);
428 Reference<XConfigurationController> xCC( xCM->getConfigurationController());
429 mxConfigurationControllerWeak = xCC;
431 Reference<drawing::framework::XResourceId> xMainPaneId(
432 GetMainPaneId(xPresentation));
433 // An empty reference means that the presenter screen can
434 // not or must not be displayed.
435 if ( ! xMainPaneId.is())
436 return;
438 if (xCC.is() && xContext.is())
440 // Store the current configuration so that we can restore it when
441 // the presenter view is deactivated.
442 mxSavedConfiguration = xCC->getRequestedConfiguration();
443 xCC->lock();
447 // At the moment the presenter controller is displayed in its
448 // own full screen window that is controlled by the same
449 // configuration controller as the Impress document from
450 // which the presentation was started. Therefore the main
451 // pane is actived additionally to the already existing
452 // panes and does not replace them.
453 xCC->requestResourceActivation(
454 xMainPaneId,
455 ResourceActivationMode_ADD);
456 SetupConfiguration(xContext, xMainPaneId);
458 mpPresenterController = new PresenterController(
459 xContext,
460 mxController,
461 xSlideShowController,
462 mpPaneContainer,
463 xMainPaneId);
465 // Create pane and view factories and integrate them into the
466 // drawing framework.
467 SetupPaneFactory(xContext);
468 SetupViewFactory(xContext);
470 mpPresenterController->GetWindowManager()->SetSlideSorterState(false);
471 mpPresenterController->GetWindowManager()->SetLayoutMode(
472 PresenterWindowManager::Standard);
474 catch (RuntimeException&)
476 xCC->restoreConfiguration(mxSavedConfiguration);
478 xCC->unlock();
481 catch (Exception&)
489 sal_Int32 PresenterScreen::GetScreenNumber (
490 const Reference<presentation::XPresentation2>& rxPresentation) const
492 // Determine the screen on which the full screen presentation is being
493 // displayed.
494 sal_Int32 nScreenNumber (0);
495 sal_Int32 nScreenCount (1);
498 Reference<beans::XPropertySet> xProperties (rxPresentation, UNO_QUERY);
499 if ( ! xProperties.is())
500 return -1;
502 sal_Int32 nDisplayNumber (-1);
503 if ( ! (xProperties->getPropertyValue(A2S("Display")) >>= nDisplayNumber))
504 return -1;
506 Reference<XComponentContext> xContext (mxContextWeak);
507 if ( ! xContext.is())
508 return -1;
509 Reference<lang::XMultiComponentFactory> xFactory (
510 xContext->getServiceManager(), UNO_QUERY);
511 if ( ! xFactory.is())
512 return -1;
513 Reference<beans::XPropertySet> xDisplayProperties (
514 xFactory->createInstanceWithContext(A2S("com.sun.star.awt.DisplayAccess"),xContext),
515 UNO_QUERY);
516 if ( ! xDisplayProperties.is())
517 return -1;
519 if (nDisplayNumber > 0)
521 nScreenNumber = nDisplayNumber - 1;
523 else if (nDisplayNumber == 0)
525 // A display number value of 0 indicates the primary screen.
526 // Instantiate the DisplayAccess service to find out which
527 // screen number that is.
528 if (nDisplayNumber <= 0 && xDisplayProperties.is())
529 xDisplayProperties->getPropertyValue(A2S("DefaultDisplay")) >>= nScreenNumber;
532 // We still have to determine the number of screens to decide
533 // whether the presenter screen may be shown at all.
534 Reference<container::XIndexAccess> xIndexAccess (xDisplayProperties, UNO_QUERY);
535 if ( ! xIndexAccess.is())
536 return -1;
537 nScreenCount = xIndexAccess->getCount();
539 if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
541 // There is either only one screen or the full screen
542 // presentation spans all available screens. The presenter
543 // screen is shown only when a special flag in the configuration
544 // is set.
545 PresenterConfigurationAccess aConfiguration (
546 xContext,
547 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
548 PresenterConfigurationAccess::READ_ONLY);
549 bool bStartAlways (false);
550 if (aConfiguration.GetConfigurationNode(
551 OUString::createFromAscii("Presenter/StartAlways")) >>= bStartAlways)
553 if (bStartAlways)
554 return nScreenNumber;
556 return -1;
559 catch (beans::UnknownPropertyException&)
561 OSL_ASSERT(false);
562 // For some reason we can not access the screen number. Use
563 // the default instead.
566 return nScreenNumber;
572 Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
573 const Reference<presentation::XPresentation2>& rxPresentation) const
575 // A negative value means that the presentation spans all available
576 // displays. That leaves no room for the presenter.
577 const sal_Int32 nScreenNumber(GetScreenNumber(rxPresentation));
578 if (nScreenNumber < 0)
579 return NULL;
581 // Setup the resource id of the full screen background pane so that
582 // it is displayed on another screen than the presentation.
583 sal_Int32 nPresenterScreenNumber (1);
584 switch (nScreenNumber)
586 case 0:
587 nPresenterScreenNumber = 1;
588 break;
590 case 1:
591 nPresenterScreenNumber = 0;
592 break;
594 default:
595 // When the full screen presentation is displayed on a screen
596 // other than 0 or 1 then place the presenter on the first
597 // available screen.
598 nPresenterScreenNumber = 0;
599 break;
602 return ResourceId::create(
603 Reference<XComponentContext>(mxContextWeak),
604 PresenterHelper::msFullScreenPaneURL
605 +A2S("?FullScreen=true&ScreenNumber=")
606 + OUString::valueOf(nPresenterScreenNumber));
612 void PresenterScreen::RequestShutdownPresenterScreen (void)
614 // Restore the configuration that was active before the presenter screen
615 // has been activated. Now, that the presenter screen is displayed in
616 // its own top level window this probably not necessary, but one never knows.
617 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
618 if (xCC.is() && mxSavedConfiguration.is())
620 xCC->restoreConfiguration(mxSavedConfiguration);
621 mxSavedConfiguration = NULL;
624 if (xCC.is())
626 // The actual restoration of the configuration takes place
627 // asynchronously. The view and pane factories can only by disposed
628 // after that. Therefore, set up a listener and wait for the
629 // restoration.
630 rtl::Reference<PresenterScreen> pSelf (this);
631 PresenterFrameworkObserver::RunOnUpdateEnd(
632 xCC,
633 ::boost::bind(&PresenterScreen::ShutdownPresenterScreen, pSelf));
634 xCC->update();
641 void PresenterScreen::ShutdownPresenterScreen (void)
643 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
644 if (xViewFactoryComponent.is())
645 xViewFactoryComponent->dispose();
646 mxViewFactory = NULL;
648 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
649 if (xPaneFactoryComponent.is())
650 xPaneFactoryComponent->dispose();
651 mxPaneFactory = NULL;
653 if (mpPresenterController.get() != NULL)
655 mpPresenterController->dispose();
656 mpPresenterController = rtl::Reference<PresenterController>();
658 mpPaneContainer = new PresenterPaneContainer(Reference<XComponentContext>(mxContextWeak));
664 void PresenterScreen::SetupPaneFactory (const Reference<XComponentContext>& rxContext)
668 if ( ! mxPaneFactory.is())
669 mxPaneFactory = PresenterPaneFactory::Create(
670 rxContext,
671 mxController,
672 mpPresenterController);
674 catch (RuntimeException&)
676 OSL_ASSERT(false);
683 void PresenterScreen::SetupViewFactory (const Reference<XComponentContext>& rxContext)
687 if ( ! mxViewFactory.is())
688 mxViewFactory = PresenterViewFactory::Create(
689 rxContext,
690 mxController,
691 mpPresenterController);
693 catch (RuntimeException&)
695 OSL_ASSERT(false);
702 void PresenterScreen::SetupConfiguration (
703 const Reference<XComponentContext>& rxContext,
704 const Reference<XResourceId>& rxAnchorId)
708 PresenterConfigurationAccess aConfiguration (
709 rxContext,
710 OUString::createFromAscii("org.openoffice.Office.extension.PresenterScreen"),
711 PresenterConfigurationAccess::READ_ONLY);
712 maViewDescriptors.clear();
713 ProcessViewDescriptions(aConfiguration);
714 OUString sLayoutName (OUString::createFromAscii("DefaultLayout"));
715 aConfiguration.GetConfigurationNode(
716 OUString::createFromAscii("Presenter/CurrentLayout")) >>= sLayoutName;
717 ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
719 catch (RuntimeException&)
727 void PresenterScreen::ProcessLayout (
728 PresenterConfigurationAccess& rConfiguration,
729 const OUString& rsLayoutName,
730 const Reference<XComponentContext>& rxContext,
731 const Reference<XResourceId>& rxAnchorId)
735 Reference<container::XHierarchicalNameAccess> xLayoutNode (
736 rConfiguration.GetConfigurationNode(
737 OUString::createFromAscii("Presenter/Layouts/")+rsLayoutName),
738 UNO_QUERY_THROW);
740 // Read the parent layout first, if one is referenced.
741 OUString sParentLayout;
742 rConfiguration.GetConfigurationNode(
743 xLayoutNode,
744 OUString::createFromAscii("ParentLayout")) >>= sParentLayout;
745 if (sParentLayout.getLength() > 0)
747 // Prevent infinite recursion.
748 if (rsLayoutName != sParentLayout)
749 ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
752 // Process the actual layout list.
753 Reference<container::XNameAccess> xList (
754 rConfiguration.GetConfigurationNode(
755 xLayoutNode,
756 OUString::createFromAscii("Layout")),
757 UNO_QUERY_THROW);
759 ::std::vector<rtl::OUString> aProperties (6);
760 aProperties[0] = OUString::createFromAscii("PaneURL");
761 aProperties[1] = OUString::createFromAscii("ViewURL");
762 aProperties[2] = OUString::createFromAscii("RelativeX");
763 aProperties[3] = OUString::createFromAscii("RelativeY");
764 aProperties[4] = OUString::createFromAscii("RelativeWidth");
765 aProperties[5] = OUString::createFromAscii("RelativeHeight");
766 mnComponentIndex = 1;
767 PresenterConfigurationAccess::ForAll(
768 xList,
769 aProperties,
770 ::boost::bind(&PresenterScreen::ProcessComponent, this,
773 rxContext,
774 rxAnchorId));
776 catch (RuntimeException&)
784 void PresenterScreen::ProcessViewDescriptions (
785 PresenterConfigurationAccess& rConfiguration)
789 Reference<container::XNameAccess> xViewDescriptionsNode (
790 rConfiguration.GetConfigurationNode(A2S("Presenter/Views")),
791 UNO_QUERY_THROW);
793 ::std::vector<rtl::OUString> aProperties (3);
794 aProperties[0] = OUString::createFromAscii("ViewURL");
795 aProperties[1] = OUString::createFromAscii("Title");
796 aProperties[2] = OUString::createFromAscii("IsOpaque");
797 mnComponentIndex = 1;
798 PresenterConfigurationAccess::ForAll(
799 xViewDescriptionsNode,
800 aProperties,
801 ::boost::bind(&PresenterScreen::ProcessViewDescription, this, _1, _2));
803 catch (RuntimeException&)
805 OSL_ASSERT(false);
812 void PresenterScreen::ProcessComponent (
813 const OUString& rsKey,
814 const ::std::vector<Any>& rValues,
815 const Reference<XComponentContext>& rxContext,
816 const Reference<XResourceId>& rxAnchorId)
818 (void)rsKey;
820 if (rValues.size() != 6)
821 return;
825 OUString sPaneURL;
826 OUString sViewURL;
827 double nX = 0;
828 double nY = 0;
829 double nWidth = 0;
830 double nHeight = 0;
831 rValues[0] >>= sPaneURL;
832 rValues[1] >>= sViewURL;
833 rValues[2] >>= nX;
834 rValues[3] >>= nY;
835 rValues[4] >>= nWidth;
836 rValues[5] >>= nHeight;
838 if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)
840 SetupView(
841 rxContext,
842 rxAnchorId,
843 sPaneURL,
844 sViewURL,
845 PresenterPaneContainer::ViewInitializationFunction(),
848 nX+nWidth,
849 nY+nHeight);
852 catch (Exception& e)
854 (void)e;
855 OSL_ASSERT(false);
862 void PresenterScreen::ProcessViewDescription (
863 const OUString& rsKey,
864 const ::std::vector<Any>& rValues)
866 (void)rsKey;
868 if (rValues.size() != 3)
869 return;
873 ViewDescriptor aViewDescriptor;
874 OUString sViewURL;
875 rValues[0] >>= sViewURL;
876 rValues[1] >>= aViewDescriptor.msTitle;
877 rValues[2] >>= aViewDescriptor.mbIsOpaque;
878 maViewDescriptors[sViewURL] = aViewDescriptor;
880 catch (Exception&)
882 OSL_ASSERT(false);
889 void PresenterScreen::SetupView(
890 const Reference<XComponentContext>& rxContext,
891 const Reference<XResourceId>& rxAnchorId,
892 const OUString& rsPaneURL,
893 const OUString& rsViewURL,
894 const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization,
895 const double nLeft,
896 const double nTop,
897 const double nRight,
898 const double nBottom)
900 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
901 if (xCC.is())
903 Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
904 // Look up the view descriptor.
905 ViewDescriptor aViewDescriptor;
906 ViewDescriptorContainer::const_iterator iDescriptor (maViewDescriptors.find(rsViewURL));
907 if (iDescriptor != maViewDescriptors.end())
908 aViewDescriptor = iDescriptor->second;
910 // Prepare the pane.
911 OSL_ASSERT(mpPaneContainer.get() != NULL);
912 mpPaneContainer->PreparePane(
913 xPaneId,
914 rsViewURL,
915 aViewDescriptor.msTitle,
916 aViewDescriptor.mbIsOpaque,
917 rViewInitialization,
918 nLeft,
919 nTop,
920 nRight,
921 nBottom);
928 } } // end of namespace ::sdext::presenter