22 #include <string_view>
38 #include <com/sun/star/awt/Key.hpp>
39 #include <com/sun/star/awt/KeyModifier.hpp>
40 #include <com/sun/star/awt/MouseButton.hpp>
41 #include <com/sun/star/container/XNamed.hpp>
42 #include <com/sun/star/drawing/XDrawView.hpp>
43 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
44 #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
45 #include <com/sun/star/drawing/framework/ResourceId.hpp>
46 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
47 #include <com/sun/star/frame/FrameSearchFlag.hpp>
48 #include <com/sun/star/frame/XDispatchProvider.hpp>
49 #include <com/sun/star/presentation/AnimationEffect.hpp>
50 #include <com/sun/star/presentation/XPresentation.hpp>
51 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
52 #include <com/sun/star/rendering/TextDirection.hpp>
53 #include <com/sun/star/util/URLTransformer.hpp>
55 #include <rtl/ustrbuf.hxx>
63 const sal_Int32 ResourceActivationEventType = 0;
64 const sal_Int32 ResourceDeactivationEventType = 1;
65 const sal_Int32 ConfigurationUpdateEndEventType = 2;
77 const css::uno::Reference<css::frame::XFrame>& rxFrame)
79 InstanceContainer::const_iterator iInstance (
maInstances.find(rxFrame));
81 return iInstance->second;
83 return ::rtl::Reference<PresenterController>();
87 const css::uno::WeakReference<css::lang::XEventListener> &rxScreen,
89 const Reference<frame::XController>& rxController,
90 const Reference<presentation::XSlideShowController>& rxSlideShowController,
92 const Reference<XResourceId>& rxMainPaneId)
96 mxController(rxController),
97 mxConfigurationController(),
98 mxSlideShowController(rxSlideShowController),
99 mxMainPaneId(rxMainPaneId),
100 mpPaneContainer(rpPaneContainer),
101 mnCurrentSlideIndex(-1),
107 mpPaneBorderPainter(),
111 mnPendingSlideNumber(-1),
113 mpAccessibleObject(),
114 mbIsAccessibilityActive(false)
119 throw lang::IllegalArgumentException(
120 "missing slide show controller",
121 static_cast<XWeak*>(
this),
127 Reference<XControllerManager> xCM (
mxController, UNO_QUERY_THROW);
133 "ResourceActivation",
134 Any(ResourceActivationEventType));
137 "ResourceDeactivation",
138 Any(ResourceDeactivationEventType));
141 "ConfigurationUpdateEnd",
142 Any(ConfigurationUpdateEndEventType));
148 xFrame->addFrameActionListener(
this);
156 Reference<lang::XMultiComponentFactory>
xFactory =
157 rxContext->getServiceManager();
158 if ( ! xFactory.is())
161 xFactory->createInstanceWithContext(
162 "com.sun.star.drawing.PresenterHelper",
170 if (xProperties.is())
172 Reference<awt::XWindow> xWindow (
173 xProperties->getPropertyValue(
"ParentWindow"), UNO_QUERY);
175 xWindow->addKeyListener(
this);
207 Reference<XComponent> xWindowManagerComponent (
210 if (xWindowManagerComponent.is())
211 xWindowManagerComponent->dispose();
217 xFrame->removeFrameActionListener(
this);
235 xComponent->dispose();
242 xComponent->dispose();
250 xComponent->dispose();
282 if (xIndexAccess.is() && nSlideIndex>=0)
284 if (nSlideIndex < xIndexAccess->getCount())
287 mxCurrentSlide.set( xIndexAccess->getByIndex(nSlideIndex), UNO_QUERY);
300 if (nNextSlideIndex >= 0)
302 if (xIndexAccess.is())
304 if (nNextSlideIndex < xIndexAccess->getCount())
305 mxNextSlide.set( xIndexAccess->getByIndex(nNextSlideIndex), UNO_QUERY);
320 const OUString sCurrentSlideNumberPlaceholder (
"CURRENT_SLIDE_NUMBER");
321 const OUString sCurrentSlideNamePlaceholder (
"CURRENT_SLIDE_NAME");
322 const OUString sSlideCountPlaceholder (
"SLIDE_COUNT");
325 OUString sSlideCount (
"---");
327 if (xIndexAccess.is())
328 sSlideCount = OUString::number(xIndexAccess->getCount());
334 OUString sCurrentSlideName;
335 Reference<container::XNamed> xNamedSlide (
mxCurrentSlide, UNO_QUERY);
336 if (xNamedSlide.is())
337 sCurrentSlideName = xNamedSlide->getName();
339 if (xSlideProperties.is())
344 if (xSlideProperties->getPropertyValue(
"LinkDisplayName") >>= sName)
348 if (sName != sCurrentSlideName)
349 sCurrentSlideName = sName;
352 catch (
const beans::UnknownPropertyException&)
360 OSL_ASSERT(rxPane !=
nullptr);
363 ? rxPane->msAccessibleTitleTemplate
364 : rxPane->msTitleTemplate);
365 if (sTemplate.isEmpty())
368 OUStringBuffer sResult;
369 sResult.ensureCapacity(sTemplate.getLength());
374 sal_Int32 nStartIndex = sTemplate.indexOf(
'%', nIndex);
378 sResult.append(std::u16string_view(sTemplate).substr(nIndex));
384 sResult.append(std::u16string_view(sTemplate).substr(nIndex, nStartIndex-nIndex));
388 const sal_Int32 nEndIndex (sTemplate.indexOf(
'%', nStartIndex+1));
389 const OUString sPlaceholder (sTemplate.copy(nStartIndex, nEndIndex-nStartIndex));
390 nIndex = nEndIndex+1;
393 if (sPlaceholder == sCurrentSlideNumberPlaceholder)
394 sResult.append(sCurrentSlideNumber);
395 else if (sPlaceholder == sCurrentSlideNamePlaceholder)
396 sResult.append(sCurrentSlideName);
397 else if (sPlaceholder == sSlideCountPlaceholder)
398 sResult.append(sSlideCount);
402 rxPane->msTitle = sResult.makeStringAndClear();
403 if (rxPane->mxPane.is())
404 rxPane->mxPane->SetTitle(rxPane->msTitle);
413 Reference<drawing::XDrawView> xDrawView (rxPane->mxView, UNO_QUERY);
424 const OUString sStyleName (
mpTheme->GetStyleName(rsViewURL));
425 return mpTheme->GetBitmap(sStyleName,
"Background");
435 const OUString sStyleName (
mpTheme->GetStyleName(rsViewURL));
436 return mpTheme->GetFont(sStyleName);
451 const Reference<presentation::XSlideShowController>&
489 pDescriptor->mbIsActive =
true;
491 pDescriptor->mxPaneId,
492 ResourceActivationMode_ADD);
494 ResourceId::createWithAnchor(
497 pDescriptor->mxPaneId),
498 ResourceActivationMode_REPLACE);
508 ResourceId::createWithAnchor(
511 pDescriptor->mxPaneId));
521 aURL.Complete = rsCommand;
525 if ( ! xDispatch.is())
536 Reference<frame::XDispatchProvider> xDispatchProvider (
mxController->getFrame(), UNO_QUERY);
537 if ( ! xDispatchProvider.is())
540 return xDispatchProvider->queryDispatch(
543 frame::FrameSearchFlag::SELF);
552 aURL.Complete = rsURL;
559 const Reference<drawing::framework::XConfigurationController>&
572 bool bTransition =
false;
578 sal_uInt16 aTransitionType = 0;
579 xSlidePropertySet->getPropertyValue(
"TransitionType") >>= aTransitionType;
580 if (aTransitionType > 0)
585 catch (
const beans::UnknownPropertyException&)
594 bool bCustomAnimation =
false;
597 sal_uInt32
i,
nCount = rxPage->getCount();
598 for ( i = 0; i < nCount; i++ )
600 Reference<drawing::XShape> xShape(rxPage->getByIndex(i), UNO_QUERY);
602 presentation::AnimationEffect aEffect = presentation::AnimationEffect_NONE;
603 presentation::AnimationEffect aTextEffect = presentation::AnimationEffect_NONE;
606 xShapePropertySet->getPropertyValue(
"Effect") >>= aEffect;
607 xShapePropertySet->getPropertyValue(
"TextEffect") >>= aTextEffect;
609 catch (
const beans::UnknownPropertyException&)
612 if( aEffect != presentation::AnimationEffect_NONE ||
613 aTextEffect != presentation::AnimationEffect_NONE )
615 bCustomAnimation =
true;
620 return bCustomAnimation;
638 switch (rEvent.Buttons)
640 case awt::MouseButton::LEFT:
641 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
647 case awt::MouseButton::RIGHT:
658 const bool bIsSlideSorterActive,
659 const bool bIsNotesViewActive,
660 const bool bIsHelpViewActive)
664 bool bActivate (
true);
665 const OUString sViewURL (rxPane->msViewURL);
668 bActivate = bIsNotesViewActive && !bIsSlideSorterActive && !bIsHelpViewActive;
672 bActivate = bIsSlideSorterActive;
677 bActivate = !bIsSlideSorterActive && ! bIsHelpViewActive;
685 bActivate = bIsHelpViewActive;
708 const ConfigurationChangeEvent& rEvent)
710 if (rBHelper.bDisposed || rBHelper.bInDispose)
712 throw lang::DisposedException (
713 "PresenterController object has already been disposed",
714 static_cast<uno::XWeak*>(
this));
718 if ( ! (rEvent.UserData >>= nType))
723 case ResourceActivationEventType:
728 else if (rEvent.ResourceId->isBoundTo(
mxMainPaneId,AnchorBindingMode_DIRECT))
732 Reference<XPane> xPane (rEvent.ResourceObject,UNO_QUERY);
738 else if (rEvent.ResourceId->isBoundTo(
mxMainPaneId,AnchorBindingMode_INDIRECT))
742 Reference<XView> xView (rEvent.ResourceObject,UNO_QUERY);
752 case ResourceDeactivationEventType:
753 if (rEvent.ResourceId->isBoundTo(
mxMainPaneId,AnchorBindingMode_INDIRECT))
756 Reference<XView> xView (rEvent.ResourceObject,UNO_QUERY);
773 case ConfigurationUpdateEndEventType:
786 const lang::EventObject& rEvent)
801 const frame::FrameActionEvent& rEvent)
803 if (rEvent.Action == frame::FrameAction_FRAME_ACTIVATED)
817 if ( ! rxPane->mbIsActive)
820 Reference<awt::XKeyListener> xKeyListener (rxPane->mxView, UNO_QUERY);
821 if (xKeyListener.is())
822 xKeyListener->keyPressed(rEvent);
831 switch (rEvent.KeyCode)
833 case awt::Key::ESCAPE:
834 case awt::Key::SUBTRACT:
838 Reference< XPresentationSupplier > xPS(
mxController->getModel(), UNO_QUERY );
841 Reference< XPresentation > xP( xPS->getPresentation() );
849 case awt::Key::PAGEDOWN:
852 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
859 case awt::Key::RIGHT:
860 case awt::Key::SPACE:
869 case awt::Key::PAGEUP:
872 if (rEvent.Modifiers == awt::KeyModifier::MOD2)
882 case awt::Key::BACKSPACE:
904 case awt::Key::COMMA:
915 case awt::Key::POINT:
938 case awt::Key::RETURN:
969 if ( ! rxPane->mbIsActive)
972 Reference<awt::XKeyListener> xKeyListener (rxPane->mxView, UNO_QUERY);
973 if (xKeyListener.is())
974 xKeyListener->keyReleased(rEvent);
981 const sal_Int32 nKey,
982 const sal_Int32 nModifiers)
992 case awt::KeyModifier::MOD1:
1065 Reference<XPane2> xPane2 (rxPane, UNO_QUERY);
1067 xPane2->setVisible(
true);
1071 mxCanvas.set(rxPane->getCanvas(), UNO_QUERY);
1088 double nSlideAspectRatio (28.0/21.0);
1094 Reference<drawing::XDrawPagesSupplier> xSlideSupplier (
1096 Reference<drawing::XDrawPages> xSlides (xSlideSupplier->getDrawPages());
1097 if (xSlides.is() && xSlides->getCount()>0)
1100 sal_Int32 nWidth (28000);
1101 sal_Int32 nHeight (21000);
1102 if ((xProperties->getPropertyValue(
"Width") >>= nWidth)
1103 && (xProperties->getPropertyValue(
"Height") >>= nHeight)
1106 nSlideAspectRatio = double(nWidth) / double(nHeight);
1116 return nSlideAspectRatio;
1130 mpTheme->GetFont(
"PendingSlideNumberFont"));
1135 if ( ! pFont->mxFont.is())
1139 rendering::StringContext aContext (sText, 0, sText.getLength());
1140 pFont->mxFont->createTextLayout(
1142 rendering::TextDirection::WEAK_LEFT_TO_RIGHT,
1148 Reference<lang::XEventListener> xScreen(
mxScreen );
1163 Reference< XPresentationSupplier > xPS(
mxController->getModel(), UNO_QUERY );
1166 Reference< XPresentation > xP( xPS->getPresentation() );
static::rtl::Reference< PresenterController > Instance(const css::uno::Reference< css::frame::XFrame > &rxFrame)
const std::shared_ptr< PresenterPaintManager > & GetPaintManager() const
sal_Int32 mnPendingSlideNumber
std::shared_ptr< FontDescriptor > SharedFontDescriptor
static constexpr OUStringLiteral msCurrentSlidePreviewViewURL
std::shared_ptr< PresenterCanvasHelper > mpCanvasHelper
css::uno::Reference< css::util::XURLTransformer > mxUrlTransformer
void DispatchUnoCommand(const OUString &rsCommand) const
Represents an element in the toolbar that shows the time elapsed since the presentation started...
css::uno::WeakReference< css::lang::XEventListener > mxScreen
const std::shared_ptr< PresenterTheme > & GetTheme() const
void HideView(const OUString &rsViewURL)
Reference< XFrame > xFrame
::rtl::Reference< PresenterAccessible > mpAccessibleObject
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent &rEvent) override
void InitializeMainPane(const css::uno::Reference< css::drawing::framework::XPane > &rxPane)
static bool HasCustomAnimation(css::uno::Reference< css::drawing::XDrawPage > const &rxPage)
css::util::URL CreateURLFromString(const OUString &rsURL) const
const ::rtl::Reference< PresenterPaneBorderPainter > & GetPaneBorderPainter() const
static constexpr OUStringLiteral msNotesViewURL
std::shared_ptr< T > make_shared(Args &&...args)
virtual void SAL_CALL keyPressed(const css::awt::KeyEvent &rEvent) override
const css::uno::Reference< css::drawing::XPresenterHelper > & GetPresenterHelper() const
std::shared_ptr< PresenterPaintManager > mpPaintManager
PresenterController(const css::uno::WeakReference< css::lang::XEventListener > &rxScreen, const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XController > &rxController, const css::uno::Reference< css::presentation::XSlideShowController > &rxSlideShowController, const rtl::Reference< PresenterPaneContainer > &rpPaneContainer, const css::uno::Reference< css::drawing::framework::XResourceId > &rxMainPaneId)
std::shared_ptr< PresenterBitmapContainer::BitmapDescriptor > SharedBitmapDescriptor
static constexpr OUStringLiteral msNextSlidePreviewViewURL
Reference< drawing::XPresenterHelper > mxPresenterHelper
css::uno::Reference< css::presentation::XSlideShowController > mxSlideShowController
Collection of functions to ease the life of a canvas user.
void GetSlides(const sal_Int32 nOffset)
virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent &rEvent) override
virtual ~IPresentationTime()
virtual void SAL_CALL disposing() override
::rtl::Reference< PresenterPaneBorderPainter > mpPaneBorderPainter
bool IsAccessibilityActive() const
virtual void SAL_CALL keyReleased(const css::awt::KeyEvent &rEvent) override
static constexpr OUStringLiteral msToolBarViewURL
void SwitchMonitors()
Switch / converse monitors between presenter view and slide output.
virtual void SAL_CALL mouseExited(const css::awt::MouseEvent &rEvent) override
::cppu::WeakComponentImplHelper< css::drawing::framework::XConfigurationChangeListener, css::frame::XFrameActionListener, css::awt::XKeyListener, css::awt::XMouseListener > PresenterControllerInterfaceBase
void UpdateCurrentSlide(const sal_Int32 nOffset)
SharedBitmapDescriptor GetViewBackground(const OUString &rsViewURL) const
css::uno::Reference< css::rendering::XSpriteCanvas > mxCanvas
void SetPresentationTime(IPresentationTime *pPresentationTime)
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
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.
virtual void SAL_CALL mousePressed(const css::awt::MouseEvent &rEvent) override
PresenterTheme::SharedFontDescriptor GetViewFont(const OUString &rsViewURL) const
::std::map< css::uno::Reference< css::frame::XFrame >, rtl::Reference< PresenterController > > InstanceContainer
void ShowView(const OUString &rsViewURL)
A simple manager of the positions of the panes of the presenter screen.
rtl::Reference< PresenterPaneContainer > mpPaneContainer
const css::uno::Reference< css::presentation::XSlideShowController > & GetSlideShowController() const
void LoadTheme(const css::uno::Reference< css::drawing::framework::XPane > &rxPane)
virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent &rEvent) override
const css::uno::Reference< css::drawing::XDrawPage > & GetCurrentSlide() const
css::uno::Reference< css::frame::XController > mxController
css::uno::Reference< css::frame::XDispatch > GetDispatch(const css::util::URL &rURL) const
sal_Int32 mnCurrentSlideIndex
css::uno::Reference< css::drawing::XDrawPage > mxCurrentSlide
const std::shared_ptr< PresenterCanvasHelper > & GetCanvasHelper() const
void UpdatePendingSlideNumber(const sal_Int32 nPendingSlideNumber)
Reference< XDispatch > xDispatch
void SetAccessibilityActiveState(const bool bIsActive)
const ::rtl::Reference< PresenterWindowManager > & GetWindowManager() const
IPresentationTime * mpPresentationTime
std::shared_ptr< PaneDescriptor > SharedPaneDescriptor
Check periodically the slide show controller and the frame::XController whether the current slide has...
const css::uno::Reference< css::drawing::framework::XConfigurationController > & GetConfigurationController() const
static InstanceContainer maInstances
css::uno::Reference< css::drawing::XDrawPage > mxNextSlide
virtual ~PresenterController() override
const rtl::Reference< PresenterPaneContainer > & GetPaneContainer() const
css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
css::uno::Reference< css::drawing::XPresenterHelper > mxPresenterHelper
Reference< XSingleServiceFactory > xFactory
static constexpr OUStringLiteral msHelpViewURL
virtual void SAL_CALL notifyConfigurationChange(const css::drawing::framework::ConfigurationChangeEvent &rEvent) override
std::shared_ptr< PresenterTheme > mpTheme
bool mbIsAccessibilityActive
This class is responsible for painting window borders of PresenterPane objects.
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
static constexpr OUStringLiteral msSlideSorterURL
::rtl::Reference< PresenterWindowManager > mpWindowManager
IPresentationTime * GetPresentationTime()
void HandleNumericKeyPress(const sal_Int32 nKey, const sal_Int32 nModifiers)
This method is called when the user pressed one of the numerical keys.
void HandleMouseClick(const css::awt::MouseEvent &rEvent)
static bool HasTransition(css::uno::Reference< css::drawing::XDrawPage > const &rxPage)
css::uno::Reference< css::awt::XWindow > mxMainWindow
css::uno::Reference< css::drawing::framework::XResourceId > mxMainPaneId
double GetSlideAspectRatio() const