xref: /trunk/main/sd/source/ui/inc/slideshow.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SD_SLIDESHOW_HXX
29 #define _SD_SLIDESHOW_HXX
30 
31 #include <com/sun/star/presentation/XPresentation2.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 
34 #include <rtl/ref.hxx>
35 
36 #include <tools/link.hxx>
37 
38 #include <cppuhelper/compbase2.hxx>
39 #include <cppuhelper/basemutex.hxx>
40 
41 #include <editeng/unoipset.hxx>
42 
43 #include <memory>
44 #include <boost/shared_ptr.hpp>
45 
46 namespace com { namespace sun { namespace star {
47 
48     namespace drawing {
49         class XDrawPage;
50     }
51     namespace animations {
52         class XAnimationNode;
53     }
54 } } }
55 
56 class SdDrawDocument;
57 class KeyEvent;
58 class HelpEvent;
59 class MouseEvent;
60 class Size;
61 class CommandEvent;
62 class Rectangle;
63 class Window;
64 class SfxRequest;
65 
66 // TODO: Remove
67 #define PAGE_NO_END         65535
68 #define PAGE_NO_SOFTEND     (PAGE_NO_END - 1)
69 #define PAGE_NO_PAUSE       (PAGE_NO_SOFTEND - 1)
70 #define PAGE_NO_FIRSTDEF    PAGE_NO_PAUSE // immer mit anpassen
71 
72 /* Definition of SlideShow class */
73 
74 namespace sd
75 {
76 
77 class SlideshowImpl;
78 class ShowWindow;
79 class Window;
80 class View;
81 class ViewShell;
82 struct PresentationSettings;
83 class EffectSequenceHelper;
84 class ViewShellBase;
85 struct PresentationSettingsEx;
86 class FrameView;
87 
88 enum AnimationMode
89 {
90     ANIMATIONMODE_SHOW,
91     ANIMATIONMODE_VIEW,
92     ANIMATIONMODE_PREVIEW
93 };
94 
95 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::presentation::XPresentation2, ::com::sun::star::lang::XServiceInfo > SlideshowBase;
96 
97 class SlideShow : private ::cppu::BaseMutex, public SlideshowBase
98 {
99 public:
100     /// used by the model to create a slideshow for it
101     static rtl::Reference< SlideShow > Create( SdDrawDocument* pDoc );
102 
103     // static helper api
104     static rtl::Reference< SlideShow > GetSlideShow( SdDrawDocument* pDocument );
105     static rtl::Reference< SlideShow > GetSlideShow( ViewShellBase& rBase );
106 
107     static ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XSlideShowController > GetSlideShowController(ViewShellBase& rBase );
108 
109     static bool StartPreview( ViewShellBase& rBase,
110         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage,
111         const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xAnimationNode,
112         ::Window* pParent = 0 );
113 
114     static void Stop( ViewShellBase& rBase );
115 
116     /// returns true if there is a running presentation for the given ViewShellBase
117     static bool IsRunning( ViewShellBase& rBase );
118 
119     /// returns true if there is a running presentation inside the given ViewShell
120     /// returns false even if there is a running presentation but in another ViewShell
121     static bool IsRunning( ViewShell& rViewShell );
122 
123     // helper api
124 
125     bool startPreview(
126         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage,
127         const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xAnimationNode,
128         ::Window* pParent = 0 );
129 
130     // uno api
131 
132         virtual void SAL_CALL disposing (void);
133 
134     // XServiceInfo
135     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
136     virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
137     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
138 
139     // XPropertySet
140     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw (::com::sun::star::uno::RuntimeException);
141     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
142     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
143     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
144     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
145     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
146     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
147 
148     // XPresentation
149     virtual void SAL_CALL start(  ) throw (::com::sun::star::uno::RuntimeException);
150     virtual void SAL_CALL end(  ) throw (::com::sun::star::uno::RuntimeException);
151     virtual void SAL_CALL rehearseTimings(  ) throw (::com::sun::star::uno::RuntimeException);
152 
153     // XPresentation2
154     virtual void SAL_CALL startWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::uno::RuntimeException);
155     virtual ::sal_Bool SAL_CALL isRunning(  ) throw (::com::sun::star::uno::RuntimeException);
156     virtual ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XSlideShowController > SAL_CALL getController(  ) throw (::com::sun::star::uno::RuntimeException);
157 
158     // legacy api
159 
160     // actions
161     void jumpToPageNumber( sal_Int32 nPage );               // a.k.a. FuSlideShow::JumpToPage()
162     void jumpToPageIndex( sal_Int32 nIndex );
163     void jumpToBookmark( const ::rtl::OUString& sBookmark );            // a.k.a. FuSlideShow::JumpToBookmark()
164 
165     /** sets or clears the pause state of the running slideshow.
166         !!!! This should only be called by the SdShowWindow !!!!*/
167     bool pause( bool bPause );
168 
169 
170     // settings
171     bool isFullScreen();                                // a.k.a. FuSlideShow::IsFullScreen()
172     bool isAlwaysOnTop();                               // a.k.a. FuSlideShow::IsAlwaysOnTop();
173     ShowWindow* getShowWindow();                        // a.k.a. FuSlideShow::GetShowWindow()
174     int getAnimationMode();                             // a.k.a. FuSlideShow::GetAnimationMode()
175     sal_Int32 getCurrentPageNumber();                   // a.k.a. FuSlideShow::GetCurrentPage()
176     sal_Int32 getFirstPageNumber();
177     sal_Int32 getLastPageNumber();
178     bool isEndless();
179     bool isDrawingPossible();
180 
181     // events
182     void resize( const Size &rSize );
183     void activate(ViewShellBase& rBase);
184     void deactivate(ViewShellBase& rBase);
185     void paint( const Rectangle& rRect );
186 
187     bool keyInput(const KeyEvent& rKEvt);
188 
189     void receiveRequest(SfxRequest& rReq);
190 
191     bool dependsOn( ViewShellBase* pViewShellBase );
192 
193     static sal_Int32 GetDisplay();
194 
195 private:
196     SlideShow( SdDrawDocument* pDoc );
197 
198     DECL_LINK( StartInPlacePresentationConfigurationHdl, void * );
199     void StartInPlacePresentationConfigurationCallback();
200 
201     void StartInPlacePresentation();
202     void StartFullscreenPresentation();
203 
204     void ThrowIfDisposed() throw (::com::sun::star::uno::RuntimeException);
205 
206     void CreateController( ViewShell* pViewSh, ::sd::View* pView, ::Window* pParentWindow );
207 
208     // default: disabled copy/assignment
209     SlideShow(const SlideShow&);
210     SlideShow& operator=( const SlideShow& );
211 
212     SvxItemPropertySet  maPropSet;
213 
214     rtl::Reference< SlideshowImpl > mxController;
215     /** This flag is used together with mxController.is() to prevent
216         multiple instances of the slide show for one document.  The flag
217         covers the time before mxController is set.
218     */
219     bool mbIsInStartup;
220     SdDrawDocument* mpDoc;
221 
222     boost::shared_ptr< PresentationSettingsEx > mxCurrentSettings;
223 
224     ViewShellBase* mpCurrentViewShellBase;
225     ViewShellBase* mpFullScreenViewShellBase;
226     FrameView* mpFullScreenFrameView;
227     sal_Int32   mnInPlaceConfigEvent;
228 };
229 
230 }
231 
232 #endif /* _SD_SLIDESHOW_HXX */
233