xref: /AOO41X/main/sd/source/ui/slideshow/slideshowimpl.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_SlideShowImpl_HXX_
25 #define _SD_SlideShowImpl_HXX_
26 
27 #include "sal/config.h"
28 #include "com/sun/star/uno/XComponentContext.hpp"
29 #include "cppuhelper/compbase1.hxx"
30 #include "cppuhelper/compbase2.hxx"
31 #include "cppuhelper/basemutex.hxx"
32 #include "cppuhelper/propertysetmixin.hxx"
33 #include <com/sun/star/awt/XActivateListener.hpp>
34 #include <com/sun/star/presentation/XSlideShow.hpp>
35 #include <com/sun/star/presentation/XSlideShowView.hpp>
36 #include <com/sun/star/presentation/XSlideShowListener.hpp>
37 #include <com/sun/star/presentation/XSlideShowController.hpp>
38 #include "com/sun/star/presentation/XShapeEventListener.hpp"
39 #include <com/sun/star/awt/WindowEvent.hpp>
40 #include <com/sun/star/awt/XWindowListener.hpp>
41 #include <com/sun/star/awt/XWindow.hpp>
42 #include <com/sun/star/awt/XWindowPeer.hpp>
43 #include <com/sun/star/util/XModifyListener.hpp>
44 #include <com/sun/star/awt/XPaintListener.hpp>
45 #include <com/sun/star/awt/XPointer.hpp>
46 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
47 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
48 #include <com/sun/star/presentation/ClickAction.hpp>
49 #include <com/sun/star/media/XManager.hpp>
50 #include <com/sun/star/media/XPlayer.hpp>
51 
52 #include <toolkit/helper/vclunohelper.hxx>
53 
54 #include <basegfx/matrix/b2dhommatrix.hxx>
55 #include <basegfx/tools/canvastools.hxx>
56 #include <vcl/help.hxx>
57 #include <tools/urlobj.hxx>
58 #include <unotools/pathoptions.hxx>
59 #include <unotools/saveopt.hxx>
60 #include <sfx2/bindings.hxx>
61 #include <sfx2/dispatch.hxx>
62 #include <sfx2/viewfrm.hxx>
63 #include <basic/sbstar.hxx>
64 #include <svx/svdpagv.hxx>
65 #include <svx/fmshell.hxx>
66 
67 #ifndef _SVX_SVXIDS_HRC
68 #include <svx/svxids.hrc>
69 #endif
70 #include "sdmod.hxx"
71 #include "cusshow.hxx"
72 #include "ViewShellBase.hxx"
73 #include "PresentationViewShell.hxx"
74 #include "ViewShell.hxx"
75 #include "drawview.hxx"
76 #include "drawdoc.hxx"
77 
78 #include "showwindow.hxx"
79 
80 #include "optsitem.hxx"
81 #include "FrameView.hxx"
82 #include "DrawDocShell.hxx"
83 
84 #ifndef _SD_APP_HRC_
85 #include "app.hrc"
86 #endif
87 
88 #include "slideshow.hxx"
89 
90 class SfxViewFrame;
91 class SfxRequest;
92 
93 namespace css = ::com::sun::star;
94 
95 namespace sd
96 {
97 class SlideShowView;
98 class AnimationSlideController;
99 class PaneHider;
100 
101 // --------------------------------------------------------------------
102 
103 struct PresentationSettingsEx : public PresentationSettings
104 {
105     sal_Bool mbRehearseTimings;
106     sal_Bool mbPreview;
107     ::Window* mpParentWindow;
108     css::uno::Reference< css::drawing::XDrawPage > mxStartPage;
109     css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode;
110 
111     PresentationSettingsEx( const PresentationSettingsEx& );
112     PresentationSettingsEx( PresentationSettings& );
113 
114     void SetArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments ) throw (css::lang::IllegalArgumentException);
115 
116     void SetPropertyValue( const ::rtl::OUString& rProperty, const css::uno::Any& rValue ) throw (css::lang::IllegalArgumentException);
117 };
118 
119 // --------------------------------------------------------------------
120 
121 struct WrappedShapeEventImpl
122 {
123     css::presentation::ClickAction meClickAction;
124     sal_Int32 mnVerb;
125     ::rtl::OUString maStrBookmark;
WrappedShapeEventImplsd::WrappedShapeEventImpl126     WrappedShapeEventImpl() : meClickAction( css::presentation::ClickAction_NONE ), mnVerb( 0 ) {};
127 };
128 
129 typedef boost::shared_ptr< WrappedShapeEventImpl > WrappedShapeEventImplPtr;
130 typedef std::map< css::uno::Reference< css::drawing::XShape >, WrappedShapeEventImplPtr > WrappedShapeEventImplMap;
131 
132 // --------------------------------------------------------------------
133 
134 class SlideShowListenerProxy : private ::cppu::BaseMutex,
135         public ::cppu::WeakImplHelper2< css::presentation::XSlideShowListener, css::presentation::XShapeEventListener >
136 {
137 public:
138     SlideShowListenerProxy( const rtl::Reference< SlideshowImpl >& xController, const css::uno::Reference< css::presentation::XSlideShow >& xSlideShow );
139     virtual ~SlideShowListenerProxy();
140 
141     void addAsSlideShowListener();
142     void removeAsSlideShowListener();
143 
144     void addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener );
145     void removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener );
146 
147     void addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape );
148     void removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape );
149 
150     // css::animations::XAnimationListener
151     virtual void SAL_CALL beginEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) throw (css::uno::RuntimeException);
152     virtual void SAL_CALL endEvent( const css::uno::Reference< css::animations::XAnimationNode >& Node ) throw (css::uno::RuntimeException);
153     virtual void SAL_CALL repeat( const css::uno::Reference< css::animations::XAnimationNode >& Node, ::sal_Int32 Repeat ) throw (css::uno::RuntimeException);
154 
155     // css::presentation::XSlideShowListener:
156     virtual void SAL_CALL paused() throw (css::uno::RuntimeException);
157     virtual void SAL_CALL resumed() throw (css::uno::RuntimeException);
158     virtual void SAL_CALL slideTransitionStarted() throw (css::uno::RuntimeException);
159     virtual void SAL_CALL slideTransitionEnded() throw (css::uno::RuntimeException);
160     virtual void SAL_CALL slideAnimationsEnded() throw (css::uno::RuntimeException);
161     virtual void SAL_CALL slideEnded(sal_Bool bReverse) throw (css::uno::RuntimeException);
162     virtual void SAL_CALL hyperLinkClicked(const ::rtl::OUString & hyperLink) throw (css::uno::RuntimeException);
163 
164     // css::lang::XEventListener:
165     virtual void SAL_CALL disposing(const css::lang::EventObject & Source) throw (css::uno::RuntimeException);
166 
167     // css::presentation::XShapeEventListener:
168     virtual void SAL_CALL click(const css::uno::Reference< css::drawing::XShape > & xShape, const css::awt::MouseEvent & aOriginalEvent) throw (css::uno::RuntimeException);
169 
170     ::cppu::OInterfaceContainerHelper maListeners;
171 
172     rtl::Reference< SlideshowImpl > mxController;
173     css::uno::Reference< css::presentation::XSlideShow > mxSlideShow;
174 };
175 
176 // --------------------------------------------------------------------
177 
178 typedef ::cppu::WeakComponentImplHelper2< css::presentation::XSlideShowController, css::container::XIndexAccess > SlideshowImplBase;
179 
180 class SlideshowImpl : private ::cppu::BaseMutex, public SlideshowImplBase
181 {
182 friend class SlideShow;
183 friend class SlideShowView;
184 
185 public:
186     explicit SlideshowImpl( const css::uno::Reference< css::presentation::XPresentation2 >& xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, ::Window* pParentWindow);
187 
188     // css::presentation::XSlideShowController:
189     virtual ::sal_Bool SAL_CALL getAlwaysOnTop() throw (css::uno::RuntimeException);
190     virtual void SAL_CALL setAlwaysOnTop( ::sal_Bool _alwaysontop ) throw (css::uno::RuntimeException);
191     virtual ::sal_Bool SAL_CALL getMouseVisible() throw (css::uno::RuntimeException);
192     virtual void SAL_CALL setMouseVisible( ::sal_Bool _mousevisible ) throw (css::uno::RuntimeException);
193     virtual ::sal_Bool SAL_CALL getUsePen() throw (css::uno::RuntimeException);
194     virtual void SAL_CALL setUsePen( ::sal_Bool _usepen ) throw (css::uno::RuntimeException);
195     virtual ::sal_Int32 SAL_CALL getPenColor() throw (css::uno::RuntimeException);
196     virtual void SAL_CALL setPenColor( ::sal_Int32 _pencolor ) throw (css::uno::RuntimeException);
197     virtual void SAL_CALL setUseEraser( ::sal_Bool _usepen ) throw (css::uno::RuntimeException);
198     virtual double SAL_CALL getPenWidth() throw (css::uno::RuntimeException);
199     virtual void SAL_CALL setPenWidth( double dStrokeWidth ) throw (css::uno::RuntimeException);
200     virtual void SAL_CALL setEraseAllInk( bool bEraseAllInk ) throw (css::uno::RuntimeException);
201     virtual void SAL_CALL setEraseInk( sal_Int32 nEraseInkSize ) throw (css::uno::RuntimeException);
202     virtual void SAL_CALL setPenMode( bool bSwitchPenMode) throw (css::uno::RuntimeException);
203     virtual void SAL_CALL setEraserMode( bool bSwitchEraserMode ) throw (css::uno::RuntimeException);
204     virtual ::sal_Bool SAL_CALL isRunning(  ) throw (css::uno::RuntimeException);
205     virtual ::sal_Int32 SAL_CALL getSlideCount(  ) throw (css::uno::RuntimeException);
206     virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getSlideByIndex( ::sal_Int32 Index ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException);
207     virtual void SAL_CALL addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) throw (css::uno::RuntimeException);
208     virtual void SAL_CALL removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& Listener ) throw (css::uno::RuntimeException);
209     virtual void SAL_CALL gotoNextEffect(  ) throw (css::uno::RuntimeException);
210     virtual void SAL_CALL gotoPreviousEffect(  ) throw (css::uno::RuntimeException);
211     virtual void SAL_CALL gotoFirstSlide(  ) throw (css::uno::RuntimeException);
212     virtual void SAL_CALL gotoNextSlide(  ) throw (css::uno::RuntimeException);
213     virtual void SAL_CALL gotoPreviousSlide(  ) throw (css::uno::RuntimeException);
214     virtual void SAL_CALL gotoLastSlide(  ) throw (css::uno::RuntimeException);
215     virtual void SAL_CALL gotoBookmark( const ::rtl::OUString& Bookmark ) throw (css::uno::RuntimeException);
216     virtual void SAL_CALL gotoSlide( const css::uno::Reference< css::drawing::XDrawPage >& Page ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
217     virtual void SAL_CALL gotoSlideIndex( ::sal_Int32 Index ) throw (css::uno::RuntimeException);
218     virtual void SAL_CALL stopSound(  ) throw (css::uno::RuntimeException);
219     virtual void SAL_CALL pause(  ) throw (css::uno::RuntimeException);
220     virtual void SAL_CALL resume(  ) throw (css::uno::RuntimeException);
221     virtual ::sal_Bool SAL_CALL isPaused(  ) throw (css::uno::RuntimeException);
222     virtual void SAL_CALL blankScreen( ::sal_Int32 Color ) throw (css::uno::RuntimeException);
223     virtual void SAL_CALL activate(  ) throw (css::uno::RuntimeException);
224     virtual void SAL_CALL deactivate(  ) throw (css::uno::RuntimeException);
225     virtual ::sal_Bool SAL_CALL isActive(  ) throw (css::uno::RuntimeException);
226     virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getCurrentSlide(  ) throw (css::uno::RuntimeException);
227     virtual ::sal_Int32 SAL_CALL getCurrentSlideIndex(  ) throw (css::uno::RuntimeException);
228     virtual ::sal_Int32 SAL_CALL getNextSlideIndex(  ) throw (css::uno::RuntimeException);
229     virtual ::sal_Bool SAL_CALL isEndless(  ) throw (css::uno::RuntimeException);
230     virtual ::sal_Bool SAL_CALL isFullScreen(  ) throw (css::uno::RuntimeException);
231     virtual css::uno::Reference< css::presentation::XSlideShow > SAL_CALL getSlideShow(  ) throw (css::uno::RuntimeException);
232 
233     // XIndexAccess
234     virtual ::sal_Int32 SAL_CALL getCount(  ) throw (::com::sun::star::uno::RuntimeException);
235     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);
236     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException);
237     virtual ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException);
238 
239     // will be called from the SlideShowListenerProxy when this event is fired from the XSlideShow
240     void slideEnded(const bool bReverse);
241     void hyperLinkClicked(const ::rtl::OUString & hyperLink) throw (css::uno::RuntimeException);
242     void click(const css::uno::Reference< css::drawing::XShape > & xShape, const css::awt::MouseEvent & aOriginalEvent);
243 
244     /// ends the presentation async
245     void endPresentation();
246 
getViewShell() const247     ViewShell* getViewShell() const { return mpViewShell; }
248 
249     void paint( const Rectangle& rRect );
250     bool keyInput(const KeyEvent& rKEvt);
251     void mouseButtonUp(const MouseEvent& rMEvt);
252 
253 private:
254     SlideshowImpl(SlideshowImpl &); // not defined
255     void operator =(SlideshowImpl &); // not defined
256 
257     virtual ~SlideshowImpl();
258 
259     // overload WeakComponentImplHelperBase::disposing()
260     // This function is called upon disposing the component,
261     // if your component needs special work when it becomes
262     // disposed, do it here.
263     virtual void SAL_CALL disposing();
264 
265     // internal
266     bool startShow( PresentationSettingsEx* pPresSettings );
267     bool startPreview(
268         const css::uno::Reference< css::drawing::XDrawPage >& xDrawPage,
269         const css::uno::Reference< css::animations::XAnimationNode >& xAnimationNode,
270         ::Window* pParent );
271 
getShowWindow() const272     ShowWindow* getShowWindow() const { return mpShowWindow; }
273 
274         /** forces an async call to update in the main thread */
275     void startUpdateTimer();
276 
277     double update();
278 
279     void createSlideList( bool bAll, bool bStartWithActualSlide, const String& rPresSlide );
280 
281     void displayCurrentSlide (const bool bSkipAllMainSequenceEffects = false);
282 
283     void displaySlideNumber( sal_Int32 nSlide );
284     void displaySlideIndex( sal_Int32 nIndex );
285     sal_Int32 getCurrentSlideNumber();
286     sal_Int32 getFirstSlideNumber();
287     sal_Int32 getLastSlideNumber();
isInputFreezed() const288     inline bool isInputFreezed() const { return mbInputFreeze; }
289 
290     void jumpToBookmark( const String& sBookmark );
291 
292     void hideChildWindows();
293     void showChildWindows();
294 
295     void resize( const Size& rSize );
296 
297     void setActiveXToolbarsVisible( sal_Bool bVisible );
298 
299     DECL_LINK( updateHdl, Timer* );
300     DECL_LINK( PostYieldListener, void* );
301     DECL_LINK( ReadyForNextInputHdl, Timer* );
302     DECL_LINK( endPresentationHdl, void* );
303     DECL_LINK( ContextMenuSelectHdl, Menu * );
304     DECL_LINK( ContextMenuHdl, void* );
305     DECL_LINK( deactivateHdl, Timer* );
306     DECL_LINK( EventListenerHdl, VclSimpleEvent* );
307 
308     // helper
309     void receiveRequest(SfxRequest& rReq);
310 
311     /** called only by the slideshow view when the first paint event occurs.
312         This actually starts the slideshow. */
313     void onFirstPaint();
314 
getRestoreSlide() const315     long getRestoreSlide() const { return mnRestoreSlide; }
316 
317 private:
318     bool startShowImpl(
319         const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
320 
321     SfxViewFrame* getViewFrame() const;
322     SfxDispatcher* getDispatcher() const;
323     SfxBindings* getBindings() const;
324 
325     sal_Int32 getSlideNumberForBookmark( const rtl::OUString& rStrBookmark );
326 
327     void removeShapeEvents();
328     void registerShapeEvents( sal_Int32 nSlideNumber );
329     void registerShapeEvents( css::uno::Reference< css::drawing::XShapes >& xShapes ) throw (css::uno::Exception);
330 
331     css::uno::Reference< css::presentation::XSlideShow > createSlideShow() const;
332 
333     void setAutoSaveState( bool bOn );
334     void gotoPreviousSlide (const bool bSkipAllMainSequenceEffects);
335 
336     /** Called by PostYieldListener and updateHdl handlers this method is
337         responsible to call the slideshow update() method and, depending on
338         its return value, wait for a certain amount of time before another
339         call to update() is scheduled.
340     */
341     sal_Int32 updateSlideShow (void);
342 
343     css::uno::Reference< css::presentation::XSlideShow > mxShow;
344     comphelper::ImplementationReference< ::sd::SlideShowView, css::presentation::XSlideShowView > mxView;
345     css::uno::Reference< css::frame::XModel > mxModel;
346 
347     Timer maUpdateTimer;
348     Timer maInputFreezeTimer;
349     Timer maDeactivateTimer;
350 
351     ::sd::View* mpView;
352     ViewShell* mpViewShell;
353     DrawDocShell* mpDocSh;
354     SdDrawDocument* mpDoc;
355 
356     SfxItemSet*     mpNewAttr;
357     ::Window*       mpParentWindow;
358     ShowWindow*     mpShowWindow;
359     PushButton*     mpTimeButton;
360 
361     boost::shared_ptr< AnimationSlideController > mpSlideController;
362 
363     long            mnRestoreSlide;
364     Point           maSlideOrigin;
365     Point           maPopupMousePos;
366     Size            maSlideSize;
367     Size            maPresSize;
368     AnimationMode   meAnimationMode;
369     String          maCharBuffer;
370     Pointer         maOldPointer;
371     Pointer         maPencil;
372     std::vector< ::sd::Window* > maDrawModeWindows;
373     ::sd::Window*   mpOldActiveWindow;
374     Link            maStarBASICGlobalErrorHdl;
375     unsigned long   mnChildMask;
376     bool            mbGridVisible;
377     bool            mbBordVisible;
378     bool            mbSlideBorderVisible;
379     bool            mbSetOnlineSpelling;
380     bool            mbDisposed;
381     bool            mbMouseIsDrawing;
382     bool            mbAutoSaveWasOn;
383     bool            mbRehearseTimings;
384     bool            mbDesignMode;
385     bool            mbIsPaused;
386     bool            mbWasPaused;        // used to cache pause state during context menu
387     bool            mbInputFreeze;
388     sal_Bool        mbActive;
389 
390     PresentationSettings maPresSettings;
391     sal_Int32       mnUserPaintColor;
392 
393     bool            mbUsePen;
394     double          mdUserPaintStrokeWidth;
395 
396     /// used in updateHdl to prevent recursive calls
397     sal_Int32       mnEntryCounter;
398 
399     sal_Int32       mnLastSlideNumber;
400     WrappedShapeEventImplMap    maShapeEventMap;
401 
402     ::rtl::OUString msOnClick;
403     ::rtl::OUString msBookmark;
404     ::rtl::OUString msVerb;
405 
406     css::uno::Reference< css::drawing::XDrawPage > mxPreviewDrawPage;
407     css::uno::Reference< css::animations::XAnimationNode > mxPreviewAnimationNode;
408 
409     css::uno::Reference< css::media::XPlayer > mxPlayer;
410 
411     ::std::auto_ptr<PaneHider> mpPaneHider;
412 
413     sal_uLong   mnEndShowEvent;
414     sal_uLong   mnContextMenuEvent;
415     sal_Int32 mnUpdateEvent;
416 
417     css::uno::Reference< css::presentation::XPresentation2 > mxPresentation;
418     ::rtl::Reference< SlideShowListenerProxy > mxListenerProxy;
419 };
420 
421 } // namespace ::sd
422 
423 #endif
424