Updated core
[LibreOffice.git] / sdext / source / presenter / PresenterController.hxx
blobe8b4ec6c2c9ac5009c806b13f4898ce9434d8e06
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 SDEXT_PRESENTER_CONTROLLER_HXX
21 #define SDEXT_PRESENTER_CONTROLLER_HXX
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 <vector>
49 #include <boost/function.hpp>
50 #include <boost/shared_ptr.hpp>
51 #include <boost/scoped_ptr.hpp>
53 namespace sdext { namespace presenter {
55 class PresenterCanvasHelper;
56 class PresenterPaintManager;
57 class PresenterPaneAnimator;
58 class PresenterPaneContainer;
59 class PresenterPaneBorderPainter;
60 class PresenterTheme;
61 class PresenterWindowManager;
63 namespace {
64 typedef ::cppu::WeakComponentImplHelper6 <
65 css::drawing::framework::XConfigurationChangeListener,
66 css::frame::XFrameActionListener,
67 css::awt::XKeyListener,
68 css::awt::XFocusListener,
69 css::awt::XMouseListener,
70 css::awt::XMouseMotionListener
71 > PresenterControllerInterfaceBase;
74 /** The controller of the presenter screen is responsible for telling the
75 individual views which slides to show. Additionally it provides access
76 to frequently used values of the current theme.
78 class PresenterController
79 : protected ::cppu::BaseMutex,
80 public PresenterControllerInterfaceBase
82 public:
83 static ::rtl::Reference<PresenterController> Instance (
84 const css::uno::Reference<css::frame::XFrame>& rxFrame);
86 PresenterController (
87 const css::uno::WeakReference<css::lang::XEventListener> &rxScreen,
88 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
89 const css::uno::Reference<css::frame::XController>& rxController,
90 const css::uno::Reference<css::presentation::XSlideShowController>& rxSlideShowController,
91 const rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
92 const css::uno::Reference<css::drawing::framework::XResourceId>& rxMainPaneId);
93 ~PresenterController (void);
95 virtual void SAL_CALL disposing (void);
97 void UpdateCurrentSlide (const sal_Int32 nOffset);
99 SharedBitmapDescriptor
100 GetViewBackground (const OUString& rsViewURL) const;
101 PresenterTheme::SharedFontDescriptor
102 GetViewFont (const OUString& rsViewURL) const;
103 ::boost::shared_ptr<PresenterTheme> GetTheme (void) const;
104 ::rtl::Reference<PresenterWindowManager> GetWindowManager (void) const;
105 css::uno::Reference<css::presentation::XSlideShowController>
106 GetSlideShowController (void) const;
107 rtl::Reference<PresenterPaneContainer> GetPaneContainer (void) const;
108 ::rtl::Reference<PresenterPaneBorderPainter> GetPaneBorderPainter (void) const;
109 ::boost::shared_ptr<PresenterCanvasHelper> GetCanvasHelper (void) const;
110 css::uno::Reference<css::drawing::XPresenterHelper> GetPresenterHelper (void) const;
111 ::boost::shared_ptr<PresenterPaintManager> GetPaintManager (void) const;
112 void HideSlideSorter (void);
113 double GetSlideAspectRatio (void) const;
114 void ShowView (const OUString& rsViewURL);
115 void HideView (const OUString& rsViewURL);
116 void SwitchMonitors (void);
117 void DispatchUnoCommand (const OUString& rsCommand) const;
118 css::uno::Reference<css::frame::XDispatch> GetDispatch (
119 const css::util::URL& rURL) const;
120 css::util::URL CreateURLFromString (const OUString& rsURL) const;
121 css::uno::Reference<css::drawing::framework::XConfigurationController>
122 GetConfigurationController (void) const;
123 css::uno::Reference<css::drawing::XDrawPage> GetCurrentSlide (void) const;
124 void SetAccessibilityActiveState (const bool bIsActive);
125 bool IsAccessibilityActive (void) const;
127 void HandleMouseClick (const css::awt::MouseEvent& rEvent);
128 void UpdatePaneTitles (void);
130 /** Request activation or deactivation of (some of) the views according
131 to the given parameters.
133 void RequestViews (
134 const bool bIsSlideSorterActive,
135 const bool bIsNotesViewActive,
136 const bool bIsHelpViewActive);
138 // XConfigurationChangeListener
140 virtual void SAL_CALL notifyConfigurationChange (
141 const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
142 throw (com::sun::star::uno::RuntimeException);
144 // XEventListener
146 virtual void SAL_CALL disposing (
147 const com::sun::star::lang::EventObject& rEvent)
148 throw (com::sun::star::uno::RuntimeException);
150 // XFrameActionListener
152 virtual void SAL_CALL frameAction (
153 const css::frame::FrameActionEvent& rEvent)
154 throw (com::sun::star::uno::RuntimeException);
156 // XKeyListener
158 virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent)
159 throw (css::uno::RuntimeException);
160 virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent)
161 throw (css::uno::RuntimeException);
163 // XFocusListener
165 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent)
166 throw (css::uno::RuntimeException);
167 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent)
168 throw (css::uno::RuntimeException);
170 // XMouseListener
172 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
173 throw (css::uno::RuntimeException);
175 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
176 throw (css::uno::RuntimeException);
178 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
179 throw (css::uno::RuntimeException);
181 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
182 throw (css::uno::RuntimeException);
184 // XMouseMotionListener
186 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
187 throw (css::uno::RuntimeException);
189 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
190 throw (css::uno::RuntimeException);
192 private:
193 typedef ::std::map<css::uno::Reference<css::frame::XFrame>,rtl::Reference<PresenterController> > InstanceContainer;
194 static InstanceContainer maInstances;
196 css::uno::WeakReference<css::lang::XEventListener> mxScreen;
197 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
198 css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas;
199 css::uno::Reference<css::frame::XController> mxController;
200 css::uno::Reference<css::drawing::framework::XConfigurationController>
201 mxConfigurationController;
202 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
203 css::uno::Reference<css::drawing::framework::XResourceId> mxMainPaneId;
204 rtl::Reference<PresenterPaneContainer> mpPaneContainer;
205 sal_Int32 mnCurrentSlideIndex;
206 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
207 css::uno::Reference<css::drawing::XDrawPage> mxNextSlide;
208 ::rtl::Reference<PresenterWindowManager> mpWindowManager;
209 ::boost::shared_ptr<PresenterPaneAnimator> mpCurrentPaneAnimation;
210 sal_Int32 mnWindowBackgroundColor;
211 ::boost::shared_ptr<PresenterTheme> mpTheme;
212 css::uno::Reference<css::awt::XWindow> mxMainWindow;
213 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter;
214 ::boost::shared_ptr<PresenterCanvasHelper> mpCanvasHelper;
215 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
216 ::boost::shared_ptr<PresenterPaintManager> mpPaintManager;
217 sal_Int32 mnPendingSlideNumber;
218 css::uno::Reference<css::util::XURLTransformer> mxUrlTransformer;
219 ::rtl::Reference<PresenterAccessible> mpAccessibleObject;
220 bool mbIsAccessibilityActive;
222 void InitializePresenterScreen (void);
223 void InitializeSlideShowView (const css::uno::Reference<css::uno::XInterface>& rxView);
224 void GetSlides (const sal_Int32 nOffset);
225 void UpdateViews (void);
226 void InitializeMainPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
227 void LoadTheme (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
228 void UpdatePendingSlideNumber (const sal_Int32 nPendingSlideNumber);
230 /** This method is called when the user pressed one of the numerical
231 keys. Depending on the modifier, numeric keys switch to another
232 slide (no modifier), or change to another view (Ctrl modifier).
233 @param nKey
234 Numeric value that is printed on the pressed key. For example
235 pressing the key '4' will result in the value 4, not the ASCII
236 code (0x34?).
237 @param nModifiers
238 The modifier bit field as provided by the key up event.
240 void HandleNumericKeyPress (const sal_Int32 nKey, const sal_Int32 nModifiers);
242 void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
245 } } // end of namespace ::sdext::presenter
247 #endif
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */