Update ooo320-m1
[ooovba.git] / sdext / source / presenter / PresenterScreen.cxx
blob646cd3a520c8a256601986e69b498045030a562f
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()->RestoreViewMode();
472 catch (RuntimeException&)
474 xCC->restoreConfiguration(mxSavedConfiguration);
476 xCC->unlock();
479 catch (Exception&)
487 sal_Int32 PresenterScreen::GetScreenNumber (
488 const Reference<presentation::XPresentation2>& rxPresentation) const
490 // Determine the screen on which the full screen presentation is being
491 // displayed.
492 sal_Int32 nScreenNumber (0);
493 sal_Int32 nScreenCount (1);
496 Reference<beans::XPropertySet> xProperties (rxPresentation, UNO_QUERY);
497 if ( ! xProperties.is())
498 return -1;
500 sal_Int32 nDisplayNumber (-1);
501 if ( ! (xProperties->getPropertyValue(A2S("Display")) >>= nDisplayNumber))
502 return -1;
504 Reference<XComponentContext> xContext (mxContextWeak);
505 if ( ! xContext.is())
506 return -1;
507 Reference<lang::XMultiComponentFactory> xFactory (
508 xContext->getServiceManager(), UNO_QUERY);
509 if ( ! xFactory.is())
510 return -1;
511 Reference<beans::XPropertySet> xDisplayProperties (
512 xFactory->createInstanceWithContext(A2S("com.sun.star.awt.DisplayAccess"),xContext),
513 UNO_QUERY);
514 if ( ! xDisplayProperties.is())
515 return -1;
517 if (nDisplayNumber > 0)
519 nScreenNumber = nDisplayNumber - 1;
521 else if (nDisplayNumber == 0)
523 // A display number value of 0 indicates the primary screen.
524 // Instantiate the DisplayAccess service to find out which
525 // screen number that is.
526 if (nDisplayNumber <= 0 && xDisplayProperties.is())
527 xDisplayProperties->getPropertyValue(A2S("DefaultDisplay")) >>= nScreenNumber;
530 // We still have to determine the number of screens to decide
531 // whether the presenter screen may be shown at all.
532 Reference<container::XIndexAccess> xIndexAccess (xDisplayProperties, UNO_QUERY);
533 if ( ! xIndexAccess.is())
534 return -1;
535 nScreenCount = xIndexAccess->getCount();
537 if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
539 // There is either only one screen or the full screen
540 // presentation spans all available screens. The presenter
541 // screen is shown only when a special flag in the configuration
542 // is set.
543 PresenterConfigurationAccess aConfiguration (
544 xContext,
545 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
546 PresenterConfigurationAccess::READ_ONLY);
547 bool bStartAlways (false);
548 if (aConfiguration.GetConfigurationNode(
549 OUString::createFromAscii("Presenter/StartAlways")) >>= bStartAlways)
551 if (bStartAlways)
552 return nScreenNumber;
554 return -1;
557 catch (beans::UnknownPropertyException&)
559 OSL_ASSERT(false);
560 // For some reason we can not access the screen number. Use
561 // the default instead.
564 return nScreenNumber;
570 Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
571 const Reference<presentation::XPresentation2>& rxPresentation) const
573 // A negative value means that the presentation spans all available
574 // displays. That leaves no room for the presenter.
575 const sal_Int32 nScreenNumber(GetScreenNumber(rxPresentation));
576 if (nScreenNumber < 0)
577 return NULL;
579 // Setup the resource id of the full screen background pane so that
580 // it is displayed on another screen than the presentation.
581 sal_Int32 nPresenterScreenNumber (1);
582 switch (nScreenNumber)
584 case 0:
585 nPresenterScreenNumber = 1;
586 break;
588 case 1:
589 nPresenterScreenNumber = 0;
590 break;
592 default:
593 // When the full screen presentation is displayed on a screen
594 // other than 0 or 1 then place the presenter on the first
595 // available screen.
596 nPresenterScreenNumber = 0;
597 break;
600 return ResourceId::create(
601 Reference<XComponentContext>(mxContextWeak),
602 PresenterHelper::msFullScreenPaneURL
603 +A2S("?FullScreen=true&ScreenNumber=")
604 + OUString::valueOf(nPresenterScreenNumber));
610 void PresenterScreen::RequestShutdownPresenterScreen (void)
612 // Restore the configuration that was active before the presenter screen
613 // has been activated. Now, that the presenter screen is displayed in
614 // its own top level window this probably not necessary, but one never knows.
615 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
616 if (xCC.is() && mxSavedConfiguration.is())
618 xCC->restoreConfiguration(mxSavedConfiguration);
619 mxSavedConfiguration = NULL;
622 if (xCC.is())
624 // The actual restoration of the configuration takes place
625 // asynchronously. The view and pane factories can only by disposed
626 // after that. Therefore, set up a listener and wait for the
627 // restoration.
628 rtl::Reference<PresenterScreen> pSelf (this);
629 PresenterFrameworkObserver::RunOnUpdateEnd(
630 xCC,
631 ::boost::bind(&PresenterScreen::ShutdownPresenterScreen, pSelf));
632 xCC->update();
639 void PresenterScreen::ShutdownPresenterScreen (void)
641 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
642 if (xViewFactoryComponent.is())
643 xViewFactoryComponent->dispose();
644 mxViewFactory = NULL;
646 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
647 if (xPaneFactoryComponent.is())
648 xPaneFactoryComponent->dispose();
649 mxPaneFactory = NULL;
651 if (mpPresenterController.get() != NULL)
653 mpPresenterController->dispose();
654 mpPresenterController = rtl::Reference<PresenterController>();
656 mpPaneContainer = new PresenterPaneContainer(Reference<XComponentContext>(mxContextWeak));
662 void PresenterScreen::SetupPaneFactory (const Reference<XComponentContext>& rxContext)
666 if ( ! mxPaneFactory.is())
667 mxPaneFactory = PresenterPaneFactory::Create(
668 rxContext,
669 mxController,
670 mpPresenterController);
672 catch (RuntimeException&)
674 OSL_ASSERT(false);
681 void PresenterScreen::SetupViewFactory (const Reference<XComponentContext>& rxContext)
685 if ( ! mxViewFactory.is())
686 mxViewFactory = PresenterViewFactory::Create(
687 rxContext,
688 mxController,
689 mpPresenterController);
691 catch (RuntimeException&)
693 OSL_ASSERT(false);
700 void PresenterScreen::SetupConfiguration (
701 const Reference<XComponentContext>& rxContext,
702 const Reference<XResourceId>& rxAnchorId)
706 PresenterConfigurationAccess aConfiguration (
707 rxContext,
708 OUString::createFromAscii("org.openoffice.Office.extension.PresenterScreen"),
709 PresenterConfigurationAccess::READ_ONLY);
710 maViewDescriptors.clear();
711 ProcessViewDescriptions(aConfiguration);
712 OUString sLayoutName (OUString::createFromAscii("DefaultLayout"));
713 aConfiguration.GetConfigurationNode(
714 OUString::createFromAscii("Presenter/CurrentLayout")) >>= sLayoutName;
715 ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
717 catch (RuntimeException&)
725 void PresenterScreen::ProcessLayout (
726 PresenterConfigurationAccess& rConfiguration,
727 const OUString& rsLayoutName,
728 const Reference<XComponentContext>& rxContext,
729 const Reference<XResourceId>& rxAnchorId)
733 Reference<container::XHierarchicalNameAccess> xLayoutNode (
734 rConfiguration.GetConfigurationNode(
735 OUString::createFromAscii("Presenter/Layouts/")+rsLayoutName),
736 UNO_QUERY_THROW);
738 // Read the parent layout first, if one is referenced.
739 OUString sParentLayout;
740 rConfiguration.GetConfigurationNode(
741 xLayoutNode,
742 OUString::createFromAscii("ParentLayout")) >>= sParentLayout;
743 if (sParentLayout.getLength() > 0)
745 // Prevent infinite recursion.
746 if (rsLayoutName != sParentLayout)
747 ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
750 // Process the actual layout list.
751 Reference<container::XNameAccess> xList (
752 rConfiguration.GetConfigurationNode(
753 xLayoutNode,
754 OUString::createFromAscii("Layout")),
755 UNO_QUERY_THROW);
757 ::std::vector<rtl::OUString> aProperties (6);
758 aProperties[0] = OUString::createFromAscii("PaneURL");
759 aProperties[1] = OUString::createFromAscii("ViewURL");
760 aProperties[2] = OUString::createFromAscii("RelativeX");
761 aProperties[3] = OUString::createFromAscii("RelativeY");
762 aProperties[4] = OUString::createFromAscii("RelativeWidth");
763 aProperties[5] = OUString::createFromAscii("RelativeHeight");
764 mnComponentIndex = 1;
765 PresenterConfigurationAccess::ForAll(
766 xList,
767 aProperties,
768 ::boost::bind(&PresenterScreen::ProcessComponent, this,
771 rxContext,
772 rxAnchorId));
774 catch (RuntimeException&)
782 void PresenterScreen::ProcessViewDescriptions (
783 PresenterConfigurationAccess& rConfiguration)
787 Reference<container::XNameAccess> xViewDescriptionsNode (
788 rConfiguration.GetConfigurationNode(A2S("Presenter/Views")),
789 UNO_QUERY_THROW);
791 ::std::vector<rtl::OUString> aProperties (4);
792 aProperties[0] = OUString::createFromAscii("ViewURL");
793 aProperties[1] = OUString::createFromAscii("Title");
794 aProperties[2] = OUString::createFromAscii("AccessibleTitle");
795 aProperties[3] = OUString::createFromAscii("IsOpaque");
796 mnComponentIndex = 1;
797 PresenterConfigurationAccess::ForAll(
798 xViewDescriptionsNode,
799 aProperties,
800 ::boost::bind(&PresenterScreen::ProcessViewDescription, this, _1, _2));
802 catch (RuntimeException&)
804 OSL_ASSERT(false);
811 void PresenterScreen::ProcessComponent (
812 const OUString& rsKey,
813 const ::std::vector<Any>& rValues,
814 const Reference<XComponentContext>& rxContext,
815 const Reference<XResourceId>& rxAnchorId)
817 (void)rsKey;
819 if (rValues.size() != 6)
820 return;
824 OUString sPaneURL;
825 OUString sViewURL;
826 double nX = 0;
827 double nY = 0;
828 double nWidth = 0;
829 double nHeight = 0;
830 rValues[0] >>= sPaneURL;
831 rValues[1] >>= sViewURL;
832 rValues[2] >>= nX;
833 rValues[3] >>= nY;
834 rValues[4] >>= nWidth;
835 rValues[5] >>= nHeight;
837 if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)
839 SetupView(
840 rxContext,
841 rxAnchorId,
842 sPaneURL,
843 sViewURL,
844 PresenterPaneContainer::ViewInitializationFunction(),
847 nX+nWidth,
848 nY+nHeight);
851 catch (Exception& e)
853 (void)e;
854 OSL_ASSERT(false);
861 void PresenterScreen::ProcessViewDescription (
862 const OUString& rsKey,
863 const ::std::vector<Any>& rValues)
865 (void)rsKey;
867 if (rValues.size() != 4)
868 return;
872 ViewDescriptor aViewDescriptor;
873 OUString sViewURL;
874 rValues[0] >>= sViewURL;
875 rValues[1] >>= aViewDescriptor.msTitle;
876 rValues[2] >>= aViewDescriptor.msAccessibleTitle;
877 rValues[3] >>= aViewDescriptor.mbIsOpaque;
878 if (aViewDescriptor.msAccessibleTitle.getLength()==0)
879 aViewDescriptor.msAccessibleTitle = aViewDescriptor.msTitle;
880 maViewDescriptors[sViewURL] = aViewDescriptor;
882 catch (Exception&)
884 OSL_ASSERT(false);
891 void PresenterScreen::SetupView(
892 const Reference<XComponentContext>& rxContext,
893 const Reference<XResourceId>& rxAnchorId,
894 const OUString& rsPaneURL,
895 const OUString& rsViewURL,
896 const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization,
897 const double nLeft,
898 const double nTop,
899 const double nRight,
900 const double nBottom)
902 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
903 if (xCC.is())
905 Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
906 // Look up the view descriptor.
907 ViewDescriptor aViewDescriptor;
908 ViewDescriptorContainer::const_iterator iDescriptor (maViewDescriptors.find(rsViewURL));
909 if (iDescriptor != maViewDescriptors.end())
910 aViewDescriptor = iDescriptor->second;
912 // Prepare the pane.
913 OSL_ASSERT(mpPaneContainer.get() != NULL);
914 mpPaneContainer->PreparePane(
915 xPaneId,
916 rsViewURL,
917 aViewDescriptor.msTitle,
918 aViewDescriptor.msAccessibleTitle,
919 aViewDescriptor.mbIsOpaque,
920 rViewInitialization,
921 nLeft,
922 nTop,
923 nRight,
924 nBottom);
931 } } // end of namespace ::sdext::presenter