1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_slideshow.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <canvas/debug.hxx> 32*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 33*cdf0e10cSrcweir #include <com/sun/star/awt/MouseButton.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/awt/SystemPointer.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/presentation/XShapeEventListener.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShowListener.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/awt/MouseButton.hpp> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include "shapemanagerimpl.hxx" 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <boost/bind.hpp> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir using namespace com::sun::star; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir namespace slideshow { 46*cdf0e10cSrcweir namespace internal { 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir ShapeManagerImpl::ShapeManagerImpl( EventMultiplexer& rMultiplexer, 49*cdf0e10cSrcweir LayerManagerSharedPtr const& rLayerManager, 50*cdf0e10cSrcweir CursorManager& rCursorManager, 51*cdf0e10cSrcweir const ShapeEventListenerMap& rGlobalListenersMap, 52*cdf0e10cSrcweir const ShapeCursorMap& rGlobalCursorMap ): 53*cdf0e10cSrcweir mrMultiplexer(rMultiplexer), 54*cdf0e10cSrcweir mpLayerManager(rLayerManager), 55*cdf0e10cSrcweir mrCursorManager(rCursorManager), 56*cdf0e10cSrcweir mrGlobalListenersMap(rGlobalListenersMap), 57*cdf0e10cSrcweir mrGlobalCursorMap(rGlobalCursorMap), 58*cdf0e10cSrcweir maShapeListenerMap(), 59*cdf0e10cSrcweir maShapeCursorMap(), 60*cdf0e10cSrcweir maHyperlinkShapes(), 61*cdf0e10cSrcweir mbEnabled(false) 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir void ShapeManagerImpl::activate( bool bSlideBackgoundPainted ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir if( !mbEnabled ) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir mbEnabled = true; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir // register this handler on EventMultiplexer. 72*cdf0e10cSrcweir // Higher prio (overrides other engine handlers) 73*cdf0e10cSrcweir mrMultiplexer.addMouseMoveHandler( shared_from_this(), 2.0 ); 74*cdf0e10cSrcweir mrMultiplexer.addClickHandler( shared_from_this(), 2.0 ); 75*cdf0e10cSrcweir mrMultiplexer.addShapeListenerHandler( shared_from_this() ); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir // clone listener map 78*cdf0e10cSrcweir uno::Reference<presentation::XShapeEventListener> xDummyListener; 79*cdf0e10cSrcweir std::for_each( mrGlobalListenersMap.begin(), 80*cdf0e10cSrcweir mrGlobalListenersMap.end(), 81*cdf0e10cSrcweir boost::bind( &ShapeManagerImpl::listenerAdded, 82*cdf0e10cSrcweir this, 83*cdf0e10cSrcweir boost::cref(xDummyListener), 84*cdf0e10cSrcweir boost::bind( 85*cdf0e10cSrcweir std::select1st<ShapeEventListenerMap::value_type>(), 86*cdf0e10cSrcweir _1 ))); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // clone cursor map 89*cdf0e10cSrcweir std::for_each( mrGlobalCursorMap.begin(), 90*cdf0e10cSrcweir mrGlobalCursorMap.end(), 91*cdf0e10cSrcweir boost::bind( &ShapeManagerImpl::cursorChanged, 92*cdf0e10cSrcweir this, 93*cdf0e10cSrcweir boost::bind( 94*cdf0e10cSrcweir std::select1st<ShapeCursorMap::value_type>(), 95*cdf0e10cSrcweir _1 ), 96*cdf0e10cSrcweir boost::bind( 97*cdf0e10cSrcweir std::select2nd<ShapeCursorMap::value_type>(), 98*cdf0e10cSrcweir _1 ))); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir if( mpLayerManager ) 101*cdf0e10cSrcweir mpLayerManager->activate( bSlideBackgoundPainted ); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir void ShapeManagerImpl::deactivate() 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir if( mbEnabled ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir mbEnabled = false; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir if( mpLayerManager ) 112*cdf0e10cSrcweir mpLayerManager->deactivate(); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir maShapeListenerMap.clear(); 115*cdf0e10cSrcweir maShapeCursorMap.clear(); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir mrMultiplexer.removeShapeListenerHandler( shared_from_this() ); 118*cdf0e10cSrcweir mrMultiplexer.removeMouseMoveHandler( shared_from_this() ); 119*cdf0e10cSrcweir mrMultiplexer.removeClickHandler( shared_from_this() ); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir void ShapeManagerImpl::dispose() 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir // remove listeners (EventMultiplexer holds shared_ptr on us) 126*cdf0e10cSrcweir deactivate(); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir maHyperlinkShapes.clear(); 129*cdf0e10cSrcweir maShapeCursorMap.clear(); 130*cdf0e10cSrcweir maShapeListenerMap.clear(); 131*cdf0e10cSrcweir mpLayerManager.reset(); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir bool ShapeManagerImpl::handleMousePressed( awt::MouseEvent const& ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir // not used here 137*cdf0e10cSrcweir return false; // did not handle the event 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir bool ShapeManagerImpl::handleMouseReleased( awt::MouseEvent const& e ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir if( !mbEnabled || e.Buttons != awt::MouseButton::LEFT) 143*cdf0e10cSrcweir return false; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir basegfx::B2DPoint const aPosition( e.X, e.Y ); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir // first check for hyperlinks, because these have 148*cdf0e10cSrcweir // highest prio: 149*cdf0e10cSrcweir rtl::OUString const hyperlink( checkForHyperlink(aPosition) ); 150*cdf0e10cSrcweir if( hyperlink.getLength() > 0 ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir mrMultiplexer.notifyHyperlinkClicked(hyperlink); 153*cdf0e10cSrcweir return true; // event consumed 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir // find matching shape (scan reversely, to coarsely match 157*cdf0e10cSrcweir // paint order) 158*cdf0e10cSrcweir ShapeToListenersMap::reverse_iterator aCurrBroadcaster( 159*cdf0e10cSrcweir maShapeListenerMap.rbegin() ); 160*cdf0e10cSrcweir ShapeToListenersMap::reverse_iterator const aEndBroadcasters( 161*cdf0e10cSrcweir maShapeListenerMap.rend() ); 162*cdf0e10cSrcweir while( aCurrBroadcaster != aEndBroadcasters ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir // TODO(F2): Get proper geometry polygon from the 165*cdf0e10cSrcweir // shape, to avoid having areas outside the shape 166*cdf0e10cSrcweir // react on the mouse 167*cdf0e10cSrcweir if( aCurrBroadcaster->first->getBounds().isInside( aPosition ) && 168*cdf0e10cSrcweir aCurrBroadcaster->first->isVisible() ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir // shape hit, and shape is visible. Raise 171*cdf0e10cSrcweir // event. 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir boost::shared_ptr<cppu::OInterfaceContainerHelper> const pCont( 174*cdf0e10cSrcweir aCurrBroadcaster->second ); 175*cdf0e10cSrcweir uno::Reference<drawing::XShape> const xShape( 176*cdf0e10cSrcweir aCurrBroadcaster->first->getXShape() ); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir // DON'T do anything with /this/ after this point! 179*cdf0e10cSrcweir pCont->forEach<presentation::XShapeEventListener>( 180*cdf0e10cSrcweir boost::bind( &presentation::XShapeEventListener::click, 181*cdf0e10cSrcweir _1, 182*cdf0e10cSrcweir boost::cref(xShape), 183*cdf0e10cSrcweir boost::cref(e) )); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir return true; // handled this event 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir ++aCurrBroadcaster; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir return false; // did not handle this event 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir bool ShapeManagerImpl::handleMouseEntered( const awt::MouseEvent& ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir // not used here 197*cdf0e10cSrcweir return false; // did not handle the event 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir bool ShapeManagerImpl::handleMouseExited( const awt::MouseEvent& ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir // not used here 203*cdf0e10cSrcweir return false; // did not handle the event 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir bool ShapeManagerImpl::handleMouseDragged( const awt::MouseEvent& ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir // not used here 209*cdf0e10cSrcweir return false; // did not handle the event 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir bool ShapeManagerImpl::handleMouseMoved( const awt::MouseEvent& e ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir if( !mbEnabled ) 215*cdf0e10cSrcweir return false; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir // find hit shape in map 218*cdf0e10cSrcweir const ::basegfx::B2DPoint aPosition( e.X, e.Y ); 219*cdf0e10cSrcweir sal_Int16 nNewCursor(-1); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir if( checkForHyperlink(aPosition).getLength() > 0 ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir nNewCursor = awt::SystemPointer::REFHAND; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir else 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir // find matching shape (scan reversely, to coarsely match 228*cdf0e10cSrcweir // paint order) 229*cdf0e10cSrcweir ShapeToCursorMap::reverse_iterator aCurrCursor( 230*cdf0e10cSrcweir maShapeCursorMap.rbegin() ); 231*cdf0e10cSrcweir ShapeToCursorMap::reverse_iterator const aEndCursors( 232*cdf0e10cSrcweir maShapeCursorMap.rend() ); 233*cdf0e10cSrcweir while( aCurrCursor != aEndCursors ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir // TODO(F2): Get proper geometry polygon from the 236*cdf0e10cSrcweir // shape, to avoid having areas outside the shape 237*cdf0e10cSrcweir // react on the mouse 238*cdf0e10cSrcweir if( aCurrCursor->first->getBounds().isInside( aPosition ) && 239*cdf0e10cSrcweir aCurrCursor->first->isVisible() ) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir // shape found, and it's visible. set 242*cdf0e10cSrcweir // requested cursor to shape's 243*cdf0e10cSrcweir nNewCursor = aCurrCursor->second; 244*cdf0e10cSrcweir break; 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir ++aCurrCursor; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir if( nNewCursor == -1 ) 252*cdf0e10cSrcweir mrCursorManager.resetCursor(); 253*cdf0e10cSrcweir else 254*cdf0e10cSrcweir mrCursorManager.requestCursor( nNewCursor ); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir return false; // we don't /eat/ this event. Lower prio 257*cdf0e10cSrcweir // handler should see it, too. 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir bool ShapeManagerImpl::update() 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir if( mbEnabled && mpLayerManager ) 263*cdf0e10cSrcweir return mpLayerManager->update(); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir return false; 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir bool ShapeManagerImpl::update( ViewSharedPtr const& /*rView*/ ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir // am not doing view-specific updates here. 271*cdf0e10cSrcweir return false; 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir bool ShapeManagerImpl::needsUpdate() const 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir if( mbEnabled && mpLayerManager ) 277*cdf0e10cSrcweir return mpLayerManager->isUpdatePending(); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir return false; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir void ShapeManagerImpl::enterAnimationMode( const AnimatableShapeSharedPtr& rShape ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir if( mbEnabled && mpLayerManager ) 285*cdf0e10cSrcweir mpLayerManager->enterAnimationMode(rShape); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir void ShapeManagerImpl::leaveAnimationMode( const AnimatableShapeSharedPtr& rShape ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir if( mbEnabled && mpLayerManager ) 291*cdf0e10cSrcweir mpLayerManager->leaveAnimationMode(rShape); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir void ShapeManagerImpl::notifyShapeUpdate( const ShapeSharedPtr& rShape ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir if( mbEnabled && mpLayerManager ) 297*cdf0e10cSrcweir mpLayerManager->notifyShapeUpdate(rShape); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir ShapeSharedPtr ShapeManagerImpl::lookupShape( uno::Reference< drawing::XShape > const & xShape ) const 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir if( mpLayerManager ) 303*cdf0e10cSrcweir return mpLayerManager->lookupShape(xShape); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir return ShapeSharedPtr(); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir void ShapeManagerImpl::addHyperlinkArea( const HyperlinkAreaSharedPtr& rArea ) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir maHyperlinkShapes.insert(rArea); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir void ShapeManagerImpl::removeHyperlinkArea( const HyperlinkAreaSharedPtr& rArea ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir maHyperlinkShapes.erase(rArea); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir AttributableShapeSharedPtr ShapeManagerImpl::getSubsetShape( const AttributableShapeSharedPtr& rOrigShape, 319*cdf0e10cSrcweir const DocTreeNode& rTreeNode ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir if( mpLayerManager ) 322*cdf0e10cSrcweir return mpLayerManager->getSubsetShape(rOrigShape,rTreeNode); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir return AttributableShapeSharedPtr(); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir void ShapeManagerImpl::revokeSubset( const AttributableShapeSharedPtr& rOrigShape, 328*cdf0e10cSrcweir const AttributableShapeSharedPtr& rSubsetShape ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir if( mpLayerManager ) 331*cdf0e10cSrcweir mpLayerManager->revokeSubset(rOrigShape,rSubsetShape); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir bool ShapeManagerImpl::listenerAdded( 335*cdf0e10cSrcweir const uno::Reference<presentation::XShapeEventListener>& /*xListener*/, 336*cdf0e10cSrcweir const uno::Reference<drawing::XShape>& xShape ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir ShapeEventListenerMap::const_iterator aIter; 339*cdf0e10cSrcweir if( (aIter = mrGlobalListenersMap.find( xShape )) == 340*cdf0e10cSrcweir mrGlobalListenersMap.end() ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir ENSURE_OR_RETURN_FALSE(false, 343*cdf0e10cSrcweir "ShapeManagerImpl::listenerAdded(): global " 344*cdf0e10cSrcweir "shape listener map inconsistency!"); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir // is this one of our shapes? other shapes are ignored. 348*cdf0e10cSrcweir ShapeSharedPtr pShape( lookupShape(xShape) ); 349*cdf0e10cSrcweir if( pShape ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir maShapeListenerMap.insert( 352*cdf0e10cSrcweir ShapeToListenersMap::value_type( 353*cdf0e10cSrcweir pShape, 354*cdf0e10cSrcweir aIter->second)); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir return true; 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir bool ShapeManagerImpl::listenerRemoved( 361*cdf0e10cSrcweir const uno::Reference<presentation::XShapeEventListener>& /*xListener*/, 362*cdf0e10cSrcweir const uno::Reference<drawing::XShape>& xShape ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir // shape really erased from map? maybe there are other listeners 365*cdf0e10cSrcweir // for the same shape pending... 366*cdf0e10cSrcweir if( mrGlobalListenersMap.find(xShape) == mrGlobalListenersMap.end() ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir // is this one of our shapes? other shapes are ignored. 369*cdf0e10cSrcweir ShapeSharedPtr pShape( lookupShape(xShape) ); 370*cdf0e10cSrcweir if( pShape ) 371*cdf0e10cSrcweir maShapeListenerMap.erase(pShape); 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir return true; 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir bool ShapeManagerImpl::cursorChanged( const uno::Reference<drawing::XShape>& xShape, 378*cdf0e10cSrcweir sal_Int16 nCursor ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir ShapeSharedPtr pShape( lookupShape(xShape) ); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir // is this one of our shapes? other shapes are ignored. 383*cdf0e10cSrcweir if( !pShape ) 384*cdf0e10cSrcweir return false; 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir if( mrGlobalCursorMap.find(xShape) == mrGlobalCursorMap.end() ) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir // erased from global map - erase locally, too 389*cdf0e10cSrcweir maShapeCursorMap.erase(pShape); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir else 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir // included in global map - update local one 394*cdf0e10cSrcweir ShapeToCursorMap::iterator aIter; 395*cdf0e10cSrcweir if( (aIter = maShapeCursorMap.find(pShape)) 396*cdf0e10cSrcweir == maShapeCursorMap.end() ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir maShapeCursorMap.insert( 399*cdf0e10cSrcweir ShapeToCursorMap::value_type( 400*cdf0e10cSrcweir pShape, 401*cdf0e10cSrcweir nCursor )); 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir else 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir aIter->second = nCursor; 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir return true; 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir rtl::OUString ShapeManagerImpl::checkForHyperlink( basegfx::B2DPoint const& hitPos ) const 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir // find matching region (scan reversely, to coarsely match 415*cdf0e10cSrcweir // paint order): set is ordered by priority 416*cdf0e10cSrcweir AreaSet::const_reverse_iterator iPos( maHyperlinkShapes.rbegin() ); 417*cdf0e10cSrcweir AreaSet::const_reverse_iterator const iEnd( maHyperlinkShapes.rend() ); 418*cdf0e10cSrcweir for( ; iPos != iEnd; ++iPos ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir HyperlinkAreaSharedPtr const& pArea = *iPos; 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir HyperlinkArea::HyperlinkRegions const linkRegions( 423*cdf0e10cSrcweir pArea->getHyperlinkRegions() ); 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir for( std::size_t i = linkRegions.size(); i--; ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir basegfx::B2DRange const& region = linkRegions[i].first; 428*cdf0e10cSrcweir if( region.isInside(hitPos) ) 429*cdf0e10cSrcweir return linkRegions[i].second; 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir return rtl::OUString(); 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir void ShapeManagerImpl::addIntrinsicAnimationHandler( const IntrinsicAnimationEventHandlerSharedPtr& rHandler ) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir maIntrinsicAnimationEventHandlers.add( rHandler ); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir void ShapeManagerImpl::removeIntrinsicAnimationHandler( const IntrinsicAnimationEventHandlerSharedPtr& rHandler ) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir maIntrinsicAnimationEventHandlers.remove( rHandler ); 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir bool ShapeManagerImpl::notifyIntrinsicAnimationsEnabled() 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir return maIntrinsicAnimationEventHandlers.applyAll( 449*cdf0e10cSrcweir boost::mem_fn(&IntrinsicAnimationEventHandler::enableAnimations)); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir bool ShapeManagerImpl::notifyIntrinsicAnimationsDisabled() 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir return maIntrinsicAnimationEventHandlers.applyAll( 455*cdf0e10cSrcweir boost::mem_fn(&IntrinsicAnimationEventHandler::disableAnimations)); 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir } // namespace internal 461*cdf0e10cSrcweir } // namespace presentation 462