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: slideshowimpl.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 ************************************************************************/
31 #ifndef _SD_SlideShowImpl_HXX_
32 #define _SD_SlideShowImpl_HXX_
34 #include "sal/config.h"
35 #include "com/sun/star/uno/XComponentContext.hpp"
36 #include "cppuhelper/compbase1.hxx"
37 #include "cppuhelper/compbase2.hxx"
38 #include "cppuhelper/basemutex.hxx"
39 #include "cppuhelper/propertysetmixin.hxx"
40 #include <com/sun/star/awt/XActivateListener.hpp>
41 #include <com/sun/star/presentation/XSlideShow.hpp>
42 #include <com/sun/star/presentation/XSlideShowView.hpp>
43 #include <com/sun/star/presentation/XSlideShowListener.hpp>
44 #include <com/sun/star/presentation/XSlideShowController.hpp>
45 #include "com/sun/star/presentation/XShapeEventListener.hpp"
46 #include <com/sun/star/awt/WindowEvent.hpp>
47 #include <com/sun/star/awt/XWindowListener.hpp>
48 #include <com/sun/star/awt/XWindow.hpp>
49 #include <com/sun/star/awt/XWindowPeer.hpp>
50 #include <com/sun/star/util/XModifyListener.hpp>
51 #include <com/sun/star/awt/XPaintListener.hpp>
52 #include <com/sun/star/awt/XPointer.hpp>
53 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
54 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
55 #include <com/sun/star/presentation/ClickAction.hpp>
56 #include <com/sun/star/media/XManager.hpp>
57 #include <com/sun/star/media/XPlayer.hpp>
59 #include <toolkit/helper/vclunohelper.hxx>
61 #include <basegfx/matrix/b2dhommatrix.hxx>
62 #include <basegfx/tools/canvastools.hxx>
63 #include <vcl/help.hxx>
64 #include <tools/urlobj.hxx>
65 #include <svtools/pathoptions.hxx>
66 #include <svtools/saveopt.hxx>
67 #include <sfx2/bindings.hxx>
68 #include <sfx2/dispatch.hxx>
69 #include <sfx2/viewfrm.hxx>
70 #include <basic/sbstar.hxx>
71 #include <svx/svdpagv.hxx>
72 #include <svx/fmshell.hxx>
74 #ifndef _SVX_SVXIDS_HRC
75 #include <svx/svxids.hrc>
78 #include "cusshow.hxx"
79 #include "ViewShellBase.hxx"
80 #include "PresentationViewShell.hxx"
81 #include "ViewShell.hxx"
82 #include "drawview.hxx"
83 #include "drawdoc.hxx"
85 #include "showwindow.hxx"
87 #include "optsitem.hxx"
88 #include "FrameView.hxx"
89 #include "DrawDocShell.hxx"
95 #include "slideshow.hxx"
100 namespace css
= ::com::sun::star
;
105 class AnimationSlideController
;
108 // --------------------------------------------------------------------
110 struct PresentationSettingsEx
: public PresentationSettings
112 sal_Bool mbRehearseTimings
;
114 ::Window
* mpParentWindow
;
115 css::uno::Reference
< css::drawing::XDrawPage
> mxStartPage
;
116 css::uno::Reference
< css::animations::XAnimationNode
> mxAnimationNode
;
118 PresentationSettingsEx();
119 PresentationSettingsEx( PresentationSettingsEx
& );
120 PresentationSettingsEx( PresentationSettings
& );
122 void SetArguments( const css::uno::Sequence
< css::beans::PropertyValue
>& rArguments
) throw (css::lang::IllegalArgumentException
);
124 void SetPropertyValue( const ::rtl::OUString
& rProperty
, const css::uno::Any
& rValue
) throw (css::lang::IllegalArgumentException
);
127 // --------------------------------------------------------------------
129 struct WrappedShapeEventImpl
131 css::presentation::ClickAction meClickAction
;
133 ::rtl::OUString maStrBookmark
;
134 WrappedShapeEventImpl() : meClickAction( css::presentation::ClickAction_NONE
), mnVerb( 0 ) {};
137 typedef boost::shared_ptr
< WrappedShapeEventImpl
> WrappedShapeEventImplPtr
;
138 typedef std::map
< css::uno::Reference
< css::drawing::XShape
>, WrappedShapeEventImplPtr
> WrappedShapeEventImplMap
;
140 // --------------------------------------------------------------------
142 class SlideShowListenerProxy
: private ::cppu::BaseMutex
,
143 public ::cppu::WeakImplHelper2
< css::presentation::XSlideShowListener
, css::presentation::XShapeEventListener
>
146 SlideShowListenerProxy( const rtl::Reference
< SlideshowImpl
>& xController
, const css::uno::Reference
< css::presentation::XSlideShow
>& xSlideShow
);
147 virtual ~SlideShowListenerProxy();
149 void addAsSlideShowListener();
150 void removeAsSlideShowListener();
152 void addSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
);
153 void removeSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
);
155 void addShapeEventListener( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
156 void removeShapeEventListener( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
158 // css::animations::XAnimationListener
159 virtual void SAL_CALL
beginEvent( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
) throw (css::uno::RuntimeException
);
160 virtual void SAL_CALL
endEvent( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
) throw (css::uno::RuntimeException
);
161 virtual void SAL_CALL
repeat( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
, ::sal_Int32 Repeat
) throw (css::uno::RuntimeException
);
163 // css::presentation::XSlideShowListener:
164 virtual void SAL_CALL
paused() throw (css::uno::RuntimeException
);
165 virtual void SAL_CALL
resumed() throw (css::uno::RuntimeException
);
166 virtual void SAL_CALL
slideTransitionStarted() throw (css::uno::RuntimeException
);
167 virtual void SAL_CALL
slideTransitionEnded() throw (css::uno::RuntimeException
);
168 virtual void SAL_CALL
slideAnimationsEnded() throw (css::uno::RuntimeException
);
169 virtual void SAL_CALL
slideEnded(sal_Bool bReverse
) throw (css::uno::RuntimeException
);
170 virtual void SAL_CALL
hyperLinkClicked(const ::rtl::OUString
& hyperLink
) throw (css::uno::RuntimeException
);
172 // css::lang::XEventListener:
173 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) throw (css::uno::RuntimeException
);
175 // css::presentation::XShapeEventListener:
176 virtual void SAL_CALL
click(const css::uno::Reference
< css::drawing::XShape
> & xShape
, const css::awt::MouseEvent
& aOriginalEvent
) throw (css::uno::RuntimeException
);
178 ::cppu::OInterfaceContainerHelper maListeners
;
180 rtl::Reference
< SlideshowImpl
> mxController
;
181 css::uno::Reference
< css::presentation::XSlideShow
> mxSlideShow
;
184 // --------------------------------------------------------------------
186 typedef ::cppu::WeakComponentImplHelper2
< css::presentation::XSlideShowController
, css::container::XIndexAccess
> SlideshowImplBase
;
188 class SlideshowImpl
: private ::cppu::BaseMutex
, public SlideshowImplBase
190 friend class SlideShow
;
191 friend class SlideShowView
;
194 explicit SlideshowImpl( const css::uno::Reference
< css::presentation::XPresentation2
>& xPresentation
, ViewShell
* pViewSh
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, ::Window
* pParentWindow
);
196 // css::presentation::XSlideShowController:
197 virtual ::sal_Bool SAL_CALL
getAlwaysOnTop() throw (css::uno::RuntimeException
);
198 virtual void SAL_CALL
setAlwaysOnTop( ::sal_Bool _alwaysontop
) throw (css::uno::RuntimeException
);
199 virtual ::sal_Bool SAL_CALL
getMouseVisible() throw (css::uno::RuntimeException
);
200 virtual void SAL_CALL
setMouseVisible( ::sal_Bool _mousevisible
) throw (css::uno::RuntimeException
);
201 virtual ::sal_Bool SAL_CALL
getUsePen() throw (css::uno::RuntimeException
);
202 virtual void SAL_CALL
setUsePen( ::sal_Bool _usepen
) throw (css::uno::RuntimeException
);
203 virtual double SAL_CALL
getPenWidth() throw (css::uno::RuntimeException
);
204 virtual void SAL_CALL
setPenWidth( double dStrokeWidth
) throw (css::uno::RuntimeException
);
205 virtual ::sal_Int32 SAL_CALL
getPenColor() throw (css::uno::RuntimeException
);
206 virtual void SAL_CALL
setPenColor( ::sal_Int32 _pencolor
) throw (css::uno::RuntimeException
);
207 virtual ::sal_Bool SAL_CALL
isRunning( ) throw (css::uno::RuntimeException
);
208 virtual ::sal_Int32 SAL_CALL
getSlideCount( ) throw (css::uno::RuntimeException
);
209 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
getSlideByIndex( ::sal_Int32 Index
) throw (css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
);
210 virtual void SAL_CALL
addSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
) throw (css::uno::RuntimeException
);
211 virtual void SAL_CALL
removeSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
) throw (css::uno::RuntimeException
);
212 virtual void SAL_CALL
gotoNextEffect( ) throw (css::uno::RuntimeException
);
213 virtual void SAL_CALL
gotoPreviousEffect( ) throw (css::uno::RuntimeException
);
214 virtual void SAL_CALL
gotoFirstSlide( ) throw (css::uno::RuntimeException
);
215 virtual void SAL_CALL
gotoNextSlide( ) throw (css::uno::RuntimeException
);
216 virtual void SAL_CALL
gotoPreviousSlide( ) throw (css::uno::RuntimeException
);
217 virtual void SAL_CALL
gotoLastSlide( ) throw (css::uno::RuntimeException
);
218 virtual void SAL_CALL
gotoBookmark( const ::rtl::OUString
& Bookmark
) throw (css::uno::RuntimeException
);
219 virtual void SAL_CALL
gotoSlide( const css::uno::Reference
< css::drawing::XDrawPage
>& Page
) throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
220 virtual void SAL_CALL
gotoSlideIndex( ::sal_Int32 Index
) throw (css::uno::RuntimeException
);
221 virtual void SAL_CALL
stopSound( ) throw (css::uno::RuntimeException
);
222 virtual void SAL_CALL
pause( ) throw (css::uno::RuntimeException
);
223 virtual void SAL_CALL
resume( ) throw (css::uno::RuntimeException
);
224 virtual ::sal_Bool SAL_CALL
isPaused( ) throw (css::uno::RuntimeException
);
225 virtual void SAL_CALL
blankScreen( ::sal_Int32 Color
) throw (css::uno::RuntimeException
);
226 virtual void SAL_CALL
activate( ) throw (css::uno::RuntimeException
);
227 virtual void SAL_CALL
deactivate( ) throw (css::uno::RuntimeException
);
228 virtual ::sal_Bool SAL_CALL
isActive( ) throw (css::uno::RuntimeException
);
229 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
getCurrentSlide( ) throw (css::uno::RuntimeException
);
230 virtual ::sal_Int32 SAL_CALL
getCurrentSlideIndex( ) throw (css::uno::RuntimeException
);
231 virtual ::sal_Int32 SAL_CALL
getNextSlideIndex( ) throw (css::uno::RuntimeException
);
232 virtual ::sal_Bool SAL_CALL
isEndless( ) throw (css::uno::RuntimeException
);
233 virtual ::sal_Bool SAL_CALL
isFullScreen( ) throw (css::uno::RuntimeException
);
234 virtual css::uno::Reference
< css::presentation::XSlideShow
> SAL_CALL
getSlideShow( ) throw (css::uno::RuntimeException
);
237 virtual ::sal_Int32 SAL_CALL
getCount( ) throw (::com::sun::star::uno::RuntimeException
);
238 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
);
239 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw (::com::sun::star::uno::RuntimeException
);
240 virtual ::sal_Bool SAL_CALL
hasElements( ) throw (::com::sun::star::uno::RuntimeException
);
242 // will be called from the SlideShowListenerProxy when this event is fired from the XSlideShow
243 void slideEnded(const bool bReverse
);
244 void hyperLinkClicked(const ::rtl::OUString
& hyperLink
) throw (css::uno::RuntimeException
);
245 void click(const css::uno::Reference
< css::drawing::XShape
> & xShape
, const css::awt::MouseEvent
& aOriginalEvent
);
247 /// ends the presentation async
248 void endPresentation();
250 ViewShell
* getViewShell() const { return mpViewShell
; }
252 void paint( const Rectangle
& rRect
);
253 bool keyInput(const KeyEvent
& rKEvt
);
254 void mouseButtonUp(const MouseEvent
& rMEvt
);
257 SlideshowImpl(SlideshowImpl
&); // not defined
258 void operator =(SlideshowImpl
&); // not defined
260 virtual ~SlideshowImpl();
262 // overload WeakComponentImplHelperBase::disposing()
263 // This function is called upon disposing the component,
264 // if your component needs special work when it becomes
265 // disposed, do it here.
266 virtual void SAL_CALL
disposing();
269 bool startShow( PresentationSettingsEx
* pPresSettings
);
271 const css::uno::Reference
< css::drawing::XDrawPage
>& xDrawPage
,
272 const css::uno::Reference
< css::animations::XAnimationNode
>& xAnimationNode
,
275 ShowWindow
* getShowWindow() const { return mpShowWindow
; }
277 /** forces an async call to update in the main thread */
278 void startUpdateTimer();
282 void createSlideList( bool bAll
, bool bStartWithActualSlide
, const String
& rPresSlide
);
284 void displayCurrentSlide (const bool bSkipAllMainSequenceEffects
= false);
286 void displaySlideNumber( sal_Int32 nSlide
);
287 void displaySlideIndex( sal_Int32 nIndex
);
288 sal_Int32
getCurrentSlideNumber();
289 sal_Int32
getFirstSlideNumber();
290 sal_Int32
getLastSlideNumber();
291 inline bool isInputFreezed() const { return mbInputFreeze
; }
293 void jumpToBookmark( const String
& sBookmark
);
295 void hideChildWindows();
296 void showChildWindows();
298 void resize( const Size
& rSize
);
300 void setActiveXToolbarsVisible( sal_Bool bVisible
);
302 DECL_LINK( updateHdl
, Timer
* );
303 DECL_LINK( ReadyForNextInputHdl
, Timer
* );
304 DECL_LINK( endPresentationHdl
, void* );
305 DECL_LINK( ContextMenuSelectHdl
, Menu
* );
306 DECL_LINK( ContextMenuHdl
, void* );
307 DECL_LINK( deactivateHdl
, Timer
* );
308 DECL_LINK( EventListenerHdl
, VclSimpleEvent
* );
311 void receiveRequest(SfxRequest
& rReq
);
313 /** called only by the slideshow view when the first paint event occurs.
314 This actually starts the slideshow. */
317 long getRestoreSlide() const { return mnRestoreSlide
; }
321 const css::uno::Sequence
< css::beans::PropertyValue
>& aProperties
);
323 SfxViewFrame
* getViewFrame() const;
324 SfxDispatcher
* getDispatcher() const;
325 SfxBindings
* getBindings() const;
327 sal_Int32
getSlideNumberForBookmark( const rtl::OUString
& rStrBookmark
);
329 void removeShapeEvents();
330 void registerShapeEvents( sal_Int32 nSlideNumber
);
331 void registerShapeEvents( css::uno::Reference
< css::drawing::XShapes
>& xShapes
) throw (css::uno::Exception
);
333 css::uno::Reference
< css::presentation::XSlideShow
> createSlideShow() const;
335 void setAutoSaveState( bool bOn
);
336 void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects
);
338 css::uno::Reference
< css::presentation::XSlideShow
> mxShow
;
339 comphelper::ImplementationReference
< ::sd::SlideShowView
, css::presentation::XSlideShowView
> mxView
;
340 css::uno::Reference
< css::frame::XModel
> mxModel
;
343 Timer maInputFreezeTimer
;
344 Timer maDeactivateTimer
;
347 ViewShell
* mpViewShell
;
348 DrawDocShell
* mpDocSh
;
349 SdDrawDocument
* mpDoc
;
351 SfxItemSet
* mpNewAttr
;
352 ::Window
* mpParentWindow
;
353 ShowWindow
* mpShowWindow
;
354 PushButton
* mpTimeButton
;
356 boost::shared_ptr
< AnimationSlideController
> mpSlideController
;
360 Point maPopupMousePos
;
363 AnimationMode meAnimationMode
;
365 Pointer maOldPointer
;
367 std::vector
< ::sd::Window
* > maDrawModeWindows
;
368 ::sd::Window
* mpOldActiveWindow
;
369 Link maStarBASICGlobalErrorHdl
;
370 unsigned long mnChildMask
;
373 bool mbSlideBorderVisible
;
374 bool mbSetOnlineSpelling
;
376 bool mbMouseIsDrawing
;
377 bool mbAutoSaveWasOn
;
378 bool mbRehearseTimings
;
381 bool mbWasPaused
; // used to cache pause state during context menu
385 PresentationSettings maPresSettings
;
386 sal_Int32 mnUserPaintColor
;
388 double mdUserPaintStrokeWidth
;
390 /// used in updateHdl to prevent recursive calls
391 sal_Int32 mnEntryCounter
;
393 sal_Int32 mnLastSlideNumber
;
394 WrappedShapeEventImplMap maShapeEventMap
;
396 ::rtl::OUString msOnClick
;
397 ::rtl::OUString msBookmark
;
398 ::rtl::OUString msVerb
;
400 css::uno::Reference
< css::drawing::XDrawPage
> mxPreviewDrawPage
;
401 css::uno::Reference
< css::animations::XAnimationNode
> mxPreviewAnimationNode
;
403 css::uno::Reference
< css::media::XPlayer
> mxPlayer
;
405 ::std::auto_ptr
<PaneHider
> mpPaneHider
;
407 ULONG mnEndShowEvent
;
408 ULONG mnContextMenuEvent
;
409 sal_Int32 mnUpdateEvent
;
411 css::uno::Reference
< css::presentation::XPresentation2
> mxPresentation
;
412 ::rtl::Reference
< SlideShowListenerProxy
> mxListenerProxy
;