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>
53 typedef ::cppu::WeakComponentImplHelper <
54 css::document::XEventListener
55 > PresenterScreenListenerInterfaceBase;
61 class PresenterScreenListener
63 public PresenterScreenListenerInterfaceBase
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;
73 virtual void SAL_CALL disposing()
override;
77 virtual void SAL_CALL notifyEvent(
const css::document::EventObject& Event )
override;
81 virtual void SAL_CALL disposing (
const css::lang::EventObject& rEvent)
override;
84 css::uno::Reference<css::frame::XModel2 >
mxModel;
99 return "org.libreoffice.comp.PresenterScreenJob";
108extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
110 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any>
const&)
124PresenterScreenJob::~PresenterScreenJob()
128void SAL_CALL PresenterScreenJob::disposing()
135Any 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))
150 Reference< XServiceInfo > xInfo(
xModel, UNO_QUERY );
151 if( xInfo.is() && xInfo->supportsService(
"com.sun.star.presentation.PresentationDocument") )
157 pListener->Initialize();
167PresenterScreenListener::PresenterScreenListener (
168 css::uno::Reference<css::uno::XComponentContext> xContext,
169 css::uno::Reference<css::frame::XModel2> xModel)
170 : PresenterScreenListenerInterfaceBase(
m_aMutex),
176void PresenterScreenListener::Initialize()
178 Reference< document::XEventListener > xDocListener(
this);
179 Reference< document::XEventBroadcaster > xDocBroadcaster(
mxModel, UNO_QUERY );
180 if( xDocBroadcaster.is() )
181 xDocBroadcaster->addEventListener(xDocListener);
184void SAL_CALL PresenterScreenListener::disposing()
186 Reference< document::XEventBroadcaster > xDocBroadcaster(
mxModel, UNO_QUERY );
187 if( xDocBroadcaster.is() )
188 xDocBroadcaster->removeEventListener(
189 Reference<document::XEventListener>(
this) );
200void 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" )
215 else if ( Event.EventName ==
"OnEndPresentation" )
227void SAL_CALL PresenterScreenListener::disposing (
const css::lang::EventObject&)
241 const Reference<XComponentContext>& rxContext,
242 css::uno::Reference<css::frame::XModel2> xModel)
245 mxContextWeak(rxContext)
255 bool dEnablePresenterScreen=
true;
258 "/org.openoffice.Office.Impress/",
261 >>= dEnablePresenterScreen;
262 return dEnablePresenterScreen;
267 bool dPresenterScreenFullScreen =
true;
270 "/org.openoffice.Office.Impress/",
273 >>= dPresenterScreenFullScreen;
274 return dPresenterScreenFullScreen;
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();
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() )
319 auto tmpController =
mxModel->getCurrentController();
320 Reference< container::XEnumeration > xEnum(
mxModel->getControllers() );
323 while( xEnum->hasMoreElements() )
325 Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY );
326 if( xC.is() && (xC.get() != tmpController.get()) )
329 assert(
bool(
mxController) ==
bool(xC) &&
"only support instances of type DrawController");
336 Reference<XConfigurationController> xCC(
mxController->getConfigurationController());
339 Reference<drawing::framework::XResourceId> xMainPaneId(
343 if ( ! xMainPaneId.is())
346 if (xCC.is() && xContext.is())
361 xCC->requestResourceActivation(
363 ResourceActivationMode_ADD);
370 xSlideShowController,
396 Reference<XPresentationSupplier> xPS (
mxModel, UNO_QUERY_THROW);
397 Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW);
408 if (nNewScreen == nExternalDisplay)
414 Reference<beans::XPropertySet> xProperties (xPresentation, UNO_QUERY_THROW);
415 xProperties->setPropertyValue(
"Display",
Any(nNewScreen));
416 }
catch (
const uno::Exception &) {
425 const Reference<presentation::XPresentation2>& rxPresentation)
const
427 sal_Int32 nScreenNumber (0);
430 if ( ! rxPresentation.is())
435 sal_Int32 nDisplayNumber (-1);
436 if ( ! (rxPresentation->getPropertyValue(
"Display") >>= nDisplayNumber))
438 if (nDisplayNumber == -1)
446 SAL_INFO(
"sdext.presenter",
"Display number is " << nDisplayNumber);
448 if (nDisplayNumber > 0)
450 nScreenNumber = nDisplayNumber - 1;
452 else if (nDisplayNumber == 0)
463 if (nScreenCount < 2 || nDisplayNumber > nScreenCount)
473 "/org.openoffice.Office.PresenterScreen/",
475 bool bStartAlways (
false);
478 "Presenter/StartAlways") >>= bStartAlways)
480 if (bStartAlways || !bPresenterScreenFullScreen)
486 catch (
const beans::UnknownPropertyException&)
492 SAL_INFO(
"sdext.presenter",
"Get presenter screen for screen " << nScreenNumber);
500 sal_Int32 nPresenterScreenNumber (1);
501 switch (nPresentationScreen)
504 nPresenterScreenNumber = 1;
508 nPresenterScreenNumber = 0;
512 SAL_INFO(
"sdext.presenter",
"Warning unexpected, out of bound screen "
513 "mapped to 0" << nPresentationScreen);
517 nPresenterScreenNumber = 0;
520 return nPresenterScreenNumber;
524 const Reference<presentation::XPresentation2>& rxPresentation,
525 const Reference<XComponentContext>& xContext)
const
537 return ResourceId::create(
543 + OUString::number(nScreen));
567 [pSelf](
bool){
return pSelf->ShutdownPresenterScreen(); });
574 Reference<lang::XComponent> xViewFactoryComponent (
mxViewFactory, UNO_QUERY);
575 if (xViewFactoryComponent.is())
576 xViewFactoryComponent->dispose();
579 Reference<lang::XComponent> xPaneFactoryComponent (
mxPaneFactory, UNO_QUERY);
580 if (xPaneFactoryComponent.is())
581 xPaneFactoryComponent->dispose();
625 const Reference<XComponentContext>& rxContext,
626 const Reference<XResourceId>& rxAnchorId)
632 "org.openoffice.Office.PresenterScreen",
636 OUString sLayoutName (
"DefaultLayout");
638 "Presenter/CurrentLayout") >>= sLayoutName;
639 ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId);
648 std::u16string_view rsLayoutName,
649 const Reference<XComponentContext>& rxContext,
650 const Reference<XResourceId>& rxAnchorId)
654 Reference<container::XHierarchicalNameAccess> xLayoutNode (
656 OUString::Concat(
"Presenter/Layouts/")+rsLayoutName),
660 OUString sParentLayout;
663 "ParentLayout") >>= sParentLayout;
664 if (!sParentLayout.isEmpty())
667 if (rsLayoutName != sParentLayout)
668 ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId);
672 Reference<container::XNameAccess> xList (
690 [
this, rxContext, rxAnchorId](std::vector<uno::Any>
const& rArgs)
705 Reference<container::XNameAccess> xViewDescriptionsNode (
717 xViewDescriptionsNode,
719 [
this](std::vector<uno::Any>
const& rArgs)
731 const ::std::vector<Any>& rValues,
732 const Reference<XComponentContext>& rxContext,
733 const Reference<XResourceId>& rxAnchorId)
735 if (rValues.size() != 6)
746 rValues[0] >>= sPaneURL;
747 rValues[1] >>= sViewURL;
750 rValues[4] >>= nWidth;
751 rValues[5] >>= nHeight;
753 if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0)
770 const ::std::vector<Any>& rValues)
772 if (rValues.size() != 4)
779 rValues[0] >>= sViewURL;
780 rValues[1] >>= aViewDescriptor.
msTitle;
794 const Reference<XComponentContext>& rxContext,
795 const Reference<XResourceId>& rxAnchorId,
796 const OUString& rsPaneURL,
797 const OUString& rsViewURL,
804 Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId));
807 ViewDescriptorContainer::const_iterator iDescriptor (
maViewDescriptors.find(rsViewURL));
809 aViewDescriptor = iDescriptor->second;
819 rViewInitialization);
css::uno::Reference< css::frame::XModel2 > mxModel
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
rtl::Reference< PresenterScreen > mpPresenterScreen
PropertiesInfo aProperties
static unsigned int GetScreenCount()
static unsigned int GetDisplayExternalScreen()
The DrawController is the UNO controller for Impress and Draw.
This class gives access to the configuration.
css::uno::Any GetConfigurationNode(const OUString &rsPathToNode)
Return a configuration node below the root of the called object.
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.
The controller of the presenter screen is responsible for telling the individual views which slides t...
static void RunOnUpdateEnd(const css::uno::Reference< css::drawing::framework::XConfigurationController > &rxController, const Action &rAction)
This class could also be called PresenterPaneAndViewContainer because it stores not only references t...
::std::function< void(const css::uno::Reference< css::drawing::framework::XView > &)> ViewInitializationFunction
static css::uno::Reference< css::drawing::framework::XResourceFactory > Create(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const rtl::Reference<::sd::DrawController > &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...
The PresenterScreenJob service is instantiated every time a document is created or loaded.
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
PresenterScreenJob(const PresenterScreenJob &)=delete
OUString msAccessibleTitle
rtl::Reference<::sd::DrawController > mxController
css::uno::Reference< css::drawing::framework::XConfiguration > mxSavedConfiguration
virtual ~PresenterScreen() override
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.
virtual void SAL_CALL disposing() override
css::uno::Reference< css::frame::XModel2 > mxModel
static bool isPresenterScreenFullScreen(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
void ShutdownPresenterScreen()
static bool isPresenterScreenEnabled(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
::rtl::Reference< PresenterController > mpPresenterController
void RequestShutdownPresenterScreen()
Do not call ShutdownPresenterScreen() directly.
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)
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...
ViewDescriptorContainer maViewDescriptors
void InitializePresenterScreen()
Make the presenter screen visible.
css::uno::WeakReference< css::uno::XComponentContext > mxContextWeak
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.
void ProcessViewDescription(const ::std::vector< css::uno::Any > &rValues)
Called by ProcessViewDescriptions for a single entry.
css::uno::Reference< css::drawing::framework::XResourceFactory > mxPaneFactory
void SetupPaneFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Create and initialize the factory for presenter view specific panes.
void ProcessViewDescriptions(PresenterConfigurationAccess &rConfiguration)
Read the view descriptions from the configuration.
static sal_Int32 GetPresenterScreenFromScreen(sal_Int32 nPresentationScreen)
css::uno::Reference< css::drawing::framework::XResourceId > GetMainPaneId(const css::uno::Reference< css::presentation::XPresentation2 > &rxPresentation, const css::uno::Reference< com::sun::star::uno::XComponentContext > &xContext) const
Create a resource id for the full screen background pane so that it is displayed on another screen th...
PresenterScreen(const css::uno::Reference< css::uno::XComponentContext > &rxContext, css::uno::Reference< css::frame::XModel2 > xModel)
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.
void SetupViewFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Create and initialize the factory for presenter view specific views.
void SwitchMonitors()
Switch / converse monitors between presenter view and slide output.
css::uno::Reference< css::drawing::framework::XResourceFactory > mxViewFactory
::rtl::Reference< PresenterPaneContainer > mpPaneContainer
css::uno::WeakReference< css::drawing::framework::XConfigurationController > mxConfigurationControllerWeak
static css::uno::Reference< css::drawing::framework::XResourceFactory > Create(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const ::rtl::Reference<::sd::DrawController > &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...
#define SAL_INFO(area, stream)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
const OUString msFullScreenPaneURL
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * sd_PresenterScreenJob_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
::cppu::WeakComponentImplHelper< css::task::XJob, css::lang::XServiceInfo > PresenterScreenJobInterfaceBase
::cppu::WeakComponentImplHelper< css::lang::XEventListener > PresenterScreenInterfaceBase
This is the bootstrap class of the presenter screen.
Reference< XModel > xModel