xref: /trunk/main/sd/source/ui/inc/slideshow.hxx (revision 31bbceb0f9d64c0c2c3b22a794a1666c1f33396e)
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 #ifndef _SD_SLIDESHOW_HXX
23 #define _SD_SLIDESHOW_HXX
24 
25 #include <com/sun/star/presentation/XPresentation2.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 
28 #include <rtl/ref.hxx>
29 
30 #include <tools/link.hxx>
31 
32 #include <cppuhelper/compbase2.hxx>
33 #include <cppuhelper/basemutex.hxx>
34 
35 #include <editeng/unoipset.hxx>
36 
37 #include <memory>
38 #include <boost/shared_ptr.hpp>
39 
40 namespace com { namespace sun { namespace star {
41 
42     namespace drawing {
43         class XDrawPage;
44     }
45     namespace animations {
46         class XAnimationNode;
47     }
48 } } }
49 
50 class SdDrawDocument;
51 class KeyEvent;
52 class HelpEvent;
53 class MouseEvent;
54 class Size;
55 class CommandEvent;
56 class Rectangle;
57 class Window;
58 class SfxRequest;
59 
60 // TODO: Remove
61 #define PAGE_NO_END         65535
62 #define PAGE_NO_SOFTEND     (PAGE_NO_END - 1)
63 #define PAGE_NO_PAUSE       (PAGE_NO_SOFTEND - 1)
64 #define PAGE_NO_FIRSTDEF    PAGE_NO_PAUSE // immer mit anpassen
65 
66 /* Definition of SlideShow class */
67 
68 namespace sd
69 {
70 
71 class SlideshowImpl;
72 class ShowWindow;
73 class Window;
74 class View;
75 class ViewShell;
76 struct PresentationSettings;
77 class EffectSequenceHelper;
78 class ViewShellBase;
79 struct PresentationSettingsEx;
80 class FrameView;
81 
82 enum AnimationMode
83 {
84     ANIMATIONMODE_SHOW,
85     ANIMATIONMODE_VIEW,
86     ANIMATIONMODE_PREVIEW
87 };
88 
89 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::presentation::XPresentation2, ::com::sun::star::lang::XServiceInfo > SlideshowBase;
90 
91 class SlideShow : private ::cppu::BaseMutex, public SlideshowBase
92 {
93 public:
94     // used by the model to create a slideshow for it
95     static rtl::Reference< SlideShow > Create( SdDrawDocument* pDoc );
96 
97     // static helper api
98     static rtl::Reference< SlideShow > GetSlideShow( SdDrawDocument* pDocument );
99     static rtl::Reference< SlideShow > GetSlideShow( ViewShellBase& rBase );
100 
101     static ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XSlideShowController > GetSlideShowController(ViewShellBase& rBase );
102 
103     static bool StartPreview( ViewShellBase& rBase,
104         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage,
105         const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xAnimationNode,
106         ::Window* pParent = 0 );
107 
108     static void Stop( ViewShellBase& rBase );
109 
110     // returns true if there is a running presentation for the given ViewShellBase
111     static bool IsRunning( ViewShellBase& rBase );
112 
113     // returns true if there is a running presentation inside the given ViewShell
114     // returns false even if there is a running presentation but in another ViewShell
115     static bool IsRunning( ViewShell& rViewShell );
116 
117     // helper api
118 
119     bool startPreview(
120         const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xDrawPage,
121         const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xAnimationNode,
122         ::Window* pParent = 0 );
123 
124     // uno api
125 
126         virtual void SAL_CALL disposing (void);
127 
128     // XServiceInfo
129     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
130     virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
131     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
132 
133     // XPropertySet
134     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw (::com::sun::star::uno::RuntimeException);
135     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);
136     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);
137     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);
138     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);
139     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);
140     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);
141 
142     // XPresentation
143     virtual void SAL_CALL start(  ) throw (::com::sun::star::uno::RuntimeException);
144     virtual void SAL_CALL end(  ) throw (::com::sun::star::uno::RuntimeException);
145     virtual void SAL_CALL rehearseTimings(  ) throw (::com::sun::star::uno::RuntimeException);
146 
147     // XPresentation2
148     virtual void SAL_CALL startWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::uno::RuntimeException);
149     virtual ::sal_Bool SAL_CALL isRunning(  ) throw (::com::sun::star::uno::RuntimeException);
150     virtual ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XSlideShowController > SAL_CALL getController(  ) throw (::com::sun::star::uno::RuntimeException);
151 
152     // legacy api
153 
154     // actions
155     void jumpToPageNumber( sal_Int32 nPage ); // a.k.a. FuSlideShow::JumpToPage()
156     void jumpToPageIndex( sal_Int32 nIndex );
157     void jumpToBookmark( const ::rtl::OUString& sBookmark ); // a.k.a. FuSlideShow::JumpToBookmark()
158 
159     /** sets or clears the pause state of the running slideshow.
160         !!!! This should only be called by the SdShowWindow !!!!*/
161     bool pause( bool bPause );
162 
163 
164     // settings
165     bool isFullScreen();                                // a.k.a. FuSlideShow::IsFullScreen()
166     bool isAlwaysOnTop();                               // a.k.a. FuSlideShow::IsAlwaysOnTop();
167     ShowWindow* getShowWindow();                        // a.k.a. FuSlideShow::GetShowWindow()
168     int getAnimationMode();                             // a.k.a. FuSlideShow::GetAnimationMode()
169     sal_Int32 getCurrentPageNumber();                   // a.k.a. FuSlideShow::GetCurrentPage()
170     sal_Int32 getFirstPageNumber();
171     sal_Int32 getLastPageNumber();
172     bool isEndless();
173     bool isDrawingPossible();
174 
175     // events
176     void resize( const Size &rSize );
177     void activate(ViewShellBase& rBase);
178     void deactivate(ViewShellBase& rBase);
179     void paint( const Rectangle& rRect );
180 
181     bool keyInput(const KeyEvent& rKEvt);
182 
183     void receiveRequest(SfxRequest& rReq);
184 
185     bool dependsOn( ViewShellBase* pViewShellBase );
186 
187     static sal_Int32 GetDisplay();
188 
189 private:
190     SlideShow( SdDrawDocument* pDoc );
191 
192     DECL_LINK( StartInPlacePresentationConfigurationHdl, void * );
193     void StartInPlacePresentationConfigurationCallback();
194 
195     void StartInPlacePresentation();
196     void StartFullscreenPresentation();
197 
198     void ThrowIfDisposed() throw (::com::sun::star::uno::RuntimeException);
199 
200     void CreateController( ViewShell* pViewSh, ::sd::View* pView, ::Window* pParentWindow );
201 
202     // default: disabled copy/assignment
203     SlideShow(const SlideShow&);
204     SlideShow& operator=( const SlideShow& );
205 
206     SvxItemPropertySet  maPropSet;
207 
208     rtl::Reference< SlideshowImpl > mxController;
209     /** This flag is used together with mxController.is() to prevent
210         multiple instances of the slide show for one document. The flag
211         covers the time before mxController is set.
212     */
213     bool mbIsInStartup;
214     SdDrawDocument* mpDoc;
215 
216     boost::shared_ptr< PresentationSettingsEx > mxCurrentSettings;
217 
218     ViewShellBase* mpCurrentViewShellBase;
219     ViewShellBase* mpFullScreenViewShellBase;
220     FrameView* mpFullScreenFrameView;
221     sal_Int32   mnInPlaceConfigEvent;
222 };
223 
224 }
225 
226 #endif /* _SD_SLIDESHOW_HXX */
227 
228 /* vim: set noet sw=4 ts=4: */
229