1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_SLIDESHOWVIEWIMPL_HXX_
25 #define _SD_SLIDESHOWVIEWIMPL_HXX_
26 
27 #include <cppuhelper/implbase1.hxx>
28 #include <cppuhelper/compbase4.hxx>
29 #include <comphelper/broadcasthelper.hxx>
30 #include <comphelper/listenernotification.hxx>
31 #include <toolkit/helper/vclunohelper.hxx>
32 #include <comphelper/processfactory.hxx>
33 #include <com/sun/star/awt/WindowEvent.hpp>
34 #include <com/sun/star/awt/XWindowListener.hpp>
35 #include <com/sun/star/awt/XWindow.hpp>
36 #include <com/sun/star/awt/XWindowPeer.hpp>
37 #include <com/sun/star/util/XModifyListener.hpp>
38 #include <com/sun/star/awt/XPaintListener.hpp>
39 #include <com/sun/star/awt/XPointer.hpp>
40 #include <com/sun/star/presentation/XSlideShow.hpp>
41 #include <com/sun/star/presentation/XSlideShowView.hpp>
42 #include <com/sun/star/presentation/XSlideShowListener.hpp>
43 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
44 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
45 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
46 #include <comphelper/implementationreference.hxx>
47 #include <basegfx/matrix/b2dhommatrix.hxx>
48 #include <basegfx/tools/canvastools.hxx>
49 #include <cppcanvas/spritecanvas.hxx>
50 #include <vcl/help.hxx>
51 #include <tools/urlobj.hxx>
52 #include <unotools/pathoptions.hxx>
53 #include <unotools/saveopt.hxx>
54 #include <sfx2/bindings.hxx>
55 #include <sfx2/dispatch.hxx>
56 #include <sfx2/viewfrm.hxx>
57 #include <basic/sbstar.hxx>
58 #include <svx/svdpagv.hxx>
59 #include <svx/fmshell.hxx>
60 
61 #ifndef _SVX_SVXIDS_HRC
62 #include <svx/svxids.hrc>
63 #endif
64 #include "sdmod.hxx"
65 #include "cusshow.hxx"
66 #include "ViewShellBase.hxx"
67 #include "PresentationViewShell.hxx"
68 #include "ViewShell.hxx"
69 #include "drawview.hxx"
70 #include "slideshow.hxx"
71 #include "drawdoc.hxx"
72 #include "showwindow.hxx"
73 #include "optsitem.hxx"
74 #include "FrameView.hxx"
75 #include "DrawDocShell.hxx"
76 
77 #ifndef _SD_APP_HRC_
78 #include "app.hrc"
79 #endif
80 
81 namespace sd
82 {
83 
84 struct WrappedMouseEvent : public ::com::sun::star::lang::EventObject
85 {
86     enum EventType
87     {
88         PRESSED,
89         RELEASED,
90         ENTERED,
91         EXITED
92     };
93 
94     EventType 		meType;
95     ::com::sun::star::awt::MouseEvent	maEvent;
96 };
97 
98 struct WrappedMouseMotionEvent : public ::com::sun::star::lang::EventObject
99 {
100     enum EventType
101     {
102         DRAGGED,
103         MOVED
104     };
105 
106     EventType 		meType;
107     ::com::sun::star::awt::MouseEvent	maEvent;
108 };
109 
110 ///////////////////////////////////////////////////////////////////////
111 // SlideShowViewListeners
112 ///////////////////////////////////////////////////////////////////////
113 
114 typedef std::vector< ::com::sun::star::uno::WeakReference< ::com::sun::star::util::XModifyListener > > ViewListenerVector;
115 class SlideShowViewListeners
116 {
117 public:
118 	SlideShowViewListeners( ::osl::Mutex& rMutex );
119 
120     void    addListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& _rxListener );
121     void    removeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& _rxListener );
122 	bool    notify( const ::com::sun::star::lang::EventObject& _rEvent ) throw( com::sun::star::uno::Exception );
123 	void    disposing( const ::com::sun::star::lang::EventObject& _rEventSource );
124 
125 protected:
126 	ViewListenerVector maListeners;
127 	::osl::Mutex& mrMutex;
128 };
129 
130 typedef ::std::auto_ptr< SlideShowViewListeners >	SlideShowViewListenersPtr;
131 
132 ///////////////////////////////////////////////////////////////////////
133 // SlideShowViewPaintListeners
134 ///////////////////////////////////////////////////////////////////////
135 
136 typedef ::comphelper::OListenerContainerBase< ::com::sun::star::awt::XPaintListener,
137                                                 ::com::sun::star::awt::PaintEvent >   		SlideShowViewPaintListeners_Base;
138 
139 class SlideShowViewPaintListeners : public SlideShowViewPaintListeners_Base
140 {
141 public:
142     SlideShowViewPaintListeners( ::osl::Mutex& rMutex );
143 
144 protected:
145     virtual bool implTypedNotify( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rListener, const ::com::sun::star::awt::PaintEvent& rEvent ) throw( ::com::sun::star::uno::Exception );
146 };
147 typedef ::std::auto_ptr< SlideShowViewPaintListeners >	SlideShowViewPaintListenersPtr;
148 
149 ///////////////////////////////////////////////////////////////////////
150 // SlideShowViewMouseListeners
151 ///////////////////////////////////////////////////////////////////////
152 
153 typedef ::comphelper::OListenerContainerBase< ::com::sun::star::awt::XMouseListener, WrappedMouseEvent > SlideShowViewMouseListeners_Base;
154 
155 class SlideShowViewMouseListeners : public SlideShowViewMouseListeners_Base
156 {
157 public:
158     SlideShowViewMouseListeners( ::osl::Mutex& rMutex );
159 
160 protected:
161     virtual bool implTypedNotify( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >&	rListener,
162                              const WrappedMouseEvent& 			  		rEvent ) throw( ::com::sun::star::uno::Exception );
163 };
164 
165 typedef ::std::auto_ptr< SlideShowViewMouseListeners >	SlideShowViewMouseListenersPtr;
166 
167 
168 ///////////////////////////////////////////////////////////////////////
169 // SlideShowViewMouseMotionListeners
170 ///////////////////////////////////////////////////////////////////////
171 
172 typedef ::comphelper::OListenerContainerBase< ::com::sun::star::awt::XMouseMotionListener,
173                                                 WrappedMouseMotionEvent > SlideShowViewMouseMotionListeners_Base;
174 
175 class SlideShowViewMouseMotionListeners : public SlideShowViewMouseMotionListeners_Base
176 {
177 public:
178     SlideShowViewMouseMotionListeners( ::osl::Mutex& rMutex );
179 
180 protected:
181     virtual bool implTypedNotify( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >&	rListener,
182                              const WrappedMouseMotionEvent& 		  		rEvent ) throw( ::com::sun::star::uno::Exception );
183 };
184 typedef ::std::auto_ptr< SlideShowViewMouseMotionListeners >	SlideShowViewMouseMotionListenersPtr;
185 
186 
187 ///////////////////////////////////////////////////////////////////////
188 // SlideShowView
189 ///////////////////////////////////////////////////////////////////////
190 
191 class ShowWindow;
192 class SlideshowImpl;
193 
194 typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::presentation::XSlideShowView,
195 											::com::sun::star::awt::XWindowListener,
196                                             ::com::sun::star::awt::XMouseListener,
197                                             ::com::sun::star::awt::XMouseMotionListener > SlideShowView_Base;
198 
199 class SlideShowView : public ::comphelper::OBaseMutex,
200                     public SlideShowView_Base
201 {
202 public:
203 	SlideShowView( ShowWindow&     rOutputWindow,
204                    SdDrawDocument* pDoc,
205                    AnimationMode   eAnimationMode,
206                    SlideshowImpl*  pSlideShow,
207                    bool            bFullScreen );
208 
209 	void ignoreNextMouseReleased() { mbMousePressedEaten = true; }
210 
211     /// Dispose all internal references
212     virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
213 
214     /// Disposing our broadcaster
215     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& ) throw(::com::sun::star::uno::RuntimeException);
216 
217     virtual void SAL_CALL paint( const ::com::sun::star::awt::PaintEvent& e ) throw (::com::sun::star::uno::RuntimeException);
218 
219     // XSlideShowView methods
220 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSpriteCanvas > SAL_CALL getCanvas(  ) throw (::com::sun::star::uno::RuntimeException);
221 	virtual void SAL_CALL clear(  ) throw (::com::sun::star::uno::RuntimeException);
222 	virtual ::com::sun::star::geometry::AffineMatrix2D SAL_CALL getTransformation(  ) throw (::com::sun::star::uno::RuntimeException);
223     virtual void SAL_CALL addTransformationChangedListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
224     virtual void SAL_CALL removeTransformationChangedListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
225     virtual void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
226     virtual void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
227     virtual void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
228     virtual void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
229     virtual void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
230 	virtual void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
231     virtual void SAL_CALL setMouseCursor( sal_Int16 nPointerShape ) throw (::com::sun::star::uno::RuntimeException);
232     virtual ::com::sun::star::awt::Rectangle SAL_CALL getCanvasArea(  ) throw (::com::sun::star::uno::RuntimeException);
233 
234     // XWindowListener methods
235     virtual void SAL_CALL windowResized( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException);
236     virtual void SAL_CALL windowMoved( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException);
237     virtual void SAL_CALL windowShown( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
238     virtual void SAL_CALL windowHidden( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
239 
240     // XMouseListener implementation
241     virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
242     virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
243     virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
244     virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
245 
246     // XMouseMotionListener implementation
247     virtual void SAL_CALL mouseDragged( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
248     virtual void SAL_CALL mouseMoved( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException);
249 
250 	using cppu::WeakComponentImplHelperBase::disposing;
251 
252 protected:
253     ~SlideShowView() {}
254 
255 private:
256     void init();
257 
258 	void updateimpl( ::osl::ClearableMutexGuard& rGuard, SlideshowImpl* pSlideShow );
259 
260     ::cppcanvas::SpriteCanvasSharedPtr												mpCanvas;
261     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >				mxWindow;
262     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >			mxWindowPeer;
263     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer >				mxPointer;
264 	SlideshowImpl*							mpSlideShow;
265 	ShowWindow&								mrOutputWindow;
266     SlideShowViewListenersPtr				mpViewListeners;
267 	SlideShowViewPaintListenersPtr			mpPaintListeners;
268     SlideShowViewMouseListenersPtr			mpMouseListeners;
269     SlideShowViewMouseMotionListenersPtr	mpMouseMotionListeners;
270 	SdDrawDocument*							mpDoc;
271     bool									mbIsMouseMotionListener;
272 	Rectangle								maPresentationArea;
273 	AnimationMode							meAnimationMode;
274 	bool									mbFirstPaint;
275     bool                                    mbFullScreen;
276 	bool									mbMousePressedEaten;
277 };
278 
279 
280 } // namespace ::sd
281 
282 #endif
283