29 #include <com/sun/star/frame/XController.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/drawing/framework/XControllerManager.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>
52 typedef ::cppu::WeakComponentImplHelper <
53 css::document::XEventListener
54 > PresenterScreenListenerInterfaceBase;
60 class PresenterScreenListener
62 public PresenterScreenListenerInterfaceBase
65 PresenterScreenListener (
66 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
67 const css::uno::Reference<css::frame::XModel2>& rxModel);
68 PresenterScreenListener(
const PresenterScreenListener&) =
delete;
69 PresenterScreenListener& operator=(
const PresenterScreenListener&) =
delete;
72 virtual void SAL_CALL disposing()
override;
76 virtual void SAL_CALL notifyEvent(
const css::document::EventObject& Event )
override;
80 virtual void SAL_CALL disposing (
const css::lang::EventObject& rEvent)
override;
83 css::uno::Reference<css::frame::XModel2 >
mxModel;
98 return "org.libreoffice.comp.PresenterScreenJob";
107 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
109 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any>
const&)
123 PresenterScreenJob::~PresenterScreenJob()
127 void SAL_CALL PresenterScreenJob::disposing()
134 Any SAL_CALL PresenterScreenJob::execute(
138 auto pArg = std::find_if(Arguments.begin(), Arguments.end(),
139 [](
const beans::NamedValue& rArg) {
return rArg.Name ==
"Environment"; });
140 if (pArg != Arguments.end())
141 pArg->Value >>= lEnv;
143 Reference<frame::XModel2>
xModel;
144 auto pProp = std::find_if(lEnv.begin(), lEnv.end(),
145 [](
const beans::NamedValue& rProp) {
return rProp.Name ==
"Model"; });
146 if (pProp != lEnv.end())
149 Reference< XServiceInfo > xInfo(
xModel, UNO_QUERY );
150 if( xInfo.is() && xInfo->supportsService(
"com.sun.star.presentation.PresentationDocument") )
156 pListener->Initialize();
166 PresenterScreenListener::PresenterScreenListener (
167 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
168 const css::uno::Reference<css::frame::XModel2>& rxModel)
169 : PresenterScreenListenerInterfaceBase(
m_aMutex),
176 void PresenterScreenListener::Initialize()
178 Reference< document::XEventListener > xDocListener(
179 static_cast< document::XEventListener* >(
this), UNO_QUERY);
180 Reference< document::XEventBroadcaster > xDocBroadcaster(
mxModel, UNO_QUERY );
181 if( xDocBroadcaster.is() )
182 xDocBroadcaster->addEventListener(xDocListener);
185 void SAL_CALL PresenterScreenListener::disposing()
187 Reference< document::XEventBroadcaster > xDocBroadcaster(
mxModel, UNO_QUERY );
188 if( xDocBroadcaster.is() )
189 xDocBroadcaster->removeEventListener(
190 Reference<document::XEventListener>(
191 static_cast<document::XEventListener*>(
this), UNO_QUERY));
202 void SAL_CALL PresenterScreenListener::notifyEvent(
const css::document::EventObject& Event )
204 if (rBHelper.bDisposed || rBHelper.bInDispose)
206 throw lang::DisposedException (
207 "PresenterScreenListener object has already been disposed",
208 static_cast<uno::XWeak*>(
this));
211 if ( Event.EventName ==
"OnStartPresentation" )
217 else if ( Event.EventName ==
"OnEndPresentation" )
229 void SAL_CALL PresenterScreenListener::disposing (
const css::lang::EventObject&)
244 const css::uno::Reference<css::frame::XModel2>& rxModel)
248 mxConfigurationControllerWeak(),
249 mxContextWeak(rxContext),
251 mxSavedConfiguration(),
265 bool dEnablePresenterScreen=
true;
268 "/org.openoffice.Office.Impress/",
271 >>= dEnablePresenterScreen;
272 return dEnablePresenterScreen;
284 if (xViewFactoryComponent.is())
285 xViewFactoryComponent->dispose();
287 if (xPaneFactoryComponent.is())
288 xPaneFactoryComponent->dispose();
308 Reference<XPresentationSupplier> xPS (
mxModel, UNO_QUERY_THROW);
309 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
310 Reference<presentation::XSlideShowController> xSlideShowController( xPresentation->getController() );
312 if( !xSlideShowController.is() || !xSlideShowController->isFullScreen() )
317 Reference< container::XEnumeration > xEnum(
mxModel->getControllers() );
320 while( xEnum->hasMoreElements() )
322 Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY );
331 Reference<XControllerManager> xCM(
mxController, UNO_QUERY_THROW);
333 Reference<XConfigurationController> xCC( xCM->getConfigurationController());
336 Reference<drawing::framework::XResourceId> xMainPaneId(
340 if ( ! xMainPaneId.is())
343 if (xCC.is() && xContext.is())
358 xCC->requestResourceActivation(
360 ResourceActivationMode_ADD);
364 css::uno::WeakReference<css::lang::XEventListener>(
this),
367 xSlideShowController,
393 Reference<XPresentationSupplier> xPS (
mxModel, UNO_QUERY_THROW);
394 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
405 if (nNewScreen == nExternalDisplay)
412 xProperties->setPropertyValue(
"Display",
Any(nNewScreen));
413 }
catch (
const uno::Exception &) {
422 const Reference<presentation::XPresentation2>& rxPresentation)
const
424 sal_Int32 nScreenNumber (0);
427 if ( ! rxPresentation.is())
432 sal_Int32 nDisplayNumber (-1);
433 if ( ! (rxPresentation->getPropertyValue(
"Display") >>= nDisplayNumber))
435 if (nDisplayNumber == -1)
443 SAL_INFO(
"sdext.presenter",
"Display number is " << nDisplayNumber);
445 if (nDisplayNumber > 0)
447 nScreenNumber = nDisplayNumber - 1;
449 else if (nDisplayNumber == 0)
460 if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
469 "/org.openoffice.Office.PresenterScreen/",
471 bool bStartAlways (
false);
473 "Presenter/StartAlways") >>= bStartAlways)
481 catch (
const beans::UnknownPropertyException&)
487 SAL_INFO(
"sdext.presenter",
"Get presenter screen for screen " << nScreenNumber);
495 sal_Int32 nPresenterScreenNumber (1);
496 switch (nPresentationScreen)
499 nPresenterScreenNumber = 1;
503 nPresenterScreenNumber = 0;
507 SAL_INFO(
"sdext.presenter",
"Warning unexpected, out of bound screen "
508 "mapped to 0" << nPresentationScreen);
512 nPresenterScreenNumber = 0;
515 return nPresenterScreenNumber;
519 const Reference<presentation::XPresentation2>& rxPresentation)
const
527 return ResourceId::create(
530 +
"?FullScreen=true&ScreenNumber="
531 + OUString::number(nScreen));
555 [pSelf](
bool){
return pSelf->ShutdownPresenterScreen(); });
563 if (xViewFactoryComponent.is())
564 xViewFactoryComponent->dispose();
568 if (xPaneFactoryComponent.is())
569 xPaneFactoryComponent->dispose();
614 const Reference<XResourceId>& rxAnchorId)
620 "org.openoffice.Office.PresenterScreen",
624 OUString sLayoutName (
"DefaultLayout");
626 "Presenter/CurrentLayout") >>= sLayoutName;
627 ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
636 std::u16string_view rsLayoutName,
638 const Reference<XResourceId>& rxAnchorId)
642 Reference<container::XHierarchicalNameAccess> xLayoutNode (
644 OUString::Concat(
"Presenter/Layouts/")+rsLayoutName),
648 OUString sParentLayout;
651 "ParentLayout") >>= sParentLayout;
652 if (!sParentLayout.isEmpty())
655 if (rsLayoutName != sParentLayout)
656 ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
667 aProperties[0] =
"PaneURL";
668 aProperties[1] =
"ViewURL";
669 aProperties[2] =
"RelativeX";
670 aProperties[3] =
"RelativeY";
671 aProperties[4] =
"RelativeWidth";
672 aProperties[5] =
"RelativeHeight";
676 [
this, rxContext, rxAnchorId](std::vector<uno::Any>
const& rArgs)
696 aProperties[0] =
"ViewURL";
697 aProperties[1] =
"Title";
698 aProperties[2] =
"AccessibleTitle";
699 aProperties[3] =
"IsOpaque";
701 xViewDescriptionsNode,
703 [
this](std::vector<uno::Any>
const& rArgs)
715 const ::std::vector<Any>& rValues,
717 const Reference<XResourceId>& rxAnchorId)
719 if (rValues.size() != 6)
730 rValues[0] >>= sPaneURL;
731 rValues[1] >>= sViewURL;
734 rValues[4] >>= nWidth;
735 rValues[5] >>= nHeight;
737 if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)
754 const ::std::vector<Any>& rValues)
756 if (rValues.size() != 4)
763 rValues[0] >>= sViewURL;
764 rValues[1] >>= aViewDescriptor.
msTitle;
779 const Reference<XResourceId>& rxAnchorId,
780 const OUString& rsPaneURL,
781 const OUString& rsViewURL,
788 Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
791 ViewDescriptorContainer::const_iterator iDescriptor (
maViewDescriptors.find(rsViewURL));
793 aViewDescriptor = iDescriptor->second;
803 rViewInitialization);
static void ForAll(const css::uno::Reference< css::container::XNameAccess > &rxContainer, const ::std::vector< OUString > &rArguments, const ItemProcessor &rProcessor)
Execute a functor for all elements of the given container.
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
void ShutdownPresenterScreen()
css::uno::Reference< css::frame::XModel2 > mxModel
css::uno::Reference< css::drawing::framework::XResourceFactory > mxViewFactory
::cppu::WeakComponentImplHelper< css::lang::XEventListener > PresenterScreenInterfaceBase
This is the bootstrap class of the presenter screen.
css::uno::WeakReference< css::uno::XComponentContext > mxContextWeak
::cppu::WeakComponentImplHelper< css::task::XJob, css::lang::XServiceInfo > PresenterScreenJobInterfaceBase
css::uno::Reference< css::frame::XModel2 > mxModel
void ProcessLayout(PresenterConfigurationAccess &rConfiguration, std::u16string_view rsLayoutName, const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::drawing::framework::XResourceId > &rxAnchorId)
Read one layout from the configuration and make resource activation requests to bring it on to the sc...
static sal_Int32 GetPresenterScreenFromScreen(sal_Int32 nPresentationScreen)
PresenterScreenJob(const PresenterScreenJob &)=delete
PropertiesInfo aProperties
This class gives access to the configuration.
static unsigned int GetDisplayExternalScreen()
void ProcessComponent(const ::std::vector< css::uno::Any > &rValues, const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::drawing::framework::XResourceId > &rxAnchorId)
Called by ProcessLayout for a single entry of a Layouts configuration list.
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * sdext_PresenterScreenJob_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
OUString msAccessibleTitle
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
rtl::Reference< PresenterScreen > mpPresenterScreen
void SetupView(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::drawing::framework::XResourceId > &rxAnchorId, const OUString &rsPaneURL, const OUString &rsViewURL, const PresenterPaneContainer::ViewInitializationFunction &rViewInitialization)
The controller of the presenter screen is responsible for telling the individual views which slides t...
void SwitchMonitors()
Switch / converse monitors between presenter view and slide output.
void SetupConfiguration(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::drawing::framework::XResourceId > &rxAnchorId)
Read the current layout from the configuration and call ProcessLayout to bring it on to the screen...
void InitializePresenterScreen()
Make the presenter screen visible.
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
void SetupPaneFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Create and initialize the factory for presenter view specific panes.
sal_Int32 GetPresenterScreenNumber(const css::uno::Reference< css::presentation::XPresentation2 > &rxPresentation) const
Return the built-in screen number on the presentation will normally display the presenter console...
::std::function< void(const css::uno::Reference< css::drawing::framework::XView > &)> ViewInitializationFunction
css::uno::Any GetConfigurationNode(const OUString &rsPathToNode)
Return a configuration node below the root of the called object.
static void RunOnUpdateEnd(const css::uno::Reference< css::drawing::framework::XConfigurationController > &rxController, const Action &rAction)
css::uno::Reference< css::drawing::framework::XResourceId > GetMainPaneId(const css::uno::Reference< css::presentation::XPresentation2 > &rxPresentation) const
Create a resource id for the full screen background pane so that it is displayed on another screen th...
static unsigned int GetScreenCount()
css::uno::Reference< css::frame::XController > mxController
css::uno::Reference< css::drawing::framework::XResourceFactory > mxPaneFactory
static css::uno::Reference< css::drawing::framework::XResourceFactory > Create(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XController > &rxController, const ::rtl::Reference< PresenterController > &rpPresenterController)
Create a new instance of this class and register it as resource factory in the drawing framework of t...
void ProcessViewDescriptions(PresenterConfigurationAccess &rConfiguration)
Read the view descriptions from the configuration.
::rtl::Reference< PresenterPaneContainer > mpPaneContainer
::rtl::Reference< PresenterController > mpPresenterController
The PresenterScreenJob service is instantiated every time a document is created or loaded...
This class could also be called PresenterPaneAndViewContainer because it stores not only references t...
rtl::Reference< PresenterController > mpPresenterController
#define SAL_INFO(area, stream)
css::uno::WeakReference< css::drawing::framework::XConfigurationController > mxConfigurationControllerWeak
ViewDescriptorContainer maViewDescriptors
void SetupViewFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Create and initialize the factory for presenter view specific views.
css::uno::Reference< css::drawing::framework::XConfiguration > mxSavedConfiguration
Reference< XModel > xModel
void RequestShutdownPresenterScreen()
Do not call ShutdownPresenterScreen() directly.
static bool isPresenterScreenEnabled(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
const OUString msFullScreenPaneURL
static css::uno::Reference< css::drawing::framework::XResourceFactory > Create(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XController > &rxController, const ::rtl::Reference< PresenterController > &rpPresenterController)
Create a new instance of this class and register it as resource factory in the drawing framework of t...
PresenterScreen(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XModel2 > &rxModel)
virtual void SAL_CALL disposing() override
void ProcessViewDescription(const ::std::vector< css::uno::Any > &rValues)
Called by ProcessViewDescriptions for a single entry.
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual ~PresenterScreen() override