1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SDEXT_PRESENTER_TOOL_BAR_HXX 29 #define SDEXT_PRESENTER_TOOL_BAR_HXX 30 31 #include "PresenterController.hxx" 32 #include "PresenterViewFactory.hxx" 33 34 #include <cppuhelper/basemutex.hxx> 35 #include <cppuhelper/compbase3.hxx> 36 #include <cppuhelper/compbase5.hxx> 37 #include <com/sun/star/awt/ActionEvent.hpp> 38 #include <com/sun/star/awt/XActionListener.hpp> 39 #include <com/sun/star/awt/XButton.hpp> 40 #include <com/sun/star/awt/XControl.hpp> 41 #include <com/sun/star/awt/XControlContainer.hpp> 42 #include <com/sun/star/awt/XFixedText.hpp> 43 #include <com/sun/star/awt/XMouseListener.hpp> 44 #include <com/sun/star/awt/XMouseMotionListener.hpp> 45 #include <com/sun/star/awt/XPaintListener.hpp> 46 #include <com/sun/star/awt/XWindowListener.hpp> 47 #include <com/sun/star/container/XNameAccess.hpp> 48 #include <com/sun/star/drawing/XDrawPage.hpp> 49 #include <com/sun/star/drawing/XDrawView.hpp> 50 #include <com/sun/star/drawing/XPresenterHelper.hpp> 51 #include <com/sun/star/drawing/framework/XView.hpp> 52 #include <com/sun/star/drawing/framework/XResourceId.hpp> 53 #include <com/sun/star/frame/XController.hpp> 54 #include <map> 55 #include <boost/scoped_ptr.hpp> 56 #include <boost/function.hpp> 57 #include <boost/noncopyable.hpp> 58 59 namespace css = ::com::sun::star; 60 61 namespace { 62 typedef cppu::WeakComponentImplHelper5< 63 css::awt::XWindowListener, 64 css::awt::XPaintListener, 65 css::awt::XMouseListener, 66 css::awt::XMouseMotionListener, 67 css::drawing::XDrawView 68 > PresenterToolBarInterfaceBase; 69 70 typedef cppu::WeakComponentImplHelper3< 71 css::awt::XPaintListener, 72 css::drawing::framework::XView, 73 css::drawing::XDrawView 74 > PresenterToolBarViewInterfaceBase; 75 } 76 77 namespace sdext { namespace presenter { 78 79 /** A simple tool bar that can display bitmapped buttons and labels. At the 80 moment there are buttons for moving to the next and previous slide and 81 to the next effect. A label displayes the index of the current slide 82 and the total number of slides. 83 */ 84 class PresenterToolBar 85 : private ::cppu::BaseMutex, 86 private ::boost::noncopyable, 87 public PresenterToolBarInterfaceBase, 88 public CachablePresenterView 89 { 90 public: 91 typedef ::boost::function<void(void)> Action; 92 93 enum Anchor { Left, Center, Right }; 94 95 PresenterToolBar ( 96 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 97 const css::uno::Reference<css::awt::XWindow>& rxWindow, 98 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 99 const ::rtl::Reference<PresenterController>& rpPresenterController, 100 const Anchor eAnchor); 101 virtual ~PresenterToolBar (void); 102 103 void Initialize ( 104 const ::rtl::OUString& rsConfigurationPath); 105 106 virtual void SAL_CALL disposing (void); 107 108 void InvalidateArea ( 109 const css::awt::Rectangle& rRepaintBox, 110 const bool bSynchronous); 111 sal_Int32 GetSlideCount (void); 112 sal_Int32 GetCurrentSlideIndex (void); 113 void RequestLayout (void); 114 css::geometry::RealSize2D GetSize (void); 115 css::geometry::RealSize2D GetMinimalSize (void); 116 ::rtl::Reference<PresenterController> GetPresenterController (void) const; 117 css::uno::Reference<css::awt::XWindow> GetWindow (void) const; 118 css::uno::Reference<css::uno::XComponentContext> GetComponentContext (void) const; 119 120 // lang::XEventListener 121 122 virtual void SAL_CALL 123 disposing (const css::lang::EventObject& rEventObject) 124 throw (css::uno::RuntimeException); 125 126 127 // XWindowListener 128 129 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) 130 throw (css::uno::RuntimeException); 131 132 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) 133 throw (css::uno::RuntimeException); 134 135 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) 136 throw (css::uno::RuntimeException); 137 138 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) 139 throw (css::uno::RuntimeException); 140 141 142 // XPaintListener 143 144 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) 145 throw (css::uno::RuntimeException); 146 147 148 // XMouseListener 149 150 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) 151 throw (css::uno::RuntimeException); 152 153 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) 154 throw (css::uno::RuntimeException); 155 156 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) 157 throw (css::uno::RuntimeException); 158 159 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) 160 throw (css::uno::RuntimeException); 161 162 163 // XMouseMotionListener 164 165 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) 166 throw (css::uno::RuntimeException); 167 168 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) 169 throw (css::uno::RuntimeException); 170 171 172 // XDrawView 173 174 virtual void SAL_CALL setCurrentPage ( 175 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) 176 throw (css::uno::RuntimeException); 177 178 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void) 179 throw (css::uno::RuntimeException); 180 181 class Context; 182 183 private: 184 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 185 186 class ElementContainerPart; 187 typedef ::boost::shared_ptr<ElementContainerPart> SharedElementContainerPart; 188 typedef ::std::vector<SharedElementContainerPart> ElementContainer; 189 ElementContainer maElementContainer; 190 SharedElementContainerPart mpCurrentContainerPart; 191 css::uno::Reference<css::awt::XWindow> mxWindow; 192 css::uno::Reference<css::rendering::XCanvas> mxCanvas; 193 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController; 194 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide; 195 ::rtl::Reference<PresenterController> mpPresenterController; 196 bool mbIsLayoutPending; 197 const Anchor meAnchor; 198 css::geometry::RealRectangle2D maBoundingBox; 199 /** The minimal size that is necessary to display all elements without 200 overlap and with minimal gaps between them. 201 */ 202 css::geometry::RealSize2D maMinimalSize; 203 204 void CreateControls ( 205 const ::rtl::OUString& rsConfigurationPath); 206 void Layout (const css::uno::Reference<css::rendering::XCanvas>& rxCanvas); 207 css::geometry::RealSize2D CalculatePartSize ( 208 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 209 const SharedElementContainerPart& rpPart, 210 const bool bIsHorizontal); 211 void LayoutPart ( 212 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 213 const SharedElementContainerPart& rpPart, 214 const css::geometry::RealRectangle2D& rBoundingBox, 215 const css::geometry::RealSize2D& rPartSize, 216 const bool bIsHorizontal); 217 void Clear ( 218 const css::awt::Rectangle& rUpdateBox, 219 const css::rendering::ViewState& rViewState); 220 void Paint ( 221 const css::awt::Rectangle& rUpdateBox, 222 const css::rendering::ViewState& rViewState); 223 224 void UpdateSlideNumber (void); 225 226 void CheckMouseOver ( 227 const css::awt::MouseEvent& rEvent, 228 const bool bOverWindow, 229 const bool bMouseDown=false); 230 231 void ProcessEntry ( 232 const ::css::uno::Reference<css::beans::XPropertySet>& rProperties, 233 Context& rContext); 234 235 /** This method throws a DisposedException when the object has already been 236 disposed. 237 */ 238 void ThrowIfDisposed (void) const 239 throw (css::lang::DisposedException); 240 }; 241 242 243 244 245 /** View for the PresenterToolBar. 246 */ 247 class PresenterToolBarView 248 : private ::cppu::BaseMutex, 249 private ::boost::noncopyable, 250 public PresenterToolBarViewInterfaceBase 251 { 252 public: 253 explicit PresenterToolBarView ( 254 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 255 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 256 const css::uno::Reference<css::frame::XController>& rxController, 257 const ::rtl::Reference<PresenterController>& rpPresenterController); 258 virtual ~PresenterToolBarView (void); 259 260 virtual void SAL_CALL disposing (void); 261 262 ::rtl::Reference<PresenterToolBar> GetPresenterToolBar (void) const; 263 264 265 // XPaintListener 266 267 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) 268 throw (css::uno::RuntimeException); 269 270 271 // lang::XEventListener 272 273 virtual void SAL_CALL 274 disposing (const css::lang::EventObject& rEventObject) 275 throw (css::uno::RuntimeException); 276 277 278 // XResourceId 279 280 virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void) 281 throw (css::uno::RuntimeException); 282 283 virtual sal_Bool SAL_CALL isAnchorOnly (void) 284 throw (com::sun::star::uno::RuntimeException); 285 286 287 // XDrawView 288 289 virtual void SAL_CALL setCurrentPage ( 290 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) 291 throw (css::uno::RuntimeException); 292 293 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void) 294 throw (css::uno::RuntimeException); 295 296 private: 297 // css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 298 css::uno::Reference<css::drawing::framework::XPane> mxPane; 299 css::uno::Reference<css::drawing::framework::XResourceId> mxViewId; 300 css::uno::Reference<css::awt::XWindow> mxWindow; 301 css::uno::Reference<css::rendering::XCanvas> mxCanvas; 302 ::rtl::Reference<PresenterController> mpPresenterController; 303 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController; 304 ::rtl::Reference<PresenterToolBar> mpToolBar; 305 306 /** This method throws a DisposedException when the object has already been 307 disposed. 308 */ 309 void ThrowIfDisposed (void) const 310 throw (css::lang::DisposedException); 311 }; 312 313 } } // end of namespace ::sdext::presenter 314 315 #endif 316