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 152 153 // XEventListener 154 155 virtual void SAL_CALL disposing ( 156 const com::sun::star::lang::EventObject& rEvent); 157 158 159 // XFrameActionListener 160 161 virtual void SAL_CALL frameAction ( 162 const css::frame::FrameActionEvent& rEvent); 163 164 165 // XKeyListener 166 167 virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent); 168 virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent); 169 170 171 // XFocusListener 172 173 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent); 174 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent); 175 176 177 // XMouseListener 178 179 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent); 180 181 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent); 182 183 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent); 184 185 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent); 186 187 188 // XMouseMotionListener 189 190 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent); 191 192 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent); 193 194 private: 195 typedef ::std::map<css::uno::Reference<css::frame::XFrame>,rtl::Reference<PresenterController> > InstanceContainer; 196 static InstanceContainer maInstances; 197 198 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 199 css::uno::Reference<css::rendering::XSpriteCanvas> mxCanvas; 200 css::uno::Reference<css::frame::XController> mxController; 201 css::uno::Reference<css::drawing::framework::XConfigurationController> 202 mxConfigurationController; 203 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController; 204 css::uno::Reference<css::drawing::framework::XResourceId> mxMainPaneId; 205 rtl::Reference<PresenterPaneContainer> mpPaneContainer; 206 sal_Int32 mnCurrentSlideIndex; 207 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide; 208 css::uno::Reference<css::drawing::XDrawPage> mxNextSlide; 209 ::rtl::Reference<PresenterWindowManager> mpWindowManager; 210 ::boost::shared_ptr<PresenterPaneAnimator> mpCurrentPaneAnimation; 211 sal_Int32 mnWindowBackgroundColor; 212 ::boost::shared_ptr<PresenterTheme> mpTheme; 213 css::uno::Reference<css::awt::XWindow> mxMainWindow; 214 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter; 215 ::boost::shared_ptr<PresenterAnimator> mpAnimator; 216 ::boost::shared_ptr<PresenterCanvasHelper> mpCanvasHelper; 217 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 218 ::boost::shared_ptr<PresenterPaintManager> mpPaintManager; 219 sal_Int32 mnPendingSlideNumber; 220 css::uno::Reference<css::util::XURLTransformer> mxUrlTransformer; 221 ::rtl::Reference<PresenterAccessible> mpAccessibleObject; 222 bool mbIsAccessibilityActive; 223 224 void InitializePresenterScreen (void); 225 void InitializeSlideShowView (const css::uno::Reference<css::uno::XInterface>& rxView); 226 void GetSlides (const sal_Int32 nOffset); 227 void UpdateViews (void); 228 void InitializeMainPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane); 229 void LoadTheme (const css::uno::Reference<css::drawing::framework::XPane>& rxPane); 230 void UpdatePendingSlideNumber (const sal_Int32 nPendingSlideNumber); 231 232 /** This method is called when the user pressed one of the numerical 233 keys. Depending on the modifier, numeric keys switch to another 234 slide (no modifier), or change to another view (Ctrl modifier). 235 @param nKey 236 Numeric value that is printed on the pressed key. For example 237 pressing the key '4' will result in the value 4, not the ASCII 238 code (0x34?). 239 @param nModifiers 240 The modifier bit field as provided by the key up event. 241 */ 242 void HandleNumericKeyPress (const sal_Int32 nKey, const sal_Int32 nModifiers); 243 244 void ThrowIfDisposed (void) const; 245 }; 246 247 248 } } // end of namespace ::sdext::presenter 249 250 #endif 251