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