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 :
20 : #ifndef _SD_SlideShowImpl_HXX_
21 : #define _SD_SlideShowImpl_HXX_
22 :
23 : #include "sal/config.h"
24 : #include "com/sun/star/uno/XComponentContext.hpp"
25 : #include "cppuhelper/compbase1.hxx"
26 : #include "cppuhelper/compbase2.hxx"
27 : #include "cppuhelper/basemutex.hxx"
28 : #include "cppuhelper/propertysetmixin.hxx"
29 : #include <com/sun/star/awt/XActivateListener.hpp>
30 : #include <com/sun/star/presentation/XSlideShow.hpp>
31 : #include <com/sun/star/presentation/XSlideShowView.hpp>
32 : #include <com/sun/star/presentation/XSlideShowListener.hpp>
33 : #include <com/sun/star/presentation/XSlideShowController.hpp>
34 : #include "com/sun/star/presentation/XShapeEventListener.hpp"
35 : #include <com/sun/star/awt/WindowEvent.hpp>
36 : #include <com/sun/star/awt/XWindowListener.hpp>
37 : #include <com/sun/star/awt/XWindow.hpp>
38 : #include <com/sun/star/awt/XWindowPeer.hpp>
39 : #include <com/sun/star/util/XModifyListener.hpp>
40 : #include <com/sun/star/awt/XPaintListener.hpp>
41 : #include <com/sun/star/awt/XPointer.hpp>
42 : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
43 : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
44 : #include <com/sun/star/presentation/ClickAction.hpp>
45 : #include <com/sun/star/media/XManager.hpp>
46 : #include <com/sun/star/media/XPlayer.hpp>
47 :
48 : #include <toolkit/helper/vclunohelper.hxx>
49 :
50 : #include <basegfx/matrix/b2dhommatrix.hxx>
51 : #include <basegfx/tools/canvastools.hxx>
52 : #include <vcl/help.hxx>
53 : #include <unotools/pathoptions.hxx>
54 : #include <unotools/saveopt.hxx>
55 : #include <sfx2/bindings.hxx>
56 : #include <sfx2/dispatch.hxx>
57 : #include <sfx2/viewfrm.hxx>
58 : #include <basic/sbstar.hxx>
59 : #include <svx/svdpagv.hxx>
60 : #include <svx/fmshell.hxx>
61 :
62 : #include <svx/svxids.hrc>
63 : #include "sdmod.hxx"
64 : #include "cusshow.hxx"
65 : #include "ViewShellBase.hxx"
66 : #include "PresentationViewShell.hxx"
67 : #include "ViewShell.hxx"
68 : #include "drawview.hxx"
69 : #include "drawdoc.hxx"
70 :
71 : #include "showwindow.hxx"
72 :
73 : #include "optsitem.hxx"
74 : #include "FrameView.hxx"
75 : #include "DrawDocShell.hxx"
76 :
77 : #include "app.hrc"
78 :
79 : #include "slideshow.hxx"
80 :
81 : class SfxViewFrame;
82 : class SfxRequest;
83 :
84 : namespace sd
85 : {
86 : class SlideShowView;
87 : class AnimationSlideController;
88 : class PaneHider;
89 :
90 : // --------------------------------------------------------------------
91 :
92 0 : struct PresentationSettingsEx : public PresentationSettings
93 : {
94 : sal_Bool mbRehearseTimings;
95 : sal_Bool mbPreview;
96 : ::Window* mpParentWindow;
97 : css::uno::Reference< css::drawing::XDrawPage > mxStartPage;
98 : css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode;
99 :
100 : PresentationSettingsEx( const PresentationSettingsEx& );
101 : PresentationSettingsEx( PresentationSettings& );
102 :
103 : void SetArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments ) throw (css::lang::IllegalArgumentException);
104 :
105 : void SetPropertyValue( const ::rtl::OUString& rProperty, const css::uno::Any& rValue ) throw (css::lang::IllegalArgumentException);
106 : };
107 :
108 : // --------------------------------------------------------------------
109 :
110 0 : struct WrappedShapeEventImpl
111 : {
112 : css::presentation::ClickAction meClickAction;
113 : sal_Int32 mnVerb;
114 : ::rtl::OUString maStrBookmark;
115 0 : WrappedShapeEventImpl() : meClickAction( css::presentation::ClickAction_NONE ), mnVerb( 0 ) {};
116 : };
117 :
118 : typedef boost::shared_ptr< WrappedShapeEventImpl > WrappedShapeEventImplPtr;
119 : typedef std::map< css::uno::Reference< css::drawing::XShape >, WrappedShapeEventImplPtr > WrappedShapeEventImplMap;
120 :
121 : // --------------------------------------------------------------------
122 :
123 : class SlideShowListenerProxy : private ::cppu::BaseMutex,
124 : public ::cppu::WeakImplHelper2< css::presentation::XSlideShowListener, css::presentation::XShapeEventListener >
125 : {
126 : public:
127 : SlideShowListenerProxy( const rtl::Reference< SlideshowImpl >& xController, const css::uno::Reference< css::presentation::XSlideShow >& xSlideShow );
128 : virtual ~SlideShowListenerProxy();
129 :
130 : void addAsSlideShowListener();
131 : void removeAsSlideShowListener();
132 :
133 : void addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener );
134 : void removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener );
135 :
136 : void addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape );
137 : void removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape );
138 :
139 : // css::animations::XAnimationListener
140 : virtual void SAL_CALL beginEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) throw (css::uno::RuntimeException);
141 : virtual void SAL_CALL endEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) throw (css::uno::RuntimeException);
142 : virtual void SAL_CALL repeat( const css::uno::Reference< css::animations::XAnimationNode >& Node, ::sal_Int32 Repeat ) throw (css::uno::RuntimeException);
143 :
144 : // css::presentation::XSlideShowListener:
145 : virtual void SAL_CALL paused() throw (css::uno::RuntimeException);
146 : virtual void SAL_CALL resumed() throw (css::uno::RuntimeException);
147 : virtual void SAL_CALL slideTransitionStarted() throw (css::uno::RuntimeException);
148 : virtual void SAL_CALL slideTransitionEnded() throw (css::uno::RuntimeException);
149 : virtual void SAL_CALL slideAnimationsEnded() throw (css::uno::RuntimeException);
150 : virtual void SAL_CALL slideEnded(sal_Bool bReverse) throw (css::uno::RuntimeException);
151 : virtual void SAL_CALL hyperLinkClicked(const ::rtl::OUString & hyperLink) throw (css::uno::RuntimeException);
152 :
153 : // css::lang::XEventListener:
154 : virtual void SAL_CALL disposing(const css::lang::EventObject & Source) throw (css::uno::RuntimeException);
155 :
156 : // css::presentation::XShapeEventListener:
157 : virtual void SAL_CALL click(const css::uno::Reference< css::drawing::XShape > & xShape, const css::awt::MouseEvent & aOriginalEvent) throw (css::uno::RuntimeException);
158 :
159 : ::cppu::OInterfaceContainerHelper maListeners;
160 :
161 : rtl::Reference< SlideshowImpl > mxController;
162 : css::uno::Reference< css::presentation::XSlideShow > mxSlideShow;
163 : };
164 :
165 : // --------------------------------------------------------------------
166 :
167 : typedef ::cppu::WeakComponentImplHelper2< css::presentation::XSlideShowController, css::container::XIndexAccess > SlideshowImplBase;
168 :
169 : class SlideshowImpl : private ::cppu::BaseMutex, public SlideshowImplBase
170 : {
171 : friend class SlideShow;
172 : friend class SlideShowView;
173 :
174 : public:
175 : explicit SlideshowImpl( const css::uno::Reference< css::presentation::XPresentation2 >& xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, ::Window* pParentWindow);
176 :
177 : // css::presentation::XSlideShowController:
178 : virtual ::sal_Bool SAL_CALL getAlwaysOnTop() throw (css::uno::RuntimeException);
179 : virtual void SAL_CALL setAlwaysOnTop( ::sal_Bool _alwaysontop ) throw (css::uno::RuntimeException);
180 : virtual ::sal_Bool SAL_CALL getMouseVisible() throw (css::uno::RuntimeException);
181 : virtual void SAL_CALL setMouseVisible( ::sal_Bool _mousevisible ) throw (css::uno::RuntimeException);
182 : virtual ::sal_Bool SAL_CALL getUsePen() throw (css::uno::RuntimeException);
183 : virtual void SAL_CALL setUsePen( ::sal_Bool _usepen ) throw (css::uno::RuntimeException);
184 : virtual ::sal_Int32 SAL_CALL getPenColor() throw (css::uno::RuntimeException);
185 : virtual void SAL_CALL setPenColor( ::sal_Int32 _pencolor ) throw (css::uno::RuntimeException);
186 : virtual void SAL_CALL setUseEraser( ::sal_Bool _usepen ) throw (css::uno::RuntimeException);
187 : virtual double SAL_CALL getPenWidth() throw (css::uno::RuntimeException);
188 : virtual void SAL_CALL setPenWidth( double dStrokeWidth ) throw (css::uno::RuntimeException);
189 : virtual void SAL_CALL setEraseAllInk( bool bEraseAllInk ) throw (css::uno::RuntimeException);
190 : virtual void SAL_CALL setEraseInk( sal_Int32 nEraseInkSize ) throw (css::uno::RuntimeException);
191 : virtual void SAL_CALL setPenMode( bool bSwitchPenMode) throw (css::uno::RuntimeException);
192 : virtual void SAL_CALL setEraserMode( bool bSwitchEraserMode ) throw (css::uno::RuntimeException);
193 : virtual ::sal_Bool SAL_CALL isRunning( ) throw (css::uno::RuntimeException);
194 : virtual ::sal_Int32 SAL_CALL getSlideCount( ) throw (css::uno::RuntimeException);
195 : virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getSlideByIndex( ::sal_Int32 Index ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException);
196 : virtual void SAL_CALL addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) throw (css::uno::RuntimeException);
197 : virtual void SAL_CALL removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) throw (css::uno::RuntimeException);
198 : virtual void SAL_CALL gotoNextEffect( ) throw (css::uno::RuntimeException);
199 : virtual void SAL_CALL gotoPreviousEffect( ) throw (css::uno::RuntimeException);
200 : virtual void SAL_CALL gotoFirstSlide( ) throw (css::uno::RuntimeException);
201 : virtual void SAL_CALL gotoNextSlide( ) throw (css::uno::RuntimeException);
202 : virtual void SAL_CALL gotoPreviousSlide( ) throw (css::uno::RuntimeException);
203 : virtual void SAL_CALL gotoLastSlide( ) throw (css::uno::RuntimeException);
204 : virtual void SAL_CALL gotoBookmark( const ::rtl::OUString& Bookmark ) throw (css::uno::RuntimeException);
205 : virtual void SAL_CALL gotoSlide( const css::uno::Reference< css::drawing::XDrawPage >& Page ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
206 : virtual void SAL_CALL gotoSlideIndex( ::sal_Int32 Index ) throw (css::uno::RuntimeException);
207 : virtual void SAL_CALL stopSound( ) throw (css::uno::RuntimeException);
208 : virtual void SAL_CALL pause( ) throw (css::uno::RuntimeException);
209 : virtual void SAL_CALL resume( ) throw (css::uno::RuntimeException);
210 : virtual ::sal_Bool SAL_CALL isPaused( ) throw (css::uno::RuntimeException);
211 : virtual void SAL_CALL blankScreen( ::sal_Int32 Color ) throw (css::uno::RuntimeException);
212 : virtual void SAL_CALL activate( ) throw (css::uno::RuntimeException);
213 : virtual void SAL_CALL deactivate( ) throw (css::uno::RuntimeException);
214 : virtual ::sal_Bool SAL_CALL isActive( ) throw (css::uno::RuntimeException);
215 : virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getCurrentSlide( ) throw (css::uno::RuntimeException);
216 : virtual ::sal_Int32 SAL_CALL getCurrentSlideIndex( ) throw (css::uno::RuntimeException);
217 : virtual ::sal_Int32 SAL_CALL getNextSlideIndex( ) throw (css::uno::RuntimeException);
218 : virtual ::sal_Bool SAL_CALL isEndless( ) throw (css::uno::RuntimeException);
219 : virtual ::sal_Bool SAL_CALL isFullScreen( ) throw (css::uno::RuntimeException);
220 : virtual css::uno::Reference< css::presentation::XSlideShow > SAL_CALL getSlideShow( ) throw (css::uno::RuntimeException);
221 :
222 : // XIndexAccess
223 : virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
224 : virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
225 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
226 : virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
227 :
228 : // will be called from the SlideShowListenerProxy when this event is fired from the XSlideShow
229 : void slideEnded(const bool bReverse);
230 : void hyperLinkClicked(const ::rtl::OUString & hyperLink) throw (css::uno::RuntimeException);
231 : void click(const css::uno::Reference< css::drawing::XShape > & xShape, const css::awt::MouseEvent & aOriginalEvent);
232 :
233 : /// ends the presentation async
234 : void endPresentation();
235 :
236 0 : ViewShell* getViewShell() const { return mpViewShell; }
237 :
238 : void paint( const Rectangle& rRect );
239 : bool keyInput(const KeyEvent& rKEvt);
240 : void mouseButtonUp(const MouseEvent& rMEvt);
241 :
242 : private:
243 : SlideshowImpl(SlideshowImpl &); // not defined
244 : void operator =(SlideshowImpl &); // not defined
245 :
246 : virtual ~SlideshowImpl();
247 :
248 : // overload WeakComponentImplHelperBase::disposing()
249 : // This function is called upon disposing the component,
250 : // if your component needs special work when it becomes
251 : // disposed, do it here.
252 : virtual void SAL_CALL disposing();
253 :
254 : // internal
255 : bool startShow( PresentationSettingsEx* pPresSettings );
256 : bool startPreview(
257 : const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
258 : const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode,
259 : ::Window* pParent );
260 :
261 : ShowWindow* getShowWindow() const { return mpShowWindow; }
262 :
263 : /** forces an async call to update in the main thread */
264 : void startUpdateTimer();
265 :
266 : double update();
267 :
268 : void createSlideList( bool bAll, bool bStartWithActualSlide, const String& rPresSlide );
269 :
270 : void displayCurrentSlide (const bool bSkipAllMainSequenceEffects = false);
271 :
272 : void displaySlideNumber( sal_Int32 nSlide );
273 : void displaySlideIndex( sal_Int32 nIndex );
274 : sal_Int32 getCurrentSlideNumber();
275 : sal_Int32 getFirstSlideNumber();
276 : sal_Int32 getLastSlideNumber();
277 0 : inline bool isInputFreezed() const { return mbInputFreeze; }
278 :
279 : void jumpToBookmark( const String& sBookmark );
280 :
281 : void hideChildWindows();
282 : void showChildWindows();
283 :
284 : void resize( const Size& rSize );
285 :
286 : void setActiveXToolbarsVisible( sal_Bool bVisible );
287 :
288 : DECL_LINK(updateHdl, void *);
289 : DECL_LINK( PostYieldListener, void* );
290 : DECL_LINK(ReadyForNextInputHdl, void *);
291 : DECL_LINK( endPresentationHdl, void* );
292 : DECL_LINK( ContextMenuSelectHdl, Menu * );
293 : DECL_LINK( ContextMenuHdl, void* );
294 : DECL_LINK(deactivateHdl, void *);
295 : DECL_LINK( EventListenerHdl, VclSimpleEvent* );
296 :
297 : // helper
298 : void receiveRequest(SfxRequest& rReq);
299 :
300 : /** called only by the slideshow view when the first paint event occurs.
301 : This actually starts the slideshow. */
302 : void onFirstPaint();
303 :
304 0 : long getRestoreSlide() const { return mnRestoreSlide; }
305 :
306 : private:
307 : bool startShowImpl(
308 : const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
309 :
310 : SfxViewFrame* getViewFrame() const;
311 : SfxDispatcher* getDispatcher() const;
312 : SfxBindings* getBindings() const;
313 :
314 : sal_Int32 getSlideNumberForBookmark( const rtl::OUString& rStrBookmark );
315 :
316 : void removeShapeEvents();
317 : void registerShapeEvents( sal_Int32 nSlideNumber );
318 : void registerShapeEvents( css::uno::Reference< css::drawing::XShapes >& xShapes ) throw (css::uno::Exception);
319 :
320 : css::uno::Reference< css::presentation::XSlideShow > createSlideShow() const;
321 :
322 : void setAutoSaveState( bool bOn );
323 : void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects);
324 :
325 : /** Called by PostYieldListener and updateHdl handlers this method is
326 : responsible to call the slideshow update() method and, depending on
327 : its return value, wait for a certain amount of time before another
328 : call to update() is scheduled.
329 : */
330 : sal_Int32 updateSlideShow (void);
331 :
332 : css::uno::Reference< css::presentation::XSlideShow > mxShow;
333 : comphelper::ImplementationReference< ::sd::SlideShowView, css::presentation::XSlideShowView > mxView;
334 : css::uno::Reference< css::frame::XModel > mxModel;
335 :
336 : Timer maUpdateTimer;
337 : Timer maInputFreezeTimer;
338 : Timer maDeactivateTimer;
339 :
340 : ::sd::View* mpView;
341 : ViewShell* mpViewShell;
342 : DrawDocShell* mpDocSh;
343 : SdDrawDocument* mpDoc;
344 :
345 : SfxItemSet* mpNewAttr;
346 : ::Window* mpParentWindow;
347 : ShowWindow* mpShowWindow;
348 : PushButton* mpTimeButton;
349 :
350 : boost::shared_ptr< AnimationSlideController > mpSlideController;
351 :
352 : long mnRestoreSlide;
353 : Point maSlideOrigin;
354 : Point maPopupMousePos;
355 : Size maSlideSize;
356 : Size maPresSize;
357 : AnimationMode meAnimationMode;
358 : String maCharBuffer;
359 : Pointer maOldPointer;
360 : Pointer maPencil;
361 : std::vector< ::sd::Window* > maDrawModeWindows;
362 : ::sd::Window* mpOldActiveWindow;
363 : Link maStarBASICGlobalErrorHdl;
364 : unsigned long mnChildMask;
365 : bool mbGridVisible;
366 : bool mbBordVisible;
367 : bool mbSlideBorderVisible;
368 : bool mbSetOnlineSpelling;
369 : bool mbDisposed;
370 : bool mbMouseIsDrawing;
371 : bool mbAutoSaveWasOn;
372 : bool mbRehearseTimings;
373 : bool mbDesignMode;
374 : bool mbIsPaused;
375 : bool mbWasPaused; // used to cache pause state during context menu
376 : bool mbInputFreeze;
377 : sal_Bool mbActive;
378 :
379 : PresentationSettings maPresSettings;
380 : sal_Int32 mnUserPaintColor;
381 :
382 : bool mbUsePen;
383 : double mdUserPaintStrokeWidth;
384 :
385 : /// used in updateHdl to prevent recursive calls
386 : sal_Int32 mnEntryCounter;
387 :
388 : sal_Int32 mnLastSlideNumber;
389 : WrappedShapeEventImplMap maShapeEventMap;
390 :
391 : ::rtl::OUString msOnClick;
392 : ::rtl::OUString msBookmark;
393 : ::rtl::OUString msVerb;
394 :
395 : css::uno::Reference< css::drawing::XDrawPage > mxPreviewDrawPage;
396 : css::uno::Reference< css::animations::XAnimationNode > mxPreviewAnimationNode;
397 :
398 : css::uno::Reference< css::media::XPlayer > mxPlayer;
399 :
400 : ::std::auto_ptr<PaneHider> mpPaneHider;
401 :
402 : sal_uLong mnEndShowEvent;
403 : sal_uLong mnContextMenuEvent;
404 : sal_Int32 mnUpdateEvent;
405 :
406 : css::uno::Reference< css::presentation::XPresentation2 > mxPresentation;
407 : ::rtl::Reference< SlideShowListenerProxy > mxListenerProxy;
408 : };
409 :
410 : } // namespace ::sd
411 :
412 : #endif
413 :
414 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|