/src/libreoffice/sd/source/ui/slideshow/slideshowimpl.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <memory> |
23 | | #include <sal/config.h> |
24 | | #include <comphelper/compbase.hxx> |
25 | | #include <cppuhelper/implbase.hxx> |
26 | | #include <comphelper/interfacecontainer4.hxx> |
27 | | #include <com/sun/star/presentation/ClickAction.hpp> |
28 | | #include <com/sun/star/presentation/XSlideShowNavigationListener.hpp> |
29 | | #include <com/sun/star/presentation/XSlideShowController.hpp> |
30 | | #include <com/sun/star/presentation/XShapeEventListener.hpp> |
31 | | |
32 | | #include <drawdoc.hxx> |
33 | | |
34 | | #include "showwindow.hxx" |
35 | | |
36 | | #include <slideshow.hxx> |
37 | | |
38 | | namespace com::sun::star::media { class XPlayer; } |
39 | | namespace sd { class DrawDocShell; } |
40 | | namespace sd { class ViewShell; } |
41 | | |
42 | | class SfxBindings; |
43 | | class SfxDispatcher; |
44 | | class SfxViewFrame; |
45 | | class StarBASIC; |
46 | | class VclSimpleEvent; |
47 | | |
48 | | namespace sd |
49 | | { |
50 | | class SlideShowView; |
51 | | class AnimationSlideController; |
52 | | class PaneHider; |
53 | | |
54 | | struct PresentationSettingsEx : public PresentationSettings |
55 | | { |
56 | | bool mbRehearseTimings; |
57 | | bool mbPreview; |
58 | | VclPtr<vcl::Window> mpParentWindow; |
59 | | css::uno::Reference< css::drawing::XDrawPage > mxStartPage; |
60 | | css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode; |
61 | | |
62 | | PresentationSettingsEx( const PresentationSettingsEx& ); |
63 | | explicit PresentationSettingsEx( PresentationSettings const & ); |
64 | | |
65 | | /// @throws css::lang::IllegalArgumentException |
66 | | void SetArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments ); |
67 | | |
68 | | /// @throws css::lang::IllegalArgumentException |
69 | | void SetPropertyValue( std::u16string_view rProperty, const css::uno::Any& rValue ); |
70 | | }; |
71 | | |
72 | | struct WrappedShapeEventImpl |
73 | | { |
74 | | css::presentation::ClickAction meClickAction; |
75 | | sal_Int32 mnVerb; |
76 | | OUString maStrBookmark; |
77 | 0 | WrappedShapeEventImpl() : meClickAction( css::presentation::ClickAction_NONE ), mnVerb( 0 ) {}; |
78 | | }; |
79 | | |
80 | | class SlideShowListenerProxy : |
81 | | public ::cppu::WeakImplHelper< css::presentation::XSlideShowNavigationListener, css::presentation::XShapeEventListener > |
82 | | { |
83 | | public: |
84 | | SlideShowListenerProxy( rtl::Reference< SlideshowImpl > xController, css::uno::Reference< css::presentation::XSlideShow > xSlideShow ); |
85 | | virtual ~SlideShowListenerProxy() override; |
86 | | |
87 | | void addAsSlideShowListener(); |
88 | | void removeAsSlideShowListener(); |
89 | | |
90 | | void addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ); |
91 | | void removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ); |
92 | | |
93 | | void addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape ); |
94 | | void removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape ); |
95 | | |
96 | | // css::animations::XAnimationListener |
97 | | virtual void SAL_CALL beginEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) override; |
98 | | virtual void SAL_CALL endEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) override; |
99 | | virtual void SAL_CALL repeat( const css::uno::Reference< css::animations::XAnimationNode >& Node, ::sal_Int32 Repeat ) override; |
100 | | |
101 | | // css::presentation::XSlideShowListener: |
102 | | virtual void SAL_CALL paused() override; |
103 | | virtual void SAL_CALL resumed() override; |
104 | | virtual void SAL_CALL slideTransitionStarted() override; |
105 | | virtual void SAL_CALL slideTransitionEnded() override; |
106 | | virtual void SAL_CALL slideAnimationsEnded() override; |
107 | | virtual void SAL_CALL slideEnded(sal_Bool bReverse) override; |
108 | | virtual void SAL_CALL hyperLinkClicked(const OUString & hyperLink) override; |
109 | | |
110 | | // css::presentation::XSlideShowNavigationListener: |
111 | | virtual void SAL_CALL contextMenuShow(const css::awt::Point& point) override; |
112 | | |
113 | | // css::lang::XEventListener: |
114 | | virtual void SAL_CALL disposing(const css::lang::EventObject & Source) override; |
115 | | |
116 | | // css::presentation::XShapeEventListener: |
117 | | virtual void SAL_CALL click(const css::uno::Reference< css::drawing::XShape > & xShape, const css::awt::MouseEvent & aOriginalEvent) override; |
118 | | |
119 | | private: |
120 | | std::mutex m_aMutex; |
121 | | ::comphelper::OInterfaceContainerHelper4<css::presentation::XSlideShowListener> maListeners; |
122 | | rtl::Reference< SlideshowImpl > mxController; |
123 | | css::uno::Reference< css::presentation::XSlideShow > mxSlideShow; |
124 | | }; |
125 | | |
126 | | typedef comphelper::WeakComponentImplHelper< css::presentation::XSlideShowController, css::container::XIndexAccess > SlideshowImplBase; |
127 | | |
128 | | class SlideshowImpl final : public SlideshowImplBase, public SfxListener |
129 | | { |
130 | | friend class SlideShow; |
131 | | friend class SlideShowView; |
132 | | |
133 | | public: |
134 | | explicit SlideshowImpl( const css::uno::Reference< css::presentation::XPresentation2 >& xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, vcl::Window* pParentWindow); |
135 | | |
136 | | // css::presentation::XSlideShowController: |
137 | | virtual sal_Bool SAL_CALL getAlwaysOnTop() override; |
138 | | virtual void SAL_CALL setAlwaysOnTop( sal_Bool _alwaysontop ) override; |
139 | | virtual sal_Bool SAL_CALL getMouseVisible() override; |
140 | | virtual void SAL_CALL setMouseVisible( sal_Bool _mousevisible ) override; |
141 | | virtual sal_Bool SAL_CALL getUsePen() override; |
142 | | virtual void SAL_CALL setUsePen( sal_Bool _usepen ) override; |
143 | | virtual ::sal_Int32 SAL_CALL getPenColor() override; |
144 | | virtual void SAL_CALL setPenColor( ::sal_Int32 _pencolor ) override; |
145 | | virtual double SAL_CALL getPenWidth() override; |
146 | | virtual void SAL_CALL setPenWidth( double dStrokeWidth ) override; |
147 | | /// @throws css::uno::RuntimeException |
148 | | virtual void SAL_CALL setEraseAllInk( sal_Bool bEraseAllInk ) override; |
149 | | virtual sal_Bool SAL_CALL isRunning( ) override; |
150 | | virtual ::sal_Int32 SAL_CALL getSlideCount( ) override; |
151 | | virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getSlideByIndex( ::sal_Int32 Index ) override; |
152 | | virtual void SAL_CALL addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) override; |
153 | | virtual void SAL_CALL removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) override; |
154 | | virtual void SAL_CALL gotoNextEffect( ) override; |
155 | | virtual void SAL_CALL gotoPreviousEffect( ) override; |
156 | | virtual void SAL_CALL gotoFirstSlide( ) override; |
157 | | virtual void SAL_CALL gotoNextSlide( ) override; |
158 | | virtual void SAL_CALL gotoPreviousSlide( ) override; |
159 | | virtual void SAL_CALL gotoLastSlide( ) override; |
160 | | virtual void SAL_CALL gotoBookmark( const OUString& Bookmark ) override; |
161 | | virtual void SAL_CALL gotoSlide( const css::uno::Reference< css::drawing::XDrawPage >& Page ) override; |
162 | | virtual void SAL_CALL gotoSlideIndex( ::sal_Int32 Index ) override; |
163 | | virtual void SAL_CALL stopSound( ) override; |
164 | | virtual void SAL_CALL pause( ) override; |
165 | | virtual void SAL_CALL resume( ) override; |
166 | | virtual sal_Bool SAL_CALL isPaused( ) override; |
167 | | virtual void SAL_CALL blankScreen( ::sal_Int32 Color ) override; |
168 | | virtual void SAL_CALL activate( ) override; |
169 | | virtual void SAL_CALL deactivate( ) override; |
170 | | virtual sal_Bool SAL_CALL isActive( ) override; |
171 | | virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getCurrentSlide( ) override; |
172 | | virtual ::sal_Int32 SAL_CALL getCurrentSlideIndex( ) override; |
173 | | virtual ::sal_Int32 SAL_CALL getNextSlideIndex( ) override; |
174 | | virtual sal_Bool SAL_CALL isEndless( ) override; |
175 | | virtual sal_Bool SAL_CALL isFullScreen( ) override; |
176 | | virtual css::uno::Reference< css::presentation::XSlideShow > SAL_CALL getSlideShow( ) override; |
177 | | |
178 | | // XIndexAccess |
179 | | virtual ::sal_Int32 SAL_CALL getCount( ) override; |
180 | | virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override; |
181 | | virtual css::uno::Type SAL_CALL getElementType( ) override; |
182 | | virtual sal_Bool SAL_CALL hasElements( ) override; |
183 | | |
184 | | // SfxListener |
185 | | virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; |
186 | | |
187 | | // will be called from the SlideShowListenerProxy when this event is fired from the XSlideShow |
188 | | void slideEnded(const bool bReverse); |
189 | | void contextMenuShow(const css::awt::Point& point); |
190 | | /// @throws css::uno::RuntimeException |
191 | | void hyperLinkClicked(const OUString & hyperLink); |
192 | | void click(const css::uno::Reference< css::drawing::XShape > & xShape); |
193 | | bool swipe(const CommandGestureSwipeData &rSwipeData); |
194 | | bool longpress(const CommandGestureLongPressData& rLongPressData); |
195 | | |
196 | | /// ends the presentation async |
197 | | void endPresentation(); |
198 | | |
199 | | // possibly triggered from events @SlideshowImpl::Notify if needed, but make it asynchronous to |
200 | | // allow the noted event to completely finish in the core |
201 | | void AsyncNotifyEvent(const css::uno::Reference< css::drawing::XDrawPage >&, const SdrHintKind); |
202 | | |
203 | 0 | ViewShell* getViewShell() const { return mpViewShell; } |
204 | | |
205 | | void paint(); |
206 | | bool keyInput(const KeyEvent& rKEvt); |
207 | | void mouseButtonUp(const MouseEvent& rMEvt); |
208 | | |
209 | | private: |
210 | | SlideshowImpl(SlideshowImpl const &) = delete; |
211 | | void operator =(SlideshowImpl const &) = delete; |
212 | | |
213 | | virtual ~SlideshowImpl() override; |
214 | | |
215 | | // helper to check if given hint is associated with CurrentSlide |
216 | | bool isCurrentSlideInvolved(const SdrHint& rHint); |
217 | | |
218 | | // tdf#160669 IASS: helper to inform presentation::XSlideShow about change so that |
219 | | // prefetch can be corrected/flushed |
220 | | void sendHintSlideChanged(const SdrPage* pChangedPage) const; |
221 | | |
222 | | // override WeakComponentImplHelperBase::disposing() |
223 | | // This function is called upon disposing the component, |
224 | | // if your component needs special work when it becomes |
225 | | // disposed, do it here. |
226 | | virtual void disposing(std::unique_lock<std::mutex>&) override; |
227 | | |
228 | | // internal |
229 | | bool startShow( PresentationSettingsEx const * pPresSettings ); |
230 | | bool startPreview( |
231 | | const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage, |
232 | | const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode, |
233 | | vcl::Window* pParent ); |
234 | | |
235 | | // methods for InterActiveSlideShow that support to |
236 | | // re-use a running FullScreen presentation for previews IASS |
237 | | void startInteractivePreview( |
238 | | const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage, |
239 | | const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode); |
240 | | void endInteractivePreview(); |
241 | | bool isInteractiveSetup() const; |
242 | | |
243 | | /** forces an async call to update in the main thread */ |
244 | | void startUpdateTimer(); |
245 | | |
246 | | void update(); |
247 | | |
248 | | void createSlideList( bool bAll, std::u16string_view rPresSlide ); |
249 | | |
250 | | void displayCurrentSlide (const bool bSkipAllMainSequenceEffects = false); |
251 | | |
252 | | void displaySlideNumber( sal_Int32 nSlide ); |
253 | | void displaySlideIndex( sal_Int32 nIndex ); |
254 | | sal_Int32 getCurrentSlideNumber() const; |
255 | 0 | bool isInputFreezed() const { return mbInputFreeze; } |
256 | | |
257 | | void jumpToBookmark( const OUString& sBookmark ); |
258 | | |
259 | | void hideChildWindows(); |
260 | | void showChildWindows(); |
261 | | |
262 | | void resize( const Size& rSize ); |
263 | | |
264 | | void setActiveXToolbarsVisible( bool bVisible ); |
265 | | |
266 | | DECL_LINK( updateHdl, Timer *, void ); |
267 | | DECL_LINK( ReadyForNextInputHdl, Timer *, void ); |
268 | | DECL_LINK( endPresentationHdl, void*, void ); |
269 | | void ContextMenuSelectHdl(std::u16string_view rIdent); |
270 | | DECL_LINK( ContextMenuHdl, void*, void ); |
271 | | DECL_LINK( deactivateHdl, Timer *, void ); |
272 | | DECL_LINK( EventListenerHdl, VclSimpleEvent&, void ); |
273 | | |
274 | | /** called only by the slideshow view when the first paint event occurs. |
275 | | This actually starts the slideshow. */ |
276 | | void onFirstPaint(); |
277 | | |
278 | 0 | ::tools::Long getRestoreSlide() const { return mnRestoreSlide; } |
279 | | |
280 | | private: |
281 | | bool startShowImpl( |
282 | | const css::uno::Sequence< css::beans::PropertyValue >& aProperties ); |
283 | | |
284 | | SAL_RET_MAYBENULL SfxViewFrame* getViewFrame() const; |
285 | | SAL_RET_MAYBENULL SfxDispatcher* getDispatcher() const; |
286 | | SAL_RET_MAYBENULL SfxBindings* getBindings() const; |
287 | | |
288 | | sal_Int32 getSlideNumberForBookmark( const OUString& rStrBookmark ); |
289 | | |
290 | | void removeShapeEvents(); |
291 | | void registerShapeEvents( sal_Int32 nSlideNumber ); |
292 | | /// @throws css::uno::Exception |
293 | | void registerShapeEvents( css::uno::Reference< css::drawing::XShapes > const & xShapes ); |
294 | | |
295 | | static css::uno::Reference< css::presentation::XSlideShow > createSlideShow(); |
296 | | |
297 | | static void setAutoSaveState( bool bOn ); |
298 | | void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects); |
299 | | |
300 | | /** Called by our maUpdateTimer's updateHdl handler this method is |
301 | | responsible to call the slideshow update() method and, depending on |
302 | | its return value, wait for a certain amount of time before another |
303 | | call to update() is scheduled. |
304 | | */ |
305 | | void updateSlideShow(); |
306 | | |
307 | | css::uno::Reference< css::presentation::XSlideShow > mxShow; |
308 | | rtl::Reference<sd::SlideShowView> mxView; |
309 | | rtl::Reference< SdXImpressDocument > mxModel; |
310 | | |
311 | | Timer maUpdateTimer; |
312 | | Timer maInputFreezeTimer; |
313 | | Timer maDeactivateTimer; |
314 | | |
315 | | ::sd::View* mpView; |
316 | | ViewShell* mpViewShell; |
317 | | DrawDocShell* mpDocSh; |
318 | | SdDrawDocument* mpDoc; |
319 | | |
320 | | VclPtr<vcl::Window> mpParentWindow; |
321 | | VclPtr<sd::ShowWindow> mpShowWindow; |
322 | | |
323 | | std::unique_ptr< AnimationSlideController > mpSlideController; |
324 | | |
325 | | ::tools::Long mnRestoreSlide; |
326 | | Point maPopupMousePos; |
327 | | Size maPresSize; |
328 | | AnimationMode meAnimationMode; |
329 | | OUString maCharBuffer; |
330 | | VclPtr< ::sd::Window> mpOldActiveWindow; |
331 | | Link<StarBASIC*,bool> maStarBASICGlobalErrorHdl; |
332 | | ::tools::ULong mnChildMask; |
333 | | |
334 | | bool mbDisposed; |
335 | | bool mbAutoSaveWasOn; |
336 | | bool mbRehearseTimings; |
337 | | bool mbIsPaused; |
338 | | bool mbWasPaused; // used to cache pause state during context menu |
339 | | bool mbInputFreeze; |
340 | | bool mbActive; |
341 | | |
342 | | PresentationSettings maPresSettings; |
343 | | sal_Int32 mnUserPaintColor; |
344 | | |
345 | | bool mbUsePen; |
346 | | double mdUserPaintStrokeWidth; |
347 | | |
348 | | std::map< css::uno::Reference< css::drawing::XShape >, WrappedShapeEventImpl > |
349 | | maShapeEventMap; |
350 | | |
351 | | css::uno::Reference< css::drawing::XDrawPage > mxPreviewDrawPage; |
352 | | css::uno::Reference< css::animations::XAnimationNode > mxPreviewAnimationNode; |
353 | | |
354 | | css::uno::Reference< css::media::XPlayer > mxPlayer; |
355 | | |
356 | | ::std::unique_ptr<PaneHider> mpPaneHider; |
357 | | |
358 | | ImplSVEvent * mnEndShowEvent; |
359 | | ImplSVEvent * mnContextMenuEvent; |
360 | | ImplSVEvent * mnEventObjectChange; |
361 | | ImplSVEvent * mnEventObjectInserted; |
362 | | ImplSVEvent * mnEventObjectRemoved; |
363 | | ImplSVEvent * mnEventPageOrderChange; |
364 | | |
365 | | css::uno::Reference< css::presentation::XPresentation2 > mxPresentation; |
366 | | ::rtl::Reference< SlideShowListenerProxy > mxListenerProxy; |
367 | | |
368 | | // local variables to support preview for a running SlideShow IASS |
369 | | css::uno::Reference< css::presentation::XSlideShow > mxShow2; |
370 | | rtl::Reference<sd::SlideShowView> mxView2; |
371 | | AnimationMode meAnimationMode2; |
372 | | bool mbInterActiveSetup; |
373 | | PresentationSettings maPresSettings2; |
374 | | css::uno::Reference< css::drawing::XDrawPage > mxPreviewDrawPage2; |
375 | | css::uno::Reference< css::animations::XAnimationNode > mxPreviewAnimationNode2; |
376 | | ::sal_Int32 mnSlideIndex; |
377 | | }; |
378 | | |
379 | | } // namespace ::sd |
380 | | |
381 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |