update dev300-m58
[ooovba.git] / sdext / source / presenter / PresenterController.hxx
blobfee3fc625bb9c15624aa973337649636e87c29fd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterController.hxx,v $
11 * $Revision: 1.4 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SDEXT_PRESENTER_CONTROLLER_HXX
33 #define SDEXT_PRESENTER_CONTROLLER_HXX
35 #include "PresenterTheme.hxx"
36 #include "PresenterSprite.hxx"
37 #include <cppuhelper/compbase6.hxx>
38 #include <cppuhelper/basemutex.hxx>
39 #include <com/sun/star/awt/FontDescriptor.hpp>
40 #include <com/sun/star/awt/XFocusListener.hpp>
41 #include <com/sun/star/awt/XKeyListener.hpp>
42 #include <com/sun/star/awt/XMouseListener.hpp>
43 #include <com/sun/star/drawing/XPresenterHelper.hpp>
44 #include <com/sun/star/frame/XController.hpp>
45 #include <com/sun/star/frame/XDispatch.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/presentation/XSlideShowController.hpp>
48 #include <com/sun/star/presentation/XSlideShowListener.hpp>
49 #include <com/sun/star/frame/XFrameActionListener.hpp>
50 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
51 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
52 #include <com/sun/star/drawing/framework/XPane.hpp>
53 #include <com/sun/star/uno/XComponentContext.hpp>
54 #include <com/sun/star/util/Color.hpp>
55 #include <com/sun/star/util/XURLTransformer.hpp>
56 #include <rtl/ref.hxx>
57 #include <map>
58 #include <vector>
59 #include <boost/function.hpp>
60 #include <boost/shared_ptr.hpp>
61 #include <boost/scoped_ptr.hpp>
63 namespace css = ::com::sun::star;
65 namespace sdext { namespace presenter {
67 class PresenterAnimator;
68 class PresenterCanvasHelper;
69 class PresenterPaintManager;
70 class PresenterPaneAnimator;
71 class PresenterPaneContainer;
72 class PresenterPaneBorderPainter;
73 class PresenterTheme;
74 class PresenterWindowManager;
76 namespace {
77 typedef ::cppu::WeakComponentImplHelper6 <
78 css::drawing::framework::XConfigurationChangeListener,
79 css::frame::XFrameActionListener,
80 css::awt::XKeyListener,
81 css::awt::XFocusListener,
82 css::awt::XMouseListener,
83 css::awt::XMouseMotionListener
84 > PresenterControllerInterfaceBase;
88 /** The controller of the presenter screen is responsible for telling the
89 individual views which slides to show. Additionally it provides access
90 to frequently used values of the current theme.
92 class PresenterController
93 : protected ::cppu::BaseMutex,
94 public PresenterControllerInterfaceBase
96 public:
97 static ::rtl::Reference<PresenterController> Instance (
98 const css::uno::Reference<css::frame::XFrame>& rxFrame);
100 PresenterController (
101 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
102 const css::uno::Reference<css::frame::XController>& rxController,
103 const css::uno::Reference<css::presentation::XSlideShowController>& rxSlideShowController,
104 const rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
105 const css::uno::Reference<css::drawing::framework::XResourceId>& rxMainPaneId);
106 ~PresenterController (void);
108 virtual void SAL_CALL disposing (void);
110 void UpdateCurrentSlide (const sal_Int32 nOffset);
112 SharedBitmapDescriptor
113 GetViewBackground (const ::rtl::OUString& rsViewURL) const;
114 PresenterTheme::SharedFontDescriptor
115 GetViewFont (const ::rtl::OUString& rsViewURL) const;
116 ::boost::shared_ptr<PresenterTheme> GetTheme (void) const;
117 ::rtl::Reference<PresenterWindowManager> GetWindowManager (void) const;
118 css::uno::Reference<css::presentation::XSlideShowController>
119 GetSlideShowController (void) const;
120 rtl::Reference<PresenterPaneContainer> GetPaneContainer (void) const;
121 ::rtl::Reference<PresenterPaneBorderPainter> GetPaneBorderPainter (void) const;
122 ::boost::shared_ptr<PresenterAnimator> GetAnimator (void) const;
123 ::boost::shared_ptr<PresenterCanvasHelper> GetCanvasHelper (void) const;
124 css::uno::Reference<css::drawing::XPresenterHelper> GetPresenterHelper (void) const;
125 ::boost::shared_ptr<PresenterPaintManager> GetPaintManager (void) const;
126 void HideSlideSorter (void);
127 double GetSlideAspectRatio (void) const;
128 void ShowView (const ::rtl::OUString& rsViewURL);
129 void HideView (const ::rtl::OUString& rsViewURL);
130 bool IsViewVisible (const ::rtl::OUString& rsViewURL) const;
131 void DispatchUnoCommand (const ::rtl::OUString& rsCommand) const;
132 css::uno::Reference<css::frame::XDispatch> GetDispatch (
133 const css::util::URL& rURL) const;
134 css::util::URL CreateURLFromString (const ::rtl::OUString& rsURL) const;
135 css::uno::Reference<css::drawing::framework::XConfigurationController>
136 GetConfigurationController (void) const;
137 css::uno::Reference<css::drawing::XDrawPage> GetCurrentSlide (void) const;
139 void HandleMouseClick (const css::awt::MouseEvent& rEvent);
140 void UpdatePaneTitles (void);
142 /** Request activation or deactivation of (some of) the views according
143 to the given parameters.
145 void RequestViews (
146 const bool bIsSlideSorterActive,
147 const bool bIsNotesViewActive,
148 const bool bIsHelpViewActive);
150 // XConfigurationChangeListener
152 virtual void SAL_CALL notifyConfigurationChange (
153 const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
154 throw (com::sun::star::uno::RuntimeException);
157 // XEventListener
159 virtual void SAL_CALL disposing (
160 const com::sun::star::lang::EventObject& rEvent)
161 throw (com::sun::star::uno::RuntimeException);
164 // XFrameActionListener
166 virtual void SAL_CALL frameAction (
167 const css::frame::FrameActionEvent& rEvent)
168 throw (com::sun::star::uno::RuntimeException);
171 // XKeyListener
173 virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent)
174 throw (css::uno::RuntimeException);
175 virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent)
176 throw (css::uno::RuntimeException);
179 // XFocusListener
181 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent)
182 throw (css::uno::RuntimeException);
183 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent)
184 throw (css::uno::RuntimeException);
187 // XMouseListener
189 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
190 throw (css::uno::RuntimeException);
192 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
193 throw (css::uno::RuntimeException);
195 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
196 throw (css::uno::RuntimeException);
198 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
199 throw (css::uno::RuntimeException);
202 // XMouseMotionListener
204 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent)
205 throw (css::uno::RuntimeException);
207 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent)
208 throw (css::uno::RuntimeException);
210 private:
211 typedef ::std::map<css::uno::Reference<css::frame::XFrame>,rtl::Reference<PresenterController> > InstanceContainer;
212 static InstanceContainer maInstances;
214 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
215 css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas;
216 css::uno::Reference<css::frame::XController> mxController;
217 css::uno::Reference<css::drawing::framework::XConfigurationController>
218 mxConfigurationController;
219 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController;
220 css::uno::Reference<css::drawing::framework::XResourceId> mxMainPaneId;
221 rtl::Reference<PresenterPaneContainer> mpPaneContainer;
222 sal_Int32 mnCurrentSlideIndex;
223 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide;
224 css::uno::Reference<css::drawing::XDrawPage> mxNextSlide;
225 ::rtl::Reference<PresenterWindowManager> mpWindowManager;
226 ::boost::shared_ptr<PresenterPaneAnimator> mpCurrentPaneAnimation;
227 sal_Int32 mnWindowBackgroundColor;
228 ::boost::shared_ptr<PresenterTheme> mpTheme;
229 css::uno::Reference<css::awt::XWindow> mxMainWindow;
230 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter;
231 ::boost::shared_ptr<PresenterAnimator> mpAnimator;
232 ::boost::shared_ptr<PresenterCanvasHelper> mpCanvasHelper;
233 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
234 ::boost::shared_ptr<PresenterPaintManager> mpPaintManager;
235 sal_Int32 mnPendingSlideNumber;
236 css::uno::Reference<css::util::XURLTransformer> mxUrlTransformer;
238 void InitializePresenterScreen (void);
239 void InitializeSlideShowView (const css::uno::Reference<css::uno::XInterface>& rxView);
240 void GetSlides (const sal_Int32 nOffset);
241 void UpdateViews (void);
242 void InitializeMainPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
243 void LoadTheme (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
244 void UpdatePendingSlideNumber (const sal_Int32 nPendingSlideNumber);
246 /** This method is called when the user pressed one of the numerical
247 keys. Depending on the modifier, numeric keys switch to another
248 slide (no modifier), or change to another view (Ctrl modifier).
249 @param nKey
250 Numeric value that is printed on the pressed key. For example
251 pressing the key '4' will result in the value 4, not the ASCII
252 code (0x34?).
253 @param nModifiers
254 The modifier bit field as provided by the key up event.
256 void HandleNumericKeyPress (const sal_Int32 nKey, const sal_Int32 nModifiers);
258 void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
262 } } // end of namespace ::sdext::presenter
264 #endif