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