cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / slideshow.hxx
blob4d84d5a8a994efc1d3b2df964f4a363a75985d05
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 #pragma once
22 #include <com/sun/star/presentation/XPresentation2.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <rtl/ref.hxx>
27 #include <tools/link.hxx>
29 #include <comphelper/compbase.hxx>
31 #include <editeng/unoipset.hxx>
33 #include <memory>
34 #include <sddllapi.h>
36 namespace com::sun::star {
37 namespace drawing {
38 class XDrawPage;
40 namespace animations {
41 class XAnimationNode;
44 class SdDrawDocument;
45 class KeyEvent;
46 class OutputDevice;
47 class Size;
48 namespace vcl { class Window; }
49 class SfxRequest;
50 class WorkWindow;
51 class CommandGestureSwipeData;
52 class CommandGestureLongPressData;
53 struct ImplSVEvent;
55 // TODO: Remove
56 #define PAGE_NO_END 65535
58 /* Definition of SlideShow class */
60 namespace sd
63 class SlideshowImpl;
64 class View;
65 class ViewShell;
66 class ViewShellBase;
67 struct PresentationSettingsEx;
68 class FrameView;
70 enum AnimationMode
72 ANIMATIONMODE_SHOW,
73 ANIMATIONMODE_PREVIEW
76 typedef comphelper::WeakComponentImplHelper< css::presentation::XPresentation2, css::lang::XServiceInfo > SlideshowBase;
78 class SlideShow final : public SlideshowBase
80 public:
81 /// used by the model to create a slideshow for it
82 static rtl::Reference< SlideShow > Create( SdDrawDocument* pDoc );
84 // static helper api
85 static rtl::Reference< SlideShow > GetSlideShow( SdDrawDocument const * pDocument );
86 static rtl::Reference< SlideShow > GetSlideShow( SdDrawDocument const & rDocument );
87 static rtl::Reference< SlideShow > GetSlideShow( ViewShellBase const & rBase );
89 static css::uno::Reference< css::presentation::XSlideShowController > GetSlideShowController(ViewShellBase const & rBase );
91 static bool StartPreview( ViewShellBase const & rBase,
92 const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
93 const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode );
95 static void Stop( ViewShellBase const & rBase );
97 /// returns true if there is a running presentation for the given ViewShellBase
98 static bool IsRunning( ViewShellBase const & rBase );
100 /// returns true if there is a running presentation inside the given ViewShell
101 /// returns false even if there is a running presentation but in another ViewShell
102 static bool IsRunning( const ViewShell& rViewShell );
104 /// returns true if the interactive slideshow mode is activated
105 static bool IsInteractiveSlideshow(const ViewShellBase* pViewShellBase);
106 bool IsInteractiveSlideshow() const;
108 // helper api
110 bool startInteractivePreview(
111 const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
112 const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode );
113 bool isInteractiveSetup() const;
114 void endInteractivePreview();
116 void startPreview(
117 const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
118 const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode );
120 // uno api
122 virtual void disposing(std::unique_lock<std::mutex>&) override;
124 // XServiceInfo
125 virtual OUString SAL_CALL getImplementationName( ) override;
126 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
127 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
129 // XPropertySet
130 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
131 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
132 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
133 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
134 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
135 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
136 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
138 // XPresentation
139 virtual void SAL_CALL start( ) override;
140 virtual void SAL_CALL end() override;
141 virtual void SAL_CALL rehearseTimings( ) override;
143 // XPresentation2
144 virtual void SAL_CALL startWithArguments(const css::uno::Sequence< css::beans::PropertyValue >& Arguments) override;
145 virtual sal_Bool SAL_CALL isRunning( ) override;
146 virtual css::uno::Reference< css::presentation::XSlideShowController > SAL_CALL getController( ) override;
148 // legacy api
150 // actions
151 void jumpToPageNumber( sal_Int32 nPage ); // a.k.a. FuSlideShow::JumpToPage()
152 void jumpToPageIndex( sal_Int32 nIndex );
153 void jumpToBookmark( const OUString& sBookmark ); // a.k.a. FuSlideShow::JumpToBookmark()
155 /** sets or clears the pause state of the running slideshow.
156 !!!! This should only be called by the SdShowWindow !!!!*/
157 void pause( bool bPause );
158 bool swipe(const CommandGestureSwipeData &rSwipeData);
159 bool longpress(const CommandGestureLongPressData& rLongPressData);
161 // settings
162 bool isFullScreen() const; // a.k.a. FuSlideShow::IsFullScreen()
163 OutputDevice* getShowWindow(); // a.k.a. FuSlideShow::GetShowWindow()
164 int getAnimationMode() const; // a.k.a. FuSlideShow::GetAnimationMode()
165 sal_Int32 getCurrentPageNumber() const; // a.k.a. FuSlideShow::GetCurrentPage()
167 // events
168 void resize( const Size &rSize );
169 // return false if the activate failed. callers should call end in response to failure
170 bool activate(ViewShellBase& rBase);
171 void deactivate();
172 void paint();
174 bool keyInput(const KeyEvent& rKEvt);
176 bool dependsOn( ViewShellBase const * pViewShellBase );
178 static sal_Int32 GetDisplay();
180 bool IsExitAfterPresenting() const;
181 void SetExitAfterPresenting(bool bExit);
183 private:
184 SlideShow( SdDrawDocument* pDoc );
186 DECL_LINK( StartInPlacePresentationConfigurationHdl, void *, void );
187 void StartInPlacePresentationConfigurationCallback();
189 void StartInPlacePresentation();
190 void StartFullscreenPresentation();
192 /// @throws css::uno::RuntimeException
193 void ThrowIfDisposed() const;
195 void CreateController( ViewShell* pViewSh, ::sd::View* pView, vcl::Window* pParentWindow );
196 WorkWindow *GetWorkWindow();
198 SlideShow(const SlideShow&) = delete;
199 SlideShow& operator=( const SlideShow& ) = delete;
201 SvxItemPropertySet maPropSet;
203 rtl::Reference< SlideshowImpl > mxController;
204 /** This flag is used together with mxController.is() to prevent
205 multiple instances of the slide show for one document. The flag
206 covers the time before mxController is set.
208 bool mbIsInStartup;
209 SdDrawDocument* mpDoc;
211 std::shared_ptr< PresentationSettingsEx > mxCurrentSettings;
213 ViewShellBase* mpCurrentViewShellBase;
214 ViewShellBase* mpFullScreenViewShellBase;
215 FrameView* mpFullScreenFrameView;
216 ImplSVEvent * mnInPlaceConfigEvent;
219 namespace slideshowhelp
221 SD_DLLPUBLIC void ShowSlideShow(SfxRequest const& rReq, SdDrawDocument& rDoc);
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */