Line data Source code
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 "PresenterSprite.hxx"
27 : #include <cppuhelper/compbase6.hxx>
28 : #include <cppuhelper/basemutex.hxx>
29 : #include <com/sun/star/awt/FontDescriptor.hpp>
30 : #include <com/sun/star/awt/XFocusListener.hpp>
31 : #include <com/sun/star/awt/XKeyListener.hpp>
32 : #include <com/sun/star/awt/XMouseListener.hpp>
33 : #include <com/sun/star/drawing/XPresenterHelper.hpp>
34 : #include <com/sun/star/frame/XController.hpp>
35 : #include <com/sun/star/frame/XDispatch.hpp>
36 : #include <com/sun/star/beans/XPropertySet.hpp>
37 : #include <com/sun/star/presentation/XSlideShowController.hpp>
38 : #include <com/sun/star/presentation/XSlideShowListener.hpp>
39 : #include <com/sun/star/frame/XFrameActionListener.hpp>
40 : #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
41 : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
42 : #include <com/sun/star/drawing/framework/XPane.hpp>
43 : #include <com/sun/star/uno/XComponentContext.hpp>
44 : #include <com/sun/star/util/Color.hpp>
45 : #include <com/sun/star/util/XURLTransformer.hpp>
46 : #include <rtl/ref.hxx>
47 : #include <map>
48 : #include <boost/shared_ptr.hpp>
49 :
50 : namespace sdext { namespace presenter {
51 :
52 : class PresenterCanvasHelper;
53 : class PresenterPaintManager;
54 : class PresenterPaneAnimator;
55 : class PresenterPaneContainer;
56 : class PresenterPaneBorderPainter;
57 : class PresenterTheme;
58 : class PresenterWindowManager;
59 :
60 : namespace {
61 : typedef ::cppu::WeakComponentImplHelper6 <
62 : css::drawing::framework::XConfigurationChangeListener,
63 : css::frame::XFrameActionListener,
64 : css::awt::XKeyListener,
65 : css::awt::XFocusListener,
66 : css::awt::XMouseListener,
67 : css::awt::XMouseMotionListener
68 : > PresenterControllerInterfaceBase;
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 (void);
91 :
92 : virtual void SAL_CALL disposing (void) SAL_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 : ::boost::shared_ptr<PresenterTheme> GetTheme (void) const;
101 : ::rtl::Reference<PresenterWindowManager> GetWindowManager (void) const;
102 : css::uno::Reference<css::presentation::XSlideShowController>
103 : GetSlideShowController (void) const;
104 : rtl::Reference<PresenterPaneContainer> GetPaneContainer (void) const;
105 : ::rtl::Reference<PresenterPaneBorderPainter> GetPaneBorderPainter (void) const;
106 : ::boost::shared_ptr<PresenterCanvasHelper> GetCanvasHelper (void) const;
107 : css::uno::Reference<css::drawing::XPresenterHelper> GetPresenterHelper (void) const;
108 : ::boost::shared_ptr<PresenterPaintManager> GetPaintManager (void) const;
109 : void HideSlideSorter (void);
110 : double GetSlideAspectRatio (void) const;
111 : void ShowView (const OUString& rsViewURL);
112 : void HideView (const OUString& rsViewURL);
113 : void SwitchMonitors (void);
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 : css::uno::Reference<css::drawing::framework::XConfigurationController>
119 : GetConfigurationController (void) const;
120 : css::uno::Reference<css::drawing::XDrawPage> GetCurrentSlide (void) const;
121 : bool HasTransition (css::uno::Reference<css::drawing::XDrawPage>& rxPage);
122 : bool HasCustomAnimation (css::uno::Reference<css::drawing::XDrawPage>& rxPage);
123 : void SetAccessibilityActiveState (const bool bIsActive);
124 0 : bool IsAccessibilityActive (void) const { return mbIsAccessibilityActive;}
125 :
126 : void HandleMouseClick (const css::awt::MouseEvent& rEvent);
127 : void UpdatePaneTitles (void);
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 : // XConfigurationChangeListener
138 :
139 : virtual void SAL_CALL notifyConfigurationChange (
140 : const css::drawing::framework::ConfigurationChangeEvent& rEvent)
141 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 :
143 : // XEventListener
144 :
145 : virtual void SAL_CALL disposing (
146 : const css::lang::EventObject& rEvent)
147 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 :
149 : // XFrameActionListener
150 :
151 : virtual void SAL_CALL frameAction (
152 : const css::frame::FrameActionEvent& rEvent)
153 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 :
155 : // XKeyListener
156 :
157 : virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent)
158 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 : virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent)
160 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 :
162 : // XFocusListener
163 :
164 : virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent)
165 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 : virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent)
167 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 :
169 : // XMouseListener
170 :
171 : virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
172 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 :
174 : virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
175 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 :
177 : virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
178 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 :
180 : virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
181 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
182 :
183 : // XMouseMotionListener
184 :
185 : virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
186 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 :
188 : virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
189 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
190 :
191 : private:
192 : typedef ::std::map<css::uno::Reference<css::frame::XFrame>,rtl::Reference<PresenterController> > InstanceContainer;
193 : static InstanceContainer maInstances;
194 :
195 : css::uno::WeakReference<css::lang::XEventListener> mxScreen;
196 : css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
197 : css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas;
198 : css::uno::Reference<css::frame::XController> mxController;
199 : css::uno::Reference<css::drawing::framework::XConfigurationController>
200 : mxConfigurationController;
201 : css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
202 : css::uno::Reference<css::drawing::framework::XResourceId> mxMainPaneId;
203 : rtl::Reference<PresenterPaneContainer> mpPaneContainer;
204 : sal_Int32 mnCurrentSlideIndex;
205 : css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
206 : css::uno::Reference<css::drawing::XDrawPage> mxNextSlide;
207 : ::rtl::Reference<PresenterWindowManager> mpWindowManager;
208 : ::boost::shared_ptr<PresenterPaneAnimator> mpCurrentPaneAnimation;
209 : sal_Int32 mnWindowBackgroundColor;
210 : ::boost::shared_ptr<PresenterTheme> mpTheme;
211 : css::uno::Reference<css::awt::XWindow> mxMainWindow;
212 : ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter;
213 : ::boost::shared_ptr<PresenterCanvasHelper> mpCanvasHelper;
214 : css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
215 : ::boost::shared_ptr<PresenterPaintManager> mpPaintManager;
216 : sal_Int32 mnPendingSlideNumber;
217 : css::uno::Reference<css::util::XURLTransformer> mxUrlTransformer;
218 : ::rtl::Reference<PresenterAccessible> mpAccessibleObject;
219 : bool mbIsAccessibilityActive;
220 :
221 : void InitializePresenterScreen (void);
222 : void InitializeSlideShowView (const css::uno::Reference<css::uno::XInterface>& rxView);
223 : void GetSlides (const sal_Int32 nOffset);
224 : void UpdateViews (void);
225 : void InitializeMainPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
226 : void LoadTheme (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
227 : void UpdatePendingSlideNumber (const sal_Int32 nPendingSlideNumber);
228 :
229 : /** This method is called when the user pressed one of the numerical
230 : keys. Depending on the modifier, numeric keys switch to another
231 : slide (no modifier), or change to another view (Ctrl modifier).
232 : @param nKey
233 : Numeric value that is printed on the pressed key. For example
234 : pressing the key '4' will result in the value 4, not the ASCII
235 : code (0x34?).
236 : @param nModifiers
237 : The modifier bit field as provided by the key up event.
238 : */
239 : void HandleNumericKeyPress (const sal_Int32 nKey, const sal_Int32 nModifiers);
240 :
241 : void ThrowIfDisposed (void) const throw (css::lang::DisposedException);
242 : };
243 :
244 : } } // end of namespace ::sdext::presenter
245 :
246 : #endif
247 :
248 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|