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