Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SD_SlideShowImpl_HXX_
30 : : #define _SD_SlideShowImpl_HXX_
31 : :
32 : : #include "sal/config.h"
33 : : #include "com/sun/star/uno/XComponentContext.hpp"
34 : : #include "cppuhelper/compbase1.hxx"
35 : : #include "cppuhelper/compbase2.hxx"
36 : : #include "cppuhelper/basemutex.hxx"
37 : : #include "cppuhelper/propertysetmixin.hxx"
38 : : #include <com/sun/star/awt/XActivateListener.hpp>
39 : : #include <com/sun/star/presentation/XSlideShow.hpp>
40 : : #include <com/sun/star/presentation/XSlideShowView.hpp>
41 : : #include <com/sun/star/presentation/XSlideShowListener.hpp>
42 : : #include <com/sun/star/presentation/XSlideShowController.hpp>
43 : : #include "com/sun/star/presentation/XShapeEventListener.hpp"
44 : : #include <com/sun/star/awt/WindowEvent.hpp>
45 : : #include <com/sun/star/awt/XWindowListener.hpp>
46 : : #include <com/sun/star/awt/XWindow.hpp>
47 : : #include <com/sun/star/awt/XWindowPeer.hpp>
48 : : #include <com/sun/star/util/XModifyListener.hpp>
49 : : #include <com/sun/star/awt/XPaintListener.hpp>
50 : : #include <com/sun/star/awt/XPointer.hpp>
51 : : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
52 : : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
53 : : #include <com/sun/star/presentation/ClickAction.hpp>
54 : : #include <com/sun/star/media/XManager.hpp>
55 : : #include <com/sun/star/media/XPlayer.hpp>
56 : :
57 : : #include <toolkit/helper/vclunohelper.hxx>
58 : :
59 : : #include <basegfx/matrix/b2dhommatrix.hxx>
60 : : #include <basegfx/tools/canvastools.hxx>
61 : : #include <vcl/help.hxx>
62 : : #include <unotools/pathoptions.hxx>
63 : : #include <unotools/saveopt.hxx>
64 : : #include <sfx2/bindings.hxx>
65 : : #include <sfx2/dispatch.hxx>
66 : : #include <sfx2/viewfrm.hxx>
67 : : #include <basic/sbstar.hxx>
68 : : #include <svx/svdpagv.hxx>
69 : : #include <svx/fmshell.hxx>
70 : :
71 : : #include <svx/svxids.hrc>
72 : : #include "sdmod.hxx"
73 : : #include "cusshow.hxx"
74 : : #include "ViewShellBase.hxx"
75 : : #include "PresentationViewShell.hxx"
76 : : #include "ViewShell.hxx"
77 : : #include "drawview.hxx"
78 : : #include "drawdoc.hxx"
79 : :
80 : : #include "showwindow.hxx"
81 : :
82 : : #include "optsitem.hxx"
83 : : #include "FrameView.hxx"
84 : : #include "DrawDocShell.hxx"
85 : :
86 : : #include "app.hrc"
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 : 0 : 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 : 0 : struct WrappedShapeEventImpl
122 : : {
123 : : css::presentation::ClickAction meClickAction;
124 : : sal_Int32 mnVerb;
125 : : ::rtl::OUString maStrBookmark;
126 : 0 : 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 : :
247 : 0 : 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 : :
272 : : 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();
288 : 0 : 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, void *);
300 : : DECL_LINK( PostYieldListener, void* );
301 : : DECL_LINK(ReadyForNextInputHdl, void *);
302 : : DECL_LINK( endPresentationHdl, void* );
303 : : DECL_LINK( ContextMenuSelectHdl, Menu * );
304 : : DECL_LINK( ContextMenuHdl, void* );
305 : : DECL_LINK(deactivateHdl, void *);
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 : :
315 : 0 : 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 : :
425 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|