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