1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESHOW_SLIDESHOWIMPL_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESHOW_SLIDESHOWIMPL_HXX
24 #include <sal/config.h>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <cppuhelper/compbase.hxx>
27 #include <cppuhelper/implbase.hxx>
28 #include <cppuhelper/basemutex.hxx>
29 #include <cppuhelper/propertysetmixin.hxx>
30 #include <comphelper/interfacecontainer2.hxx>
31 #include <com/sun/star/awt/XActivateListener.hpp>
32 #include <com/sun/star/presentation/XSlideShow.hpp>
33 #include <com/sun/star/presentation/XSlideShowListener.hpp>
34 #include <com/sun/star/presentation/XSlideShowController.hpp>
35 #include <com/sun/star/presentation/XShapeEventListener.hpp>
36 #include <com/sun/star/awt/WindowEvent.hpp>
37 #include <com/sun/star/awt/XWindowListener.hpp>
38 #include <com/sun/star/awt/XWindow.hpp>
39 #include <com/sun/star/awt/XWindowPeer.hpp>
40 #include <com/sun/star/util/XModifyListener.hpp>
41 #include <com/sun/star/awt/XPaintListener.hpp>
42 #include <com/sun/star/awt/XPointer.hpp>
43 #include <com/sun/star/drawing/XDrawPagesSupplier.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>
48 #include <basegfx/matrix/b2dhommatrix.hxx>
49 #include <basegfx/utils/canvastools.hxx>
50 #include <vcl/help.hxx>
51 #include <unotools/pathoptions.hxx>
52 #include <unotools/saveopt.hxx>
53 #include <sfx2/bindings.hxx>
54 #include <sfx2/dispatch.hxx>
55 #include <sfx2/viewfrm.hxx>
56 #include <basic/sbstar.hxx>
57 #include <svx/svdpagv.hxx>
58 #include <svx/fmshell.hxx>
60 #include <svx/svxids.hrc>
62 #include <cusshow.hxx>
63 #include <ViewShellBase.hxx>
64 #include <PresentationViewShell.hxx>
65 #include <ViewShell.hxx>
66 #include <drawview.hxx>
67 #include <drawdoc.hxx>
69 #include "showwindow.hxx"
71 #include <optsitem.hxx>
72 #include <FrameView.hxx>
73 #include <DrawDocShell.hxx>
77 #include <slideshow.hxx>
85 class AnimationSlideController
;
89 struct PresentationSettingsEx
: public PresentationSettings
91 bool mbRehearseTimings
;
93 VclPtr
<vcl::Window
> mpParentWindow
;
94 css::uno::Reference
< css::drawing::XDrawPage
> mxStartPage
;
95 css::uno::Reference
< css::animations::XAnimationNode
> mxAnimationNode
;
97 PresentationSettingsEx( const PresentationSettingsEx
& );
98 explicit PresentationSettingsEx( PresentationSettings
const & );
100 /// @throws css::lang::IllegalArgumentException
101 void SetArguments( const css::uno::Sequence
< css::beans::PropertyValue
>& rArguments
);
103 /// @throws css::lang::IllegalArgumentException
104 void SetPropertyValue( const OUString
& rProperty
, const css::uno::Any
& rValue
);
107 struct WrappedShapeEventImpl
109 css::presentation::ClickAction meClickAction
;
111 OUString maStrBookmark
;
112 WrappedShapeEventImpl() : meClickAction( css::presentation::ClickAction_NONE
), mnVerb( 0 ) {};
115 typedef std::shared_ptr
< WrappedShapeEventImpl
> WrappedShapeEventImplPtr
;
116 typedef std::map
< css::uno::Reference
< css::drawing::XShape
>, WrappedShapeEventImplPtr
> WrappedShapeEventImplMap
;
118 class SlideShowListenerProxy
: private ::cppu::BaseMutex
,
119 public ::cppu::WeakImplHelper
< css::presentation::XSlideShowListener
, css::presentation::XShapeEventListener
>
122 SlideShowListenerProxy( const rtl::Reference
< SlideshowImpl
>& xController
, const css::uno::Reference
< css::presentation::XSlideShow
>& xSlideShow
);
123 virtual ~SlideShowListenerProxy() override
;
125 void addAsSlideShowListener();
126 void removeAsSlideShowListener();
128 void addSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
);
129 void removeSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
);
131 void addShapeEventListener( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
132 void removeShapeEventListener( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
134 // css::animations::XAnimationListener
135 virtual void SAL_CALL
beginEvent( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
) override
;
136 virtual void SAL_CALL
endEvent( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
) override
;
137 virtual void SAL_CALL
repeat( const css::uno::Reference
< css::animations::XAnimationNode
>& Node
, ::sal_Int32 Repeat
) override
;
139 // css::presentation::XSlideShowListener:
140 virtual void SAL_CALL
paused() override
;
141 virtual void SAL_CALL
resumed() override
;
142 virtual void SAL_CALL
slideTransitionStarted() override
;
143 virtual void SAL_CALL
slideTransitionEnded() override
;
144 virtual void SAL_CALL
slideAnimationsEnded() override
;
145 virtual void SAL_CALL
slideEnded(sal_Bool bReverse
) override
;
146 virtual void SAL_CALL
hyperLinkClicked(const OUString
& hyperLink
) override
;
148 // css::lang::XEventListener:
149 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) override
;
151 // css::presentation::XShapeEventListener:
152 virtual void SAL_CALL
click(const css::uno::Reference
< css::drawing::XShape
> & xShape
, const css::awt::MouseEvent
& aOriginalEvent
) override
;
154 ::comphelper::OInterfaceContainerHelper2 maListeners
;
156 rtl::Reference
< SlideshowImpl
> mxController
;
157 css::uno::Reference
< css::presentation::XSlideShow
> mxSlideShow
;
160 typedef ::cppu::WeakComponentImplHelper
< css::presentation::XSlideShowController
, css::container::XIndexAccess
> SlideshowImplBase
;
162 class SlideshowImpl
: private ::cppu::BaseMutex
, public SlideshowImplBase
164 friend class SlideShow
;
165 friend class SlideShowView
;
168 explicit SlideshowImpl( const css::uno::Reference
< css::presentation::XPresentation2
>& xPresentation
, ViewShell
* pViewSh
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, vcl::Window
* pParentWindow
);
170 // css::presentation::XSlideShowController:
171 virtual sal_Bool SAL_CALL
getAlwaysOnTop() override
;
172 virtual void SAL_CALL
setAlwaysOnTop( sal_Bool _alwaysontop
) override
;
173 virtual sal_Bool SAL_CALL
getMouseVisible() override
;
174 virtual void SAL_CALL
setMouseVisible( sal_Bool _mousevisible
) override
;
175 virtual sal_Bool SAL_CALL
getUsePen() override
;
176 virtual void SAL_CALL
setUsePen( sal_Bool _usepen
) override
;
177 virtual ::sal_Int32 SAL_CALL
getPenColor() override
;
178 virtual void SAL_CALL
setPenColor( ::sal_Int32 _pencolor
) override
;
179 virtual double SAL_CALL
getPenWidth() override
;
180 virtual void SAL_CALL
setPenWidth( double dStrokeWidth
) override
;
181 /// @throws css::uno::RuntimeException
182 void setEraseAllInk( bool bEraseAllInk
);
183 virtual sal_Bool SAL_CALL
isRunning( ) override
;
184 virtual ::sal_Int32 SAL_CALL
getSlideCount( ) override
;
185 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
getSlideByIndex( ::sal_Int32 Index
) override
;
186 virtual void SAL_CALL
addSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
) override
;
187 virtual void SAL_CALL
removeSlideShowListener( const css::uno::Reference
< css::presentation::XSlideShowListener
>& Listener
) override
;
188 virtual void SAL_CALL
gotoNextEffect( ) override
;
189 virtual void SAL_CALL
gotoPreviousEffect( ) override
;
190 virtual void SAL_CALL
gotoFirstSlide( ) override
;
191 virtual void SAL_CALL
gotoNextSlide( ) override
;
192 virtual void SAL_CALL
gotoPreviousSlide( ) override
;
193 virtual void SAL_CALL
gotoLastSlide( ) override
;
194 virtual void SAL_CALL
gotoBookmark( const OUString
& Bookmark
) override
;
195 virtual void SAL_CALL
gotoSlide( const css::uno::Reference
< css::drawing::XDrawPage
>& Page
) override
;
196 virtual void SAL_CALL
gotoSlideIndex( ::sal_Int32 Index
) override
;
197 virtual void SAL_CALL
stopSound( ) override
;
198 virtual void SAL_CALL
pause( ) override
;
199 virtual void SAL_CALL
resume( ) override
;
200 virtual sal_Bool SAL_CALL
isPaused( ) override
;
201 virtual void SAL_CALL
blankScreen( ::sal_Int32 Color
) override
;
202 virtual void SAL_CALL
activate( ) override
;
203 virtual void SAL_CALL
deactivate( ) override
;
204 virtual sal_Bool SAL_CALL
isActive( ) override
;
205 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
getCurrentSlide( ) override
;
206 virtual ::sal_Int32 SAL_CALL
getCurrentSlideIndex( ) override
;
207 virtual ::sal_Int32 SAL_CALL
getNextSlideIndex( ) override
;
208 virtual sal_Bool SAL_CALL
isEndless( ) override
;
209 virtual sal_Bool SAL_CALL
isFullScreen( ) override
;
210 virtual css::uno::Reference
< css::presentation::XSlideShow
> SAL_CALL
getSlideShow( ) override
;
213 virtual ::sal_Int32 SAL_CALL
getCount( ) override
;
214 virtual css::uno::Any SAL_CALL
getByIndex( ::sal_Int32 Index
) override
;
215 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
216 virtual sal_Bool SAL_CALL
hasElements( ) override
;
218 // will be called from the SlideShowListenerProxy when this event is fired from the XSlideShow
219 void slideEnded(const bool bReverse
);
220 /// @throws css::uno::RuntimeException
221 void hyperLinkClicked(const OUString
& hyperLink
);
222 void click(const css::uno::Reference
< css::drawing::XShape
> & xShape
);
223 bool swipe(const CommandSwipeData
&rSwipeData
);
224 bool longpress(const CommandLongPressData
& rLongPressData
);
226 /// ends the presentation async
227 void endPresentation();
229 ViewShell
* getViewShell() const { return mpViewShell
; }
232 bool keyInput(const KeyEvent
& rKEvt
);
233 void mouseButtonUp(const MouseEvent
& rMEvt
);
236 SlideshowImpl(SlideshowImpl
&) = delete;
237 void operator =(SlideshowImpl
&) = delete;
239 virtual ~SlideshowImpl() override
;
241 // override WeakComponentImplHelperBase::disposing()
242 // This function is called upon disposing the component,
243 // if your component needs special work when it becomes
244 // disposed, do it here.
245 virtual void SAL_CALL
disposing() override
;
248 bool startShow( PresentationSettingsEx
const * pPresSettings
);
250 const css::uno::Reference
< css::drawing::XDrawPage
>& xDrawPage
,
251 const css::uno::Reference
< css::animations::XAnimationNode
>& xAnimationNode
,
252 vcl::Window
* pParent
);
254 /** forces an async call to update in the main thread */
255 void startUpdateTimer();
259 void createSlideList( bool bAll
, const OUString
& rPresSlide
);
261 void displayCurrentSlide (const bool bSkipAllMainSequenceEffects
= false);
263 void displaySlideNumber( sal_Int32 nSlide
);
264 void displaySlideIndex( sal_Int32 nIndex
);
265 sal_Int32
getCurrentSlideNumber();
266 bool isInputFreezed() const { return mbInputFreeze
; }
268 void jumpToBookmark( const OUString
& sBookmark
);
270 void hideChildWindows();
271 void showChildWindows();
273 void resize( const Size
& rSize
);
275 void setActiveXToolbarsVisible( bool bVisible
);
277 DECL_LINK( updateHdl
, Timer
*, void );
278 DECL_LINK( ReadyForNextInputHdl
, Timer
*, void );
279 DECL_LINK( endPresentationHdl
, void*, void );
280 DECL_LINK( ContextMenuSelectHdl
, Menu
*, bool );
281 DECL_LINK( ContextMenuHdl
, void*, void );
282 DECL_LINK( deactivateHdl
, Timer
*, void );
283 DECL_LINK( EventListenerHdl
, VclSimpleEvent
&, void );
285 /** called only by the slideshow view when the first paint event occurs.
286 This actually starts the slideshow. */
289 long getRestoreSlide() const { return mnRestoreSlide
; }
293 const css::uno::Sequence
< css::beans::PropertyValue
>& aProperties
);
295 SfxViewFrame
* getViewFrame() const;
296 SfxDispatcher
* getDispatcher() const;
297 SfxBindings
* getBindings() const;
299 sal_Int32
getSlideNumberForBookmark( const OUString
& rStrBookmark
);
301 void removeShapeEvents();
302 void registerShapeEvents( sal_Int32 nSlideNumber
);
303 /// @throws css::uno::Exception
304 void registerShapeEvents( css::uno::Reference
< css::drawing::XShapes
> const & xShapes
);
306 static css::uno::Reference
< css::presentation::XSlideShow
> createSlideShow();
308 static void setAutoSaveState( bool bOn
);
309 void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects
);
311 /** Called by our maUpdateTimer's updateHdl handler this method is
312 responsible to call the slideshow update() method and, depending on
313 its return value, wait for a certain amount of time before another
314 call to update() is scheduled.
316 void updateSlideShow();
318 css::uno::Reference
< css::presentation::XSlideShow
> mxShow
;
319 rtl::Reference
<sd::SlideShowView
> mxView
;
320 css::uno::Reference
< css::frame::XModel
> mxModel
;
323 Timer maInputFreezeTimer
;
324 Timer maDeactivateTimer
;
327 ViewShell
* mpViewShell
;
328 DrawDocShell
* mpDocSh
;
329 SdDrawDocument
* mpDoc
;
331 VclPtr
<vcl::Window
> mpParentWindow
;
332 VclPtr
<sd::ShowWindow
> mpShowWindow
;
333 VclPtr
<PushButton
> mpTimeButton
;
335 std::shared_ptr
< AnimationSlideController
> mpSlideController
;
338 Point maPopupMousePos
;
340 AnimationMode meAnimationMode
;
341 OUString maCharBuffer
;
342 VclPtr
< ::sd::Window
> mpOldActiveWindow
;
343 Link
<StarBASIC
*,bool> maStarBASICGlobalErrorHdl
;
344 unsigned long mnChildMask
;
346 bool mbAutoSaveWasOn
;
347 bool mbRehearseTimings
;
349 bool mbWasPaused
; // used to cache pause state during context menu
353 PresentationSettings maPresSettings
;
354 sal_Int32 mnUserPaintColor
;
357 double mdUserPaintStrokeWidth
;
359 WrappedShapeEventImplMap maShapeEventMap
;
365 css::uno::Reference
< css::drawing::XDrawPage
> mxPreviewDrawPage
;
366 css::uno::Reference
< css::animations::XAnimationNode
> mxPreviewAnimationNode
;
368 css::uno::Reference
< css::media::XPlayer
> mxPlayer
;
370 ::std::unique_ptr
<PaneHider
> mpPaneHider
;
372 ImplSVEvent
* mnEndShowEvent
;
373 ImplSVEvent
* mnContextMenuEvent
;
375 css::uno::Reference
< css::presentation::XPresentation2
> mxPresentation
;
376 ::rtl::Reference
< SlideShowListenerProxy
> mxListenerProxy
;
383 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */