1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SDEXT_PRESENTER_CONTROLLER_HXX 25 #define SDEXT_PRESENTER_CONTROLLER_HXX 26 27 #include "PresenterAccessibility.hxx" 28 #include "PresenterPaneContainer.hxx" 29 #include "PresenterTheme.hxx" 30 #include "PresenterSprite.hxx" 31 #include <cppuhelper/compbase6.hxx> 32 #include <cppuhelper/basemutex.hxx> 33 #include <com/sun/star/awt/FontDescriptor.hpp> 34 #include <com/sun/star/awt/XFocusListener.hpp> 35 #include <com/sun/star/awt/XKeyListener.hpp> 36 #include <com/sun/star/awt/XMouseListener.hpp> 37 #include <com/sun/star/drawing/XPresenterHelper.hpp> 38 #include <com/sun/star/frame/XController.hpp> 39 #include <com/sun/star/frame/XDispatch.hpp> 40 #include <com/sun/star/beans/XPropertySet.hpp> 41 #include <com/sun/star/presentation/XSlideShowController.hpp> 42 #include <com/sun/star/presentation/XSlideShowListener.hpp> 43 #include <com/sun/star/frame/XFrameActionListener.hpp> 44 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp> 45 #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 46 #include <com/sun/star/drawing/framework/XPane.hpp> 47 #include <com/sun/star/uno/XComponentContext.hpp> 48 #include <com/sun/star/util/Color.hpp> 49 #include <com/sun/star/util/XURLTransformer.hpp> 50 #include <rtl/ref.hxx> 51 #include <map> 52 #include <vector> 53 #include <boost/function.hpp> 54 #include <boost/shared_ptr.hpp> 55 #include <boost/scoped_ptr.hpp> 56 57 namespace css = ::com::sun::star; 58 59 namespace sdext { namespace presenter { 60 61 class PresenterAnimator; 62 class PresenterCanvasHelper; 63 class PresenterPaintManager; 64 class PresenterPaneAnimator; 65 class PresenterPaneContainer; 66 class PresenterPaneBorderPainter; 67 class PresenterTheme; 68 class PresenterWindowManager; 69 70 namespace { 71 typedef ::cppu::WeakComponentImplHelper6 < 72 css::drawing::framework::XConfigurationChangeListener, 73 css::frame::XFrameActionListener, 74 css::awt::XKeyListener, 75 css::awt::XFocusListener, 76 css::awt::XMouseListener, 77 css::awt::XMouseMotionListener 78 > PresenterControllerInterfaceBase; 79 } 80 81 82 /** The controller of the presenter screen is responsible for telling the 83 individual views which slides to show. Additionally it provides access 84 to frequently used values of the current theme. 85 */ 86 class PresenterController 87 : protected ::cppu::BaseMutex, 88 public PresenterControllerInterfaceBase 89 { 90 public: 91 static ::rtl::Reference<PresenterController> Instance ( 92 const css::uno::Reference<css::frame::XFrame>& rxFrame); 93 94 PresenterController ( 95 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 96 const css::uno::Reference<css::frame::XController>& rxController, 97 const css::uno::Reference<css::presentation::XSlideShowController>& rxSlideShowController, 98 const rtl::Reference<PresenterPaneContainer>& rpPaneContainer, 99 const css::uno::Reference<css::drawing::framework::XResourceId>& rxMainPaneId); 100 ~PresenterController (void); 101 102 virtual void SAL_CALL disposing (void); 103 104 void UpdateCurrentSlide (const sal_Int32 nOffset); 105 106 SharedBitmapDescriptor 107 GetViewBackground (const ::rtl::OUString& rsViewURL) const; 108 PresenterTheme::SharedFontDescriptor 109 GetViewFont (const ::rtl::OUString& rsViewURL) const; 110 ::boost::shared_ptr<PresenterTheme> GetTheme (void) const; 111 ::rtl::Reference<PresenterWindowManager> GetWindowManager (void) const; 112 css::uno::Reference<css::presentation::XSlideShowController> 113 GetSlideShowController (void) const; 114 rtl::Reference<PresenterPaneContainer> GetPaneContainer (void) const; 115 ::rtl::Reference<PresenterPaneBorderPainter> GetPaneBorderPainter (void) const; 116 ::boost::shared_ptr<PresenterAnimator> GetAnimator (void) const; 117 ::boost::shared_ptr<PresenterCanvasHelper> GetCanvasHelper (void) const; 118 css::uno::Reference<css::drawing::XPresenterHelper> GetPresenterHelper (void) const; 119 ::boost::shared_ptr<PresenterPaintManager> GetPaintManager (void) const; 120 void HideSlideSorter (void); 121 double GetSlideAspectRatio (void) const; 122 void ShowView (const ::rtl::OUString& rsViewURL); 123 void HideView (const ::rtl::OUString& rsViewURL); 124 bool IsViewVisible (const ::rtl::OUString& rsViewURL) const; 125 void DispatchUnoCommand (const ::rtl::OUString& rsCommand) const; 126 css::uno::Reference<css::frame::XDispatch> GetDispatch ( 127 const css::util::URL& rURL) const; 128 css::util::URL CreateURLFromString (const ::rtl::OUString& rsURL) const; 129 css::uno::Reference<css::drawing::framework::XConfigurationController> 130 GetConfigurationController (void) const; 131 css::uno::Reference<css::drawing::XDrawPage> GetCurrentSlide (void) const; 132 ::rtl::Reference<PresenterAccessible> GetAccessible (void) const; 133 void SetAccessibilityActiveState (const bool bIsActive); 134 bool IsAccessibilityActive (void) const; 135 136 void HandleMouseClick (const css::awt::MouseEvent& rEvent); 137 void UpdatePaneTitles (void); 138 139 /** Request activation or deactivation of (some of) the views according 140 to the given parameters. 141 */ 142 void RequestViews ( 143 const bool bIsSlideSorterActive, 144 const bool bIsNotesViewActive, 145 const bool bIsHelpViewActive); 146 147 // XConfigurationChangeListener 148 149 virtual void SAL_CALL notifyConfigurationChange ( 150 const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent) 151 throw (com::sun::star::uno::RuntimeException); 152 153 154 // XEventListener 155 156 virtual void SAL_CALL disposing ( 157 const com::sun::star::lang::EventObject& rEvent) 158 throw (com::sun::star::uno::RuntimeException); 159 160 161 // XFrameActionListener 162 163 virtual void SAL_CALL frameAction ( 164 const css::frame::FrameActionEvent& rEvent) 165 throw (com::sun::star::uno::RuntimeException); 166 167 168 // XKeyListener 169 170 virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent) 171 throw (css::uno::RuntimeException); 172 virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent) 173 throw (css::uno::RuntimeException); 174 175 176 // XFocusListener 177 178 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent) 179 throw (css::uno::RuntimeException); 180 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent) 181 throw (css::uno::RuntimeException); 182 183 184 // XMouseListener 185 186 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) 187 throw (css::uno::RuntimeException); 188 189 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) 190 throw (css::uno::RuntimeException); 191 192 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) 193 throw (css::uno::RuntimeException); 194 195 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) 196 throw (css::uno::RuntimeException); 197 198 199 // XMouseMotionListener 200 201 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) 202 throw (css::uno::RuntimeException); 203 204 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) 205 throw (css::uno::RuntimeException); 206 207 private: 208 typedef ::std::map<css::uno::Reference<css::frame::XFrame>,rtl::Reference<PresenterController> > InstanceContainer; 209 static InstanceContainer maInstances; 210 211 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 212 css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas; 213 css::uno::Reference<css::frame::XController> mxController; 214 css::uno::Reference<css::drawing::framework::XConfigurationController> 215 mxConfigurationController; 216 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController; 217 css::uno::Reference<css::drawing::framework::XResourceId> mxMainPaneId; 218 rtl::Reference<PresenterPaneContainer> mpPaneContainer; 219 sal_Int32 mnCurrentSlideIndex; 220 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide; 221 css::uno::Reference<css::drawing::XDrawPage> mxNextSlide; 222 ::rtl::Reference<PresenterWindowManager> mpWindowManager; 223 ::boost::shared_ptr<PresenterPaneAnimator> mpCurrentPaneAnimation; 224 sal_Int32 mnWindowBackgroundColor; 225 ::boost::shared_ptr<PresenterTheme> mpTheme; 226 css::uno::Reference<css::awt::XWindow> mxMainWindow; 227 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter; 228 ::boost::shared_ptr<PresenterAnimator> mpAnimator; 229 ::boost::shared_ptr<PresenterCanvasHelper> mpCanvasHelper; 230 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 231 ::boost::shared_ptr<PresenterPaintManager> mpPaintManager; 232 sal_Int32 mnPendingSlideNumber; 233 css::uno::Reference<css::util::XURLTransformer> mxUrlTransformer; 234 ::rtl::Reference<PresenterAccessible> mpAccessibleObject; 235 bool mbIsAccessibilityActive; 236 237 void InitializePresenterScreen (void); 238 void InitializeSlideShowView (const css::uno::Reference<css::uno::XInterface>& rxView); 239 void GetSlides (const sal_Int32 nOffset); 240 void UpdateViews (void); 241 void InitializeMainPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane); 242 void LoadTheme (const css::uno::Reference<css::drawing::framework::XPane>& rxPane); 243 void UpdatePendingSlideNumber (const sal_Int32 nPendingSlideNumber); 244 245 /** This method is called when the user pressed one of the numerical 246 keys. Depending on the modifier, numeric keys switch to another 247 slide (no modifier), or change to another view (Ctrl modifier). 248 @param nKey 249 Numeric value that is printed on the pressed key. For example 250 pressing the key '4' will result in the value 4, not the ASCII 251 code (0x34?). 252 @param nModifiers 253 The modifier bit field as provided by the key up event. 254 */ 255 void HandleNumericKeyPress (const sal_Int32 nKey, const sal_Int32 nModifiers); 256 257 void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException); 258 }; 259 260 261 } } // end of namespace ::sdext::presenter 262 263 #endif 264