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