1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERCONTROLLER_HXX 21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERCONTROLLER_HXX 22 23 #include "PresenterAccessibility.hxx" 24 #include "PresenterPaneContainer.hxx" 25 #include "PresenterTheme.hxx" 26 #include <cppuhelper/compbase.hxx> 27 #include <cppuhelper/basemutex.hxx> 28 #include <com/sun/star/awt/XKeyListener.hpp> 29 #include <com/sun/star/awt/XMouseListener.hpp> 30 #include <com/sun/star/drawing/XPresenterHelper.hpp> 31 #include <com/sun/star/frame/XController.hpp> 32 #include <com/sun/star/frame/XDispatch.hpp> 33 #include <com/sun/star/presentation/XSlideShowController.hpp> 34 #include <com/sun/star/frame/XFrameActionListener.hpp> 35 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp> 36 #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 37 #include <com/sun/star/drawing/framework/XPane.hpp> 38 #include <com/sun/star/uno/XComponentContext.hpp> 39 #include <com/sun/star/util/XURLTransformer.hpp> 40 #include <rtl/ref.hxx> 41 #include <map> 42 #include <memory> 43 44 namespace sdext::presenter { 45 46 class PresenterCanvasHelper; 47 class PresenterPaintManager; 48 class PresenterPaneAnimator; 49 class PresenterPaneContainer; 50 class PresenterPaneBorderPainter; 51 class PresenterTheme; 52 class PresenterWindowManager; 53 54 typedef ::cppu::WeakComponentImplHelper < 55 css::drawing::framework::XConfigurationChangeListener, 56 css::frame::XFrameActionListener, 57 css::awt::XKeyListener, 58 css::awt::XMouseListener 59 > PresenterControllerInterfaceBase; 60 61 /// Represents an element in the toolbar that shows the time elapsed since the presentation started. 62 class IPresentationTime 63 { 64 public: 65 virtual void restart() = 0; 66 virtual bool isPaused() = 0; 67 virtual void setPauseStatus(const bool pauseStatus) = 0; 68 virtual ~IPresentationTime(); 69 }; 70 71 /** The controller of the presenter screen is responsible for telling the 72 individual views which slides to show. Additionally it provides access 73 to frequently used values of the current theme. 74 */ 75 class PresenterController 76 : protected ::cppu::BaseMutex, 77 public PresenterControllerInterfaceBase 78 { 79 public: 80 static ::rtl::Reference<PresenterController> Instance ( 81 const css::uno::Reference<css::frame::XFrame>& rxFrame); 82 83 PresenterController ( 84 const css::uno::WeakReference<css::lang::XEventListener> &rxScreen, 85 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 86 const css::uno::Reference<css::frame::XController>& rxController, 87 const css::uno::Reference<css::presentation::XSlideShowController>& rxSlideShowController, 88 const rtl::Reference<PresenterPaneContainer>& rpPaneContainer, 89 const css::uno::Reference<css::drawing::framework::XResourceId>& rxMainPaneId); 90 virtual ~PresenterController() override; 91 92 virtual void SAL_CALL disposing() override; 93 94 void UpdateCurrentSlide (const sal_Int32 nOffset); 95 96 SharedBitmapDescriptor 97 GetViewBackground (const OUString& rsViewURL) const; 98 PresenterTheme::SharedFontDescriptor 99 GetViewFont (const OUString& rsViewURL) const; 100 const std::shared_ptr<PresenterTheme>& GetTheme() const; 101 const ::rtl::Reference<PresenterWindowManager>& GetWindowManager() const; 102 const css::uno::Reference<css::presentation::XSlideShowController>& 103 GetSlideShowController() const; 104 const rtl::Reference<PresenterPaneContainer>& GetPaneContainer() const; 105 const ::rtl::Reference<PresenterPaneBorderPainter>& GetPaneBorderPainter() const; 106 const std::shared_ptr<PresenterCanvasHelper>& GetCanvasHelper() const; 107 const css::uno::Reference<css::drawing::XPresenterHelper>& GetPresenterHelper() const; 108 const std::shared_ptr<PresenterPaintManager>& GetPaintManager() const; 109 double GetSlideAspectRatio() const; 110 void ShowView (const OUString& rsViewURL); 111 void HideView (const OUString& rsViewURL); 112 void SwitchMonitors(); 113 void ExitPresenter(); 114 void DispatchUnoCommand (const OUString& rsCommand) const; 115 css::uno::Reference<css::frame::XDispatch> GetDispatch ( 116 const css::util::URL& rURL) const; 117 css::util::URL CreateURLFromString (const OUString& rsURL) const; 118 const css::uno::Reference<css::drawing::framework::XConfigurationController>& 119 GetConfigurationController() const; 120 const css::uno::Reference<css::drawing::XDrawPage>& GetCurrentSlide() const; 121 static bool HasTransition (css::uno::Reference<css::drawing::XDrawPage> const & rxPage); 122 static bool HasCustomAnimation (css::uno::Reference<css::drawing::XDrawPage> const & rxPage); 123 void SetAccessibilityActiveState (const bool bIsActive); IsAccessibilityActive() const124 bool IsAccessibilityActive() const { return mbIsAccessibilityActive;} 125 126 void HandleMouseClick (const css::awt::MouseEvent& rEvent); 127 void UpdatePaneTitles(); 128 129 /** Request activation or deactivation of (some of) the views according 130 to the given parameters. 131 */ 132 void RequestViews ( 133 const bool bIsSlideSorterActive, 134 const bool bIsNotesViewActive, 135 const bool bIsHelpViewActive); 136 137 void SetPresentationTime(IPresentationTime* pPresentationTime); 138 IPresentationTime* GetPresentationTime(); 139 140 // XConfigurationChangeListener 141 142 virtual void SAL_CALL notifyConfigurationChange ( 143 const css::drawing::framework::ConfigurationChangeEvent& rEvent) override; 144 145 // XEventListener 146 147 virtual void SAL_CALL disposing ( 148 const css::lang::EventObject& rEvent) override; 149 150 // XFrameActionListener 151 152 virtual void SAL_CALL frameAction ( 153 const css::frame::FrameActionEvent& rEvent) override; 154 155 // XKeyListener 156 157 virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent) override; 158 virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent) override; 159 160 // XMouseListener 161 162 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) override; 163 164 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) override; 165 166 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) override; 167 168 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) override; 169 170 private: 171 typedef ::std::map<css::uno::Reference<css::frame::XFrame>,rtl::Reference<PresenterController> > InstanceContainer; 172 static InstanceContainer maInstances; 173 174 css::uno::WeakReference<css::lang::XEventListener> mxScreen; 175 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 176 css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas; 177 css::uno::Reference<css::frame::XController> mxController; 178 css::uno::Reference<css::drawing::framework::XConfigurationController> 179 mxConfigurationController; 180 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController; 181 css::uno::Reference<css::drawing::framework::XResourceId> mxMainPaneId; 182 rtl::Reference<PresenterPaneContainer> mpPaneContainer; 183 sal_Int32 mnCurrentSlideIndex; 184 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide; 185 css::uno::Reference<css::drawing::XDrawPage> mxNextSlide; 186 ::rtl::Reference<PresenterWindowManager> mpWindowManager; 187 std::shared_ptr<PresenterTheme> mpTheme; 188 css::uno::Reference<css::awt::XWindow> mxMainWindow; 189 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter; 190 std::shared_ptr<PresenterCanvasHelper> mpCanvasHelper; 191 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 192 std::shared_ptr<PresenterPaintManager> mpPaintManager; 193 sal_Int32 mnPendingSlideNumber; 194 css::uno::Reference<css::util::XURLTransformer> mxUrlTransformer; 195 ::rtl::Reference<PresenterAccessible> mpAccessibleObject; 196 bool mbIsAccessibilityActive; 197 IPresentationTime* mpPresentationTime; 198 199 void GetSlides (const sal_Int32 nOffset); 200 void UpdateViews(); 201 void InitializeMainPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane); 202 void LoadTheme (const css::uno::Reference<css::drawing::framework::XPane>& rxPane); 203 void UpdatePendingSlideNumber (const sal_Int32 nPendingSlideNumber); 204 205 /** This method is called when the user pressed one of the numerical 206 keys. Depending on the modifier, numeric keys switch to another 207 slide (no modifier), or change to another view (Ctrl modifier). 208 @param nKey 209 Numeric value that is printed on the pressed key. For example 210 pressing the key '4' will result in the value 4, not the ASCII 211 code (0x34?). 212 @param nModifiers 213 The modifier bit field as provided by the key up event. 214 */ 215 void HandleNumericKeyPress (const sal_Int32 nKey, const sal_Int32 nModifiers); 216 }; 217 218 } // end of namespace ::sdext::presenter 219 220 #endif 221 222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 223