android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / slideshow / slideshowimpl.hxx
blob48802ba54499db55e7bb391e1d3034a82f5817c0
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 <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>
32 #include <drawdoc.hxx>
34 #include "showwindow.hxx"
36 #include <slideshow.hxx>
38 namespace com::sun::star::frame { class XModel; }
39 namespace com::sun::star::media { class XPlayer; }
40 namespace sd { class DrawDocShell; }
41 namespace sd { class ViewShell; }
43 class SfxBindings;
44 class SfxDispatcher;
45 class SfxViewFrame;
46 class StarBASIC;
48 namespace sd
50 class SlideShowView;
51 class AnimationSlideController;
52 class PaneHider;
54 struct PresentationSettingsEx : public PresentationSettings
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;
62 PresentationSettingsEx( const PresentationSettingsEx& );
63 explicit PresentationSettingsEx( PresentationSettings const & );
65 /// @throws css::lang::IllegalArgumentException
66 void SetArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments );
68 /// @throws css::lang::IllegalArgumentException
69 void SetPropertyValue( std::u16string_view rProperty, const css::uno::Any& rValue );
72 struct WrappedShapeEventImpl
74 css::presentation::ClickAction meClickAction;
75 sal_Int32 mnVerb;
76 OUString maStrBookmark;
77 WrappedShapeEventImpl() : meClickAction( css::presentation::ClickAction_NONE ), mnVerb( 0 ) {};
80 typedef std::shared_ptr< WrappedShapeEventImpl > WrappedShapeEventImplPtr;
82 class SlideShowListenerProxy :
83 public ::cppu::WeakImplHelper< css::presentation::XSlideShowNavigationListener, css::presentation::XShapeEventListener >
85 public:
86 SlideShowListenerProxy( rtl::Reference< SlideshowImpl > xController, css::uno::Reference< css::presentation::XSlideShow > xSlideShow );
87 virtual ~SlideShowListenerProxy() override;
89 void addAsSlideShowListener();
90 void removeAsSlideShowListener();
92 void addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener );
93 void removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener );
95 void addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape );
96 void removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape );
98 // css::animations::XAnimationListener
99 virtual void SAL_CALL beginEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) override;
100 virtual void SAL_CALL endEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) override;
101 virtual void SAL_CALL repeat( const css::uno::Reference< css::animations::XAnimationNode >& Node, ::sal_Int32 Repeat ) override;
103 // css::presentation::XSlideShowListener:
104 virtual void SAL_CALL paused() override;
105 virtual void SAL_CALL resumed() override;
106 virtual void SAL_CALL slideTransitionStarted() override;
107 virtual void SAL_CALL slideTransitionEnded() override;
108 virtual void SAL_CALL slideAnimationsEnded() override;
109 virtual void SAL_CALL slideEnded(sal_Bool bReverse) override;
110 virtual void SAL_CALL hyperLinkClicked(const OUString & hyperLink) override;
112 // css::presentation::XSlideShowNavigationListener:
113 virtual void SAL_CALL contextMenuShow(const css::awt::Point& point) override;
115 // css::lang::XEventListener:
116 virtual void SAL_CALL disposing(const css::lang::EventObject & Source) override;
118 // css::presentation::XShapeEventListener:
119 virtual void SAL_CALL click(const css::uno::Reference< css::drawing::XShape > & xShape, const css::awt::MouseEvent & aOriginalEvent) override;
121 private:
122 std::mutex m_aMutex;
123 ::comphelper::OInterfaceContainerHelper4<css::presentation::XSlideShowListener> maListeners;
124 rtl::Reference< SlideshowImpl > mxController;
125 css::uno::Reference< css::presentation::XSlideShow > mxSlideShow;
128 typedef comphelper::WeakComponentImplHelper< css::presentation::XSlideShowController, css::container::XIndexAccess > SlideshowImplBase;
130 class SlideshowImpl final : public SlideshowImplBase
132 friend class SlideShow;
133 friend class SlideShowView;
135 public:
136 explicit SlideshowImpl( const css::uno::Reference< css::presentation::XPresentation2 >& xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, vcl::Window* pParentWindow);
138 // css::presentation::XSlideShowController:
139 virtual sal_Bool SAL_CALL getAlwaysOnTop() override;
140 virtual void SAL_CALL setAlwaysOnTop( sal_Bool _alwaysontop ) override;
141 virtual sal_Bool SAL_CALL getMouseVisible() override;
142 virtual void SAL_CALL setMouseVisible( sal_Bool _mousevisible ) override;
143 virtual sal_Bool SAL_CALL getUsePen() override;
144 virtual void SAL_CALL setUsePen( sal_Bool _usepen ) override;
145 virtual ::sal_Int32 SAL_CALL getPenColor() override;
146 virtual void SAL_CALL setPenColor( ::sal_Int32 _pencolor ) override;
147 virtual double SAL_CALL getPenWidth() override;
148 virtual void SAL_CALL setPenWidth( double dStrokeWidth ) override;
149 /// @throws css::uno::RuntimeException
150 virtual void SAL_CALL setEraseAllInk( sal_Bool bEraseAllInk ) override;
151 virtual sal_Bool SAL_CALL isRunning( ) override;
152 virtual ::sal_Int32 SAL_CALL getSlideCount( ) override;
153 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getSlideByIndex( ::sal_Int32 Index ) override;
154 virtual void SAL_CALL addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) override;
155 virtual void SAL_CALL removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) override;
156 virtual void SAL_CALL gotoNextEffect( ) override;
157 virtual void SAL_CALL gotoPreviousEffect( ) override;
158 virtual void SAL_CALL gotoFirstSlide( ) override;
159 virtual void SAL_CALL gotoNextSlide( ) override;
160 virtual void SAL_CALL gotoPreviousSlide( ) override;
161 virtual void SAL_CALL gotoLastSlide( ) override;
162 virtual void SAL_CALL gotoBookmark( const OUString& Bookmark ) override;
163 virtual void SAL_CALL gotoSlide( const css::uno::Reference< css::drawing::XDrawPage >& Page ) override;
164 virtual void SAL_CALL gotoSlideIndex( ::sal_Int32 Index ) override;
165 virtual void SAL_CALL stopSound( ) override;
166 virtual void SAL_CALL pause( ) override;
167 virtual void SAL_CALL resume( ) override;
168 virtual sal_Bool SAL_CALL isPaused( ) override;
169 virtual void SAL_CALL blankScreen( ::sal_Int32 Color ) override;
170 virtual void SAL_CALL activate( ) override;
171 virtual void SAL_CALL deactivate( ) override;
172 virtual sal_Bool SAL_CALL isActive( ) override;
173 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getCurrentSlide( ) override;
174 virtual ::sal_Int32 SAL_CALL getCurrentSlideIndex( ) override;
175 virtual ::sal_Int32 SAL_CALL getNextSlideIndex( ) override;
176 virtual sal_Bool SAL_CALL isEndless( ) override;
177 virtual sal_Bool SAL_CALL isFullScreen( ) override;
178 virtual css::uno::Reference< css::presentation::XSlideShow > SAL_CALL getSlideShow( ) override;
180 // XIndexAccess
181 virtual ::sal_Int32 SAL_CALL getCount( ) override;
182 virtual css::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) override;
183 virtual css::uno::Type SAL_CALL getElementType( ) override;
184 virtual sal_Bool SAL_CALL hasElements( ) override;
186 // will be called from the SlideShowListenerProxy when this event is fired from the XSlideShow
187 void slideEnded(const bool bReverse);
188 void contextMenuShow(const css::awt::Point& point);
189 /// @throws css::uno::RuntimeException
190 void hyperLinkClicked(const OUString & hyperLink);
191 void click(const css::uno::Reference< css::drawing::XShape > & xShape);
192 bool swipe(const CommandGestureSwipeData &rSwipeData);
193 bool longpress(const CommandGestureLongPressData& rLongPressData);
195 /// ends the presentation async
196 void endPresentation();
198 ViewShell* getViewShell() const { return mpViewShell; }
200 void paint();
201 bool keyInput(const KeyEvent& rKEvt);
202 void mouseButtonUp(const MouseEvent& rMEvt);
204 private:
205 SlideshowImpl(SlideshowImpl const &) = delete;
206 void operator =(SlideshowImpl const &) = delete;
208 virtual ~SlideshowImpl() override;
210 // override WeakComponentImplHelperBase::disposing()
211 // This function is called upon disposing the component,
212 // if your component needs special work when it becomes
213 // disposed, do it here.
214 virtual void disposing(std::unique_lock<std::mutex>&) override;
216 // internal
217 bool startShow( PresentationSettingsEx const * pPresSettings );
218 bool startPreview(
219 const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
220 const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode,
221 vcl::Window* pParent );
223 /** forces an async call to update in the main thread */
224 void startUpdateTimer();
226 void update();
228 void createSlideList( bool bAll, std::u16string_view rPresSlide );
230 void displayCurrentSlide (const bool bSkipAllMainSequenceEffects = false);
232 void displaySlideNumber( sal_Int32 nSlide );
233 void displaySlideIndex( sal_Int32 nIndex );
234 sal_Int32 getCurrentSlideNumber() const;
235 bool isInputFreezed() const { return mbInputFreeze; }
237 void jumpToBookmark( const OUString& sBookmark );
239 void hideChildWindows();
240 void showChildWindows();
242 void resize( const Size& rSize );
244 void setActiveXToolbarsVisible( bool bVisible );
246 DECL_LINK( updateHdl, Timer *, void );
247 DECL_LINK( ReadyForNextInputHdl, Timer *, void );
248 DECL_LINK( endPresentationHdl, void*, void );
249 void ContextMenuSelectHdl(std::u16string_view rIdent);
250 DECL_LINK( ContextMenuHdl, void*, void );
251 DECL_LINK( deactivateHdl, Timer *, void );
252 DECL_LINK( EventListenerHdl, VclSimpleEvent&, void );
254 /** called only by the slideshow view when the first paint event occurs.
255 This actually starts the slideshow. */
256 void onFirstPaint();
258 ::tools::Long getRestoreSlide() const { return mnRestoreSlide; }
260 private:
261 bool startShowImpl(
262 const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
264 SfxViewFrame* getViewFrame() const;
265 SfxDispatcher* getDispatcher() const;
266 SfxBindings* getBindings() const;
268 sal_Int32 getSlideNumberForBookmark( const OUString& rStrBookmark );
270 void removeShapeEvents();
271 void registerShapeEvents( sal_Int32 nSlideNumber );
272 /// @throws css::uno::Exception
273 void registerShapeEvents( css::uno::Reference< css::drawing::XShapes > const & xShapes );
275 static css::uno::Reference< css::presentation::XSlideShow > createSlideShow();
277 static void setAutoSaveState( bool bOn );
278 void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects);
280 /** Called by our maUpdateTimer's updateHdl handler this method is
281 responsible to call the slideshow update() method and, depending on
282 its return value, wait for a certain amount of time before another
283 call to update() is scheduled.
285 void updateSlideShow();
287 css::uno::Reference< css::presentation::XSlideShow > mxShow;
288 rtl::Reference<sd::SlideShowView> mxView;
289 css::uno::Reference< css::frame::XModel > mxModel;
291 Timer maUpdateTimer;
292 Timer maInputFreezeTimer;
293 Timer maDeactivateTimer;
295 ::sd::View* mpView;
296 ViewShell* mpViewShell;
297 DrawDocShell* mpDocSh;
298 SdDrawDocument* mpDoc;
300 VclPtr<vcl::Window> mpParentWindow;
301 VclPtr<sd::ShowWindow> mpShowWindow;
303 std::shared_ptr< AnimationSlideController > mpSlideController;
305 ::tools::Long mnRestoreSlide;
306 Point maPopupMousePos;
307 Size maPresSize;
308 AnimationMode meAnimationMode;
309 OUString maCharBuffer;
310 VclPtr< ::sd::Window> mpOldActiveWindow;
311 Link<StarBASIC*,bool> maStarBASICGlobalErrorHdl;
312 ::tools::ULong mnChildMask;
313 bool mbDisposed;
314 bool mbAutoSaveWasOn;
315 bool mbRehearseTimings;
316 bool mbIsPaused;
317 bool mbWasPaused; // used to cache pause state during context menu
318 bool mbInputFreeze;
319 bool mbActive;
321 PresentationSettings maPresSettings;
322 sal_Int32 mnUserPaintColor;
324 bool mbUsePen;
325 double mdUserPaintStrokeWidth;
327 std::map< css::uno::Reference< css::drawing::XShape >, WrappedShapeEventImplPtr >
328 maShapeEventMap;
330 css::uno::Reference< css::drawing::XDrawPage > mxPreviewDrawPage;
331 css::uno::Reference< css::animations::XAnimationNode > mxPreviewAnimationNode;
333 css::uno::Reference< css::media::XPlayer > mxPlayer;
335 ::std::unique_ptr<PaneHider> mpPaneHider;
337 ImplSVEvent * mnEndShowEvent;
338 ImplSVEvent * mnContextMenuEvent;
340 css::uno::Reference< css::presentation::XPresentation2 > mxPresentation;
341 ::rtl::Reference< SlideShowListenerProxy > mxListenerProxy;
344 } // namespace ::sd
346 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */