1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shapemanagerimpl.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef INCLUDED_SLIDESHOW_SHAPEMANAGERIMPL_HXX
31 #define INCLUDED_SLIDESHOW_SHAPEMANAGERIMPL_HXX
33 #include <osl/mutex.hxx>
34 #include <cppuhelper/interfacecontainer.h>
35 #include <com/sun/star/presentation/XShapeEventListener.hpp>
38 #include "subsettableshapemanager.hxx"
39 #include "eventmultiplexer.hxx"
40 #include "layermanager.hxx"
41 #include "viewupdate.hxx"
42 #include "shapemaps.hxx"
43 #include "cursormanager.hxx"
44 #include "hyperlinkarea.hxx"
45 #include "listenercontainer.hxx"
46 #include "shapelistenereventhandler.hxx"
47 #include "mouseeventhandler.hxx"
49 #include <boost/shared_ptr.hpp>
50 #include <boost/enable_shared_from_this.hpp>
51 #include <boost/noncopyable.hpp>
58 /** Listener class for shape events
60 This helper class registers itself on each view, and
61 broadcasts the XShapeEventListener events. The mouse motion
62 events are needed for setting the shape cursor.
64 class ShapeManagerImpl
: public SubsettableShapeManager
,
65 public ShapeListenerEventHandler
,
66 public MouseEventHandler
,
68 public boost::enable_shared_from_this
<ShapeManagerImpl
>,
69 private boost::noncopyable
72 /** Create a shape event broadcaster
74 @param rEventMultiplexer
75 The slideshow-global event source, where this class
76 registeres its event handlers.
78 ShapeManagerImpl( EventMultiplexer
& rMultiplexer
,
79 LayerManagerSharedPtr
const& rLayerManager
,
80 CursorManager
& rCursorManager
,
81 const ShapeEventListenerMap
& rGlobalListenersMap
,
82 const ShapeCursorMap
& rGlobalCursorMap
);
84 /** Enables event listening.
86 @param bSlideBackgoundPainted
87 When true, the initial slide content on the background layer
88 is already rendered (e.g. from a previous slide
89 transition). When false, slide renders initial content of
92 void activate( bool bSlideBackgoundPainted
);
94 /** Disables event listening.
98 // Disposable interface
99 // ---------------------------------------------------------------
101 virtual void dispose();
105 // MouseEventHandler interface
106 // ---------------------------------------------------------------
108 virtual bool handleMousePressed(
109 ::com::sun::star::awt::MouseEvent
const& evt
);
110 virtual bool handleMouseReleased(
111 ::com::sun::star::awt::MouseEvent
const& evt
);
112 virtual bool handleMouseEntered(
113 ::com::sun::star::awt::MouseEvent
const& evt
);
114 virtual bool handleMouseExited(
115 ::com::sun::star::awt::MouseEvent
const& evt
);
116 virtual bool handleMouseDragged(
117 ::com::sun::star::awt::MouseEvent
const& evt
);
118 virtual bool handleMouseMoved(
119 ::com::sun::star::awt::MouseEvent
const& evt
);
122 // ViewUpdate interface
123 // -------------------------------------------------------------------
125 virtual bool update();
126 virtual bool update( ViewSharedPtr
const& rView
);
127 virtual bool needsUpdate() const;
130 // ShapeManager interface
131 // ---------------------------------------------------
133 virtual void enterAnimationMode( const AnimatableShapeSharedPtr
& rShape
);
134 virtual void leaveAnimationMode( const AnimatableShapeSharedPtr
& rShape
);
135 virtual void notifyShapeUpdate( const ShapeSharedPtr
& rShape
);
136 virtual ShapeSharedPtr
lookupShape(
137 ::com::sun::star::uno::Reference
<
138 ::com::sun::star::drawing::XShape
> const & xShape
) const;
139 virtual void addHyperlinkArea( const boost::shared_ptr
<HyperlinkArea
>& rArea
);
140 virtual void removeHyperlinkArea( const boost::shared_ptr
<HyperlinkArea
>& rArea
);
143 // SubsettableShapeManager interface
144 // ---------------------------------------------------
146 virtual boost::shared_ptr
<AttributableShape
> getSubsetShape(
147 const boost::shared_ptr
<AttributableShape
>& rOrigShape
,
148 const DocTreeNode
& rTreeNode
);
149 virtual void revokeSubset(
150 const boost::shared_ptr
<AttributableShape
>& rOrigShape
,
151 const boost::shared_ptr
<AttributableShape
>& rSubsetShape
);
153 virtual void addIntrinsicAnimationHandler(
154 const IntrinsicAnimationEventHandlerSharedPtr
& rHandler
);
155 virtual void removeIntrinsicAnimationHandler(
156 const IntrinsicAnimationEventHandlerSharedPtr
& rHandler
);
157 virtual bool notifyIntrinsicAnimationsEnabled();
158 virtual bool notifyIntrinsicAnimationsDisabled();
161 // ShapeListenerEventHandler
162 // ---------------------------------------------
164 virtual bool listenerAdded( const ::com::sun::star::uno::Reference
<
165 ::com::sun::star::presentation::XShapeEventListener
>& xListener
,
166 const ::com::sun::star::uno::Reference
<
167 ::com::sun::star::drawing::XShape
>& xShape
);
169 virtual bool listenerRemoved( const ::com::sun::star::uno::Reference
<
170 ::com::sun::star::presentation::XShapeEventListener
>& xListener
,
171 const ::com::sun::star::uno::Reference
<
172 ::com::sun::star::drawing::XShape
>& xShape
);
174 // ShapeCursorEventHandler interface
175 // ---------------------------------------------------------------
177 virtual bool cursorChanged( const ::com::sun::star::uno::Reference
<
178 ::com::sun::star::drawing::XShape
>& xShape
,
182 ::rtl::OUString
checkForHyperlink( ::basegfx::B2DPoint
const& hitPos
)const;
185 typedef std::map
<ShapeSharedPtr
,
186 boost::shared_ptr
< ::cppu::OInterfaceContainerHelper
>,
187 Shape::lessThanShape
> ShapeToListenersMap
;
188 typedef std::map
<ShapeSharedPtr
, sal_Int16
,
189 Shape::lessThanShape
> ShapeToCursorMap
;
190 typedef std::set
<HyperlinkAreaSharedPtr
,
191 HyperlinkArea::lessThanArea
> AreaSet
;
193 typedef ThreadUnsafeListenerContainer
<
194 IntrinsicAnimationEventHandlerSharedPtr
,
195 std::vector
<IntrinsicAnimationEventHandlerSharedPtr
> > ImplIntrinsicAnimationEventHandlers
;
197 EventMultiplexer
& mrMultiplexer
;
198 LayerManagerSharedPtr mpLayerManager
;
199 CursorManager
& mrCursorManager
;
200 const ShapeEventListenerMap
& mrGlobalListenersMap
;
201 const ShapeCursorMap
& mrGlobalCursorMap
;
202 ShapeToListenersMap maShapeListenerMap
;
203 ShapeToCursorMap maShapeCursorMap
;
204 AreaSet maHyperlinkShapes
;
205 ImplIntrinsicAnimationEventHandlers maIntrinsicAnimationEventHandlers
;
209 } // namespace internal
210 } // namespace presentation
212 #endif /* INCLUDED_SLIDESHOW_SHAPEMANAGERIMPL_HXX */