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