1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _SD_SlideShowImpl_HXX_
29 #define _SD_SlideShowImpl_HXX_
31 #include "sal/config.h"
32 #include "com/sun/star/uno/XComponentContext.hpp"
33 #include "cppuhelper/compbase1.hxx"
34 #include "cppuhelper/compbase2.hxx"
35 #include "cppuhelper/basemutex.hxx"
36 #include "cppuhelper/propertysetmixin.hxx"
37 #include <com/sun/star/awt/XActivateListener.hpp>
38 #include <com/sun/star/presentation/XSlideShow.hpp>
39 #include <com/sun/star/presentation/XSlideShowView.hpp>
40 #include <com/sun/star/presentation/XSlideShowListener.hpp>
41 #include <com/sun/star/presentation/XSlideShowController.hpp>
42 #include "com/sun/star/presentation/XShapeEventListener.hpp"
43 #include <com/sun/star/awt/WindowEvent.hpp>
44 #include <com/sun/star/awt/XWindowListener.hpp>
45 #include <com/sun/star/awt/XWindow.hpp>
46 #include <com/sun/star/awt/XWindowPeer.hpp>
47 #include <com/sun/star/util/XModifyListener.hpp>
48 #include <com/sun/star/awt/XPaintListener.hpp>
49 #include <com/sun/star/awt/XPointer.hpp>
50 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
51 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
52 #include <com/sun/star/presentation/ClickAction.hpp>
53 #include <com/sun/star/media/XManager.hpp>
54 #include <com/sun/star/media/XPlayer.hpp>
56 #include <toolkit/helper/vclunohelper.hxx>
58 #include <basegfx/matrix/b2dhommatrix.hxx>
59 #include <basegfx/tools/canvastools.hxx>
60 #include <vcl/help.hxx>
61 #include <tools/urlobj.hxx>
62 #include <unotools/pathoptions.hxx>
63 #include <unotools/saveopt.hxx>
64 #include <sfx2/bindings.hxx>
65 #include <sfx2/dispatch.hxx>
66 #include <sfx2/viewfrm.hxx>
67 #include <basic/sbstar.hxx>
68 #include <svx/svdpagv.hxx>
69 #include <svx/fmshell.hxx>
71 #ifndef _SVX_SVXIDS_HRC
72 #include <svx/svxids.hrc>
75 #include "cusshow.hxx"
76 #include "ViewShellBase.hxx"
77 #include "PresentationViewShell.hxx"
78 #include "ViewShell.hxx"
79 #include "drawview.hxx"
80 #include "drawdoc.hxx"
82 #include "showwindow.hxx"
84 #include "optsitem.hxx"
85 #include "FrameView.hxx"
86 #include "DrawDocShell.hxx"
92 #include "slideshow.hxx"
97 namespace css
= ::com::sun::star
;
102 class AnimationSlideController
;
105 // --------------------------------------------------------------------
107 struct PresentationSettingsEx
: public PresentationSettings
109 sal_Bool mbRehearseTimings
;
111 ::Window
* mpParentWindow
;
112 css::uno::Reference
< css::drawing::XDrawPage
> mxStartPage
;
113 css::uno::Reference
< css::animations::XAnimationNode
> mxAnimationNode
;
115 PresentationSettingsEx( const PresentationSettingsEx
& );
116 PresentationSettingsEx( PresentationSettings
& );
118 void SetArguments( const css::uno::Sequence
< css::beans::PropertyValue
>& rArguments
) throw (css::lang::IllegalArgumentException
);
120 void SetPropertyValue( const ::rtl::OUString
& rProperty
, const css::uno::Any
& rValue
) throw (css::lang::IllegalArgumentException
);
123 // --------------------------------------------------------------------
125 struct WrappedShapeEventImpl
127 css::presentation::ClickAction meClickAction
;
129 ::rtl::OUString maStrBookmark
;
130 WrappedShapeEventImpl() : meClickAction( css::presentation::ClickAction_NONE
), mnVerb( 0 ) {};
133 typedef boost::shared_ptr
< WrappedShapeEventImpl
> WrappedShapeEventImplPtr
;
134 typedef std::map
< css::uno::Reference
< css::drawing::XShape
>, WrappedShapeEventImplPtr
> WrappedShapeEventImplMap
;
136 // --------------------------------------------------------------------
138 class SlideShowListenerProxy
: private ::cppu::BaseMutex
,
139 public ::cppu::WeakImplHelper2
< css::presentation::XSlideShowListener
, css::presentation::XShapeEventListener
>
142 SlideShowListenerProxy( const rtl::Reference
< SlideshowImpl
>& xController
, const css::uno::Reference
< css::presentation::XSlideShow
>& xSlideShow
);
143 virtual ~SlideShowListenerProxy();
145 void addAsSlideShowListener();
146 void removeAsSlideShowListener();
148 void addSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
);
149 void removeSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
);
151 void addShapeEventListener( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
152 void removeShapeEventListener( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
154 // css::animations::XAnimationListener
155 virtual void SAL_CALL
beginEvent( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
) throw (css::uno::RuntimeException
);
156 virtual void SAL_CALL
endEvent( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
) throw (css::uno::RuntimeException
);
157 virtual void SAL_CALL
repeat( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
, ::sal_Int32 Repeat
) throw (css::uno::RuntimeException
);
159 // css::presentation::XSlideShowListener:
160 virtual void SAL_CALL
paused() throw (css::uno::RuntimeException
);
161 virtual void SAL_CALL
resumed() throw (css::uno::RuntimeException
);
162 virtual void SAL_CALL
slideTransitionStarted() throw (css::uno::RuntimeException
);
163 virtual void SAL_CALL
slideTransitionEnded() throw (css::uno::RuntimeException
);
164 virtual void SAL_CALL
slideAnimationsEnded() throw (css::uno::RuntimeException
);
165 virtual void SAL_CALL
slideEnded(sal_Bool bReverse
) throw (css::uno::RuntimeException
);
166 virtual void SAL_CALL
hyperLinkClicked(const ::rtl::OUString
& hyperLink
) throw (css::uno::RuntimeException
);
168 // css::lang::XEventListener:
169 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) throw (css::uno::RuntimeException
);
171 // css::presentation::XShapeEventListener:
172 virtual void SAL_CALL
click(const css::uno::Reference
< css::drawing::XShape
> & xShape
, const css::awt::MouseEvent
& aOriginalEvent
) throw (css::uno::RuntimeException
);
174 ::cppu::OInterfaceContainerHelper maListeners
;
176 rtl::Reference
< SlideshowImpl
> mxController
;
177 css::uno::Reference
< css::presentation::XSlideShow
> mxSlideShow
;
180 // --------------------------------------------------------------------
182 typedef ::cppu::WeakComponentImplHelper2
< css::presentation::XSlideShowController
, css::container::XIndexAccess
> SlideshowImplBase
;
184 class SlideshowImpl
: private ::cppu::BaseMutex
, public SlideshowImplBase
186 friend class SlideShow
;
187 friend class SlideShowView
;
190 explicit SlideshowImpl( const css::uno::Reference
< css::presentation::XPresentation2
>& xPresentation
, ViewShell
* pViewSh
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, ::Window
* pParentWindow
);
192 // css::presentation::XSlideShowController:
193 virtual ::sal_Bool SAL_CALL
getAlwaysOnTop() throw (css::uno::RuntimeException
);
194 virtual void SAL_CALL
setAlwaysOnTop( ::sal_Bool _alwaysontop
) throw (css::uno::RuntimeException
);
195 virtual ::sal_Bool SAL_CALL
getMouseVisible() throw (css::uno::RuntimeException
);
196 virtual void SAL_CALL
setMouseVisible( ::sal_Bool _mousevisible
) throw (css::uno::RuntimeException
);
197 virtual ::sal_Bool SAL_CALL
getUsePen() throw (css::uno::RuntimeException
);
198 virtual void SAL_CALL
setUsePen( ::sal_Bool _usepen
) throw (css::uno::RuntimeException
);
199 virtual ::sal_Int32 SAL_CALL
getPenColor() throw (css::uno::RuntimeException
);
200 virtual void SAL_CALL
setPenColor( ::sal_Int32 _pencolor
) throw (css::uno::RuntimeException
);
201 virtual void SAL_CALL
setUseEraser( ::sal_Bool _usepen
) throw (css::uno::RuntimeException
);
202 virtual double SAL_CALL
getPenWidth() throw (css::uno::RuntimeException
);
203 virtual void SAL_CALL
setPenWidth( double dStrokeWidth
) throw (css::uno::RuntimeException
);
204 virtual void SAL_CALL
setEraseAllInk( bool bEraseAllInk
) throw (css::uno::RuntimeException
);
205 virtual void SAL_CALL
setEraseInk( sal_Int32 nEraseInkSize
) throw (css::uno::RuntimeException
);
206 virtual void SAL_CALL
setPenMode( bool bSwitchPenMode
) throw (css::uno::RuntimeException
);
207 virtual void SAL_CALL
setEraserMode( bool bSwitchEraserMode
) throw (css::uno::RuntimeException
);
208 virtual ::sal_Bool SAL_CALL
isRunning( ) throw (css::uno::RuntimeException
);
209 virtual ::sal_Int32 SAL_CALL
getSlideCount( ) throw (css::uno::RuntimeException
);
210 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
getSlideByIndex( ::sal_Int32 Index
) throw (css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
);
211 virtual void SAL_CALL
addSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
) throw (css::uno::RuntimeException
);
212 virtual void SAL_CALL
removeSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
) throw (css::uno::RuntimeException
);
213 virtual void SAL_CALL
gotoNextEffect( ) throw (css::uno::RuntimeException
);
214 virtual void SAL_CALL
gotoPreviousEffect( ) throw (css::uno::RuntimeException
);
215 virtual void SAL_CALL
gotoFirstSlide( ) throw (css::uno::RuntimeException
);
216 virtual void SAL_CALL
gotoNextSlide( ) throw (css::uno::RuntimeException
);
217 virtual void SAL_CALL
gotoPreviousSlide( ) throw (css::uno::RuntimeException
);
218 virtual void SAL_CALL
gotoLastSlide( ) throw (css::uno::RuntimeException
);
219 virtual void SAL_CALL
gotoBookmark( const ::rtl::OUString
& Bookmark
) throw (css::uno::RuntimeException
);
220 virtual void SAL_CALL
gotoSlide( const css::uno::Reference
< css::drawing::XDrawPage
>& Page
) throw (css::lang::IllegalArgumentException
, css::uno::RuntimeException
);
221 virtual void SAL_CALL
gotoSlideIndex( ::sal_Int32 Index
) throw (css::uno::RuntimeException
);
222 virtual void SAL_CALL
stopSound( ) throw (css::uno::RuntimeException
);
223 virtual void SAL_CALL
pause( ) throw (css::uno::RuntimeException
);
224 virtual void SAL_CALL
resume( ) throw (css::uno::RuntimeException
);
225 virtual ::sal_Bool SAL_CALL
isPaused( ) throw (css::uno::RuntimeException
);
226 virtual void SAL_CALL
blankScreen( ::sal_Int32 Color
) throw (css::uno::RuntimeException
);
227 virtual void SAL_CALL
activate( ) throw (css::uno::RuntimeException
);
228 virtual void SAL_CALL
deactivate( ) throw (css::uno::RuntimeException
);
229 virtual ::sal_Bool SAL_CALL
isActive( ) throw (css::uno::RuntimeException
);
230 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
getCurrentSlide( ) throw (css::uno::RuntimeException
);
231 virtual ::sal_Int32 SAL_CALL
getCurrentSlideIndex( ) throw (css::uno::RuntimeException
);
232 virtual ::sal_Int32 SAL_CALL
getNextSlideIndex( ) throw (css::uno::RuntimeException
);
233 virtual ::sal_Bool SAL_CALL
isEndless( ) throw (css::uno::RuntimeException
);
234 virtual ::sal_Bool SAL_CALL
isFullScreen( ) throw (css::uno::RuntimeException
);
235 virtual css::uno::Reference
< css::presentation::XSlideShow
> SAL_CALL
getSlideShow( ) throw (css::uno::RuntimeException
);
238 virtual ::sal_Int32 SAL_CALL
getCount( ) throw (::com::sun::star::uno::RuntimeException
);
239 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
);
240 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw (::com::sun::star::uno::RuntimeException
);
241 virtual ::sal_Bool SAL_CALL
hasElements( ) throw (::com::sun::star::uno::RuntimeException
);
243 // will be called from the SlideShowListenerProxy when this event is fired from the XSlideShow
244 void slideEnded(const bool bReverse
);
245 void hyperLinkClicked(const ::rtl::OUString
& hyperLink
) throw (css::uno::RuntimeException
);
246 void click(const css::uno::Reference
< css::drawing::XShape
> & xShape
, const css::awt::MouseEvent
& aOriginalEvent
);
248 /// ends the presentation async
249 void endPresentation();
251 ViewShell
* getViewShell() const { return mpViewShell
; }
253 void paint( const Rectangle
& rRect
);
254 bool keyInput(const KeyEvent
& rKEvt
);
255 void mouseButtonUp(const MouseEvent
& rMEvt
);
258 SlideshowImpl(SlideshowImpl
&); // not defined
259 void operator =(SlideshowImpl
&); // not defined
261 virtual ~SlideshowImpl();
263 // overload WeakComponentImplHelperBase::disposing()
264 // This function is called upon disposing the component,
265 // if your component needs special work when it becomes
266 // disposed, do it here.
267 virtual void SAL_CALL
disposing();
270 bool startShow( PresentationSettingsEx
* pPresSettings
);
272 const css::uno::Reference
< css::drawing::XDrawPage
>& xDrawPage
,
273 const css::uno::Reference
< css::animations::XAnimationNode
>& xAnimationNode
,
276 ShowWindow
* getShowWindow() const { return mpShowWindow
; }
278 /** forces an async call to update in the main thread */
279 void startUpdateTimer();
283 void createSlideList( bool bAll
, bool bStartWithActualSlide
, const String
& rPresSlide
);
285 void displayCurrentSlide (const bool bSkipAllMainSequenceEffects
= false);
287 void displaySlideNumber( sal_Int32 nSlide
);
288 void displaySlideIndex( sal_Int32 nIndex
);
289 sal_Int32
getCurrentSlideNumber();
290 sal_Int32
getFirstSlideNumber();
291 sal_Int32
getLastSlideNumber();
292 inline bool isInputFreezed() const { return mbInputFreeze
; }
294 void jumpToBookmark( const String
& sBookmark
);
296 void hideChildWindows();
297 void showChildWindows();
299 void resize( const Size
& rSize
);
301 void setActiveXToolbarsVisible( sal_Bool bVisible
);
303 DECL_LINK( updateHdl
, Timer
* );
304 DECL_LINK( PostYieldListener
, void* );
305 DECL_LINK( ReadyForNextInputHdl
, Timer
* );
306 DECL_LINK( endPresentationHdl
, void* );
307 DECL_LINK( ContextMenuSelectHdl
, Menu
* );
308 DECL_LINK( ContextMenuHdl
, void* );
309 DECL_LINK( deactivateHdl
, Timer
* );
310 DECL_LINK( EventListenerHdl
, VclSimpleEvent
* );
313 void receiveRequest(SfxRequest
& rReq
);
315 /** called only by the slideshow view when the first paint event occurs.
316 This actually starts the slideshow. */
319 long getRestoreSlide() const { return mnRestoreSlide
; }
323 const css::uno::Sequence
< css::beans::PropertyValue
>& aProperties
);
325 SfxViewFrame
* getViewFrame() const;
326 SfxDispatcher
* getDispatcher() const;
327 SfxBindings
* getBindings() const;
329 sal_Int32
getSlideNumberForBookmark( const rtl::OUString
& rStrBookmark
);
331 void removeShapeEvents();
332 void registerShapeEvents( sal_Int32 nSlideNumber
);
333 void registerShapeEvents( css::uno::Reference
< css::drawing::XShapes
>& xShapes
) throw (css::uno::Exception
);
335 css::uno::Reference
< css::presentation::XSlideShow
> createSlideShow() const;
337 void setAutoSaveState( bool bOn
);
338 void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects
);
340 /** Called by PostYieldListener and updateHdl handlers this method is
341 responsible to call the slideshow update() method and, depending on
342 its return value, wait for a certain amount of time before another
343 call to update() is scheduled.
345 sal_Int32
updateSlideShow (void);
347 css::uno::Reference
< css::presentation::XSlideShow
> mxShow
;
348 comphelper::ImplementationReference
< ::sd::SlideShowView
, css::presentation::XSlideShowView
> mxView
;
349 css::uno::Reference
< css::frame::XModel
> mxModel
;
352 Timer maInputFreezeTimer
;
353 Timer maDeactivateTimer
;
356 ViewShell
* mpViewShell
;
357 DrawDocShell
* mpDocSh
;
358 SdDrawDocument
* mpDoc
;
360 SfxItemSet
* mpNewAttr
;
361 ::Window
* mpParentWindow
;
362 ShowWindow
* mpShowWindow
;
363 PushButton
* mpTimeButton
;
365 boost::shared_ptr
< AnimationSlideController
> mpSlideController
;
369 Point maPopupMousePos
;
372 AnimationMode meAnimationMode
;
374 Pointer maOldPointer
;
376 std::vector
< ::sd::Window
* > maDrawModeWindows
;
377 ::sd::Window
* mpOldActiveWindow
;
378 Link maStarBASICGlobalErrorHdl
;
379 unsigned long mnChildMask
;
382 bool mbSlideBorderVisible
;
383 bool mbSetOnlineSpelling
;
385 bool mbMouseIsDrawing
;
386 bool mbAutoSaveWasOn
;
387 bool mbRehearseTimings
;
390 bool mbWasPaused
; // used to cache pause state during context menu
394 PresentationSettings maPresSettings
;
395 sal_Int32 mnUserPaintColor
;
398 double mdUserPaintStrokeWidth
;
400 /// used in updateHdl to prevent recursive calls
401 sal_Int32 mnEntryCounter
;
403 sal_Int32 mnLastSlideNumber
;
404 WrappedShapeEventImplMap maShapeEventMap
;
406 ::rtl::OUString msOnClick
;
407 ::rtl::OUString msBookmark
;
408 ::rtl::OUString msVerb
;
410 css::uno::Reference
< css::drawing::XDrawPage
> mxPreviewDrawPage
;
411 css::uno::Reference
< css::animations::XAnimationNode
> mxPreviewAnimationNode
;
413 css::uno::Reference
< css::media::XPlayer
> mxPlayer
;
415 ::std::auto_ptr
<PaneHider
> mpPaneHider
;
417 sal_uLong mnEndShowEvent
;
418 sal_uLong mnContextMenuEvent
;
419 sal_Int32 mnUpdateEvent
;
421 css::uno::Reference
< css::presentation::XPresentation2
> mxPresentation
;
422 ::rtl::Reference
< SlideShowListenerProxy
> mxListenerProxy
;