36#include <com/sun/star/awt/Key.hpp>
37#include <com/sun/star/awt/KeyModifier.hpp>
38#include <com/sun/star/awt/MouseButton.hpp>
39#include <com/sun/star/container/XNamed.hpp>
40#include <com/sun/star/drawing/XDrawView.hpp>
41#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
42#include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
43#include <com/sun/star/drawing/framework/ResourceId.hpp>
44#include <com/sun/star/drawing/framework/XControllerManager.hpp>
45#include <com/sun/star/frame/FrameSearchFlag.hpp>
46#include <com/sun/star/frame/XDispatchProvider.hpp>
47#include <com/sun/star/presentation/AnimationEffect.hpp>
48#include <com/sun/star/presentation/XPresentation.hpp>
49#include <com/sun/star/presentation/XPresentationSupplier.hpp>
50#include <com/sun/star/rendering/TextDirection.hpp>
51#include <com/sun/star/util/URLTransformer.hpp>
53#include <rtl/ustrbuf.hxx>
62 const sal_Int32 ResourceActivationEventType = 0;
63 const sal_Int32 ResourceDeactivationEventType = 1;
64 const sal_Int32 ConfigurationUpdateEndEventType = 2;
76 const css::uno::Reference<css::frame::XFrame>& rxFrame)
78 InstanceContainer::const_iterator iInstance (
maInstances.find(rxFrame));
80 return iInstance->second;
82 return ::rtl::Reference<PresenterController>();
86 css::uno::WeakReference<css::lang::XEventListener> xScreen,
87 const Reference<XComponentContext>& rxContext,
88 const Reference<frame::XController>& rxController,
89 const Reference<presentation::XSlideShowController>& rxSlideShowController,
91 const Reference<XResourceId>& rxMainPaneId)
93 mxScreen(
std::move(xScreen)),
95 mxController(rxController),
96 mxSlideShowController(rxSlideShowController),
97 mxMainPaneId(rxMainPaneId),
98 mpPaneContainer(
std::move(xPaneContainer)),
99 mnCurrentSlideIndex(-1),
102 mnPendingSlideNumber(-1),
103 mbIsAccessibilityActive(false)
108 throw lang::IllegalArgumentException(
109 "missing slide show controller",
110 static_cast<XWeak*
>(
this),
116 Reference<XControllerManager> xCM (
mxController, UNO_QUERY_THROW);
122 "ResourceActivation",
123 Any(ResourceActivationEventType));
126 "ResourceDeactivation",
127 Any(ResourceDeactivationEventType));
130 "ConfigurationUpdateEnd",
131 Any(ConfigurationUpdateEndEventType));
137 xFrame->addFrameActionListener(
this);
145 Reference<lang::XMultiComponentFactory>
xFactory =
146 rxContext->getServiceManager();
150 xFactory->createInstanceWithContext(
151 "com.sun.star.drawing.PresenterHelper",
159 if (xProperties.is())
161 Reference<awt::XWindow> xWindow (
162 xProperties->getPropertyValue(
"ParentWindow"), UNO_QUERY);
164 xWindow->addKeyListener(
this);
200 xFrame->removeFrameActionListener(
this);
206 if (xWindowManagerComponent.is())
207 xWindowManagerComponent->dispose();
222 xComponent->dispose();
229 xComponent->dispose();
237 xComponent->dispose();
269 if (xIndexAccess.is() && nSlideIndex>=0)
271 if (nSlideIndex < xIndexAccess->getCount())
274 mxCurrentSlide.set( xIndexAccess->getByIndex(nSlideIndex), UNO_QUERY);
287 if (nNextSlideIndex >= 0)
289 if (xIndexAccess.is())
291 if (nNextSlideIndex < xIndexAccess->getCount())
292 mxNextSlide.set( xIndexAccess->getByIndex(nNextSlideIndex), UNO_QUERY);
307 static const OUStringLiteral sCurrentSlideNumberPlaceholder (
u"CURRENT_SLIDE_NUMBER");
308 static const OUStringLiteral sCurrentSlideNamePlaceholder (
u"CURRENT_SLIDE_NAME");
309 static const OUStringLiteral sSlideCountPlaceholder (
u"SLIDE_COUNT");
312 OUString sSlideCount (
"---");
314 if (xIndexAccess.is())
315 sSlideCount = OUString::number(xIndexAccess->getCount());
321 OUString sCurrentSlideName;
322 Reference<container::XNamed> xNamedSlide (
mxCurrentSlide, UNO_QUERY);
323 if (xNamedSlide.is())
324 sCurrentSlideName = xNamedSlide->getName();
325 Reference<beans::XPropertySet> xSlideProperties (
mxCurrentSlide, UNO_QUERY);
326 if (xSlideProperties.is())
331 if (xSlideProperties->getPropertyValue(
"LinkDisplayName") >>=
sName)
335 if (
sName != sCurrentSlideName)
336 sCurrentSlideName =
sName;
339 catch (
const beans::UnknownPropertyException&)
347 OSL_ASSERT(rxPane !=
nullptr);
350 ? rxPane->msAccessibleTitleTemplate
351 : rxPane->msTitleTemplate);
352 if (sTemplate.isEmpty())
355 OUStringBuffer sResult;
356 sResult.ensureCapacity(sTemplate.getLength());
361 sal_Int32 nStartIndex = sTemplate.indexOf(
'%',
nIndex);
365 sResult.append(sTemplate.subView(
nIndex));
371 sResult.append(sTemplate.subView(
nIndex, nStartIndex-
nIndex));
375 const sal_Int32 nEndIndex (sTemplate.indexOf(
'%', nStartIndex+1));
376 const std::u16string_view sPlaceholder (sTemplate.subView(nStartIndex, nEndIndex-nStartIndex));
380 if (sPlaceholder == sCurrentSlideNumberPlaceholder)
381 sResult.append(sCurrentSlideNumber);
382 else if (sPlaceholder == sCurrentSlideNamePlaceholder)
383 sResult.append(sCurrentSlideName);
384 else if (sPlaceholder == sSlideCountPlaceholder)
385 sResult.append(sSlideCount);
389 rxPane->msTitle = sResult.makeStringAndClear();
390 if (rxPane->mxPane.is())
391 rxPane->mxPane->SetTitle(rxPane->msTitle);
400 Reference<drawing::XDrawView> xDrawView (rxPane->mxView, UNO_QUERY);
411 const OUString sStyleName (
mpTheme->GetStyleName(rsViewURL));
412 return mpTheme->GetBitmap(sStyleName,
"Background");
422 const OUString sStyleName (
mpTheme->GetStyleName(rsViewURL));
423 return mpTheme->GetFont(sStyleName);
438const Reference<presentation::XSlideShowController>&
476 pDescriptor->mbIsActive =
true;
478 pDescriptor->mxPaneId,
479 ResourceActivationMode_ADD);
481 ResourceId::createWithAnchor(
484 pDescriptor->mxPaneId),
485 ResourceActivationMode_REPLACE);
495 ResourceId::createWithAnchor(
498 pDescriptor->mxPaneId));
508 aURL.Complete = rsCommand;
523 Reference<frame::XDispatchProvider> xDispatchProvider (
mxController->getFrame(), UNO_QUERY);
524 if ( ! xDispatchProvider.is())
527 return xDispatchProvider->queryDispatch(
530 frame::FrameSearchFlag::SELF);
539 aURL.Complete = rsURL;
546const Reference<drawing::framework::XConfigurationController>&
559 bool bTransition =
false;
562 Reference<beans::XPropertySet> xSlidePropertySet (rxPage, UNO_QUERY);
565 sal_uInt16 aTransitionType = 0;
566 xSlidePropertySet->getPropertyValue(
"TransitionType") >>= aTransitionType;
567 if (aTransitionType > 0)
572 catch (
const beans::UnknownPropertyException&)
581 bool bCustomAnimation =
false;
584 sal_uInt32
i,
nCount = rxPage->getCount();
587 Reference<drawing::XShape> xShape(rxPage->getByIndex(
i), UNO_QUERY);
588 Reference<beans::XPropertySet> xShapePropertySet(xShape, UNO_QUERY);
589 presentation::AnimationEffect aEffect = presentation::AnimationEffect_NONE;
590 presentation::AnimationEffect aTextEffect = presentation::AnimationEffect_NONE;
593 xShapePropertySet->getPropertyValue(
"Effect") >>= aEffect;
594 xShapePropertySet->getPropertyValue(
"TextEffect") >>= aTextEffect;
596 catch (
const beans::UnknownPropertyException&)
599 if( aEffect != presentation::AnimationEffect_NONE ||
600 aTextEffect != presentation::AnimationEffect_NONE )
602 bCustomAnimation =
true;
607 return bCustomAnimation;
625 switch (rEvent.Buttons)
627 case awt::MouseButton::LEFT:
628 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
634 case awt::MouseButton::RIGHT:
645 const bool bIsSlideSorterActive,
646 const bool bIsNotesViewActive,
647 const bool bIsHelpViewActive)
651 bool bActivate (
true);
652 const OUString sViewURL (rxPane->msViewURL);
655 bActivate = bIsNotesViewActive && !bIsSlideSorterActive && !bIsHelpViewActive;
659 bActivate = bIsSlideSorterActive;
664 bActivate = !bIsSlideSorterActive && ! bIsHelpViewActive;
672 bActivate = bIsHelpViewActive;
695 const ConfigurationChangeEvent& rEvent)
697 if (rBHelper.bDisposed || rBHelper.bInDispose)
699 throw lang::DisposedException (
700 "PresenterController object has already been disposed",
701 static_cast<uno::XWeak*
>(
this));
705 if ( ! (rEvent.UserData >>=
nType))
710 case ResourceActivationEventType:
715 else if (rEvent.ResourceId->isBoundTo(
mxMainPaneId,AnchorBindingMode_DIRECT))
719 Reference<XPane> xPane (rEvent.ResourceObject,UNO_QUERY);
725 else if (rEvent.ResourceId->isBoundTo(
mxMainPaneId,AnchorBindingMode_INDIRECT))
729 Reference<XView> xView (rEvent.ResourceObject,UNO_QUERY);
739 case ResourceDeactivationEventType:
740 if (rEvent.ResourceId->isBoundTo(
mxMainPaneId,AnchorBindingMode_INDIRECT))
743 Reference<XView> xView (rEvent.ResourceObject,UNO_QUERY);
760 case ConfigurationUpdateEndEventType:
773 const lang::EventObject& rEvent)
788 const frame::FrameActionEvent& rEvent)
790 if (rEvent.Action == frame::FrameAction_FRAME_ACTIVATED)
804 if ( ! rxPane->mbIsActive)
807 Reference<awt::XKeyListener> xKeyListener (rxPane->mxView, UNO_QUERY);
808 if (xKeyListener.is())
809 xKeyListener->keyPressed(rEvent);
818 switch (rEvent.KeyCode)
820 case awt::Key::ESCAPE:
821 case awt::Key::SUBTRACT:
825 Reference< XPresentationSupplier > xPS(
mxController->getModel(), UNO_QUERY );
828 Reference< XPresentation > xP( xPS->getPresentation() );
836 case awt::Key::PAGEDOWN:
839 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
846 case awt::Key::RIGHT:
847 case awt::Key::SPACE:
855 case awt::Key::PAGEUP:
858 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
867 case awt::Key::BACKSPACE:
886 if (rEvent.Modifiers == awt::KeyModifier::MOD1)
915 case awt::Key::COMMA:
926 case awt::Key::POINT:
949 case awt::Key::RETURN:
980 if ( ! rxPane->mbIsActive)
983 Reference<awt::XKeyListener> xKeyListener (rxPane->mxView, UNO_QUERY);
984 if (xKeyListener.is())
985 xKeyListener->keyReleased(rEvent);
992 const sal_Int32 nKey,
993 const sal_Int32 nModifiers)
1003 case awt::KeyModifier::MOD1:
1076 Reference<XPane2> xPane2 (rxPane, UNO_QUERY);
1078 xPane2->setVisible(
true);
1082 mxCanvas.set(rxPane->getCanvas(), UNO_QUERY);
1099 double nSlideAspectRatio (28.0/21.0);
1105 Reference<drawing::XDrawPagesSupplier> xSlideSupplier (
1107 Reference<drawing::XDrawPages> xSlides (xSlideSupplier->getDrawPages());
1108 if (xSlides.is() && xSlides->getCount()>0)
1110 Reference<beans::XPropertySet> xProperties(xSlides->getByIndex(0),UNO_QUERY_THROW);
1111 sal_Int32 nWidth (28000);
1112 sal_Int32 nHeight (21000);
1113 if ((xProperties->getPropertyValue(
"Width") >>= nWidth)
1114 && (xProperties->getPropertyValue(
"Height") >>= nHeight)
1117 nSlideAspectRatio = double(nWidth) / double(nHeight);
1127 return nSlideAspectRatio;
1141 mpTheme->GetFont(
"PendingSlideNumberFont"));
1146 if ( ! pFont->mxFont.is())
1150 rendering::StringContext aContext (sText, 0, sText.getLength());
1151 pFont->mxFont->createTextLayout(
1153 rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
1159 Reference<lang::XEventListener> xScreen(
mxScreen );
1174 Reference< XPresentationSupplier > xPS(
mxController->getModel(), UNO_QUERY );
1177 Reference< XPresentation > xP( xPS->getPresentation() );
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
Represents an element in the toolbar that shows the time elapsed since the presentation started.
virtual ~IPresentationTime()
Collection of functions to ease the life of a canvas user.
void SetAccessibilityActiveState(const bool bIsActive)
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent &rEvent) override
css::uno::Reference< css::presentation::XSlideShowController > mxSlideShowController
void GetSlides(const sal_Int32 nOffset)
double GetSlideAspectRatio() const
IPresentationTime * GetPresentationTime()
const std::shared_ptr< PresenterPaintManager > & GetPaintManager() const
void SetPresentationTime(IPresentationTime *pPresentationTime)
css::uno::Reference< css::drawing::XPresenterHelper > mxPresenterHelper
void InitializeMainPane(const css::uno::Reference< css::drawing::framework::XPane > &rxPane)
virtual void SAL_CALL notifyConfigurationChange(const css::drawing::framework::ConfigurationChangeEvent &rEvent) override
virtual void SAL_CALL keyPressed(const css::awt::KeyEvent &rEvent) override
const css::uno::Reference< css::drawing::framework::XConfigurationController > & GetConfigurationController() const
void HandleMouseClick(const css::awt::MouseEvent &rEvent)
css::uno::Reference< css::drawing::XDrawPage > mxCurrentSlide
void ShowView(const OUString &rsViewURL)
const css::uno::Reference< css::drawing::XDrawPage > & GetCurrentSlide() const
const ::rtl::Reference< PresenterWindowManager > & GetWindowManager() const
css::uno::Reference< css::rendering::XSpriteCanvas > mxCanvas
css::uno::Reference< css::frame::XDispatch > GetDispatch(const css::util::URL &rURL) const
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent &rEvent) override
void DispatchUnoCommand(const OUString &rsCommand) const
virtual void SAL_CALL keyReleased(const css::awt::KeyEvent &rEvent) override
css::uno::WeakReference< css::lang::XEventListener > mxScreen
void UpdatePendingSlideNumber(const sal_Int32 nPendingSlideNumber)
const ::rtl::Reference< PresenterPaneBorderPainter > & GetPaneBorderPainter() const
virtual void SAL_CALL mouseExited(const css::awt::MouseEvent &rEvent) override
std::shared_ptr< PresenterCanvasHelper > mpCanvasHelper
virtual void SAL_CALL disposing() override
IPresentationTime * mpPresentationTime
static bool HasTransition(css::uno::Reference< css::drawing::XDrawPage > const &rxPage)
const std::shared_ptr< PresenterCanvasHelper > & GetCanvasHelper() const
static bool HasCustomAnimation(css::uno::Reference< css::drawing::XDrawPage > const &rxPage)
const rtl::Reference< PresenterPaneContainer > & GetPaneContainer() const
PresenterTheme::SharedFontDescriptor GetViewFont(const OUString &rsViewURL) const
sal_Int32 mnCurrentSlideIndex
css::uno::Reference< css::awt::XWindow > mxMainWindow
virtual void SAL_CALL mousePressed(const css::awt::MouseEvent &rEvent) override
sal_Int32 mnPendingSlideNumber
static ::rtl::Reference< PresenterController > Instance(const css::uno::Reference< css::frame::XFrame > &rxFrame)
const css::uno::Reference< css::drawing::XPresenterHelper > & GetPresenterHelper() const
std::shared_ptr< PresenterPaintManager > mpPaintManager
void LoadTheme(const css::uno::Reference< css::drawing::framework::XPane > &rxPane)
css::uno::Reference< css::util::XURLTransformer > mxUrlTransformer
void HandleNumericKeyPress(const sal_Int32 nKey, const sal_Int32 nModifiers)
This method is called when the user pressed one of the numerical keys.
bool mbIsAccessibilityActive
void HideView(const OUString &rsViewURL)
rtl::Reference< PresenterPaneContainer > mpPaneContainer
SharedBitmapDescriptor GetViewBackground(const OUString &rsViewURL) const
bool IsAccessibilityActive() const
PresenterController(css::uno::WeakReference< css::lang::XEventListener > xScreen, const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XController > &rxController, const css::uno::Reference< css::presentation::XSlideShowController > &rxSlideShowController, rtl::Reference< PresenterPaneContainer > xPaneContainer, const css::uno::Reference< css::drawing::framework::XResourceId > &rxMainPaneId)
std::shared_ptr< PresenterTheme > mpTheme
const css::uno::Reference< css::presentation::XSlideShowController > & GetSlideShowController() const
const std::shared_ptr< PresenterTheme > & GetTheme() const
static InstanceContainer maInstances
css::uno::Reference< css::frame::XController > mxController
::std::map< css::uno::Reference< css::frame::XFrame >, rtl::Reference< PresenterController > > InstanceContainer
css::uno::Reference< css::drawing::framework::XResourceId > mxMainPaneId
css::uno::Reference< css::drawing::XDrawPage > mxNextSlide
virtual ~PresenterController() override
virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent &rEvent) override
void UpdateCurrentSlide(const sal_Int32 nOffset)
::rtl::Reference< PresenterPaneBorderPainter > mpPaneBorderPainter
css::util::URL CreateURLFromString(const OUString &rsURL) const
::rtl::Reference< PresenterAccessible > mpAccessibleObject
css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
void RequestViews(const bool bIsSlideSorterActive, const bool bIsNotesViewActive, const bool bIsHelpViewActive)
Request activation or deactivation of (some of) the views according to the given parameters.
::rtl::Reference< PresenterWindowManager > mpWindowManager
Check periodically the slide show controller and the frame::XController whether the current slide has...
This class is responsible for painting window borders of PresenterPane objects.
std::shared_ptr< PaneDescriptor > SharedPaneDescriptor
void SwitchMonitors()
Switch / converse monitors between presenter view and slide output.
std::shared_ptr< FontDescriptor > SharedFontDescriptor
static constexpr OUStringLiteral msCurrentSlidePreviewViewURL
static constexpr OUStringLiteral msToolBarViewURL
static constexpr OUStringLiteral msNotesViewURL
static constexpr OUStringLiteral msSlideSorterURL
static constexpr OUStringLiteral msNextSlidePreviewViewURL
static constexpr OUStringLiteral msHelpViewURL
A simple manager of the positions of the panes of the presenter screen.
Reference< XDispatch > xDispatch
Reference< XSingleServiceFactory > xFactory
std::shared_ptr< T > make_shared(Args &&... args)
::cppu::WeakComponentImplHelper< css::drawing::framework::XConfigurationChangeListener, css::frame::XFrameActionListener, css::awt::XKeyListener, css::awt::XMouseListener > PresenterControllerInterfaceBase
std::shared_ptr< PresenterBitmapContainer::BitmapDescriptor > SharedBitmapDescriptor
Reference< XFrame > xFrame