Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / console / PresenterScreen.cxx
blobcd6c20d38cc5df28eedf5f7bee904b6165166293
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 <DrawController.hxx>
30 #include <com/sun/star/frame/XController.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/drawing/framework/ResourceId.hpp>
33 #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
34 #include <com/sun/star/presentation/XPresentation2.hpp>
35 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
36 #include <com/sun/star/document/XEventBroadcaster.hpp>
37 #include <cppuhelper/compbase.hxx>
38 #include <cppuhelper/supportsservice.hxx>
40 #include <utility>
41 #include <vcl/svapp.hxx>
42 #include <sal/log.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::presenter {
52 namespace {
53 typedef ::cppu::WeakComponentImplHelper <
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 ::cppu::BaseMutex,
63 public PresenterScreenListenerInterfaceBase
65 public:
66 PresenterScreenListener (
67 css::uno::Reference<css::uno::XComponentContext> xContext,
68 css::uno::Reference<css::frame::XModel2> xModel);
69 PresenterScreenListener(const PresenterScreenListener&) = delete;
70 PresenterScreenListener& operator=(const PresenterScreenListener&) = delete;
72 void Initialize();
73 virtual void SAL_CALL disposing() override;
75 // document::XEventListener
77 virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) override;
79 // XEventListener
81 virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) override;
83 private:
84 css::uno::Reference<css::frame::XModel2 > mxModel;
85 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
86 rtl::Reference<PresenterScreen> mpPresenterScreen;
90 //----- XServiceInfo ---------------------------------------------------------------
92 Sequence< OUString > SAL_CALL PresenterScreenJob::getSupportedServiceNames()
94 return { };
97 OUString SAL_CALL PresenterScreenJob::getImplementationName()
99 return "org.libreoffice.comp.PresenterScreenJob";
102 sal_Bool SAL_CALL PresenterScreenJob::supportsService(const OUString& aServiceName)
104 return cppu::supportsService(this, aServiceName);
108 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
109 sd_PresenterScreenJob_get_implementation(
110 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
112 return cppu::acquire(new PresenterScreenJob(context));
116 //===== PresenterScreenJob ====================================================
118 PresenterScreenJob::PresenterScreenJob (const Reference<XComponentContext>& rxContext)
119 : PresenterScreenJobInterfaceBase(m_aMutex),
120 mxComponentContext(rxContext)
124 PresenterScreenJob::~PresenterScreenJob()
128 void SAL_CALL PresenterScreenJob::disposing()
130 mxComponentContext = nullptr;
133 //----- XJob -----------------------------------------------------------
135 Any SAL_CALL PresenterScreenJob::execute(
136 const Sequence< beans::NamedValue >& Arguments )
138 Sequence< beans::NamedValue > lEnv;
139 auto pArg = std::find_if(Arguments.begin(), Arguments.end(),
140 [](const beans::NamedValue& rArg) { return rArg.Name == "Environment"; });
141 if (pArg != Arguments.end())
142 pArg->Value >>= lEnv;
144 Reference<frame::XModel2> xModel;
145 auto pProp = std::find_if(std::cbegin(lEnv), std::cend(lEnv),
146 [](const beans::NamedValue& rProp) { return rProp.Name == "Model"; });
147 if (pProp != std::cend(lEnv))
148 pProp->Value >>= xModel;
150 Reference< XServiceInfo > xInfo( xModel, UNO_QUERY );
151 if( xInfo.is() && xInfo->supportsService("com.sun.star.presentation.PresentationDocument") )
153 // Create a new listener that waits for the full screen presentation
154 // to start and to end. It takes care of its own lifetime.
155 ::rtl::Reference<PresenterScreenListener> pListener (
156 new PresenterScreenListener(mxComponentContext, xModel));
157 pListener->Initialize();
160 return Any();
163 //===== PresenterScreenListener ===============================================
165 namespace {
167 PresenterScreenListener::PresenterScreenListener (
168 css::uno::Reference<css::uno::XComponentContext> xContext,
169 css::uno::Reference<css::frame::XModel2> xModel)
170 : PresenterScreenListenerInterfaceBase(m_aMutex),
171 mxModel(std::move(xModel)),
172 mxComponentContext(std::move(xContext))
176 void PresenterScreenListener::Initialize()
178 Reference< document::XEventListener > xDocListener(this);
179 Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
180 if( xDocBroadcaster.is() )
181 xDocBroadcaster->addEventListener(xDocListener);
184 void SAL_CALL PresenterScreenListener::disposing()
186 Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY );
187 if( xDocBroadcaster.is() )
188 xDocBroadcaster->removeEventListener(
189 Reference<document::XEventListener>(this) );
191 if (mpPresenterScreen.is())
193 mpPresenterScreen->RequestShutdownPresenterScreen();
194 mpPresenterScreen = nullptr;
198 // document::XEventListener
200 void SAL_CALL PresenterScreenListener::notifyEvent( const css::document::EventObject& Event )
202 if (rBHelper.bDisposed || rBHelper.bInDispose)
204 throw lang::DisposedException (
205 "PresenterScreenListener object has already been disposed",
206 static_cast<uno::XWeak*>(this));
209 if ( Event.EventName == "OnStartPresentation" )
211 mpPresenterScreen = new PresenterScreen(mxComponentContext, mxModel);
212 if(PresenterScreen::isPresenterScreenEnabled(mxComponentContext))
213 mpPresenterScreen->InitializePresenterScreen();
215 else if ( Event.EventName == "OnEndPresentation" )
217 if (mpPresenterScreen.is())
219 mpPresenterScreen->RequestShutdownPresenterScreen();
220 mpPresenterScreen = nullptr;
225 // XEventListener
227 void SAL_CALL PresenterScreenListener::disposing (const css::lang::EventObject&)
229 if (mpPresenterScreen.is())
231 mpPresenterScreen->RequestShutdownPresenterScreen();
232 mpPresenterScreen = nullptr;
236 } // end of anonymous namespace
238 //===== PresenterScreen =======================================================
240 PresenterScreen::PresenterScreen (
241 const Reference<XComponentContext>& rxContext,
242 css::uno::Reference<css::frame::XModel2> xModel)
243 : PresenterScreenInterfaceBase(m_aMutex),
244 mxModel(std::move(xModel)),
245 mxContextWeak(rxContext)
249 PresenterScreen::~PresenterScreen()
253 bool PresenterScreen::isPresenterScreenEnabled(const css::uno::Reference<css::uno::XComponentContext>& rxContext)
255 bool dEnablePresenterScreen=true;
256 PresenterConfigurationAccess aConfiguration (
257 rxContext,
258 "/org.openoffice.Office.Impress/",
259 PresenterConfigurationAccess::READ_ONLY);
260 aConfiguration.GetConfigurationNode("Misc/Start/EnablePresenterScreen")
261 >>= dEnablePresenterScreen;
262 return dEnablePresenterScreen;
265 bool PresenterScreen::isPresenterScreenFullScreen(const css::uno::Reference<css::uno::XComponentContext>& rxContext)
267 bool dPresenterScreenFullScreen = true;
268 PresenterConfigurationAccess aConfiguration (
269 rxContext,
270 "/org.openoffice.Office.Impress/",
271 PresenterConfigurationAccess::READ_ONLY);
272 aConfiguration.GetConfigurationNode("Misc/Start/PresenterScreenFullScreen")
273 >>= dPresenterScreenFullScreen;
274 return dPresenterScreenFullScreen;
277 void SAL_CALL PresenterScreen::disposing()
279 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
280 if (xCC.is() && mxSavedConfiguration.is())
282 xCC->restoreConfiguration(mxSavedConfiguration);
284 mxConfigurationControllerWeak = Reference<XConfigurationController>(nullptr);
286 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
287 if (xViewFactoryComponent.is())
288 xViewFactoryComponent->dispose();
289 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
290 if (xPaneFactoryComponent.is())
291 xPaneFactoryComponent->dispose();
293 mxModel = nullptr;
296 //----- XEventListener --------------------------------------------------------
298 void SAL_CALL PresenterScreen::disposing (const lang::EventObject& /*rEvent*/)
300 RequestShutdownPresenterScreen();
304 void PresenterScreen::InitializePresenterScreen()
308 Reference<XComponentContext> xContext (mxContextWeak);
309 mpPaneContainer = new PresenterPaneContainer(xContext);
311 Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
312 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
313 Reference<presentation::XSlideShowController> xSlideShowController( xPresentation->getController() );
315 if( !xSlideShowController.is() || !xSlideShowController->isFullScreen() )
316 return;
318 // find first controller that is not the current controller (the one with the slideshow
319 auto tmpController = mxModel->getCurrentController();
320 Reference< container::XEnumeration > xEnum( mxModel->getControllers() );
321 if( xEnum.is() )
323 while( xEnum->hasMoreElements() )
325 Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY );
326 if( xC.is() && (xC.get() != tmpController.get()) )
328 mxController = dynamic_cast<::sd::DrawController*>(xC.get());
329 assert(bool(mxController) == bool(xC) && "only support instances of type DrawController");
330 break;
334 // Get the XController from the first argument.
336 Reference<XConfigurationController> xCC( mxController->getConfigurationController());
337 mxConfigurationControllerWeak = xCC;
339 Reference<drawing::framework::XResourceId> xMainPaneId(
340 GetMainPaneId(xPresentation, xContext));
341 // An empty reference means that the presenter screen can
342 // not or must not be displayed.
343 if ( ! xMainPaneId.is())
344 return;
346 if (xCC.is() && xContext.is())
348 // Store the current configuration so that we can restore it when
349 // the presenter view is deactivated.
350 mxSavedConfiguration = xCC->getRequestedConfiguration();
351 xCC->lock();
355 // At the moment the presenter controller is displayed in its
356 // own full screen window that is controlled by the same
357 // configuration controller as the Impress document from
358 // which the presentation was started. Therefore the main
359 // pane is activated additionally to the already existing
360 // panes and does not replace them.
361 xCC->requestResourceActivation(
362 xMainPaneId,
363 ResourceActivationMode_ADD);
364 SetupConfiguration(xContext, xMainPaneId);
366 mpPresenterController = new PresenterController(
367 this,
368 xContext,
369 mxController,
370 xSlideShowController,
371 mpPaneContainer,
372 xMainPaneId);
374 // Create pane and view factories and integrate them into the
375 // drawing framework.
376 SetupPaneFactory(xContext);
377 SetupViewFactory(xContext);
379 mpPresenterController->GetWindowManager()->RestoreViewMode();
381 catch (const RuntimeException&)
383 xCC->restoreConfiguration(mxSavedConfiguration);
385 xCC->unlock();
388 catch (const Exception&)
393 void PresenterScreen::SwitchMonitors()
395 try {
396 Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW);
397 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
399 // Get the existing presenter console screen, we want to switch the
400 // presentation to use that instead.
401 sal_Int32 nNewScreen = GetPresenterScreenNumber (xPresentation);
402 if (nNewScreen < 0)
403 return;
405 // Adapt that display number to be the 'default' setting of 0 if it matches
406 sal_Int32 nExternalDisplay = Application::GetDisplayExternalScreen();
408 if (nNewScreen == nExternalDisplay)
409 nNewScreen = 0; // screen zero is best == the primary display
410 else
411 nNewScreen++; // otherwise we store screens offset by one.
413 // Set the new presentation display
414 Reference<beans::XPropertySet> xProperties (xPresentation, UNO_QUERY_THROW);
415 xProperties->setPropertyValue("Display", Any(nNewScreen));
416 } catch (const uno::Exception &) {
421 * Return the real VCL screen number to show the presenter console
422 * on or -1 to not show anything.
424 sal_Int32 PresenterScreen::GetPresenterScreenNumber (
425 const Reference<presentation::XPresentation2>& rxPresentation) const
427 sal_Int32 nScreenNumber (0);
430 if ( ! rxPresentation.is())
431 return -1;
433 // Determine the screen on which the full screen presentation is being
434 // displayed.
435 sal_Int32 nDisplayNumber (-1);
436 if ( ! (rxPresentation->getPropertyValue("Display") >>= nDisplayNumber))
437 return -1;
438 if (nDisplayNumber == -1)
440 // The special value -1 indicates that the slide show
441 // spans all available displays. That leaves no room for
442 // the presenter screen.
443 return -1;
446 SAL_INFO("sdext.presenter", "Display number is " << nDisplayNumber);
448 if (nDisplayNumber > 0)
450 nScreenNumber = nDisplayNumber - 1;
452 else if (nDisplayNumber == 0)
454 // A display number value of 0 indicates the primary screen.
455 // Find out which screen number that is.
456 nScreenNumber = Application::GetDisplayExternalScreen();
459 // We still have to determine the number of screens to decide
460 // whether the presenter screen may be shown at all.
461 sal_Int32 nScreenCount = Application::GetScreenCount();
463 if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
465 // There is either only one screen or the full screen
466 // presentation spans all available screens. The presenter
467 // screen is shown only when a special flag in the configuration
468 // is set or when the presenter screen will be shown as
469 // non-full screen window
470 Reference<XComponentContext> xContext (mxContextWeak);
471 PresenterConfigurationAccess aConfiguration (
472 xContext,
473 "/org.openoffice.Office.PresenterScreen/",
474 PresenterConfigurationAccess::READ_ONLY);
475 bool bStartAlways (false);
476 bool bPresenterScreenFullScreen = isPresenterScreenFullScreen(xContext);
477 if (aConfiguration.GetConfigurationNode(
478 "Presenter/StartAlways") >>= bStartAlways)
480 if (bStartAlways || !bPresenterScreenFullScreen)
481 return GetPresenterScreenFromScreen(nScreenNumber);
483 return -1;
486 catch (const beans::UnknownPropertyException&)
488 OSL_ASSERT(false);
489 // For some reason we can not access the screen number. Use
490 // the default instead.
492 SAL_INFO("sdext.presenter", "Get presenter screen for screen " << nScreenNumber);
493 return GetPresenterScreenFromScreen(nScreenNumber);
496 sal_Int32 PresenterScreen::GetPresenterScreenFromScreen( sal_Int32 nPresentationScreen )
498 // Setup the resource id of the full screen background pane so that
499 // it is displayed on another screen than the presentation.
500 sal_Int32 nPresenterScreenNumber (1);
501 switch (nPresentationScreen)
503 case 0:
504 nPresenterScreenNumber = 1;
505 break;
507 case 1:
508 nPresenterScreenNumber = 0;
509 break;
511 default:
512 SAL_INFO("sdext.presenter", "Warning unexpected, out of bound screen "
513 "mapped to 0" << nPresentationScreen);
514 // When the full screen presentation is displayed on a screen
515 // other than 0 or 1 then place the presenter on the first
516 // available screen.
517 nPresenterScreenNumber = 0;
518 break;
520 return nPresenterScreenNumber;
523 Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId (
524 const Reference<presentation::XPresentation2>& rxPresentation,
525 const Reference<XComponentContext>& xContext) const
527 // A negative value means that the presentation spans all available
528 // displays. That leaves no room for the presenter.
529 const sal_Int32 nScreen(GetPresenterScreenNumber(rxPresentation));
530 if (nScreen < 0)
531 return nullptr;
533 auto fullScreenStr = isPresenterScreenFullScreen(xContext)
534 ? OUString("true")
535 : OUString("false");
537 return ResourceId::create(
538 Reference<XComponentContext>(mxContextWeak),
539 PresenterHelper::msFullScreenPaneURL
540 + "?FullScreen="
541 + fullScreenStr
542 + "&ScreenNumber="
543 + OUString::number(nScreen));
546 void PresenterScreen::RequestShutdownPresenterScreen()
548 // Restore the configuration that was active before the presenter screen
549 // has been activated. Now, that the presenter screen is displayed in
550 // its own top level window this probably not necessary, but one never knows.
551 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
552 if (xCC.is() && mxSavedConfiguration.is())
554 xCC->restoreConfiguration(mxSavedConfiguration);
555 mxSavedConfiguration = nullptr;
558 if (xCC.is())
560 // The actual restoration of the configuration takes place
561 // asynchronously. The view and pane factories can only by disposed
562 // after that. Therefore, set up a listener and wait for the
563 // restoration.
564 rtl::Reference<PresenterScreen> pSelf (this);
565 PresenterFrameworkObserver::RunOnUpdateEnd(
566 xCC,
567 [pSelf](bool){ return pSelf->ShutdownPresenterScreen(); });
568 xCC->update();
572 void PresenterScreen::ShutdownPresenterScreen()
574 Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY);
575 if (xViewFactoryComponent.is())
576 xViewFactoryComponent->dispose();
577 mxViewFactory = nullptr;
579 Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY);
580 if (xPaneFactoryComponent.is())
581 xPaneFactoryComponent->dispose();
582 mxPaneFactory = nullptr;
584 if (mpPresenterController)
586 mpPresenterController->dispose();
587 mpPresenterController.clear();
589 mpPaneContainer = new PresenterPaneContainer(Reference<XComponentContext>(mxContextWeak));
592 void PresenterScreen::SetupPaneFactory (const Reference<XComponentContext>& rxContext)
596 if ( ! mxPaneFactory.is())
597 mxPaneFactory = PresenterPaneFactory::Create(
598 rxContext,
599 mxController,
600 mpPresenterController);
602 catch (const RuntimeException&)
604 OSL_ASSERT(false);
608 void PresenterScreen::SetupViewFactory (const Reference<XComponentContext>& rxContext)
612 if ( ! mxViewFactory.is())
613 mxViewFactory = PresenterViewFactory::Create(
614 rxContext,
615 mxController,
616 mpPresenterController);
618 catch (const RuntimeException&)
620 OSL_ASSERT(false);
624 void PresenterScreen::SetupConfiguration (
625 const Reference<XComponentContext>& rxContext,
626 const Reference<XResourceId>& rxAnchorId)
630 PresenterConfigurationAccess aConfiguration (
631 rxContext,
632 "org.openoffice.Office.PresenterScreen",
633 PresenterConfigurationAccess::READ_ONLY);
634 maViewDescriptors.clear();
635 ProcessViewDescriptions(aConfiguration);
636 OUString sLayoutName ("DefaultLayout");
637 aConfiguration.GetConfigurationNode(
638 "Presenter/CurrentLayout") >>= sLayoutName;
639 ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
641 catch (const RuntimeException&)
646 void PresenterScreen::ProcessLayout (
647 PresenterConfigurationAccess& rConfiguration,
648 std::u16string_view rsLayoutName,
649 const Reference<XComponentContext>& rxContext,
650 const Reference<XResourceId>& rxAnchorId)
654 Reference<container::XHierarchicalNameAccess> xLayoutNode (
655 rConfiguration.GetConfigurationNode(
656 OUString::Concat("Presenter/Layouts/")+rsLayoutName),
657 UNO_QUERY_THROW);
659 // Read the parent layout first, if one is referenced.
660 OUString sParentLayout;
661 PresenterConfigurationAccess::GetConfigurationNode(
662 xLayoutNode,
663 "ParentLayout") >>= sParentLayout;
664 if (!sParentLayout.isEmpty())
666 // Prevent infinite recursion.
667 if (rsLayoutName != sParentLayout)
668 ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
671 // Process the actual layout list.
672 Reference<container::XNameAccess> xList (
673 PresenterConfigurationAccess::GetConfigurationNode(
674 xLayoutNode,
675 "Layout"),
676 UNO_QUERY_THROW);
678 ::std::vector<OUString> aProperties
680 "PaneURL",
681 "ViewURL",
682 "RelativeX",
683 "RelativeY",
684 "RelativeWidth",
685 "RelativeHeight"
687 PresenterConfigurationAccess::ForAll(
688 xList,
689 aProperties,
690 [this, rxContext, rxAnchorId](std::vector<uno::Any> const& rArgs)
692 this->ProcessComponent(rArgs, rxContext, rxAnchorId);
695 catch (const RuntimeException&)
700 void PresenterScreen::ProcessViewDescriptions (
701 PresenterConfigurationAccess& rConfiguration)
705 Reference<container::XNameAccess> xViewDescriptionsNode (
706 rConfiguration.GetConfigurationNode("Presenter/Views"),
707 UNO_QUERY_THROW);
709 ::std::vector<OUString> aProperties
711 "ViewURL",
712 "Title",
713 "AccessibleTitle",
714 "IsOpaque"
716 PresenterConfigurationAccess::ForAll(
717 xViewDescriptionsNode,
718 aProperties,
719 [this](std::vector<uno::Any> const& rArgs)
721 return this->ProcessViewDescription(rArgs);
724 catch (const RuntimeException&)
726 OSL_ASSERT(false);
730 void PresenterScreen::ProcessComponent (
731 const ::std::vector<Any>& rValues,
732 const Reference<XComponentContext>& rxContext,
733 const Reference<XResourceId>& rxAnchorId)
735 if (rValues.size() != 6)
736 return;
740 OUString sPaneURL;
741 OUString sViewURL;
742 double nX = 0;
743 double nY = 0;
744 double nWidth = 0;
745 double nHeight = 0;
746 rValues[0] >>= sPaneURL;
747 rValues[1] >>= sViewURL;
748 rValues[2] >>= nX;
749 rValues[3] >>= nY;
750 rValues[4] >>= nWidth;
751 rValues[5] >>= nHeight;
753 if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)
755 SetupView(
756 rxContext,
757 rxAnchorId,
758 sPaneURL,
759 sViewURL,
760 PresenterPaneContainer::ViewInitializationFunction());
763 catch (const Exception&)
765 OSL_ASSERT(false);
769 void PresenterScreen::ProcessViewDescription (
770 const ::std::vector<Any>& rValues)
772 if (rValues.size() != 4)
773 return;
777 ViewDescriptor aViewDescriptor;
778 OUString sViewURL;
779 rValues[0] >>= sViewURL;
780 rValues[1] >>= aViewDescriptor.msTitle;
781 rValues[2] >>= aViewDescriptor.msAccessibleTitle;
782 rValues[3] >>= aViewDescriptor.mbIsOpaque;
783 if (aViewDescriptor.msAccessibleTitle.isEmpty())
784 aViewDescriptor.msAccessibleTitle = aViewDescriptor.msTitle;
785 maViewDescriptors[sViewURL] = aViewDescriptor;
787 catch (const Exception&)
789 OSL_ASSERT(false);
793 void PresenterScreen::SetupView(
794 const Reference<XComponentContext>& rxContext,
795 const Reference<XResourceId>& rxAnchorId,
796 const OUString& rsPaneURL,
797 const OUString& rsViewURL,
798 const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization)
800 Reference<XConfigurationController> xCC (mxConfigurationControllerWeak);
801 if (!xCC.is())
802 return;
804 Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
805 // Look up the view descriptor.
806 ViewDescriptor aViewDescriptor;
807 ViewDescriptorContainer::const_iterator iDescriptor (maViewDescriptors.find(rsViewURL));
808 if (iDescriptor != maViewDescriptors.end())
809 aViewDescriptor = iDescriptor->second;
811 // Prepare the pane.
812 OSL_ASSERT(mpPaneContainer);
813 mpPaneContainer->PreparePane(
814 xPaneId,
815 rsViewURL,
816 aViewDescriptor.msTitle,
817 aViewDescriptor.msAccessibleTitle,
818 aViewDescriptor.mbIsOpaque,
819 rViewInitialization);
822 } // end of namespace ::sdext::presenter
824 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */