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 #ifndef INCLUDED_SLIDESHOW_SHAPEMANAGERIMPL_HXX 28 #define INCLUDED_SLIDESHOW_SHAPEMANAGERIMPL_HXX 29 30 #include <osl/mutex.hxx> 31 #include <cppuhelper/interfacecontainer.h> 32 #include <com/sun/star/presentation/XShapeEventListener.hpp> 33 34 #include "shape.hxx" 35 #include "subsettableshapemanager.hxx" 36 #include "eventmultiplexer.hxx" 37 #include "layermanager.hxx" 38 #include "viewupdate.hxx" 39 #include "shapemaps.hxx" 40 #include "cursormanager.hxx" 41 #include "hyperlinkarea.hxx" 42 #include "listenercontainer.hxx" 43 #include "shapelistenereventhandler.hxx" 44 #include "mouseeventhandler.hxx" 45 46 #include <boost/shared_ptr.hpp> 47 #include <boost/enable_shared_from_this.hpp> 48 #include <boost/noncopyable.hpp> 49 #include <set> 50 #include <map> 51 52 namespace slideshow { 53 namespace internal { 54 55 /** Listener class for shape events 56 57 This helper class registers itself on each view, and 58 broadcasts the XShapeEventListener events. The mouse motion 59 events are needed for setting the shape cursor. 60 */ 61 class ShapeManagerImpl : public SubsettableShapeManager, 62 public ShapeListenerEventHandler, 63 public MouseEventHandler, 64 public ViewUpdate, 65 public boost::enable_shared_from_this<ShapeManagerImpl>, 66 private boost::noncopyable 67 { 68 public: 69 /** Create a shape event broadcaster 70 71 @param rEventMultiplexer 72 The slideshow-global event source, where this class 73 registeres its event handlers. 74 */ 75 ShapeManagerImpl( EventMultiplexer& rMultiplexer, 76 LayerManagerSharedPtr const& rLayerManager, 77 CursorManager& rCursorManager, 78 const ShapeEventListenerMap& rGlobalListenersMap, 79 const ShapeCursorMap& rGlobalCursorMap ); 80 81 /** Enables event listening. 82 83 @param bSlideBackgoundPainted 84 When true, the initial slide content on the background layer 85 is already rendered (e.g. from a previous slide 86 transition). When false, slide renders initial content of 87 slide. 88 */ 89 void activate( bool bSlideBackgoundPainted ); 90 91 /** Disables event listening. 92 */ 93 void deactivate(); 94 95 // Disposable interface 96 // --------------------------------------------------------------- 97 98 virtual void dispose(); 99 100 private: 101 102 // MouseEventHandler interface 103 // --------------------------------------------------------------- 104 105 virtual bool handleMousePressed( 106 ::com::sun::star::awt::MouseEvent const& evt ); 107 virtual bool handleMouseReleased( 108 ::com::sun::star::awt::MouseEvent const& evt ); 109 virtual bool handleMouseEntered( 110 ::com::sun::star::awt::MouseEvent const& evt ); 111 virtual bool handleMouseExited( 112 ::com::sun::star::awt::MouseEvent const& evt ); 113 virtual bool handleMouseDragged( 114 ::com::sun::star::awt::MouseEvent const& evt ); 115 virtual bool handleMouseMoved( 116 ::com::sun::star::awt::MouseEvent const& evt ); 117 118 119 // ViewUpdate interface 120 // ------------------------------------------------------------------- 121 122 virtual bool update(); 123 virtual bool update( ViewSharedPtr const& rView ); 124 virtual bool needsUpdate() const; 125 126 127 // ShapeManager interface 128 // --------------------------------------------------- 129 130 virtual void enterAnimationMode( const AnimatableShapeSharedPtr& rShape ); 131 virtual void leaveAnimationMode( const AnimatableShapeSharedPtr& rShape ); 132 virtual void notifyShapeUpdate( const ShapeSharedPtr& rShape ); 133 virtual ShapeSharedPtr lookupShape( 134 ::com::sun::star::uno::Reference< 135 ::com::sun::star::drawing::XShape > const & xShape ) const; 136 virtual void addHyperlinkArea( const boost::shared_ptr<HyperlinkArea>& rArea ); 137 virtual void removeHyperlinkArea( const boost::shared_ptr<HyperlinkArea>& rArea ); 138 139 140 // SubsettableShapeManager interface 141 // --------------------------------------------------- 142 143 virtual boost::shared_ptr<AttributableShape> getSubsetShape( 144 const boost::shared_ptr<AttributableShape>& rOrigShape, 145 const DocTreeNode& rTreeNode ); 146 virtual void revokeSubset( 147 const boost::shared_ptr<AttributableShape>& rOrigShape, 148 const boost::shared_ptr<AttributableShape>& rSubsetShape ); 149 150 virtual void addIntrinsicAnimationHandler( 151 const IntrinsicAnimationEventHandlerSharedPtr& rHandler ); 152 virtual void removeIntrinsicAnimationHandler( 153 const IntrinsicAnimationEventHandlerSharedPtr& rHandler ); 154 virtual bool notifyIntrinsicAnimationsEnabled(); 155 virtual bool notifyIntrinsicAnimationsDisabled(); 156 157 158 // ShapeListenerEventHandler 159 // --------------------------------------------- 160 161 virtual bool listenerAdded( const ::com::sun::star::uno::Reference< 162 ::com::sun::star::presentation::XShapeEventListener>& xListener, 163 const ::com::sun::star::uno::Reference< 164 ::com::sun::star::drawing::XShape>& xShape ); 165 166 virtual bool listenerRemoved( const ::com::sun::star::uno::Reference< 167 ::com::sun::star::presentation::XShapeEventListener>& xListener, 168 const ::com::sun::star::uno::Reference< 169 ::com::sun::star::drawing::XShape>& xShape ); 170 171 // ShapeCursorEventHandler interface 172 // --------------------------------------------------------------- 173 174 virtual bool cursorChanged( const ::com::sun::star::uno::Reference< 175 ::com::sun::star::drawing::XShape>& xShape, 176 sal_Int16 nCursor ); 177 178 179 ::rtl::OUString checkForHyperlink( ::basegfx::B2DPoint const& hitPos )const; 180 181 182 typedef std::map<ShapeSharedPtr, 183 boost::shared_ptr< ::cppu::OInterfaceContainerHelper >, 184 Shape::lessThanShape> ShapeToListenersMap; 185 typedef std::map<ShapeSharedPtr, sal_Int16, 186 Shape::lessThanShape> ShapeToCursorMap; 187 typedef std::set<HyperlinkAreaSharedPtr, 188 HyperlinkArea::lessThanArea> AreaSet; 189 190 typedef ThreadUnsafeListenerContainer< 191 IntrinsicAnimationEventHandlerSharedPtr, 192 std::vector<IntrinsicAnimationEventHandlerSharedPtr> > ImplIntrinsicAnimationEventHandlers; 193 194 EventMultiplexer& mrMultiplexer; 195 LayerManagerSharedPtr mpLayerManager; 196 CursorManager& mrCursorManager; 197 const ShapeEventListenerMap& mrGlobalListenersMap; 198 const ShapeCursorMap& mrGlobalCursorMap; 199 ShapeToListenersMap maShapeListenerMap; 200 ShapeToCursorMap maShapeCursorMap; 201 AreaSet maHyperlinkShapes; 202 ImplIntrinsicAnimationEventHandlers maIntrinsicAnimationEventHandlers; 203 bool mbEnabled; 204 }; 205 206 } // namespace internal 207 } // namespace presentation 208 209 #endif /* INCLUDED_SLIDESHOW_SHAPEMANAGERIMPL_HXX */ 210