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