bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / slideshow / slideshowimpl.hxx
blob3e8f00f0272dc015fc83a4367f92e6734cd39265
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
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>
48 #include <toolkit/helper/vclunohelper.hxx>
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>
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"
71 #include "showwindow.hxx"
73 #include "optsitem.hxx"
74 #include "FrameView.hxx"
75 #include "DrawDocShell.hxx"
77 #include "app.hrc"
79 #include "slideshow.hxx"
81 class SfxViewFrame;
82 class SfxRequest;
83 class ShowWindow;
85 namespace sd
87 class SlideShowView;
88 class AnimationSlideController;
89 class PaneHider;
91 struct PresentationSettingsEx : public PresentationSettings
93 bool mbRehearseTimings;
94 bool mbPreview;
95 VclPtr<vcl::Window> mpParentWindow;
96 css::uno::Reference< css::drawing::XDrawPage > mxStartPage;
97 css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode;
99 PresentationSettingsEx( const PresentationSettingsEx& );
100 PresentationSettingsEx( PresentationSettings& );
102 void SetArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments ) throw (css::lang::IllegalArgumentException);
104 void SetPropertyValue( const OUString& rProperty, const css::uno::Any& rValue ) throw (css::lang::IllegalArgumentException);
107 struct WrappedShapeEventImpl
109 css::presentation::ClickAction meClickAction;
110 sal_Int32 mnVerb;
111 OUString maStrBookmark;
112 WrappedShapeEventImpl() : meClickAction( css::presentation::ClickAction_NONE ), mnVerb( 0 ) {};
115 typedef boost::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::WeakImplHelper2< css::presentation::XSlideShowListener, css::presentation::XShapeEventListener >
121 public:
122 SlideShowListenerProxy( const rtl::Reference< SlideshowImpl >& xController, const css::uno::Reference< css::presentation::XSlideShow >& xSlideShow );
123 virtual ~SlideShowListenerProxy();
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 ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 virtual void SAL_CALL endEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 virtual void SAL_CALL repeat( const css::uno::Reference< css::animations::XAnimationNode >& Node, ::sal_Int32 Repeat ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 // css::presentation::XSlideShowListener:
140 virtual void SAL_CALL paused() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 virtual void SAL_CALL resumed() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 virtual void SAL_CALL slideTransitionStarted() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 virtual void SAL_CALL slideTransitionEnded() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 virtual void SAL_CALL slideAnimationsEnded() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
145 virtual void SAL_CALL slideEnded(sal_Bool bReverse) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 virtual void SAL_CALL hyperLinkClicked(const OUString & hyperLink) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 // css::lang::XEventListener:
149 virtual void SAL_CALL disposing(const css::lang::EventObject & Source) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
151 // css::presentation::XShapeEventListener:
152 virtual void SAL_CALL click(const css::uno::Reference< css::drawing::XShape > & xShape, const css::awt::MouseEvent & aOriginalEvent) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 ::cppu::OInterfaceContainerHelper maListeners;
156 rtl::Reference< SlideshowImpl > mxController;
157 css::uno::Reference< css::presentation::XSlideShow > mxSlideShow;
160 typedef ::cppu::WeakComponentImplHelper2< css::presentation::XSlideShowController, css::container::XIndexAccess > SlideshowImplBase;
162 class SlideshowImpl : private ::cppu::BaseMutex, public SlideshowImplBase
164 friend class SlideShow;
165 friend class SlideShowView;
167 public:
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() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
172 virtual void SAL_CALL setAlwaysOnTop( sal_Bool _alwaysontop ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 virtual sal_Bool SAL_CALL getMouseVisible() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 virtual void SAL_CALL setMouseVisible( sal_Bool _mousevisible ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
175 virtual sal_Bool SAL_CALL getUsePen() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 virtual void SAL_CALL setUsePen( sal_Bool _usepen ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 virtual ::sal_Int32 SAL_CALL getPenColor() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
178 virtual void SAL_CALL setPenColor( ::sal_Int32 _pencolor ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 virtual double SAL_CALL getPenWidth() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 virtual void SAL_CALL setPenWidth( double dStrokeWidth ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 void SAL_CALL setEraseAllInk( bool bEraseAllInk ) throw (css::uno::RuntimeException);
182 virtual sal_Bool SAL_CALL isRunning( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
183 virtual ::sal_Int32 SAL_CALL getSlideCount( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getSlideByIndex( ::sal_Int32 Index ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
185 virtual void SAL_CALL addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
186 virtual void SAL_CALL removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 virtual void SAL_CALL gotoNextEffect( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
188 virtual void SAL_CALL gotoPreviousEffect( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 virtual void SAL_CALL gotoFirstSlide( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
190 virtual void SAL_CALL gotoNextSlide( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
191 virtual void SAL_CALL gotoPreviousSlide( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
192 virtual void SAL_CALL gotoLastSlide( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 virtual void SAL_CALL gotoBookmark( const OUString& Bookmark ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
194 virtual void SAL_CALL gotoSlide( const css::uno::Reference< css::drawing::XDrawPage >& Page ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
195 virtual void SAL_CALL gotoSlideIndex( ::sal_Int32 Index ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
196 virtual void SAL_CALL stopSound( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
197 virtual void SAL_CALL pause( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 virtual void SAL_CALL resume( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
199 virtual sal_Bool SAL_CALL isPaused( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
200 virtual void SAL_CALL blankScreen( ::sal_Int32 Color ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
201 virtual void SAL_CALL activate( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
202 virtual void SAL_CALL deactivate( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
203 virtual sal_Bool SAL_CALL isActive( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
204 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getCurrentSlide( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
205 virtual ::sal_Int32 SAL_CALL getCurrentSlideIndex( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
206 virtual ::sal_Int32 SAL_CALL getNextSlideIndex( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
207 virtual sal_Bool SAL_CALL isEndless( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
208 virtual sal_Bool SAL_CALL isFullScreen( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
209 virtual css::uno::Reference< css::presentation::XSlideShow > SAL_CALL getSlideShow( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
211 // XIndexAccess
212 virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
213 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, std::exception) SAL_OVERRIDE;
214 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
215 virtual sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
217 // will be called from the SlideShowListenerProxy when this event is fired from the XSlideShow
218 void slideEnded(const bool bReverse);
219 void hyperLinkClicked(const OUString & hyperLink) throw (css::uno::RuntimeException);
220 void click(const css::uno::Reference< css::drawing::XShape > & xShape, const css::awt::MouseEvent & aOriginalEvent);
221 bool swipe(const CommandSwipeData &rSwipeData);
222 bool longpress(const CommandLongPressData& rLongPressData);
224 /// ends the presentation async
225 void endPresentation();
227 ViewShell* getViewShell() const { return mpViewShell; }
229 void paint( const Rectangle& rRect );
230 bool keyInput(const KeyEvent& rKEvt);
231 void mouseButtonUp(const MouseEvent& rMEvt);
233 private:
234 SlideshowImpl(SlideshowImpl &) SAL_DELETED_FUNCTION;
235 void operator =(SlideshowImpl &) SAL_DELETED_FUNCTION;
237 virtual ~SlideshowImpl();
239 // override WeakComponentImplHelperBase::disposing()
240 // This function is called upon disposing the component,
241 // if your component needs special work when it becomes
242 // disposed, do it here.
243 virtual void SAL_CALL disposing() SAL_OVERRIDE;
245 // internal
246 bool startShow( PresentationSettingsEx* pPresSettings );
247 bool startPreview(
248 const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
249 const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode,
250 vcl::Window* pParent );
252 /** forces an async call to update in the main thread */
253 void startUpdateTimer();
255 double update();
257 void createSlideList( bool bAll, const OUString& rPresSlide );
259 void displayCurrentSlide (const bool bSkipAllMainSequenceEffects = false);
261 void displaySlideNumber( sal_Int32 nSlide );
262 void displaySlideIndex( sal_Int32 nIndex );
263 sal_Int32 getCurrentSlideNumber();
264 sal_Int32 getFirstSlideNumber();
265 sal_Int32 getLastSlideNumber();
266 inline 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_TYPED(updateHdl, Timer *, void);
278 DECL_LINK( PostYieldListener, void* );
279 DECL_LINK_TYPED(ReadyForNextInputHdl, Timer *, void);
280 DECL_LINK( endPresentationHdl, void* );
281 DECL_LINK( ContextMenuSelectHdl, Menu * );
282 DECL_LINK( ContextMenuHdl, void* );
283 DECL_LINK_TYPED(deactivateHdl, Timer *, void);
284 DECL_LINK( EventListenerHdl, VclSimpleEvent* );
286 // helper
287 void receiveRequest(SfxRequest& rReq);
289 /** called only by the slideshow view when the first paint event occurs.
290 This actually starts the slideshow. */
291 void onFirstPaint();
293 long getRestoreSlide() const { return mnRestoreSlide; }
295 private:
296 bool startShowImpl(
297 const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
299 SfxViewFrame* getViewFrame() const;
300 SfxDispatcher* getDispatcher() const;
301 SfxBindings* getBindings() const;
303 sal_Int32 getSlideNumberForBookmark( const OUString& rStrBookmark );
305 void removeShapeEvents();
306 void registerShapeEvents( sal_Int32 nSlideNumber );
307 void registerShapeEvents( css::uno::Reference< css::drawing::XShapes >& xShapes ) throw (css::uno::Exception);
309 static css::uno::Reference< css::presentation::XSlideShow > createSlideShow();
311 static void setAutoSaveState( bool bOn );
312 void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects);
314 /** Called by PostYieldListener and updateHdl handlers this method is
315 responsible to call the slideshow update() method and, depending on
316 its return value, wait for a certain amount of time before another
317 call to update() is scheduled.
319 sal_Int32 updateSlideShow();
321 css::uno::Reference< css::presentation::XSlideShow > mxShow;
322 rtl::Reference<sd::SlideShowView> mxView;
323 css::uno::Reference< css::frame::XModel > mxModel;
325 Timer maUpdateTimer;
326 Timer maInputFreezeTimer;
327 Timer maDeactivateTimer;
329 ::sd::View* mpView;
330 ViewShell* mpViewShell;
331 DrawDocShell* mpDocSh;
332 SdDrawDocument* mpDoc;
334 SfxItemSet* mpNewAttr;
335 VclPtr<vcl::Window> mpParentWindow;
336 VclPtr<ShowWindow> mpShowWindow;
337 VclPtr<PushButton> mpTimeButton;
339 boost::shared_ptr< AnimationSlideController > mpSlideController;
341 long mnRestoreSlide;
342 Point maSlideOrigin;
343 Point maPopupMousePos;
344 Size maSlideSize;
345 Size maPresSize;
346 AnimationMode meAnimationMode;
347 OUString maCharBuffer;
348 Pointer maOldPointer;
349 Pointer maPencil;
350 std::vector< VclPtr< ::sd::Window> > maDrawModeWindows;
351 VclPtr< ::sd::Window> mpOldActiveWindow;
352 Link<StarBASIC*,bool> maStarBASICGlobalErrorHdl;
353 unsigned long mnChildMask;
354 bool mbGridVisible;
355 bool mbBordVisible;
356 bool mbSlideBorderVisible;
357 bool mbSetOnlineSpelling;
358 bool mbDisposed;
359 bool mbAutoSaveWasOn;
360 bool mbRehearseTimings;
361 bool mbDesignMode;
362 bool mbIsPaused;
363 bool mbWasPaused; // used to cache pause state during context menu
364 bool mbInputFreeze;
365 bool mbActive;
367 PresentationSettings maPresSettings;
368 sal_Int32 mnUserPaintColor;
370 bool mbUsePen;
371 double mdUserPaintStrokeWidth;
373 /// used in updateHdl to prevent recursive calls
374 sal_Int32 mnEntryCounter;
376 sal_Int32 mnLastSlideNumber;
377 WrappedShapeEventImplMap maShapeEventMap;
379 OUString msOnClick;
380 OUString msBookmark;
381 OUString msVerb;
383 css::uno::Reference< css::drawing::XDrawPage > mxPreviewDrawPage;
384 css::uno::Reference< css::animations::XAnimationNode > mxPreviewAnimationNode;
386 css::uno::Reference< css::media::XPlayer > mxPlayer;
388 ::std::unique_ptr<PaneHider> mpPaneHider;
390 ImplSVEvent * mnEndShowEvent;
391 ImplSVEvent * mnContextMenuEvent;
393 css::uno::Reference< css::presentation::XPresentation2 > mxPresentation;
394 ::rtl::Reference< SlideShowListenerProxy > mxListenerProxy;
397 } // namespace ::sd
399 #endif
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */