15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
105b190011SAndrew Rist  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125b190011SAndrew Rist  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
195b190011SAndrew Rist  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_sd.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "com/sun/star/frame/XComponentLoader.hpp"
31cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
32cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPageTarget.hpp>
34cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/SystemPointer.hpp>
39cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
40cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
41cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
42cdf0e10cSrcweir #include <vos/process.hxx>
43cdf0e10cSrcweir #include <svl/aeitem.hxx>
44cdf0e10cSrcweir #include <svl/urihelper.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
49cdf0e10cSrcweir #include <sfx2/request.hxx>
50cdf0e10cSrcweir #include <sfx2/docfile.hxx>
51cdf0e10cSrcweir #include <sfx2/app.hxx>
52cdf0e10cSrcweir #include <svx/unoapi.hxx>
53cdf0e10cSrcweir #include <svx/svdoole2.hxx>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir // for child window ids
56cdf0e10cSrcweir #include <sfx2/templdlg.hxx>
57cdf0e10cSrcweir #include <svx/f3dchild.hxx>
58cdf0e10cSrcweir #include <svx/imapdlg.hxx>
59cdf0e10cSrcweir #include <svx/fontwork.hxx>
60cdf0e10cSrcweir #include <svx/colrctrl.hxx>
61cdf0e10cSrcweir #include <svx/bmpmask.hxx>
62cdf0e10cSrcweir #include <svx/srchdlg.hxx>
63cdf0e10cSrcweir #include <svx/hyprlink.hxx>
64cdf0e10cSrcweir #include <svx/hyperdlg.hxx>
65cdf0e10cSrcweir #include <svx/galbrws.hxx>
66cdf0e10cSrcweir #include "NavigatorChildWindow.hxx"
67cdf0e10cSrcweir #include "AnimationChildWindow.hxx"
68cdf0e10cSrcweir #include <slideshowimpl.hxx>
69cdf0e10cSrcweir #include <slideshowviewimpl.hxx>
70cdf0e10cSrcweir #include <pgjump.hxx>
71cdf0e10cSrcweir #include "PaneHider.hxx"
72cdf0e10cSrcweir 
73cdf0e10cSrcweir #include "glob.hrc"
74cdf0e10cSrcweir #include "res_bmp.hrc"
75cdf0e10cSrcweir #include "sdresid.hxx"
76cdf0e10cSrcweir #include "vcl/canvastools.hxx"
77cdf0e10cSrcweir #include "comphelper/anytostring.hxx"
78cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx"
79cdf0e10cSrcweir #include "rtl/ref.hxx"
80cdf0e10cSrcweir #include "slideshow.hrc"
81cdf0e10cSrcweir #include "canvas/elapsedtime.hxx"
82cdf0e10cSrcweir #include "canvas/prioritybooster.hxx"
83cdf0e10cSrcweir #include "avmedia/mediawindow.hxx"
84cdf0e10cSrcweir #include  "svtools/colrdlg.hxx"
85cdf0e10cSrcweir 
86cdf0e10cSrcweir #include <boost/noncopyable.hpp>
87cdf0e10cSrcweir #include <boost/bind.hpp>
88cdf0e10cSrcweir 
89cdf0e10cSrcweir using ::rtl::OUString;
90cdf0e10cSrcweir using ::rtl::OString;
91cdf0e10cSrcweir using ::cppu::OInterfaceContainerHelper;
92cdf0e10cSrcweir using ::comphelper::ImplementationReference;
93cdf0e10cSrcweir using ::com::sun::star::animations::XAnimationNode;
94cdf0e10cSrcweir using ::com::sun::star::animations::XAnimationListener;
95cdf0e10cSrcweir using ::com::sun::star::awt::XWindow;
96cdf0e10cSrcweir using namespace ::com::sun::star;
97cdf0e10cSrcweir using namespace ::com::sun::star::lang;
98cdf0e10cSrcweir using namespace ::com::sun::star::uno;
99cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
100cdf0e10cSrcweir using namespace ::com::sun::star::container;
101cdf0e10cSrcweir using namespace ::com::sun::star::document;
102cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
103cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
104cdf0e10cSrcweir using namespace ::com::sun::star::beans;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir extern void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName );
107cdf0e10cSrcweir extern String getUiNameFromPageApiNameImpl( const OUString& rApiName );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir namespace sd
110cdf0e10cSrcweir {
111cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
112cdf0e10cSrcweir 
113cdf0e10cSrcweir // Slots, welche im Sfx verwaltet werden und in der SlideShow disabled
114cdf0e10cSrcweir // werden sollen (muss in Reihenfolge der SIDs geordnet sein)
115cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA pAllowed[] =
116cdf0e10cSrcweir {
117cdf0e10cSrcweir     SID_OPENDOC								, //	 5501	// damit interne Spruenge klappen
118cdf0e10cSrcweir 	SID_JUMPTOMARK							, //	 5598
119cdf0e10cSrcweir // 	SID_SHOWPOPUPS							, //	 5929
120cdf0e10cSrcweir //    SID_GALLERY                             , //     5960
121cdf0e10cSrcweir 	SID_OPENHYPERLINK						, //	 6676
122cdf0e10cSrcweir //    SID_GALLERY_FORMATS                     , //    10280
123cdf0e10cSrcweir     SID_NAVIGATOR							, //	10366
124cdf0e10cSrcweir //	SID_FM_DESIGN_MODE						, //	10629
125cdf0e10cSrcweir 	SID_PRESENTATION_END					, //	27218
126cdf0e10cSrcweir 	SID_NAVIGATOR_PAGENAME					, //	27287
127cdf0e10cSrcweir 	SID_NAVIGATOR_STATE 					, //	27288
128cdf0e10cSrcweir 	SID_NAVIGATOR_INIT						, //	27289
129cdf0e10cSrcweir 	SID_NAVIGATOR_PEN						, //	27291
130cdf0e10cSrcweir 	SID_NAVIGATOR_PAGE						, //	27292
131cdf0e10cSrcweir 	SID_NAVIGATOR_OBJECT					  //	27293
132cdf0e10cSrcweir };
133cdf0e10cSrcweir 
134cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
135cdf0e10cSrcweir 
136cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
137cdf0e10cSrcweir // AnimationSlideController
138cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
139cdf0e10cSrcweir 
140cdf0e10cSrcweir class AnimationSlideController
141cdf0e10cSrcweir {
142cdf0e10cSrcweir public:
143cdf0e10cSrcweir 	enum Mode { ALL, FROM, CUSTOM, PREVIEW };
144cdf0e10cSrcweir 
145cdf0e10cSrcweir public:
146cdf0e10cSrcweir 	AnimationSlideController( Reference< XIndexAccess > xSlides, Mode eMode );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	void setStartSlideNumber( sal_Int32 nSlideNumber ) { mnStartSlideNumber = nSlideNumber; }
149cdf0e10cSrcweir 	sal_Int32 getStartSlideIndex() const;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	sal_Int32 getCurrentSlideNumber() const;
152cdf0e10cSrcweir 	sal_Int32 getCurrentSlideIndex() const;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	sal_Int32 getSlideIndexCount() const { return maSlideNumbers.size(); }
155cdf0e10cSrcweir 	sal_Int32 getSlideNumberCount() const { return mnSlideCount; }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	sal_Int32 getSlideNumber( sal_Int32 nSlideIndex ) const;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	void insertSlideNumber( sal_Int32 nSlideNumber, bool bVisible = true );
160cdf0e10cSrcweir 	void setPreviewNode( const Reference< XAnimationNode >& xPreviewNode );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	bool jumpToSlideIndex( sal_Int32 nNewSlideIndex );
163cdf0e10cSrcweir 	bool jumpToSlideNumber( sal_Int32 nNewSlideIndex );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	bool nextSlide();
166cdf0e10cSrcweir 	bool previousSlide();
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     void displayCurrentSlide( const Reference< XSlideShow >& xShow,
169cdf0e10cSrcweir                               const Reference< XDrawPagesSupplier>& xDrawPages,
170cdf0e10cSrcweir                               const bool bSkipAllMainSequenceEffects );
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	sal_Int32 getNextSlideIndex() const;
173cdf0e10cSrcweir 	sal_Int32 getPreviousSlideIndex() const;
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	bool isVisibleSlideNumber( sal_Int32 nSlideNumber ) const;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	Reference< XDrawPage > getSlideByNumber( sal_Int32 nSlideNumber ) const;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	sal_Int32 getNextSlideNumber() const;
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	bool hasSlides() const { return !maSlideNumbers.empty(); }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir private:
184cdf0e10cSrcweir 	bool getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode );
185cdf0e10cSrcweir 	sal_Int32 findSlideIndex( sal_Int32 nSlideNumber ) const;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	bool isValidIndex( sal_Int32 nIndex ) const { return (nIndex >= 0) && (nIndex < (sal_Int32)maSlideNumbers.size()); }
188cdf0e10cSrcweir 	bool isValidSlideNumber( sal_Int32 nSlideNumber ) const { return (nSlideNumber >= 0) && (nSlideNumber < mnSlideCount); }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir private:
191cdf0e10cSrcweir 	Mode meMode;
192cdf0e10cSrcweir 	sal_Int32 mnStartSlideNumber;
193cdf0e10cSrcweir 	std::vector< sal_Int32 > maSlideNumbers;
194cdf0e10cSrcweir 	std::vector< bool > maSlideVisible;
195cdf0e10cSrcweir 	std::vector< bool > maSlideVisited;
196cdf0e10cSrcweir 	Reference< XAnimationNode > mxPreviewNode;
197cdf0e10cSrcweir 	sal_Int32 mnSlideCount;
198cdf0e10cSrcweir 	sal_Int32 mnCurrentSlideIndex;
199cdf0e10cSrcweir 	sal_Int32 mnHiddenSlideNumber;
200cdf0e10cSrcweir 	Reference< XIndexAccess > mxSlides;
201cdf0e10cSrcweir };
202cdf0e10cSrcweir 
203cdf0e10cSrcweir Reference< XDrawPage > AnimationSlideController::getSlideByNumber( sal_Int32 nSlideNumber ) const
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	Reference< XDrawPage > xSlide;
206cdf0e10cSrcweir 	if( mxSlides.is() && (nSlideNumber >= 0) && (nSlideNumber < mxSlides->getCount()) )
207cdf0e10cSrcweir 		mxSlides->getByIndex( nSlideNumber ) >>= xSlide;
208cdf0e10cSrcweir 	return xSlide;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir bool AnimationSlideController::isVisibleSlideNumber( sal_Int32 nSlideNumber ) const
212cdf0e10cSrcweir {
213cdf0e10cSrcweir 	sal_Int32 nIndex = findSlideIndex( nSlideNumber );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	if( nIndex != -1 )
216cdf0e10cSrcweir 		return maSlideVisible[ nIndex ];
217cdf0e10cSrcweir 	else
218cdf0e10cSrcweir 		return false;
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 
222cdf0e10cSrcweir void AnimationSlideController::setPreviewNode( const Reference< XAnimationNode >& xPreviewNode )
223cdf0e10cSrcweir {
224cdf0e10cSrcweir 	mxPreviewNode = xPreviewNode;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir AnimationSlideController::AnimationSlideController( Reference< XIndexAccess > xSlides, Mode eMode  )
228cdf0e10cSrcweir :	meMode( eMode )
229cdf0e10cSrcweir ,	mnStartSlideNumber(-1)
230cdf0e10cSrcweir ,	mnSlideCount( 0 )
231cdf0e10cSrcweir ,	mnCurrentSlideIndex(0)
232cdf0e10cSrcweir ,	mnHiddenSlideNumber( -1 )
233cdf0e10cSrcweir ,	mxSlides( xSlides )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir 	if( mxSlides.is() )
236cdf0e10cSrcweir 		mnSlideCount = xSlides->getCount();
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir sal_Int32 AnimationSlideController::getStartSlideIndex() const
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	if( mnStartSlideNumber >= 0 )
242cdf0e10cSrcweir 	{
243cdf0e10cSrcweir 		sal_Int32 nIndex;
244cdf0e10cSrcweir 		const sal_Int32 nCount = maSlideNumbers.size();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 		for( nIndex = 0; nIndex < nCount; nIndex++ )
247cdf0e10cSrcweir 		{
248cdf0e10cSrcweir 			if( maSlideNumbers[nIndex] == mnStartSlideNumber )
249cdf0e10cSrcweir 				return nIndex;
250cdf0e10cSrcweir 		}
251cdf0e10cSrcweir 	}
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 	return 0;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir sal_Int32 AnimationSlideController::getCurrentSlideNumber() const
257cdf0e10cSrcweir {
258cdf0e10cSrcweir 	if( mnHiddenSlideNumber != -1 )
259cdf0e10cSrcweir 		return mnHiddenSlideNumber;
260cdf0e10cSrcweir 	else if( !maSlideNumbers.empty() )
261cdf0e10cSrcweir 		return maSlideNumbers[mnCurrentSlideIndex];
262cdf0e10cSrcweir 	else
263cdf0e10cSrcweir 		return 0;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir sal_Int32 AnimationSlideController::getCurrentSlideIndex() const
267cdf0e10cSrcweir {
268cdf0e10cSrcweir 	if( mnHiddenSlideNumber != -1 )
269cdf0e10cSrcweir 		return -1;
270cdf0e10cSrcweir 	else
271cdf0e10cSrcweir 		return mnCurrentSlideIndex;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir bool AnimationSlideController::jumpToSlideIndex( sal_Int32 nNewSlideIndex )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir 	if( isValidIndex( nNewSlideIndex ) )
277cdf0e10cSrcweir 	{
278cdf0e10cSrcweir 		mnCurrentSlideIndex = nNewSlideIndex;
279cdf0e10cSrcweir 		mnHiddenSlideNumber = -1;
280cdf0e10cSrcweir 		maSlideVisited[mnCurrentSlideIndex] = true;
281cdf0e10cSrcweir 		return true;
282cdf0e10cSrcweir 	}
283cdf0e10cSrcweir 	else
284cdf0e10cSrcweir 	{
285cdf0e10cSrcweir 		return false;
286cdf0e10cSrcweir 	}
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir bool AnimationSlideController::jumpToSlideNumber( sal_Int32 nNewSlideNumber )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	sal_Int32 nIndex = findSlideIndex( nNewSlideNumber );
292cdf0e10cSrcweir 	if( isValidIndex( nIndex ) )
293cdf0e10cSrcweir 	{
294cdf0e10cSrcweir 		return jumpToSlideIndex( nIndex );
295cdf0e10cSrcweir 	}
296cdf0e10cSrcweir 	else if( (nNewSlideNumber >= 0) && (nNewSlideNumber < mnSlideCount) )
297cdf0e10cSrcweir 	{
298cdf0e10cSrcweir 		// jump to a hidden slide
299cdf0e10cSrcweir 		mnHiddenSlideNumber = nNewSlideNumber;
300cdf0e10cSrcweir 		return true;
301cdf0e10cSrcweir 	}
302cdf0e10cSrcweir 	else
303cdf0e10cSrcweir 	{
304cdf0e10cSrcweir 		return false;
305cdf0e10cSrcweir 	}
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir sal_Int32 AnimationSlideController::getSlideNumber( sal_Int32 nSlideIndex ) const
309cdf0e10cSrcweir {
310cdf0e10cSrcweir 	if( isValidIndex( nSlideIndex ) )
311cdf0e10cSrcweir 		return maSlideNumbers[nSlideIndex];
312cdf0e10cSrcweir 	else
313cdf0e10cSrcweir 		return -1;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir void AnimationSlideController::insertSlideNumber( sal_Int32 nSlideNumber, bool bVisible /* = true */ )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir 	DBG_ASSERT( isValidSlideNumber( nSlideNumber ), "sd::AnimationSlideController::insertSlideNumber(), illegal index" );
319cdf0e10cSrcweir 	if( isValidSlideNumber( nSlideNumber ) )
320cdf0e10cSrcweir 	{
321cdf0e10cSrcweir 		maSlideNumbers.push_back( nSlideNumber );
322cdf0e10cSrcweir 		maSlideVisible.push_back( bVisible );
323cdf0e10cSrcweir 		maSlideVisited.push_back( false );
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir bool AnimationSlideController::getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir 	if( isValidSlideNumber( nSlideNumber ) ) try
330cdf0e10cSrcweir 	{
331cdf0e10cSrcweir 		xSlide = Reference< XDrawPage >( mxSlides->getByIndex(nSlideNumber), UNO_QUERY_THROW );
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 		if( meMode == PREVIEW )
334cdf0e10cSrcweir 		{
335cdf0e10cSrcweir 			xAnimNode = mxPreviewNode;
336cdf0e10cSrcweir 		}
337cdf0e10cSrcweir 		else
338cdf0e10cSrcweir 		{
339cdf0e10cSrcweir 	   		Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier( xSlide, UNO_QUERY_THROW );
340cdf0e10cSrcweir 			xAnimNode = xAnimNodeSupplier->getAnimationNode();
341cdf0e10cSrcweir 		}
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 		return true;
344cdf0e10cSrcweir 	}
345cdf0e10cSrcweir 	catch( Exception& e )
346cdf0e10cSrcweir 	{
347cdf0e10cSrcweir 		(void)e;
348cdf0e10cSrcweir 		DBG_ERROR(
349cdf0e10cSrcweir 			(OString("sd::AnimationSlideController::getSlideAPI(), "
350cdf0e10cSrcweir 					"exception caught: ") +
351cdf0e10cSrcweir 			rtl::OUStringToOString(
352cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
353cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 	}
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 	return false;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir sal_Int32 AnimationSlideController::findSlideIndex( sal_Int32 nSlideNumber ) const
361cdf0e10cSrcweir {
362cdf0e10cSrcweir 	sal_Int32 nIndex;
363cdf0e10cSrcweir 	const sal_Int32 nCount = maSlideNumbers.size();
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	for( nIndex = 0; nIndex < nCount; nIndex++ )
366cdf0e10cSrcweir 	{
367cdf0e10cSrcweir 		if( maSlideNumbers[nIndex] == nSlideNumber )
368cdf0e10cSrcweir 			return nIndex;
369cdf0e10cSrcweir 	}
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	return -1;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir sal_Int32 AnimationSlideController::getNextSlideIndex() const
375cdf0e10cSrcweir {
376cdf0e10cSrcweir 	switch( meMode )
377cdf0e10cSrcweir 	{
378cdf0e10cSrcweir 	case ALL:
379cdf0e10cSrcweir 		{
380cdf0e10cSrcweir 			sal_Int32 nNewSlideIndex = mnCurrentSlideIndex + 1;
381cdf0e10cSrcweir 			if( isValidIndex( nNewSlideIndex ) )
382cdf0e10cSrcweir 			{
383cdf0e10cSrcweir 				// if the current slide is not excluded, make sure the
384cdf0e10cSrcweir 				// next slide is also not excluded.
385cdf0e10cSrcweir 				// if the current slide is excluded, we want to go
386cdf0e10cSrcweir 				// to the next slide, even if this is also excluded.
387cdf0e10cSrcweir 				if( maSlideVisible[mnCurrentSlideIndex] )
388cdf0e10cSrcweir 				{
389cdf0e10cSrcweir 					while( isValidIndex( nNewSlideIndex ) )
390cdf0e10cSrcweir 					{
391cdf0e10cSrcweir 						if( maSlideVisible[nNewSlideIndex] )
392cdf0e10cSrcweir 							break;
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 						nNewSlideIndex++;
395cdf0e10cSrcweir 					}
396cdf0e10cSrcweir 				}
397cdf0e10cSrcweir 			}
398cdf0e10cSrcweir 			return isValidIndex( nNewSlideIndex ) ? nNewSlideIndex : -1;
399cdf0e10cSrcweir 		}
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 	case FROM:
402cdf0e10cSrcweir 	case CUSTOM:
403cdf0e10cSrcweir 		return mnHiddenSlideNumber == -1 ? mnCurrentSlideIndex + 1 : mnCurrentSlideIndex;
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	default:
406cdf0e10cSrcweir 	case PREVIEW:
407cdf0e10cSrcweir 		return -1;
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 	}
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir sal_Int32 AnimationSlideController::getNextSlideNumber() const
413cdf0e10cSrcweir {
414cdf0e10cSrcweir 	sal_Int32 nNextSlideIndex = getNextSlideIndex();
415cdf0e10cSrcweir 	if( isValidIndex( nNextSlideIndex ) )
416cdf0e10cSrcweir 	{
417cdf0e10cSrcweir 		return maSlideNumbers[nNextSlideIndex];
418cdf0e10cSrcweir 	}
419cdf0e10cSrcweir 	else
420cdf0e10cSrcweir 	{
421cdf0e10cSrcweir 		return -1;
422cdf0e10cSrcweir 	}
423cdf0e10cSrcweir }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 
426cdf0e10cSrcweir bool AnimationSlideController::nextSlide()
427cdf0e10cSrcweir {
428cdf0e10cSrcweir 	return jumpToSlideIndex( getNextSlideIndex() );
429cdf0e10cSrcweir }
430cdf0e10cSrcweir 
431cdf0e10cSrcweir sal_Int32 AnimationSlideController::getPreviousSlideIndex() const
432cdf0e10cSrcweir {
433cdf0e10cSrcweir 	sal_Int32 nNewSlideIndex = mnCurrentSlideIndex - 1;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	switch( meMode )
436cdf0e10cSrcweir 	{
437cdf0e10cSrcweir 		case ALL:
438cdf0e10cSrcweir 		{
439cdf0e10cSrcweir 			// make sure the previous slide is visible
440cdf0e10cSrcweir 			// or was already visited
441cdf0e10cSrcweir 			while( isValidIndex( nNewSlideIndex ) )
442cdf0e10cSrcweir 			{
443cdf0e10cSrcweir 				if( maSlideVisible[nNewSlideIndex] || maSlideVisited[nNewSlideIndex] )
444cdf0e10cSrcweir 					break;
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 				nNewSlideIndex--;
447cdf0e10cSrcweir 			}
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 			break;
450cdf0e10cSrcweir 		}
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 		case PREVIEW:
453cdf0e10cSrcweir 			return -1;
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 		default:
456cdf0e10cSrcweir 			break;
457cdf0e10cSrcweir 	}
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 	return nNewSlideIndex;
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir bool AnimationSlideController::previousSlide()
463cdf0e10cSrcweir {
464cdf0e10cSrcweir 	return jumpToSlideIndex( getPreviousSlideIndex() );
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir void AnimationSlideController::displayCurrentSlide( const Reference< XSlideShow >& xShow,
468cdf0e10cSrcweir                                                     const Reference< XDrawPagesSupplier>& xDrawPages,
469cdf0e10cSrcweir                                                     const bool bSkipAllMainSequenceEffects )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir 	const sal_Int32 nCurrentSlideNumber = getCurrentSlideNumber();
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 	if( xShow.is() && (nCurrentSlideNumber != -1 ) )
474cdf0e10cSrcweir 	{
475cdf0e10cSrcweir 		Reference< XDrawPage > xSlide;
476cdf0e10cSrcweir 		Reference< XAnimationNode > xAnimNode;
477cdf0e10cSrcweir         ::std::vector<PropertyValue> aProperties;
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 		const sal_Int32 nNextSlideNumber = getNextSlideNumber();
480cdf0e10cSrcweir 		if( getSlideAPI( nNextSlideNumber, xSlide, xAnimNode )  )
481cdf0e10cSrcweir 		{
482cdf0e10cSrcweir 			Sequence< Any > aValue(2);
483cdf0e10cSrcweir 			aValue[0] <<= xSlide;
484cdf0e10cSrcweir 			aValue[1] <<= xAnimNode;
485cdf0e10cSrcweir 			aProperties.push_back(
486cdf0e10cSrcweir                 PropertyValue(
487cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM( "Prefetch" ) ),
488cdf0e10cSrcweir                     -1,
489cdf0e10cSrcweir                     Any(aValue),
490cdf0e10cSrcweir                     PropertyState_DIRECT_VALUE));
491cdf0e10cSrcweir 		}
492cdf0e10cSrcweir         if (bSkipAllMainSequenceEffects)
493cdf0e10cSrcweir         {
494cdf0e10cSrcweir             // Add one property that prevents the slide transition from being
495cdf0e10cSrcweir             // shown (to speed up the transition to the previous slide) and
496cdf0e10cSrcweir             // one to show all main sequence effects so that the user can
497cdf0e10cSrcweir             // continue to undo effects.
498cdf0e10cSrcweir             aProperties.push_back(
499cdf0e10cSrcweir                 PropertyValue(
500cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("SkipAllMainSequenceEffects")),
501cdf0e10cSrcweir                     -1,
502cdf0e10cSrcweir                     Any(sal_True),
503cdf0e10cSrcweir                     PropertyState_DIRECT_VALUE));
504cdf0e10cSrcweir             aProperties.push_back(
505cdf0e10cSrcweir                 PropertyValue(
506cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("SkipSlideTransition")),
507cdf0e10cSrcweir                     -1,
508cdf0e10cSrcweir                     Any(sal_True),
509cdf0e10cSrcweir                     PropertyState_DIRECT_VALUE));
510cdf0e10cSrcweir         }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir         // Convert vector into uno Sequence.
513cdf0e10cSrcweir 		Sequence< PropertyValue > aPropertySequence (aProperties.size());
514cdf0e10cSrcweir         for (int nIndex=0,nCount=aProperties.size();nIndex<nCount; ++nIndex)
515cdf0e10cSrcweir             aPropertySequence[nIndex] = aProperties[nIndex];
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 		if( getSlideAPI( nCurrentSlideNumber, xSlide, xAnimNode ) )
518cdf0e10cSrcweir 		    xShow->displaySlide( xSlide, xDrawPages, xAnimNode, aPropertySequence );
519cdf0e10cSrcweir 	}
520cdf0e10cSrcweir }
521cdf0e10cSrcweir 
522cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
523cdf0e10cSrcweir // class SlideshowImpl
524cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
525cdf0e10cSrcweir 
526cdf0e10cSrcweir SlideshowImpl::SlideshowImpl( const Reference< XPresentation2 >& xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, ::Window* pParentWindow )
527cdf0e10cSrcweir : SlideshowImplBase( m_aMutex )
528cdf0e10cSrcweir , mxModel(pDoc->getUnoModel(),UNO_QUERY_THROW)
529cdf0e10cSrcweir , mpView(pView)
530cdf0e10cSrcweir , mpViewShell(pViewSh)
531cdf0e10cSrcweir , mpDocSh(pDoc->GetDocSh())
532cdf0e10cSrcweir , mpDoc(pDoc)
533cdf0e10cSrcweir , mpNewAttr(0)
534cdf0e10cSrcweir , mpParentWindow(pParentWindow)
535cdf0e10cSrcweir , mpShowWindow(0)
536cdf0e10cSrcweir , mpTimeButton(0)
537cdf0e10cSrcweir , mnRestoreSlide(0)
538cdf0e10cSrcweir , maPresSize( -1, -1 )
539cdf0e10cSrcweir , meAnimationMode(ANIMATIONMODE_SHOW)
540cdf0e10cSrcweir , mpOldActiveWindow(0)
541cdf0e10cSrcweir , mnChildMask( 0 )
542cdf0e10cSrcweir , mbGridVisible(false)
543cdf0e10cSrcweir , mbBordVisible(false)
544cdf0e10cSrcweir , mbSlideBorderVisible(false)
545cdf0e10cSrcweir , mbSetOnlineSpelling(false)
546cdf0e10cSrcweir , mbDisposed(false)
547cdf0e10cSrcweir , mbRehearseTimings(false)
548cdf0e10cSrcweir , mbDesignMode(false)
549cdf0e10cSrcweir , mbIsPaused(false)
550cdf0e10cSrcweir , mbInputFreeze(false)
551cdf0e10cSrcweir , mbActive(sal_False)
552cdf0e10cSrcweir , maPresSettings( pDoc->getPresentationSettings() )
553cdf0e10cSrcweir , mnUserPaintColor( 0x80ff0000L )
554cdf0e10cSrcweir , mbUsePen(false)
555cdf0e10cSrcweir , mdUserPaintStrokeWidth ( 150.0 )
556cdf0e10cSrcweir #ifdef ENABLE_ERASER_UI
557cdf0e10cSrcweir , mbSwitchEraserMode(false)
558cdf0e10cSrcweir , mnEraseInkSize(100)
559cdf0e10cSrcweir #endif
560cdf0e10cSrcweir , mnEntryCounter(0)
561cdf0e10cSrcweir , mnLastSlideNumber(-1)
562cdf0e10cSrcweir , msOnClick( RTL_CONSTASCII_USTRINGPARAM("OnClick") )
563cdf0e10cSrcweir , msBookmark( RTL_CONSTASCII_USTRINGPARAM("Bookmark") )
564cdf0e10cSrcweir , msVerb( RTL_CONSTASCII_USTRINGPARAM("Verb") )
565cdf0e10cSrcweir , mnEndShowEvent(0)
566cdf0e10cSrcweir , mnContextMenuEvent(0)
567cdf0e10cSrcweir , mnUpdateEvent(0)
568cdf0e10cSrcweir , mxPresentation( xPresentation )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir     if( mpViewShell )
571cdf0e10cSrcweir         mpOldActiveWindow = mpViewShell->GetActiveWindow();
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 	maUpdateTimer.SetTimeoutHdl(LINK(this, SlideshowImpl, updateHdl));
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	maDeactivateTimer.SetTimeoutHdl(LINK(this, SlideshowImpl, deactivateHdl));
576cdf0e10cSrcweir 	maDeactivateTimer.SetTimeout( 20 );
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 	maInputFreezeTimer.SetTimeoutHdl( LINK( this, SlideshowImpl, ReadyForNextInputHdl ) );
579cdf0e10cSrcweir 	maInputFreezeTimer.SetTimeout( 20 );
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 	SvtSaveOptions aOptions;
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 		// no autosave during show
584cdf0e10cSrcweir 	if( aOptions.IsAutoSave() )
585cdf0e10cSrcweir 		mbAutoSaveWasOn = true;
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 	Application::AddEventListener( LINK( this, SlideshowImpl, EventListenerHdl ) );
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 	mbUsePen = maPresSettings.mbMouseAsPen;
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 	SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
592cdf0e10cSrcweir 	if( pOptions )
593cdf0e10cSrcweir 	{
594cdf0e10cSrcweir 		mnUserPaintColor = pOptions->GetPresentationPenColor();
595cdf0e10cSrcweir 		mdUserPaintStrokeWidth = pOptions->GetPresentationPenWidth();
596cdf0e10cSrcweir 	}
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir SlideshowImpl::~SlideshowImpl()
600cdf0e10cSrcweir {
601cdf0e10cSrcweir 	SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
602cdf0e10cSrcweir 	if( pOptions )
603cdf0e10cSrcweir 	{
604cdf0e10cSrcweir 		pOptions->SetPresentationPenColor(mnUserPaintColor);
605cdf0e10cSrcweir 		pOptions->SetPresentationPenWidth(mdUserPaintStrokeWidth);
606cdf0e10cSrcweir 	}
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 	Application::RemoveEventListener( LINK( this, SlideshowImpl, EventListenerHdl ) );
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 	maDeactivateTimer.Stop();
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 	if( !mbDisposed )
613cdf0e10cSrcweir 	{
614cdf0e10cSrcweir 		DBG_ERROR("SlideshowImpl::~SlideshowImpl(), component was not disposed!");
615cdf0e10cSrcweir 		disposing();
616cdf0e10cSrcweir 	}
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
619cdf0e10cSrcweir void SAL_CALL SlideshowImpl::disposing()
620cdf0e10cSrcweir {
621cdf0e10cSrcweir 	if( mxShow.is() && mpDoc )
622cdf0e10cSrcweir 		NotifyDocumentEvent( mpDoc, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnEndPresentation") ) );
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 	if( mbAutoSaveWasOn )
625cdf0e10cSrcweir 		setAutoSaveState( true );
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 	if( mnEndShowEvent )
628cdf0e10cSrcweir 		Application::RemoveUserEvent( mnEndShowEvent );
629cdf0e10cSrcweir 	if( mnContextMenuEvent )
630cdf0e10cSrcweir 		Application::RemoveUserEvent( mnContextMenuEvent );
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 	maInputFreezeTimer.Stop();
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 	if( !mxShow.is() )
637cdf0e10cSrcweir 		return;
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 	if( mxPresentation.is() )
640cdf0e10cSrcweir 		mxPresentation->end();
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 	maUpdateTimer.Stop();
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 	if( mnUpdateEvent )
645cdf0e10cSrcweir 	{
646cdf0e10cSrcweir 		Application::RemoveUserEvent( mnUpdateEvent );
647cdf0e10cSrcweir 		mnUpdateEvent = 0;
648cdf0e10cSrcweir 	}
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 	removeShapeEvents();
651cdf0e10cSrcweir 
652cdf0e10cSrcweir 	if( mxListenerProxy.is() )
653cdf0e10cSrcweir 		mxListenerProxy->removeAsSlideShowListener();
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 	try
656cdf0e10cSrcweir 	{
657cdf0e10cSrcweir 		if( mxView.is() )
658cdf0e10cSrcweir 			mxShow->removeView( mxView.getRef() );
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 		Reference< XComponent > xComponent( mxShow, UNO_QUERY );
661cdf0e10cSrcweir 		if( xComponent.is() )
662cdf0e10cSrcweir 			xComponent->dispose();
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 		if( mxView.is() )
665cdf0e10cSrcweir 			mxView->dispose();
666cdf0e10cSrcweir 	}
667cdf0e10cSrcweir 	catch( Exception& e )
668cdf0e10cSrcweir 	{
669cdf0e10cSrcweir 		static_cast<void>(e);
670cdf0e10cSrcweir 		DBG_ERROR(
671cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::stop(), "
672cdf0e10cSrcweir 					"exception caught: ") +
673cdf0e10cSrcweir 			rtl::OUStringToOString(
674cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
675cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	}
678cdf0e10cSrcweir 
679cdf0e10cSrcweir 	mxShow.clear();
680cdf0e10cSrcweir 	mxView.reset();
681cdf0e10cSrcweir 	mxListenerProxy.clear();
682cdf0e10cSrcweir 	mpSlideController.reset();
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	// der DrawView das Praesentationfenster wegnehmen und ihr dafuer ihre alten Fenster wiedergeben
685cdf0e10cSrcweir 	if( mpShowWindow && mpView )
686cdf0e10cSrcweir 		mpView->DeleteWindowFromPaintView( mpShowWindow );
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 	if( mpView )
689cdf0e10cSrcweir 		mpView->SetAnimationPause( sal_False );
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 	if( mpViewShell )
692cdf0e10cSrcweir 	{
693cdf0e10cSrcweir 		mpViewShell->SetActiveWindow(mpOldActiveWindow);
694cdf0e10cSrcweir 		mpShowWindow->SetViewShell( NULL );
695cdf0e10cSrcweir 	}
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 	if( mpView )
698cdf0e10cSrcweir 		mpView->InvalidateAllWin();
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     if( maPresSettings.mbFullScreen )
701cdf0e10cSrcweir     {
702cdf0e10cSrcweir         // restore StarBASICErrorHdl
703cdf0e10cSrcweir         StarBASIC::SetGlobalErrorHdl(maStarBASICGlobalErrorHdl);
704cdf0e10cSrcweir         maStarBASICGlobalErrorHdl = Link();
705cdf0e10cSrcweir     }
706cdf0e10cSrcweir     else
707cdf0e10cSrcweir 	{
708cdf0e10cSrcweir 		if( mpShowWindow )
709cdf0e10cSrcweir 			mpShowWindow->Hide();
710cdf0e10cSrcweir 	}
711cdf0e10cSrcweir 
712cdf0e10cSrcweir     if( meAnimationMode == ANIMATIONMODE_SHOW )
713cdf0e10cSrcweir     {
714cdf0e10cSrcweir         mpDocSh->SetSlotFilter();
715cdf0e10cSrcweir         mpDocSh->ApplySlotFilter();
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 		Help::EnableContextHelp();
718cdf0e10cSrcweir 		Help::EnableExtHelp();
719cdf0e10cSrcweir 
720cdf0e10cSrcweir         showChildWindows();
721cdf0e10cSrcweir 		mnChildMask = 0UL;
722cdf0e10cSrcweir     }
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 	// aktuelle Fenster wieder einblenden
725cdf0e10cSrcweir     if( mpViewShell && !mpViewShell->ISA(PresentationViewShell))
726cdf0e10cSrcweir 	{
727cdf0e10cSrcweir 		if( meAnimationMode == ANIMATIONMODE_SHOW )
728cdf0e10cSrcweir 		{
729cdf0e10cSrcweir 			mpViewShell->GetViewShellBase().ShowUIControls (true);
730cdf0e10cSrcweir             mpPaneHider.reset();
731cdf0e10cSrcweir 		}
732cdf0e10cSrcweir 		else if( meAnimationMode == ANIMATIONMODE_PREVIEW )
733cdf0e10cSrcweir 		{
734cdf0e10cSrcweir 			mpViewShell->ShowUIControls (true);
735cdf0e10cSrcweir 		}
736cdf0e10cSrcweir 	}
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 	if( mpTimeButton )
739cdf0e10cSrcweir 	{
740cdf0e10cSrcweir 		mpTimeButton->Hide();
741cdf0e10cSrcweir 		delete mpTimeButton;
742cdf0e10cSrcweir 		mpTimeButton = 0;
743cdf0e10cSrcweir 	}
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 	if( mpShowWindow )
746cdf0e10cSrcweir 		mpShowWindow->Hide();
747cdf0e10cSrcweir 
748cdf0e10cSrcweir 	if ( mpViewShell )
749cdf0e10cSrcweir 	{
750cdf0e10cSrcweir 		if( meAnimationMode == ANIMATIONMODE_SHOW )
751cdf0e10cSrcweir 		{
752cdf0e10cSrcweir 			::sd::Window* pActWin = mpViewShell->GetActiveWindow();
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 			if (pActWin)
755cdf0e10cSrcweir 			{
756cdf0e10cSrcweir 				Size aVisSizePixel = pActWin->GetOutputSizePixel();
757cdf0e10cSrcweir 				Rectangle aVisAreaWin = pActWin->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
758cdf0e10cSrcweir 				mpViewShell->VisAreaChanged(aVisAreaWin);
759cdf0e10cSrcweir 				mpView->VisAreaChanged(pActWin);
760cdf0e10cSrcweir 				pActWin->GrabFocus();
761cdf0e10cSrcweir 			}
762cdf0e10cSrcweir 		}
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 		// restart the custom show dialog if he started us
765cdf0e10cSrcweir 		if( mpViewShell->IsStartShowWithDialog() && getDispatcher() )
766cdf0e10cSrcweir 		{
767cdf0e10cSrcweir 			mpViewShell->SetStartShowWithDialog( sal_False );
768cdf0e10cSrcweir 			getDispatcher()->Execute( SID_CUSTOMSHOW_DLG, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
769cdf0e10cSrcweir 		}
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 		mpViewShell->GetViewShellBase().UpdateBorder(true);
772cdf0e10cSrcweir 	}
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 	if( mpShowWindow )
775cdf0e10cSrcweir 	{
776cdf0e10cSrcweir 		delete mpShowWindow;
777cdf0e10cSrcweir 		mpShowWindow = 0;
778cdf0e10cSrcweir 	}
779cdf0e10cSrcweir 
780cdf0e10cSrcweir     setActiveXToolbarsVisible( sal_True );
781cdf0e10cSrcweir 
782cdf0e10cSrcweir     Application::EnableNoYieldMode(false);
783cdf0e10cSrcweir     Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 	mbDisposed = true;
786cdf0e10cSrcweir }
787cdf0e10cSrcweir 
788cdf0e10cSrcweir bool SlideshowImpl::startPreview(
789cdf0e10cSrcweir 		const Reference< XDrawPage >& xDrawPage,
790cdf0e10cSrcweir 		const Reference< XAnimationNode >& xAnimationNode,
791cdf0e10cSrcweir 		::Window* pParent )
792cdf0e10cSrcweir {
793cdf0e10cSrcweir     bool bRet = false;
794cdf0e10cSrcweir 
795cdf0e10cSrcweir 	try
796cdf0e10cSrcweir 	{
797cdf0e10cSrcweir         const Reference<lang::XServiceInfo> xServiceInfo( xDrawPage, UNO_QUERY );
798cdf0e10cSrcweir         if (xServiceInfo.is()) {
799cdf0e10cSrcweir             const Sequence<OUString> supportedServices(
800cdf0e10cSrcweir                 xServiceInfo->getSupportedServiceNames() );
801cdf0e10cSrcweir             for ( sal_Int32 pos = supportedServices.getLength(); pos--; ) {
802cdf0e10cSrcweir                 if (supportedServices[pos].equalsAsciiL(
803cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM(
804cdf0e10cSrcweir                             "com.sun.star.drawing.MasterPage") )) {
805cdf0e10cSrcweir                     DBG_ERROR("sd::SlideshowImpl::startPreview() "
806cdf0e10cSrcweir                               "not allowed on master page!");
807cdf0e10cSrcweir                     return false;
808cdf0e10cSrcweir                 }
809cdf0e10cSrcweir             }
810cdf0e10cSrcweir         }
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 		mxPreviewDrawPage = xDrawPage;
813cdf0e10cSrcweir 		mxPreviewAnimationNode = xAnimationNode;
814cdf0e10cSrcweir 		meAnimationMode = ANIMATIONMODE_PREVIEW;
815cdf0e10cSrcweir 
816cdf0e10cSrcweir 		maPresSettings.mbAll = sal_False;
817cdf0e10cSrcweir 		maPresSettings.mbEndless = sal_False;
818cdf0e10cSrcweir 		maPresSettings.mbCustomShow = sal_False;
819cdf0e10cSrcweir 		maPresSettings.mbManual = sal_False;
820cdf0e10cSrcweir 		maPresSettings.mbMouseVisible = sal_False;
821cdf0e10cSrcweir 		maPresSettings.mbMouseAsPen = sal_False;
822cdf0e10cSrcweir 		maPresSettings.mbLockedPages = sal_False;
823cdf0e10cSrcweir 		maPresSettings.mbAlwaysOnTop = sal_False;
824cdf0e10cSrcweir 		maPresSettings.mbFullScreen = sal_False;
825cdf0e10cSrcweir 		maPresSettings.mbAnimationAllowed = sal_True;
826cdf0e10cSrcweir 		maPresSettings.mnPauseTimeout = 0;
827cdf0e10cSrcweir 		maPresSettings.mbShowPauseLogo = sal_False;
828cdf0e10cSrcweir 		maPresSettings.mbStartWithNavigator = sal_False;
829cdf0e10cSrcweir 
830cdf0e10cSrcweir 		Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
831cdf0e10cSrcweir 		Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
832cdf0e10cSrcweir 		mpSlideController.reset( new AnimationSlideController( xSlides, AnimationSlideController::PREVIEW ) );
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 		sal_Int32 nSlideNumber = 0;
835cdf0e10cSrcweir 		Reference< XPropertySet > xSet( mxPreviewDrawPage, UNO_QUERY_THROW );
836cdf0e10cSrcweir 		xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Number" ) ) ) >>= nSlideNumber;
837cdf0e10cSrcweir 		mpSlideController->insertSlideNumber( nSlideNumber-1 );
838cdf0e10cSrcweir 		mpSlideController->setPreviewNode( xAnimationNode );
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 		mpShowWindow = new ShowWindow( this, ((pParent == 0) && mpViewShell) ?  mpParentWindow : pParent );
841cdf0e10cSrcweir 		if( mpViewShell )
842cdf0e10cSrcweir 		{
843cdf0e10cSrcweir 			mpViewShell->SetActiveWindow( mpShowWindow );
844cdf0e10cSrcweir 			mpShowWindow->SetViewShell (mpViewShell);
845cdf0e10cSrcweir 			mpViewShell->ShowUIControls (false);
846cdf0e10cSrcweir 		}
847cdf0e10cSrcweir 
848cdf0e10cSrcweir 		if( mpView )
849cdf0e10cSrcweir 		{
850cdf0e10cSrcweir 			mpView->AddWindowToPaintView( mpShowWindow );
851cdf0e10cSrcweir 			mpView->SetAnimationPause( sal_True );
852cdf0e10cSrcweir 		}
853cdf0e10cSrcweir 
854cdf0e10cSrcweir 		// call resize handler
855cdf0e10cSrcweir 		if( pParent )
856cdf0e10cSrcweir 		{
857cdf0e10cSrcweir 			maPresSize = pParent->GetSizePixel();
858cdf0e10cSrcweir 		}
859cdf0e10cSrcweir 		else if( mpViewShell )
860cdf0e10cSrcweir 		{
861cdf0e10cSrcweir 			Rectangle aContentRect (mpViewShell->GetViewShellBase().getClientRectangle());
862cdf0e10cSrcweir 			if (Application::GetSettings().GetLayoutRTL())
863cdf0e10cSrcweir 			{
864cdf0e10cSrcweir 				aContentRect.nLeft = aContentRect.nRight;
865cdf0e10cSrcweir 				aContentRect.nRight += aContentRect.nRight;
866cdf0e10cSrcweir 			}
867cdf0e10cSrcweir 			maPresSize = aContentRect.GetSize();
868cdf0e10cSrcweir 			mpShowWindow->SetPosPixel( aContentRect.TopLeft() );
869cdf0e10cSrcweir 		}
870cdf0e10cSrcweir 		else
871cdf0e10cSrcweir 		{
872cdf0e10cSrcweir 			DBG_ERROR("sd::SlideshowImpl::startPreview(), I need either a parent window or a viewshell!");
873cdf0e10cSrcweir 		}
874cdf0e10cSrcweir 		resize( maPresSize );
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 		sal_Int32 nPropertyCount = 1;
877cdf0e10cSrcweir 		if( mxPreviewAnimationNode.is() )
878cdf0e10cSrcweir 			nPropertyCount++;
879cdf0e10cSrcweir 
880cdf0e10cSrcweir 		Sequence< beans::PropertyValue > aProperties(nPropertyCount);
881cdf0e10cSrcweir 		aProperties[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("AutomaticAdvancement") );
882cdf0e10cSrcweir 		aProperties[0].Value = uno::makeAny( (double)1.0 ); // one second timeout
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 		if( mxPreviewAnimationNode.is() )
885cdf0e10cSrcweir 		{
886cdf0e10cSrcweir 			aProperties[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("NoSlideTransitions") );
887cdf0e10cSrcweir 			aProperties[1].Value = uno::makeAny( sal_True );
888cdf0e10cSrcweir 		}
889cdf0e10cSrcweir 
890cdf0e10cSrcweir 		bRet = startShowImpl( aProperties );
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 		if( mpShowWindow != 0 && meAnimationMode == ANIMATIONMODE_PREVIEW )
893cdf0e10cSrcweir 			mpShowWindow->SetPreviewMode();
894cdf0e10cSrcweir 
895cdf0e10cSrcweir 	}
896cdf0e10cSrcweir 	catch( Exception& e )
897cdf0e10cSrcweir 	{
898cdf0e10cSrcweir 		(void)e;
899cdf0e10cSrcweir 		DBG_ERROR(
900cdf0e10cSrcweir             (OString("sd::SlideshowImpl::startPreview(), "
901cdf0e10cSrcweir                      "exception caught: ") +
902cdf0e10cSrcweir              rtl::OUStringToOString(
903cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
904cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
905cdf0e10cSrcweir         bRet = false;
906cdf0e10cSrcweir 	}
907cdf0e10cSrcweir 
908cdf0e10cSrcweir     return bRet;
909cdf0e10cSrcweir }
910cdf0e10cSrcweir 
911cdf0e10cSrcweir bool SlideshowImpl::startShow( PresentationSettingsEx* pPresSettings )
912cdf0e10cSrcweir {
913cdf0e10cSrcweir     const rtl::Reference<SlideshowImpl> this_(this);
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 	DBG_ASSERT( !mxShow.is(), "sd::SlideshowImpl::startShow(), called twice!" );
916cdf0e10cSrcweir 	if( mxShow.is() )
917cdf0e10cSrcweir 		return true;
918cdf0e10cSrcweir 	DBG_ASSERT( mpParentWindow!=NULL, "sd::SlideshowImpl::startShow() called without parent window" );
919cdf0e10cSrcweir     if (mpParentWindow == NULL)
920cdf0e10cSrcweir         return false;
921cdf0e10cSrcweir 
922cdf0e10cSrcweir     bool bRet = false;
923cdf0e10cSrcweir 
924cdf0e10cSrcweir 	try
925cdf0e10cSrcweir 	{
926cdf0e10cSrcweir 		if( pPresSettings )
927cdf0e10cSrcweir         {
928cdf0e10cSrcweir 			maPresSettings = *pPresSettings;
929cdf0e10cSrcweir             mbRehearseTimings = pPresSettings->mbRehearseTimings;
930cdf0e10cSrcweir         }
931cdf0e10cSrcweir 
932cdf0e10cSrcweir 		// ---
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 		String	aPresSlide( maPresSettings.maPresPage );
935cdf0e10cSrcweir 		SdPage* pStartPage = mpViewShell ? mpViewShell->GetActualPage() : 0;
936cdf0e10cSrcweir 		bool	bStartWithActualSlide =  pStartPage &&
937cdf0e10cSrcweir 										( (meAnimationMode != ANIMATIONMODE_SHOW) ||
938cdf0e10cSrcweir 										   SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsStartWithActualPage() );
939cdf0e10cSrcweir 
940cdf0e10cSrcweir 		// sollen Zeiten gestoppt werden?
941cdf0e10cSrcweir 		if( mbRehearseTimings )
942cdf0e10cSrcweir 		{
943cdf0e10cSrcweir 			maPresSettings.mbEndless = sal_False;
944cdf0e10cSrcweir 			maPresSettings.mbManual = sal_True;
945cdf0e10cSrcweir 			maPresSettings.mbMouseVisible = sal_True;
946cdf0e10cSrcweir 			maPresSettings.mbMouseAsPen = sal_False;
947cdf0e10cSrcweir 			maPresSettings.mnPauseTimeout = 0;
948cdf0e10cSrcweir 			maPresSettings.mbShowPauseLogo = sal_False;
949cdf0e10cSrcweir 			maPresSettings.mbStartWithNavigator = sal_False;
950cdf0e10cSrcweir 		}
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 		if( pStartPage )
953cdf0e10cSrcweir 		{
954cdf0e10cSrcweir 			if( pStartPage->GetPageKind() == PK_NOTES )
955cdf0e10cSrcweir 			{
956cdf0e10cSrcweir 				// we are in notes page mode, so get
957cdf0e10cSrcweir 				// the corresponding draw page
958cdf0e10cSrcweir 				const sal_uInt16 nPgNum = ( pStartPage->GetPageNum() - 2 ) >> 1;
959cdf0e10cSrcweir 				pStartPage = mpDoc->GetSdPage( nPgNum, PK_STANDARD );
960cdf0e10cSrcweir 			}
961cdf0e10cSrcweir 		}
962cdf0e10cSrcweir 
963cdf0e10cSrcweir 		if( bStartWithActualSlide )
964cdf0e10cSrcweir 		{
965cdf0e10cSrcweir 			if( meAnimationMode != ANIMATIONMODE_SHOW )
966cdf0e10cSrcweir 			{
967cdf0e10cSrcweir 				if( pStartPage->GetPageKind() == PK_STANDARD )
968cdf0e10cSrcweir 				{
969cdf0e10cSrcweir 					aPresSlide = pStartPage->GetName();
970cdf0e10cSrcweir 					maPresSettings.mbAll = false;
971cdf0e10cSrcweir 				}
972cdf0e10cSrcweir 				else
973cdf0e10cSrcweir 				{
974cdf0e10cSrcweir 					bStartWithActualSlide = false;
975cdf0e10cSrcweir 				}
976cdf0e10cSrcweir 			}
977cdf0e10cSrcweir 		}
978cdf0e10cSrcweir 		else
979cdf0e10cSrcweir 		{
980cdf0e10cSrcweir 			if( pStartPage->GetPageKind() != PK_STANDARD )
981cdf0e10cSrcweir 			{
982cdf0e10cSrcweir 				bStartWithActualSlide = false;
983cdf0e10cSrcweir 			}
984cdf0e10cSrcweir 		}
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 		// build page list
987cdf0e10cSrcweir         createSlideList( maPresSettings.mbAll, false, aPresSlide );
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 		if( bStartWithActualSlide )
990cdf0e10cSrcweir 		{
991cdf0e10cSrcweir 			sal_Int32 nSlideNum = ( pStartPage->GetPageNum() - 1 ) >> 1;
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 			if( !maPresSettings.mbAll && !maPresSettings.mbCustomShow )
994cdf0e10cSrcweir 			{
995cdf0e10cSrcweir 				// its start from dia, find out if it is located before our current Slide
996cdf0e10cSrcweir 				const sal_Int32 nSlideCount = mpDoc->GetSdPageCount( PK_STANDARD );
997cdf0e10cSrcweir 				sal_Int32 nSlide;
998cdf0e10cSrcweir 				for( nSlide = 0; (nSlide < nSlideCount); nSlide++ )
999cdf0e10cSrcweir 				{
1000cdf0e10cSrcweir 					if( mpDoc->GetSdPage( (sal_uInt16) nSlide, PK_STANDARD )->GetName() == aPresSlide )
1001cdf0e10cSrcweir 						break;
1002cdf0e10cSrcweir 				}
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 				if( nSlide > nSlideNum )
1005cdf0e10cSrcweir 					nSlideNum = -1;
1006cdf0e10cSrcweir 			}
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir 			if( nSlideNum != -1 )
1009cdf0e10cSrcweir 				mpSlideController->setStartSlideNumber( nSlideNum );
1010cdf0e10cSrcweir 		}
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 		// remember Slide number from where the show was started
1013cdf0e10cSrcweir 		if( pStartPage )
1014cdf0e10cSrcweir 			mnRestoreSlide = ( pStartPage->GetPageNum() - 1 ) / 2;
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir 		if( mpSlideController->hasSlides() )
1017cdf0e10cSrcweir 		{
1018cdf0e10cSrcweir 			// hide child windows
1019cdf0e10cSrcweir 			hideChildWindows();
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 			mpShowWindow = new ShowWindow( this, mpParentWindow );
1022cdf0e10cSrcweir 			mpShowWindow->SetMouseAutoHide( !maPresSettings.mbMouseVisible );
1023cdf0e10cSrcweir 			if( mpViewShell )
1024cdf0e10cSrcweir 			{
1025cdf0e10cSrcweir 				mpViewShell->SetActiveWindow( mpShowWindow );
1026cdf0e10cSrcweir 				mpShowWindow->SetViewShell (mpViewShell);
1027cdf0e10cSrcweir 				mpViewShell->GetViewShellBase().ShowUIControls (false);
1028cdf0e10cSrcweir 				// Hide the side panes for in-place presentations.
1029cdf0e10cSrcweir 				if ( ! maPresSettings.mbFullScreen)
1030cdf0e10cSrcweir 					mpPaneHider.reset(new PaneHider(*mpViewShell,this));
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir 				if( getViewFrame() )
1033cdf0e10cSrcweir 					getViewFrame()->SetChildWindow( SID_NAVIGATOR, maPresSettings.mbStartWithNavigator );
1034cdf0e10cSrcweir 			}
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir 			// these Slots are forbiden in other views for this document
1037cdf0e10cSrcweir 			if( mpDocSh )
1038cdf0e10cSrcweir 			{
1039cdf0e10cSrcweir 				mpDocSh->SetSlotFilter( sal_True, sizeof( pAllowed ) / sizeof( sal_uInt16 ), pAllowed );
1040cdf0e10cSrcweir 				mpDocSh->ApplySlotFilter();
1041cdf0e10cSrcweir 			}
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 			Help::DisableContextHelp();
1044cdf0e10cSrcweir 			Help::DisableExtHelp();
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir 		//	mpTimeButton = new PushButton( mpShowWindow, SdResId( RID_TIME_BUTTON ) );
1047cdf0e10cSrcweir 		//	maPencil = Pointer( POINTER_PEN );
1048cdf0e10cSrcweir 		//	mpTimeButton->Hide();
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir 			if( maPresSettings.mbFullScreen )
1051cdf0e10cSrcweir 			{
1052cdf0e10cSrcweir 				// disable basic ide error handling
1053cdf0e10cSrcweir 				maStarBASICGlobalErrorHdl = StarBASIC::GetGlobalErrorHdl();
1054cdf0e10cSrcweir 				StarBASIC::SetGlobalErrorHdl( Link() );
1055cdf0e10cSrcweir 			}
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 			// call resize handler
1058cdf0e10cSrcweir 			maPresSize = mpParentWindow->GetSizePixel();
1059cdf0e10cSrcweir 			if( !maPresSettings.mbFullScreen && mpViewShell )
1060cdf0e10cSrcweir 			{
1061cdf0e10cSrcweir 				const Rectangle& aClientRect = mpViewShell->GetViewShellBase().getClientRectangle();
1062cdf0e10cSrcweir 				maPresSize = aClientRect.GetSize();
1063cdf0e10cSrcweir 				mpShowWindow->SetPosPixel( aClientRect.TopLeft() );
1064cdf0e10cSrcweir 				resize( maPresSize );
1065cdf0e10cSrcweir 			}
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir 			// #i41824#
1068cdf0e10cSrcweir 			// Note: In FullScreen Mode the OS (window manager) sends a resize to
1069cdf0e10cSrcweir 			// the WorkWindow once it actually resized it to full size.  The
1070cdf0e10cSrcweir 			// WorkWindow propagates the resize to the DrawViewShell which calls
1071cdf0e10cSrcweir 			// resize() at the SlideShow (this).  Calling resize here results in a
1072cdf0e10cSrcweir 			// temporary display of a black window in the window's default size
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir /*
1075cdf0e10cSrcweir 			if ( mbRehearseTimings )
1076cdf0e10cSrcweir 			{
1077cdf0e10cSrcweir 				Size  aButtonSizePixel( pTimeButton->GetSizePixel() );
1078cdf0e10cSrcweir 				Point aButtonPosPixel( aButtonSizePixel.Width() >> 1, pShowWindow->GetSizePixel().Height() - aButtonSizePixel.Height() * 5 / 2);
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir 				pTimeButton->SetPosPixel( aButtonPosPixel );
1081cdf0e10cSrcweir 				aTimer.SetTimeoutHdl( LINK( this,FuSlideShow, TimeButtonTimeOutHdl ) );
1082cdf0e10cSrcweir 				pTimeButton->SetClickHdl( LINK( this, FuSlideShow, TimeButtonHdl ) );
1083cdf0e10cSrcweir 			}
1084cdf0e10cSrcweir */
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir 			if( mpView )
1087cdf0e10cSrcweir 			{
1088cdf0e10cSrcweir 				mpView->AddWindowToPaintView( mpShowWindow );
1089cdf0e10cSrcweir 				mpView->SetAnimationPause( sal_True );
1090cdf0e10cSrcweir 			}
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir 			SfxBindings* pBindings = getBindings();
1093cdf0e10cSrcweir 			if( pBindings )
1094cdf0e10cSrcweir 			{
1095cdf0e10cSrcweir 				pBindings->Invalidate( SID_PRESENTATION );
1096cdf0e10cSrcweir 				pBindings->Invalidate( SID_REHEARSE_TIMINGS );
1097cdf0e10cSrcweir 			}
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir 			mpShowWindow->GrabFocus();
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 			std::vector<beans::PropertyValue> aProperties;
1102cdf0e10cSrcweir 			aProperties.reserve( 4 );
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir 			aProperties.push_back(
1105cdf0e10cSrcweir 				beans::PropertyValue(
1106cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("AdvanceOnClick") ),
1107cdf0e10cSrcweir 					-1, Any( ! (maPresSettings.mbLockedPages != sal_False) ),
1108cdf0e10cSrcweir 					beans::PropertyState_DIRECT_VALUE ) );
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir 			aProperties.push_back(
1111cdf0e10cSrcweir 				beans::PropertyValue(
1112cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("ImageAnimationsAllowed") ),
1113cdf0e10cSrcweir 					-1, Any( maPresSettings.mbAnimationAllowed != sal_False ),
1114cdf0e10cSrcweir 					beans::PropertyState_DIRECT_VALUE ) );
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir 			const sal_Bool bZOrderEnabled(
1117cdf0e10cSrcweir 				SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsSlideshowRespectZOrder() );
1118cdf0e10cSrcweir 			aProperties.push_back(
1119cdf0e10cSrcweir 				beans::PropertyValue(
1120cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("DisableAnimationZOrder") ),
1121cdf0e10cSrcweir 					-1, Any( bZOrderEnabled == sal_False ),
1122cdf0e10cSrcweir 					beans::PropertyState_DIRECT_VALUE ) );
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir /*
1125cdf0e10cSrcweir 			aProperties.push_back(
1126cdf0e10cSrcweir 				beans::PropertyValue(
1127cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("MouseVisible") ),
1128cdf0e10cSrcweir 					-1, Any( maPresSettings.mbMouseVisible != sal_False ),
1129cdf0e10cSrcweir 					beans::PropertyState_DIRECT_VALUE ) );
1130cdf0e10cSrcweir */
1131cdf0e10cSrcweir 			aProperties.push_back(
1132cdf0e10cSrcweir 				beans::PropertyValue(
1133cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("ForceManualAdvance") ),
1134cdf0e10cSrcweir 					-1, Any( maPresSettings.mbManual != sal_False ),
1135cdf0e10cSrcweir 					beans::PropertyState_DIRECT_VALUE ) );
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir 			if( mbUsePen )
1138cdf0e10cSrcweir  			{
1139cdf0e10cSrcweir 				aProperties.push_back(
1140cdf0e10cSrcweir 					beans::PropertyValue(
1141cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM("UserPaintColor") ),
1142cdf0e10cSrcweir 						// User paint color is black by default.
1143cdf0e10cSrcweir 						-1, Any( mnUserPaintColor ),
1144cdf0e10cSrcweir 						beans::PropertyState_DIRECT_VALUE ) );
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir 				aProperties.push_back(
1147cdf0e10cSrcweir 					beans::PropertyValue(
1148cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM("UserPaintStrokeWidth") ),
1149cdf0e10cSrcweir 						// User paint color is black by default.
1150cdf0e10cSrcweir 						-1, Any( mdUserPaintStrokeWidth ),
1151cdf0e10cSrcweir 						beans::PropertyState_DIRECT_VALUE ) );
1152cdf0e10cSrcweir 			}
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir 			if (mbRehearseTimings) {
1155cdf0e10cSrcweir 				aProperties.push_back(
1156cdf0e10cSrcweir 					beans::PropertyValue(
1157cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM("RehearseTimings") ),
1158cdf0e10cSrcweir 						-1, Any(true), beans::PropertyState_DIRECT_VALUE ) );
1159cdf0e10cSrcweir 			}
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir 			bRet = startShowImpl( Sequence<beans::PropertyValue>(
1162cdf0e10cSrcweir 									  &aProperties[0], aProperties.size() ) );
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 		}
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir         setActiveXToolbarsVisible( sal_False );
1167cdf0e10cSrcweir 	}
1168cdf0e10cSrcweir 	catch( Exception& e )
1169cdf0e10cSrcweir 	{
1170cdf0e10cSrcweir 		(void)e;
1171cdf0e10cSrcweir 		DBG_ERROR(
1172cdf0e10cSrcweir             (OString("sd::SlideshowImpl::startShow(), "
1173cdf0e10cSrcweir                      "exception caught: ") +
1174cdf0e10cSrcweir              rtl::OUStringToOString(
1175cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
1176cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
1177cdf0e10cSrcweir         bRet = false;
1178cdf0e10cSrcweir 	}
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir     return bRet;
1181cdf0e10cSrcweir }
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir bool SlideshowImpl::startShowImpl( const Sequence< beans::PropertyValue >& aProperties )
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir 	try
1186cdf0e10cSrcweir 	{
1187cdf0e10cSrcweir 		mxShow = Reference< XSlideShow >( createSlideShow(), UNO_QUERY_THROW );
1188cdf0e10cSrcweir 		mxView = mxView.createFromQuery( new SlideShowView(
1189cdf0e10cSrcweir                                              *mpShowWindow,
1190cdf0e10cSrcweir                                              mpDoc,
1191cdf0e10cSrcweir                                              meAnimationMode,
1192cdf0e10cSrcweir                                              this,
1193cdf0e10cSrcweir                                              maPresSettings.mbFullScreen) );
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir         // try add wait symbol to properties:
1196cdf0e10cSrcweir         const Reference<rendering::XSpriteCanvas> xSpriteCanvas(
1197cdf0e10cSrcweir             mxView->getCanvas() );
1198cdf0e10cSrcweir         if (xSpriteCanvas.is())
1199cdf0e10cSrcweir 		{
1200cdf0e10cSrcweir             BitmapEx waitSymbolBitmap( SdResId(BMP_WAIT_ICON) );
1201cdf0e10cSrcweir             const Reference<rendering::XBitmap> xBitmap(
1202cdf0e10cSrcweir                 vcl::unotools::xBitmapFromBitmapEx(
1203cdf0e10cSrcweir                     xSpriteCanvas->getDevice(), waitSymbolBitmap ) );
1204cdf0e10cSrcweir             if (xBitmap.is())
1205cdf0e10cSrcweir 			{
1206cdf0e10cSrcweir 				mxShow->setProperty(
1207cdf0e10cSrcweir 					beans::PropertyValue(
1208cdf0e10cSrcweir 						OUString( RTL_CONSTASCII_USTRINGPARAM("WaitSymbolBitmap") ),
1209cdf0e10cSrcweir 						-1,
1210cdf0e10cSrcweir 						makeAny( xBitmap ),
1211cdf0e10cSrcweir 						beans::PropertyState_DIRECT_VALUE ) );
1212cdf0e10cSrcweir 			}
1213cdf0e10cSrcweir 		}
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir 		const sal_Int32 nCount = aProperties.getLength();
1216cdf0e10cSrcweir 		sal_Int32 nIndex;
1217cdf0e10cSrcweir 		for( nIndex = 0; nIndex < nCount; nIndex++ )
1218cdf0e10cSrcweir 			mxShow->setProperty( aProperties[nIndex] );
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir 		mxShow->addView( mxView.getRef() );
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir 		mxListenerProxy.set( new SlideShowListenerProxy( this, mxShow ) );
1223cdf0e10cSrcweir 		mxListenerProxy->addAsSlideShowListener();
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir 		NotifyDocumentEvent( mpDoc, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnStartPresentation") ) );
1227cdf0e10cSrcweir 		displaySlideIndex( mpSlideController->getStartSlideIndex() );
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir         return true;
1230cdf0e10cSrcweir 	}
1231cdf0e10cSrcweir 	catch( Exception& e )
1232cdf0e10cSrcweir 	{
1233cdf0e10cSrcweir 		(void)e;
1234cdf0e10cSrcweir 		DBG_ERROR(
1235cdf0e10cSrcweir             (OString("sd::SlideshowImpl::startShowImpl(), "
1236cdf0e10cSrcweir                      "exception caught: ") +
1237cdf0e10cSrcweir              rtl::OUStringToOString(
1238cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
1239cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
1240cdf0e10cSrcweir         return false;
1241cdf0e10cSrcweir 	}
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir /** called only by the slideshow view when the first paint event occurs.
1245cdf0e10cSrcweir 	This actually starts the slideshow. */
1246cdf0e10cSrcweir void SlideshowImpl::onFirstPaint()
1247cdf0e10cSrcweir {
1248cdf0e10cSrcweir 	if( mpShowWindow )
1249cdf0e10cSrcweir 	{
1250cdf0e10cSrcweir         /*
1251cdf0e10cSrcweir 		mpShowWindow->SetBackground( Wallpaper( Color( COL_BLACK ) ) );
1252cdf0e10cSrcweir 		mpShowWindow->Erase();
1253cdf0e10cSrcweir 		mpShowWindow->SetBackground();
1254cdf0e10cSrcweir         */
1255cdf0e10cSrcweir 	}
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1258cdf0e10cSrcweir 	maUpdateTimer.SetTimeout( (sal_uLong)100 );
1259cdf0e10cSrcweir 	maUpdateTimer.Start();
1260cdf0e10cSrcweir }
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir void SlideshowImpl::paint( const Rectangle& /* rRect */ )
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir 	if( mxView.is() ) try
1265cdf0e10cSrcweir 	{
1266cdf0e10cSrcweir 		awt::PaintEvent aEvt;
1267cdf0e10cSrcweir 		// aEvt.UpdateRect = TODO
1268cdf0e10cSrcweir 		mxView->paint( aEvt );
1269cdf0e10cSrcweir 	}
1270cdf0e10cSrcweir 	catch( Exception& e )
1271cdf0e10cSrcweir 	{
1272cdf0e10cSrcweir 		static_cast<void>(e);
1273cdf0e10cSrcweir 		DBG_ERROR(
1274cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::paint(), "
1275cdf0e10cSrcweir 					"exception caught: ") +
1276cdf0e10cSrcweir 			rtl::OUStringToOString(
1277cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
1278cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
1279cdf0e10cSrcweir 	}
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir // --------------------------------------------------------------------
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir void SAL_CALL SlideshowImpl::addSlideShowListener( const Reference< XSlideShowListener >& xListener ) throw (RuntimeException)
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir 	if( mxListenerProxy.is() )
1287cdf0e10cSrcweir 		mxListenerProxy->addSlideShowListener( xListener );
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir // --------------------------------------------------------------------
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir void SAL_CALL SlideshowImpl::removeSlideShowListener( const Reference< XSlideShowListener >& xListener ) throw (RuntimeException)
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir 	if( mxListenerProxy.is() )
1295cdf0e10cSrcweir 		mxListenerProxy->removeSlideShowListener( xListener );
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir // ---------------------------------------------------------
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir void SlideshowImpl::slideEnded(const bool bReverse)
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir     if (bReverse)
1303cdf0e10cSrcweir         gotoPreviousSlide(true);
1304cdf0e10cSrcweir     else
1305cdf0e10cSrcweir         gotoNextSlide();
1306cdf0e10cSrcweir }
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir // ---------------------------------------------------------
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir void SlideshowImpl::removeShapeEvents()
1311cdf0e10cSrcweir {
1312cdf0e10cSrcweir 	if( mxShow.is() && mxListenerProxy.is() ) try
1313cdf0e10cSrcweir 	{
1314cdf0e10cSrcweir 		WrappedShapeEventImplMap::iterator aIter;
1315cdf0e10cSrcweir 		const WrappedShapeEventImplMap::iterator aEnd( maShapeEventMap.end() );
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir 		for( aIter = maShapeEventMap.begin(); aIter != aEnd; aIter++ )
1318cdf0e10cSrcweir 		{
1319cdf0e10cSrcweir 			mxListenerProxy->removeShapeEventListener( (*aIter).first );
1320cdf0e10cSrcweir 			mxShow->setShapeCursor( (*aIter).first, awt::SystemPointer::ARROW );
1321cdf0e10cSrcweir 		}
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir 		maShapeEventMap.clear();
1324cdf0e10cSrcweir 	}
1325cdf0e10cSrcweir 	catch( Exception& e )
1326cdf0e10cSrcweir 	{
1327cdf0e10cSrcweir 		(void)e;
1328cdf0e10cSrcweir 		DBG_ERROR(
1329cdf0e10cSrcweir             (OString("sd::SlideshowImpl::removeShapeEvents(), "
1330cdf0e10cSrcweir                      "exception caught: ") +
1331cdf0e10cSrcweir              rtl::OUStringToOString(
1332cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
1333cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
1334cdf0e10cSrcweir 	}
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir // ---------------------------------------------------------
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir void SlideshowImpl::registerShapeEvents(sal_Int32 nSlideNumber)
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir 	if( nSlideNumber >= 0 ) try
1342cdf0e10cSrcweir 	{
1343cdf0e10cSrcweir 		Reference< XDrawPagesSupplier > xDrawPages( mxModel, UNO_QUERY_THROW );
1344cdf0e10cSrcweir 		Reference< XIndexAccess > xPages( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 		Reference< XShapes > xDrawPage;
1347cdf0e10cSrcweir 		xPages->getByIndex(nSlideNumber) >>= xDrawPage;
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 		if( xDrawPage.is() )
1350cdf0e10cSrcweir 		{
1351cdf0e10cSrcweir 			Reference< XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY );
1352cdf0e10cSrcweir 			if( xMasterPageTarget.is() )
1353cdf0e10cSrcweir 			{
1354cdf0e10cSrcweir 				Reference< XShapes > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY );
1355cdf0e10cSrcweir 				if( xMasterPage.is() )
1356cdf0e10cSrcweir 					registerShapeEvents( xMasterPage );
1357cdf0e10cSrcweir 			}
1358cdf0e10cSrcweir 			registerShapeEvents( xDrawPage );
1359cdf0e10cSrcweir 		}
1360cdf0e10cSrcweir 	}
1361cdf0e10cSrcweir 	catch( Exception& e )
1362cdf0e10cSrcweir 	{
1363cdf0e10cSrcweir 		(void)e;
1364cdf0e10cSrcweir 		DBG_ERROR(
1365cdf0e10cSrcweir             (OString("sd::SlideshowImpl::registerShapeEvents(), "
1366cdf0e10cSrcweir                      "exception caught: ") +
1367cdf0e10cSrcweir              rtl::OUStringToOString(
1368cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
1369cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
1370cdf0e10cSrcweir 	}
1371cdf0e10cSrcweir }
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir // ---------------------------------------------------------
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir void SlideshowImpl::registerShapeEvents( Reference< XShapes >& xShapes ) throw( Exception )
1376cdf0e10cSrcweir {
1377cdf0e10cSrcweir 	try
1378cdf0e10cSrcweir 	{
1379cdf0e10cSrcweir 		const sal_Int32 nShapeCount = xShapes->getCount();
1380cdf0e10cSrcweir 		sal_Int32 nShape;
1381cdf0e10cSrcweir 		for( nShape = 0; nShape < nShapeCount; nShape++ )
1382cdf0e10cSrcweir 		{
1383cdf0e10cSrcweir 			Reference< XShape > xShape;
1384cdf0e10cSrcweir 			xShapes->getByIndex( nShape ) >>= xShape;
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir 			if( xShape.is() &&
1387cdf0e10cSrcweir 				xShape->getShapeType().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape") ) )
1388cdf0e10cSrcweir 			{
1389cdf0e10cSrcweir 				Reference< XShapes > xSubShapes( xShape, UNO_QUERY );
1390cdf0e10cSrcweir 				if( xSubShapes.is() )
1391cdf0e10cSrcweir 					registerShapeEvents( xSubShapes );
1392cdf0e10cSrcweir 			}
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir 			Reference< XPropertySet > xSet( xShape, UNO_QUERY );
1395cdf0e10cSrcweir 			if( !xSet.is() )
1396cdf0e10cSrcweir 				continue;
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir 			Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1399cdf0e10cSrcweir 			if( !xSetInfo.is() || !xSetInfo->hasPropertyByName( msOnClick ) )
1400cdf0e10cSrcweir 				continue;
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir 			WrappedShapeEventImplPtr pEvent( new WrappedShapeEventImpl );
1403cdf0e10cSrcweir 			xSet->getPropertyValue( msOnClick ) >>= pEvent->meClickAction;
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir 			switch( pEvent->meClickAction )
1406cdf0e10cSrcweir 			{
1407cdf0e10cSrcweir 			case ClickAction_PREVPAGE:
1408cdf0e10cSrcweir 			case ClickAction_NEXTPAGE:
1409cdf0e10cSrcweir 			case ClickAction_FIRSTPAGE:
1410cdf0e10cSrcweir 			case ClickAction_LASTPAGE:
1411cdf0e10cSrcweir 			case ClickAction_STOPPRESENTATION:
1412cdf0e10cSrcweir 				break;
1413cdf0e10cSrcweir 			case ClickAction_BOOKMARK:
1414cdf0e10cSrcweir 				if( xSetInfo->hasPropertyByName( msBookmark ) )
1415cdf0e10cSrcweir 					xSet->getPropertyValue( msBookmark ) >>= pEvent->maStrBookmark;
1416cdf0e10cSrcweir 				if( getSlideNumberForBookmark( pEvent->maStrBookmark ) == -1 )
1417cdf0e10cSrcweir 					continue;
1418cdf0e10cSrcweir 				break;
1419cdf0e10cSrcweir 			case ClickAction_DOCUMENT:
1420cdf0e10cSrcweir 			case ClickAction_SOUND:
1421cdf0e10cSrcweir 			case ClickAction_PROGRAM:
1422cdf0e10cSrcweir 			case ClickAction_MACRO:
1423cdf0e10cSrcweir 				if( xSetInfo->hasPropertyByName( msBookmark ) )
1424cdf0e10cSrcweir 					xSet->getPropertyValue( msBookmark ) >>= pEvent->maStrBookmark;
1425cdf0e10cSrcweir 				break;
1426cdf0e10cSrcweir 			case ClickAction_VERB:
1427cdf0e10cSrcweir 				if( xSetInfo->hasPropertyByName( msVerb ) )
1428cdf0e10cSrcweir 					xSet->getPropertyValue( msVerb ) >>= pEvent->mnVerb;
1429cdf0e10cSrcweir 				break;
1430cdf0e10cSrcweir 			default:
1431cdf0e10cSrcweir 				continue; // skip all others
1432cdf0e10cSrcweir 			}
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir 			maShapeEventMap[ xShape ] = pEvent;
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir 			if( mxListenerProxy.is() )
1437cdf0e10cSrcweir 				mxListenerProxy->addShapeEventListener( xShape );
1438cdf0e10cSrcweir 			mxShow->setShapeCursor( xShape, awt::SystemPointer::REFHAND );
1439cdf0e10cSrcweir 		}
1440cdf0e10cSrcweir 	}
1441cdf0e10cSrcweir 	catch( Exception& e )
1442cdf0e10cSrcweir 	{
1443cdf0e10cSrcweir 		static_cast<void>(e);
1444cdf0e10cSrcweir 		DBG_ERROR(
1445cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::registerShapeEvents(), "
1446cdf0e10cSrcweir 					"exception caught: ") +
1447cdf0e10cSrcweir 			rtl::OUStringToOString(
1448cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
1449cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
1450cdf0e10cSrcweir 	}
1451cdf0e10cSrcweir }
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir // ---------------------------------------------------------
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir void SlideshowImpl::displayCurrentSlide (const bool bSkipAllMainSequenceEffects)
1456cdf0e10cSrcweir {
1457cdf0e10cSrcweir 	stopSound();
1458cdf0e10cSrcweir 	removeShapeEvents();
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir 	if( mpSlideController.get() && mxShow.is() )
1461cdf0e10cSrcweir 	{
1462cdf0e10cSrcweir 		Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(),
1463cdf0e10cSrcweir                                                     UNO_QUERY_THROW );
1464cdf0e10cSrcweir 		mpSlideController->displayCurrentSlide( mxShow, xDrawPages, bSkipAllMainSequenceEffects );
1465cdf0e10cSrcweir 		registerShapeEvents(mpSlideController->getCurrentSlideNumber());
1466cdf0e10cSrcweir 		update();
1467cdf0e10cSrcweir 
1468cdf0e10cSrcweir 		SfxBindings* pBindings = getBindings();
1469cdf0e10cSrcweir 		if( pBindings )
1470cdf0e10cSrcweir 		{
1471cdf0e10cSrcweir 			pBindings->Invalidate( SID_NAVIGATOR_STATE );
1472cdf0e10cSrcweir 			pBindings->Invalidate( SID_NAVIGATOR_PAGENAME );
1473cdf0e10cSrcweir 		}
1474cdf0e10cSrcweir 	}
1475cdf0e10cSrcweir }
1476cdf0e10cSrcweir 
1477cdf0e10cSrcweir // ---------------------------------------------------------
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir void SlideshowImpl::endPresentation()
1480cdf0e10cSrcweir {
1481cdf0e10cSrcweir /*
1482cdf0e10cSrcweir     if( maPresSettings.mbMouseAsPen)
1483cdf0e10cSrcweir     {
1484cdf0e10cSrcweir         Reference< XMultiServiceFactory > xDocFactory(mpDoc->getUnoModel(), UNO_QUERY );
1485cdf0e10cSrcweir         if( xDocFactory.is() )
1486cdf0e10cSrcweir             mxShow->registerUserPaintPolygons(xDocFactory);
1487cdf0e10cSrcweir     }
1488cdf0e10cSrcweir */
1489cdf0e10cSrcweir 	if( !mnEndShowEvent )
1490cdf0e10cSrcweir 		mnEndShowEvent = Application::PostUserEvent( LINK(this, SlideshowImpl, endPresentationHdl) );
1491cdf0e10cSrcweir }
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir // ---------------------------------------------------------
1494cdf0e10cSrcweir 
1495cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, endPresentationHdl, void*, EMPTYARG )
1496cdf0e10cSrcweir {
1497cdf0e10cSrcweir 	mnEndShowEvent = 0;
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir 	if( mxPresentation.is() )
1500cdf0e10cSrcweir 		mxPresentation->end();
1501cdf0e10cSrcweir 	return 0;
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir // ---------------------------------------------------------
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir void SAL_CALL SlideshowImpl::pause() throw (RuntimeException)
1507cdf0e10cSrcweir {
1508cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1509cdf0e10cSrcweir 
1510cdf0e10cSrcweir 	if( !mbIsPaused ) try
1511cdf0e10cSrcweir 	{
1512cdf0e10cSrcweir         mbIsPaused = sal_True;
1513cdf0e10cSrcweir 		if( mxShow.is() )
1514cdf0e10cSrcweir 		{
1515cdf0e10cSrcweir 			mxShow->pause(sal_True);
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir 			if( mxListenerProxy.is() )
1518cdf0e10cSrcweir 				mxListenerProxy->paused();
1519cdf0e10cSrcweir 		}
1520cdf0e10cSrcweir 	}
1521cdf0e10cSrcweir 	catch( Exception& e )
1522cdf0e10cSrcweir 	{
1523cdf0e10cSrcweir 		static_cast<void>(e);
1524cdf0e10cSrcweir 		DBG_ERROR(
1525cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::pause(), "
1526cdf0e10cSrcweir 					"exception caught: ") +
1527cdf0e10cSrcweir 			rtl::OUStringToOString(
1528cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
1529cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
1530cdf0e10cSrcweir 	}
1531cdf0e10cSrcweir }
1532cdf0e10cSrcweir 
1533cdf0e10cSrcweir // ---------------------------------------------------------
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir void SAL_CALL SlideshowImpl::resume() throw (RuntimeException)
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir 	if( mbIsPaused ) try
1540cdf0e10cSrcweir 	{
1541cdf0e10cSrcweir         if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
1542cdf0e10cSrcweir 		{
1543cdf0e10cSrcweir 			mpShowWindow->RestartShow();
1544cdf0e10cSrcweir         }
1545cdf0e10cSrcweir         else
1546cdf0e10cSrcweir         {
1547cdf0e10cSrcweir             mbIsPaused = sal_False;;
1548cdf0e10cSrcweir 		    if( mxShow.is() )
1549cdf0e10cSrcweir 		    {
1550cdf0e10cSrcweir 			    mxShow->pause(sal_False);
1551cdf0e10cSrcweir 			    update();
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir 			    if( mxListenerProxy.is() )
1554cdf0e10cSrcweir 				    mxListenerProxy->resumed();
1555cdf0e10cSrcweir 		    }
1556cdf0e10cSrcweir         }
1557cdf0e10cSrcweir 	}
1558cdf0e10cSrcweir 	catch( Exception& e )
1559cdf0e10cSrcweir 	{
1560cdf0e10cSrcweir 		static_cast<void>(e);
1561cdf0e10cSrcweir 		DBG_ERROR(
1562cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::resume(), "
1563cdf0e10cSrcweir 					"exception caught: ") +
1564cdf0e10cSrcweir 			rtl::OUStringToOString(
1565cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
1566cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
1567cdf0e10cSrcweir 	}
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir // ---------------------------------------------------------
1571cdf0e10cSrcweir 
1572cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isPaused() throw (RuntimeException)
1573cdf0e10cSrcweir {
1574cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1575cdf0e10cSrcweir 	return mbIsPaused;
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir // ---------------------------------------------------------
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir void SAL_CALL SlideshowImpl::blankScreen( sal_Int32 nColor ) throw (RuntimeException)
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir 	if( mpShowWindow && mpSlideController )
1585cdf0e10cSrcweir 	{
1586cdf0e10cSrcweir 		if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), nColor ) )
1587cdf0e10cSrcweir 		{
1588cdf0e10cSrcweir 			pause();
1589cdf0e10cSrcweir 		}
1590cdf0e10cSrcweir 	}
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir // ---------------------------------------------------------
1594cdf0e10cSrcweir // XShapeEventListener
1595cdf0e10cSrcweir // ---------------------------------------------------------
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir void SlideshowImpl::click( const Reference< XShape >& xShape, const ::com::sun::star::awt::MouseEvent& /* aOriginalEvent */ )
1598cdf0e10cSrcweir {
1599cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir 	WrappedShapeEventImplPtr pEvent = maShapeEventMap[xShape];
1602cdf0e10cSrcweir 	if( !pEvent.get() )
1603cdf0e10cSrcweir 		return;
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir 	switch( pEvent->meClickAction )
1606cdf0e10cSrcweir 	{
1607cdf0e10cSrcweir 	case ClickAction_PREVPAGE:			gotoPreviousSlide(); 		break;
1608cdf0e10cSrcweir 	case ClickAction_NEXTPAGE:			gotoNextSlide();			break;
1609cdf0e10cSrcweir 	case ClickAction_FIRSTPAGE:			gotoFirstSlide();			break;
1610cdf0e10cSrcweir 	case ClickAction_LASTPAGE:			gotoLastSlide();			break;
1611cdf0e10cSrcweir 	case ClickAction_STOPPRESENTATION:	endPresentation();			break;
1612cdf0e10cSrcweir 	case ClickAction_BOOKMARK:
1613cdf0e10cSrcweir 	{
1614cdf0e10cSrcweir 		gotoBookmark( pEvent->maStrBookmark );
1615cdf0e10cSrcweir 	}
1616cdf0e10cSrcweir 	break;
1617cdf0e10cSrcweir 	case ClickAction_SOUND:
1618cdf0e10cSrcweir 	{
1619cdf0e10cSrcweir 		try
1620cdf0e10cSrcweir 		{
1621cdf0e10cSrcweir 			mxPlayer.set(avmedia::MediaWindow::createPlayer(pEvent->maStrBookmark), uno::UNO_QUERY_THROW );
1622cdf0e10cSrcweir 			mxPlayer->start();
1623cdf0e10cSrcweir 		}
1624cdf0e10cSrcweir 		catch( uno::Exception& e )
1625cdf0e10cSrcweir 		{
1626cdf0e10cSrcweir 			(void)e;
1627cdf0e10cSrcweir 			DBG_ERROR("sd::SlideshowImpl::click(), exception caught!" );
1628cdf0e10cSrcweir 		}
1629cdf0e10cSrcweir 	}
1630cdf0e10cSrcweir 	break;
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir 	case ClickAction_DOCUMENT:
1633cdf0e10cSrcweir     {
1634cdf0e10cSrcweir 		OUString aBookmark( pEvent->maStrBookmark );
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir 		sal_Int32 nPos = aBookmark.indexOf( sal_Unicode('#') );
1637cdf0e10cSrcweir 		if( nPos >= 0 )
1638cdf0e10cSrcweir 		{
1639cdf0e10cSrcweir 			OUString aURL( aBookmark.copy( 0, nPos+1 ) );
1640cdf0e10cSrcweir 			OUString aName( aBookmark.copy( nPos+1 ) );
1641cdf0e10cSrcweir 			aURL += getUiNameFromPageApiNameImpl( aName );
1642cdf0e10cSrcweir 			aBookmark = aURL;
1643cdf0e10cSrcweir 		}
1644cdf0e10cSrcweir 
1645cdf0e10cSrcweir 		mpDocSh->OpenBookmark( aBookmark );
1646cdf0e10cSrcweir     }
1647cdf0e10cSrcweir     break;
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir 	case ClickAction_PROGRAM:
1650cdf0e10cSrcweir 	{
1651cdf0e10cSrcweir 		INetURLObject aURL(
1652cdf0e10cSrcweir             ::URIHelper::SmartRel2Abs(
1653cdf0e10cSrcweir                 INetURLObject(mpDocSh->GetMedium()->GetBaseURL()),
1654cdf0e10cSrcweir                 pEvent->maStrBookmark, ::URIHelper::GetMaybeFileHdl(), true,
1655cdf0e10cSrcweir                 false, INetURLObject::WAS_ENCODED,
1656cdf0e10cSrcweir                 INetURLObject::DECODE_UNAMBIGUOUS ) );
1657cdf0e10cSrcweir 
1658cdf0e10cSrcweir 		if( INET_PROT_FILE == aURL.GetProtocol() )
1659cdf0e10cSrcweir 		{
1660cdf0e10cSrcweir 			SfxStringItem aUrl( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
1661cdf0e10cSrcweir 			SfxBoolItem aBrowsing( SID_BROWSE, sal_True );
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir 			SfxViewFrame* pViewFrm = SfxViewFrame::Current();
1664cdf0e10cSrcweir 			if (pViewFrm)
1665cdf0e10cSrcweir 				pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
1666cdf0e10cSrcweir   											SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
1667cdf0e10cSrcweir 											&aUrl,
1668cdf0e10cSrcweir 											&aBrowsing,
1669cdf0e10cSrcweir 											0L );
1670cdf0e10cSrcweir 		}
1671cdf0e10cSrcweir 	}
1672cdf0e10cSrcweir 	break;
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir 	case presentation::ClickAction_MACRO:
1675cdf0e10cSrcweir 	{
1676cdf0e10cSrcweir 		const String aMacro( pEvent->maStrBookmark );
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir 		if ( SfxApplication::IsXScriptURL( aMacro ) )
1679cdf0e10cSrcweir 		{
1680cdf0e10cSrcweir 			Any aRet;
1681cdf0e10cSrcweir 			Sequence< sal_Int16 > aOutArgsIndex;
1682cdf0e10cSrcweir 			Sequence< Any > aOutArgs;
1683cdf0e10cSrcweir 			Sequence< Any >* pInArgs = new Sequence< Any >(0);
1684cdf0e10cSrcweir 			mpDocSh->CallXScript( aMacro, *pInArgs, aRet, aOutArgsIndex, aOutArgs);
1685cdf0e10cSrcweir 		}
1686cdf0e10cSrcweir 		else
1687cdf0e10cSrcweir 		{
1688cdf0e10cSrcweir 			// aMacro has the following syntax:
1689cdf0e10cSrcweir 			// "Macroname.Modulname.Libname.Dokumentname" or
1690cdf0e10cSrcweir 			// "Macroname.Modulname.Libname.Applikationsname"
1691cdf0e10cSrcweir 			String aMacroName = aMacro.GetToken(0, sal_Unicode('.'));
1692cdf0e10cSrcweir 			String aModulName = aMacro.GetToken(1, sal_Unicode('.'));
1693cdf0e10cSrcweir 			String aLibName   = aMacro.GetToken(2, sal_Unicode('.'));
1694cdf0e10cSrcweir 			String aDocName   = aMacro.GetToken(3, sal_Unicode('.'));
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir 			// todo: is the limitation still given that only
1697cdf0e10cSrcweir 			// Modulname+Macroname can be used here?
1698cdf0e10cSrcweir 			String aExecMacro(aModulName);
1699cdf0e10cSrcweir 			aExecMacro.Append( sal_Unicode('.') );
1700cdf0e10cSrcweir 			aExecMacro.Append( aMacroName );
1701cdf0e10cSrcweir 			mpDocSh->GetBasic()->Call(aExecMacro);
1702cdf0e10cSrcweir 		}
1703cdf0e10cSrcweir 	}
1704cdf0e10cSrcweir 	break;
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir 	case ClickAction_VERB:
1707cdf0e10cSrcweir 	{
1708cdf0e10cSrcweir 		// todo, better do it async?
1709cdf0e10cSrcweir 		SdrObject* pObj = GetSdrObjectFromXShape( xShape );
1710cdf0e10cSrcweir 		SdrOle2Obj* pOleObject = PTR_CAST(SdrOle2Obj, pObj);
1711cdf0e10cSrcweir 		if (pOleObject && mpViewShell )
1712cdf0e10cSrcweir 			mpViewShell->ActivateObject(pOleObject, pEvent->mnVerb);
1713cdf0e10cSrcweir 	}
1714cdf0e10cSrcweir 	break;
1715cdf0e10cSrcweir 	default:
1716cdf0e10cSrcweir 		break;
1717cdf0e10cSrcweir 	}
1718cdf0e10cSrcweir }
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir // ---------------------------------------------------------
1721cdf0e10cSrcweir 
1722cdf0e10cSrcweir sal_Int32 SlideshowImpl::getSlideNumberForBookmark( const OUString& rStrBookmark )
1723cdf0e10cSrcweir {
1724cdf0e10cSrcweir 	sal_Bool bIsMasterPage;
1725cdf0e10cSrcweir 	OUString aBookmark = getUiNameFromPageApiNameImpl( rStrBookmark );
1726cdf0e10cSrcweir     sal_uInt16 nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir 	if( nPgNum == SDRPAGE_NOTFOUND )
1729cdf0e10cSrcweir 	{
1730cdf0e10cSrcweir 		// Ist das Bookmark ein Objekt?
1731cdf0e10cSrcweir 		SdrObject* pObj = mpDoc->GetObj( aBookmark );
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir 		if( pObj )
1734cdf0e10cSrcweir 		{
1735cdf0e10cSrcweir 			nPgNum = pObj->GetPage()->GetPageNum();
1736cdf0e10cSrcweir 			bIsMasterPage = (sal_Bool)pObj->GetPage()->IsMasterPage();
1737cdf0e10cSrcweir 		}
1738cdf0e10cSrcweir 	}
1739cdf0e10cSrcweir 
1740cdf0e10cSrcweir 	if( (nPgNum == SDRPAGE_NOTFOUND) || bIsMasterPage || static_cast<SdPage*>(mpDoc->GetPage(nPgNum))->GetPageKind() != PK_STANDARD )
1741cdf0e10cSrcweir 		return -1;
1742cdf0e10cSrcweir 
1743cdf0e10cSrcweir 	return ( nPgNum - 1) >> 1;
1744cdf0e10cSrcweir }
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir // ---------------------------------------------------------
1747cdf0e10cSrcweir 
1748cdf0e10cSrcweir void SlideshowImpl::hyperLinkClicked( rtl::OUString const& aHyperLink ) throw (RuntimeException)
1749cdf0e10cSrcweir {
1750cdf0e10cSrcweir 	OUString aBookmark( aHyperLink );
1751cdf0e10cSrcweir 
1752cdf0e10cSrcweir 	sal_Int32 nPos = aBookmark.indexOf( sal_Unicode('#') );
1753cdf0e10cSrcweir 	if( nPos >= 0 )
1754cdf0e10cSrcweir 	{
1755cdf0e10cSrcweir 		OUString aURL( aBookmark.copy( 0, nPos+1 ) );
1756cdf0e10cSrcweir 		OUString aName( aBookmark.copy( nPos+1 ) );
1757cdf0e10cSrcweir 		aURL += getUiNameFromPageApiNameImpl( aName );
1758cdf0e10cSrcweir 		aBookmark = aURL;
1759cdf0e10cSrcweir 	}
1760cdf0e10cSrcweir 
1761cdf0e10cSrcweir 	mpDocSh->OpenBookmark( aBookmark );
1762cdf0e10cSrcweir }
1763cdf0e10cSrcweir 
1764cdf0e10cSrcweir // ---------------------------------------------------------
1765cdf0e10cSrcweir 
1766cdf0e10cSrcweir void SlideshowImpl::displaySlideNumber( sal_Int32 nSlideNumber )
1767cdf0e10cSrcweir {
1768cdf0e10cSrcweir 	if( mpSlideController.get() )
1769cdf0e10cSrcweir 	{
1770cdf0e10cSrcweir 		if( mpSlideController->jumpToSlideNumber( nSlideNumber ) )
1771cdf0e10cSrcweir 		{
1772cdf0e10cSrcweir 			displayCurrentSlide();
1773cdf0e10cSrcweir 		}
1774cdf0e10cSrcweir 	}
1775cdf0e10cSrcweir }
1776cdf0e10cSrcweir 
1777cdf0e10cSrcweir // ---------------------------------------------------------
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir /** nSlideIndex == -1 displays current slide again */
1780cdf0e10cSrcweir void SlideshowImpl::displaySlideIndex( sal_Int32 nSlideIndex )
1781cdf0e10cSrcweir {
1782cdf0e10cSrcweir 	if( mpSlideController.get() )
1783cdf0e10cSrcweir 	{
1784cdf0e10cSrcweir 		if( (nSlideIndex == -1) || mpSlideController->jumpToSlideIndex( nSlideIndex ) )
1785cdf0e10cSrcweir 		{
1786cdf0e10cSrcweir 			displayCurrentSlide();
1787cdf0e10cSrcweir 		}
1788cdf0e10cSrcweir 	}
1789cdf0e10cSrcweir }
1790cdf0e10cSrcweir 
1791cdf0e10cSrcweir // ---------------------------------------------------------
1792cdf0e10cSrcweir 
1793cdf0e10cSrcweir void SlideshowImpl::jumpToBookmark( const String& sBookmark )
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir 	sal_Int32 nSlideNumber = getSlideNumberForBookmark( sBookmark );
1796cdf0e10cSrcweir 	if( nSlideNumber != -1 )
1797cdf0e10cSrcweir 		displaySlideNumber( nSlideNumber );
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir 
1800cdf0e10cSrcweir // ---------------------------------------------------------
1801cdf0e10cSrcweir 
1802cdf0e10cSrcweir sal_Int32 SlideshowImpl::getCurrentSlideNumber()
1803cdf0e10cSrcweir {
1804cdf0e10cSrcweir 	return mpSlideController.get() ? mpSlideController->getCurrentSlideNumber() : -1;
1805cdf0e10cSrcweir }
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir // ---------------------------------------------------------
1808cdf0e10cSrcweir 
1809cdf0e10cSrcweir sal_Int32 SlideshowImpl::getFirstSlideNumber()
1810cdf0e10cSrcweir {
1811cdf0e10cSrcweir 	sal_Int32 nRet = 0;
1812cdf0e10cSrcweir 	if( mpSlideController.get() )
1813cdf0e10cSrcweir 	{
1814cdf0e10cSrcweir 		sal_Int32 nSlideIndexCount = mpSlideController->getSlideIndexCount() - 1;
1815cdf0e10cSrcweir 		if( nSlideIndexCount >= 0 )
1816cdf0e10cSrcweir 		{
1817cdf0e10cSrcweir 			nRet = mpSlideController->getSlideNumber( nSlideIndexCount );
1818cdf0e10cSrcweir 			while( nSlideIndexCount-- )
1819cdf0e10cSrcweir 			{
1820cdf0e10cSrcweir 				sal_Int32 nTemp = mpSlideController->getSlideNumber( nSlideIndexCount );
1821cdf0e10cSrcweir 				if( nRet > nTemp )
1822cdf0e10cSrcweir 					nRet = nTemp;
1823cdf0e10cSrcweir 			}
1824cdf0e10cSrcweir 		}
1825cdf0e10cSrcweir 	}
1826cdf0e10cSrcweir 
1827cdf0e10cSrcweir 	return nRet;
1828cdf0e10cSrcweir }
1829cdf0e10cSrcweir 
1830cdf0e10cSrcweir // ---------------------------------------------------------
1831cdf0e10cSrcweir 
1832cdf0e10cSrcweir sal_Int32 SlideshowImpl::getLastSlideNumber()
1833cdf0e10cSrcweir {
1834cdf0e10cSrcweir 	sal_Int32 nRet = 0;
1835cdf0e10cSrcweir 	if( mpSlideController.get() )
1836cdf0e10cSrcweir 	{
1837cdf0e10cSrcweir 		sal_Int32 nSlideIndexCount = mpSlideController->getSlideIndexCount() - 1;
1838cdf0e10cSrcweir 		if( nSlideIndexCount >= 0 )
1839cdf0e10cSrcweir 		{
1840cdf0e10cSrcweir 			nRet = mpSlideController->getSlideNumber( nSlideIndexCount );
1841cdf0e10cSrcweir 			while( nSlideIndexCount-- )
1842cdf0e10cSrcweir 			{
1843cdf0e10cSrcweir 				sal_Int32 nTemp = mpSlideController->getSlideNumber( nSlideIndexCount );
1844cdf0e10cSrcweir 				if( nRet < nTemp )
1845cdf0e10cSrcweir 					nRet = nTemp;
1846cdf0e10cSrcweir 			}
1847cdf0e10cSrcweir 		}
1848cdf0e10cSrcweir 	}
1849cdf0e10cSrcweir 
1850cdf0e10cSrcweir 	return nRet;
1851cdf0e10cSrcweir }
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir // ---------------------------------------------------------
1854cdf0e10cSrcweir 
1855cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isEndless() throw( RuntimeException )
1856cdf0e10cSrcweir {
1857cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1858cdf0e10cSrcweir 	return maPresSettings.mbEndless;
1859cdf0e10cSrcweir }
1860cdf0e10cSrcweir 
1861cdf0e10cSrcweir // ---------------------------------------------------------
1862cdf0e10cSrcweir 
1863cdf0e10cSrcweir double SlideshowImpl::update()
1864cdf0e10cSrcweir {
1865cdf0e10cSrcweir 	startUpdateTimer();
1866cdf0e10cSrcweir 	return -1;
1867cdf0e10cSrcweir }
1868cdf0e10cSrcweir 
1869cdf0e10cSrcweir // ---------------------------------------------------------
1870cdf0e10cSrcweir 
1871cdf0e10cSrcweir void SlideshowImpl::startUpdateTimer()
1872cdf0e10cSrcweir {
1873cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1874cdf0e10cSrcweir 	maUpdateTimer.SetTimeout( 0 );
1875cdf0e10cSrcweir 	maUpdateTimer.Start();
1876cdf0e10cSrcweir }
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir // ---------------------------------------------------------
1879cdf0e10cSrcweir 
1880cdf0e10cSrcweir /** this timer is called 20ms after a new slide was displayed.
1881cdf0e10cSrcweir 	This is used to unfreeze user input that was disabled after
1882cdf0e10cSrcweir 	slide change to skip input that was buffered during slide
1883cdf0e10cSrcweir 	transition preperation */
1884cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, ReadyForNextInputHdl, Timer*, EMPTYARG )
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir 	mbInputFreeze = false;
1887cdf0e10cSrcweir 	return 0;
1888cdf0e10cSrcweir }
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir // ---------------------------------------------------------
1891cdf0e10cSrcweir 
1892cdf0e10cSrcweir /** if I catch someone someday who calls this method by hand
1893cdf0e10cSrcweir 	and not by using the timer, I will personaly punish this
1894cdf0e10cSrcweir 	person seriously, even if this person is me.
1895cdf0e10cSrcweir */
1896cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, updateHdl, Timer*, EMPTYARG )
1897cdf0e10cSrcweir {
1898cdf0e10cSrcweir 	mnUpdateEvent = 0;
1899cdf0e10cSrcweir 
1900cdf0e10cSrcweir     return updateSlideShow();
1901cdf0e10cSrcweir }
1902cdf0e10cSrcweir 
1903cdf0e10cSrcweir 
1904cdf0e10cSrcweir 
1905cdf0e10cSrcweir 
1906cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, PostYieldListener, void*, EMPTYARG )
1907cdf0e10cSrcweir {
1908cdf0e10cSrcweir     Application::EnableNoYieldMode(false);
1909cdf0e10cSrcweir     Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
1910*e7b227d9SAndre Fischer 
1911cdf0e10cSrcweir     if (mbDisposed)
1912cdf0e10cSrcweir         return 0;
1913*e7b227d9SAndre Fischer 
1914*e7b227d9SAndre Fischer     // Call Reschedule() but make sure that we are not destroyed during its
1915*e7b227d9SAndre Fischer     // execution (we still can be disposed, though.)
1916*e7b227d9SAndre Fischer     const rtl::Reference<SlideshowImpl> pSelf (this);
1917cdf0e10cSrcweir     Application::Reschedule(true);
1918*e7b227d9SAndre Fischer 
1919*e7b227d9SAndre Fischer     // Update the slide show if we are still alive.
1920*e7b227d9SAndre Fischer     if ( ! mbDisposed)
1921*e7b227d9SAndre Fischer         return updateSlideShow();
1922*e7b227d9SAndre Fischer     else
1923*e7b227d9SAndre Fischer         return 0;
1924cdf0e10cSrcweir }
1925cdf0e10cSrcweir 
1926cdf0e10cSrcweir 
1927cdf0e10cSrcweir 
1928cdf0e10cSrcweir 
1929cdf0e10cSrcweir sal_Int32 SlideshowImpl::updateSlideShow (void)
1930cdf0e10cSrcweir {
1931cdf0e10cSrcweir 	// doing some nMagic
1932cdf0e10cSrcweir     const rtl::Reference<SlideshowImpl> this_(this);
1933cdf0e10cSrcweir 
1934cdf0e10cSrcweir 	Reference< XSlideShow > xShow( mxShow );
1935cdf0e10cSrcweir 	if ( ! xShow.is())
1936cdf0e10cSrcweir         return 0;
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir     try
1939cdf0e10cSrcweir 	{
1940cdf0e10cSrcweir         // TODO(Q3): Evaluate under various systems and setups,
1941cdf0e10cSrcweir         // whether this is really necessary. Under WinXP and Matrox
1942cdf0e10cSrcweir         // G550, the frame rates were much more steadier with this
1943cdf0e10cSrcweir         // tweak, although.
1944cdf0e10cSrcweir 
1945cdf0e10cSrcweir // currently no solution, because this kills sound (at least on Windows)
1946cdf0e10cSrcweir //         // Boost our prio, as long as we're in the render loop
1947cdf0e10cSrcweir //         ::canvas::tools::PriorityBooster aBooster(2);
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir 		double fUpdate = 0.0;
1950cdf0e10cSrcweir 		if( !xShow->update(fUpdate) )
1951cdf0e10cSrcweir 			fUpdate = -1.0;
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir 		if (mxShow.is() && (fUpdate >= 0.0))
1954cdf0e10cSrcweir 		{
1955cdf0e10cSrcweir             if (::basegfx::fTools::equalZero(fUpdate))
1956cdf0e10cSrcweir             {
1957cdf0e10cSrcweir                 // Use post yield listener for short update intervalls.
1958cdf0e10cSrcweir                 Application::EnableNoYieldMode(true);
1959cdf0e10cSrcweir                 Application::AddPostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
1960cdf0e10cSrcweir             }
1961cdf0e10cSrcweir             else
1962cdf0e10cSrcweir 			{
1963cdf0e10cSrcweir                 // Avoid busy loop when the previous call to update()
1964cdf0e10cSrcweir                 // returns a small positive number but not 0 (which is
1965cdf0e10cSrcweir                 // handled above).  Also, make sure that calls to update()
1966cdf0e10cSrcweir                 // have a minimum frequency.
1967cdf0e10cSrcweir                 // => Allow up to 60 frames per second.  Call at least once
1968cdf0e10cSrcweir                 // every 4 seconds.
1969cdf0e10cSrcweir                 const static sal_Int32 mnMaximumFrameCount (60);
1970cdf0e10cSrcweir                 const static double mnMinimumTimeout (1.0 / mnMaximumFrameCount);
1971cdf0e10cSrcweir                 const static double mnMaximumTimeout (4.0);
1972cdf0e10cSrcweir                 fUpdate = ::basegfx::clamp(fUpdate, mnMinimumTimeout, mnMaximumTimeout);
1973cdf0e10cSrcweir 
1974cdf0e10cSrcweir                 // Make sure that the maximum frame count has not been set
1975cdf0e10cSrcweir                 // too high (only then conversion to milliseconds and long
1976cdf0e10cSrcweir                 // integer may lead to zero value.)
1977cdf0e10cSrcweir                 OSL_ASSERT(static_cast<sal_uLong>(fUpdate * 1000.0) > 0);
1978cdf0e10cSrcweir 
1979cdf0e10cSrcweir                 Application::EnableNoYieldMode(false);
1980cdf0e10cSrcweir                 Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir                 // Use a timer for the asynchronous callback.
1983cdf0e10cSrcweir                 maUpdateTimer.SetTimeout(static_cast<sal_uLong>(fUpdate * 1000.0));
1984cdf0e10cSrcweir                 maUpdateTimer.Start();
1985cdf0e10cSrcweir             }
1986cdf0e10cSrcweir 		}
1987cdf0e10cSrcweir 	}
1988cdf0e10cSrcweir 	catch( Exception& e )
1989cdf0e10cSrcweir 	{
1990cdf0e10cSrcweir 		static_cast<void>(e);
1991cdf0e10cSrcweir 		DBG_ERROR(
1992cdf0e10cSrcweir             (OString("sd::SlideshowImpl::updateSlideShow(), exception caught: ")
1993cdf0e10cSrcweir                 + rtl::OUStringToOString(
1994cdf0e10cSrcweir                     comphelper::anyToString( cppu::getCaughtException() ),
1995cdf0e10cSrcweir                     RTL_TEXTENCODING_UTF8 )).getStr() );
1996cdf0e10cSrcweir 	}
1997cdf0e10cSrcweir 	return 0;
1998cdf0e10cSrcweir }
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir // ---------------------------------------------------------
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir bool SlideshowImpl::keyInput(const KeyEvent& rKEvt)
2003cdf0e10cSrcweir {
2004cdf0e10cSrcweir 	if( !mxShow.is() || mbInputFreeze )
2005cdf0e10cSrcweir 		return false;
2006cdf0e10cSrcweir 
2007cdf0e10cSrcweir 	bool bRet = true;
2008cdf0e10cSrcweir 
2009cdf0e10cSrcweir 	try
2010cdf0e10cSrcweir 	{
2011cdf0e10cSrcweir 		const int nKeyCode = rKEvt.GetKeyCode().GetCode();
2012cdf0e10cSrcweir 		switch( nKeyCode )
2013cdf0e10cSrcweir 		{
2014cdf0e10cSrcweir 			case awt::Key::CONTEXTMENU:
2015cdf0e10cSrcweir 				if( !mnContextMenuEvent )
2016cdf0e10cSrcweir 				{
2017cdf0e10cSrcweir 					if( mpShowWindow )
2018cdf0e10cSrcweir 						maPopupMousePos = mpShowWindow->GetPointerState().maPos;
2019cdf0e10cSrcweir 					mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
2020cdf0e10cSrcweir 				}
2021cdf0e10cSrcweir 				break;
2022cdf0e10cSrcweir 
2023cdf0e10cSrcweir 			// cancel show
2024cdf0e10cSrcweir 			case KEY_ESCAPE:
2025cdf0e10cSrcweir 			case KEY_SUBTRACT:
2026cdf0e10cSrcweir 				// in case the user cancels the presentation, switch to current slide
2027cdf0e10cSrcweir 				// in edit mode
2028cdf0e10cSrcweir 				if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
2029cdf0e10cSrcweir 				{
2030cdf0e10cSrcweir 					if( mpSlideController->getCurrentSlideNumber() != -1 )
2031cdf0e10cSrcweir 						mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
2032cdf0e10cSrcweir 				}
2033cdf0e10cSrcweir 				endPresentation();
2034cdf0e10cSrcweir 				break;
2035cdf0e10cSrcweir 
2036cdf0e10cSrcweir 			// advance show
2037cdf0e10cSrcweir 			case KEY_PAGEDOWN:
2038cdf0e10cSrcweir 				if(rKEvt.GetKeyCode().IsMod2())
2039cdf0e10cSrcweir 				{
2040cdf0e10cSrcweir 					gotoNextSlide();
2041cdf0e10cSrcweir 					break;
2042cdf0e10cSrcweir 				}
2043cdf0e10cSrcweir 				// warning, fall through!
2044cdf0e10cSrcweir 			case KEY_SPACE:
2045cdf0e10cSrcweir 			case KEY_RIGHT:
2046cdf0e10cSrcweir 			case KEY_DOWN:
2047cdf0e10cSrcweir 			case KEY_N:
2048cdf0e10cSrcweir 				gotoNextEffect();
2049cdf0e10cSrcweir 				break;
2050cdf0e10cSrcweir 
2051cdf0e10cSrcweir 			case KEY_RETURN:
2052cdf0e10cSrcweir 			{
2053cdf0e10cSrcweir 				if( maCharBuffer.Len() )
2054cdf0e10cSrcweir 				{
2055cdf0e10cSrcweir 					if( mpSlideController.get() )
2056cdf0e10cSrcweir 					{
2057cdf0e10cSrcweir 						if( mpSlideController->jumpToSlideNumber( maCharBuffer.ToInt32() - 1 ) )
2058cdf0e10cSrcweir 							displayCurrentSlide();
2059cdf0e10cSrcweir 					}
2060cdf0e10cSrcweir 					maCharBuffer.Erase();
2061cdf0e10cSrcweir 				}
2062cdf0e10cSrcweir 				else
2063cdf0e10cSrcweir 				{
2064cdf0e10cSrcweir 					gotoNextEffect();
2065cdf0e10cSrcweir 				}
2066cdf0e10cSrcweir 			}
2067cdf0e10cSrcweir 			break;
2068cdf0e10cSrcweir 
2069cdf0e10cSrcweir 			// numeric: add to buffer
2070cdf0e10cSrcweir 			case KEY_0:
2071cdf0e10cSrcweir 			case KEY_1:
2072cdf0e10cSrcweir 			case KEY_2:
2073cdf0e10cSrcweir 			case KEY_3:
2074cdf0e10cSrcweir 			case KEY_4:
2075cdf0e10cSrcweir 			case KEY_5:
2076cdf0e10cSrcweir 			case KEY_6:
2077cdf0e10cSrcweir 			case KEY_7:
2078cdf0e10cSrcweir 			case KEY_8:
2079cdf0e10cSrcweir 			case KEY_9:
2080cdf0e10cSrcweir 				maCharBuffer.Append( rKEvt.GetCharCode() );
2081cdf0e10cSrcweir 				break;
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir 			case KEY_PAGEUP:
2084cdf0e10cSrcweir 				if(rKEvt.GetKeyCode().IsMod2())
2085cdf0e10cSrcweir 				{
2086cdf0e10cSrcweir 					gotoPreviousSlide();
2087cdf0e10cSrcweir 					break;
2088cdf0e10cSrcweir 				}
2089cdf0e10cSrcweir 				// warning, fall through!
2090cdf0e10cSrcweir 			case KEY_LEFT:
2091cdf0e10cSrcweir 			case KEY_UP:
2092cdf0e10cSrcweir 			case KEY_P:
2093cdf0e10cSrcweir 			case KEY_BACKSPACE:
2094cdf0e10cSrcweir 				gotoPreviousEffect();
2095cdf0e10cSrcweir 				break;
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir 			case KEY_HOME:
2098cdf0e10cSrcweir 				gotoFirstSlide();
2099cdf0e10cSrcweir 				break;
2100cdf0e10cSrcweir 
2101cdf0e10cSrcweir 			case KEY_END:
2102cdf0e10cSrcweir 				gotoLastSlide();
2103cdf0e10cSrcweir 				break;
2104cdf0e10cSrcweir 
2105cdf0e10cSrcweir 			case KEY_B:
2106cdf0e10cSrcweir 			case KEY_W:
2107cdf0e10cSrcweir 			case KEY_POINT:
2108cdf0e10cSrcweir 			case KEY_COMMA:
2109cdf0e10cSrcweir 			{
2110cdf0e10cSrcweir 				blankScreen( ((nKeyCode == KEY_W ) || (nKeyCode == KEY_COMMA)) ? 0x00ffffff : 0x00000000 );
2111cdf0e10cSrcweir 			}
2112cdf0e10cSrcweir 			break;
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir 			default:
2115cdf0e10cSrcweir 				bRet = false;
2116cdf0e10cSrcweir 			break;
2117cdf0e10cSrcweir 		}
2118cdf0e10cSrcweir 	}
2119cdf0e10cSrcweir 	catch( Exception& e )
2120cdf0e10cSrcweir 	{
2121cdf0e10cSrcweir 		bRet = false;
2122cdf0e10cSrcweir 		static_cast<void>(e);
2123cdf0e10cSrcweir 		DBG_ERROR(
2124cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::keyInput(), "
2125cdf0e10cSrcweir 					"exception caught: ") +
2126cdf0e10cSrcweir 			rtl::OUStringToOString(
2127cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
2128cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
2129cdf0e10cSrcweir 	}
2130cdf0e10cSrcweir 
2131cdf0e10cSrcweir 	return bRet;
2132cdf0e10cSrcweir }
2133cdf0e10cSrcweir 
2134cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, EventListenerHdl, VclSimpleEvent*, pEvent )
2135cdf0e10cSrcweir {
2136cdf0e10cSrcweir 	if( !mxShow.is() || mbInputFreeze )
2137cdf0e10cSrcweir 		return 0;
2138cdf0e10cSrcweir 
2139cdf0e10cSrcweir 	if( pEvent && (pEvent->GetId() == VCLEVENT_WINDOW_COMMAND) && static_cast<VclWindowEvent*>(pEvent)->GetData() )
2140cdf0e10cSrcweir 	{
2141cdf0e10cSrcweir 		const CommandEvent& rEvent = *(const CommandEvent*)static_cast<VclWindowEvent*>(pEvent)->GetData();
2142cdf0e10cSrcweir 
2143cdf0e10cSrcweir 		if( rEvent.GetCommand() == COMMAND_MEDIA )
2144cdf0e10cSrcweir 		{
2145cdf0e10cSrcweir 			switch( rEvent.GetMediaCommand() )
2146cdf0e10cSrcweir 			{
2147cdf0e10cSrcweir #if defined( QUARTZ )
2148cdf0e10cSrcweir 			case MEDIA_COMMAND_MENU:
2149cdf0e10cSrcweir 			    if( !mnContextMenuEvent )
2150cdf0e10cSrcweir 			    {
2151cdf0e10cSrcweir 				if( mpShowWindow )
2152cdf0e10cSrcweir 				    maPopupMousePos = mpShowWindow->GetPointerState().maPos;
2153cdf0e10cSrcweir 				mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
2154cdf0e10cSrcweir 			    }
2155cdf0e10cSrcweir 				break;
2156cdf0e10cSrcweir 			case MEDIA_COMMAND_VOLUME_DOWN:
2157cdf0e10cSrcweir 				gotoPreviousSlide();
2158cdf0e10cSrcweir 				break;
2159cdf0e10cSrcweir 			case MEDIA_COMMAND_VOLUME_UP:
2160cdf0e10cSrcweir 			    gotoNextEffect();
2161cdf0e10cSrcweir 			    break;
2162cdf0e10cSrcweir #endif
2163cdf0e10cSrcweir 			case MEDIA_COMMAND_NEXTTRACK:
2164cdf0e10cSrcweir 			    gotoNextEffect();
2165cdf0e10cSrcweir 			    break;
2166cdf0e10cSrcweir 			case MEDIA_COMMAND_PAUSE:
2167cdf0e10cSrcweir 				if( !mbIsPaused )
2168cdf0e10cSrcweir 					blankScreen(0);
2169cdf0e10cSrcweir 				break;
2170cdf0e10cSrcweir 			case MEDIA_COMMAND_PLAY:
2171cdf0e10cSrcweir 				if( mbIsPaused )
2172cdf0e10cSrcweir 					resume();
2173cdf0e10cSrcweir                 break;
2174cdf0e10cSrcweir 
2175cdf0e10cSrcweir 			case MEDIA_COMMAND_PLAY_PAUSE:
2176cdf0e10cSrcweir 				if( mbIsPaused )
2177cdf0e10cSrcweir 					resume();
2178cdf0e10cSrcweir 				else
2179cdf0e10cSrcweir 					blankScreen(0);
2180cdf0e10cSrcweir 				break;
2181cdf0e10cSrcweir 			case MEDIA_COMMAND_PREVIOUSTRACK:
2182cdf0e10cSrcweir 				gotoPreviousSlide();
2183cdf0e10cSrcweir 				break;
2184cdf0e10cSrcweir 			case MEDIA_COMMAND_NEXTTRACK_HOLD:
2185cdf0e10cSrcweir 				gotoLastSlide();
2186cdf0e10cSrcweir 				break;
2187cdf0e10cSrcweir 
2188cdf0e10cSrcweir 			case MEDIA_COMMAND_REWIND:
2189cdf0e10cSrcweir 				gotoFirstSlide();
2190cdf0e10cSrcweir 				break;
2191cdf0e10cSrcweir 			case MEDIA_COMMAND_STOP:
2192cdf0e10cSrcweir 				// in case the user cancels the presentation, switch to current slide
2193cdf0e10cSrcweir 				// in edit mode
2194cdf0e10cSrcweir 				if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
2195cdf0e10cSrcweir 				{
2196cdf0e10cSrcweir 					if( mpSlideController->getCurrentSlideNumber() != -1 )
2197cdf0e10cSrcweir 						mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
2198cdf0e10cSrcweir 				}
2199cdf0e10cSrcweir 				endPresentation();
2200cdf0e10cSrcweir 				break;
2201cdf0e10cSrcweir 			}
2202cdf0e10cSrcweir 		}
2203cdf0e10cSrcweir 	}
2204cdf0e10cSrcweir 
2205cdf0e10cSrcweir 	return 0;
2206cdf0e10cSrcweir }
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir // ---------------------------------------------------------
2209cdf0e10cSrcweir 
2210cdf0e10cSrcweir void SlideshowImpl::mouseButtonUp(const MouseEvent& rMEvt)
2211cdf0e10cSrcweir {
2212cdf0e10cSrcweir 	if( rMEvt.IsRight() && !mnContextMenuEvent )
2213cdf0e10cSrcweir 	{
2214cdf0e10cSrcweir 		maPopupMousePos = rMEvt.GetPosPixel();
2215cdf0e10cSrcweir 		mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
2216cdf0e10cSrcweir 	}
2217cdf0e10cSrcweir }
2218cdf0e10cSrcweir 
2219cdf0e10cSrcweir // ---------------------------------------------------------
2220cdf0e10cSrcweir 
2221cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, ContextMenuHdl, void*, EMPTYARG )
2222cdf0e10cSrcweir {
2223cdf0e10cSrcweir 	mnContextMenuEvent = 0;
2224cdf0e10cSrcweir 
2225cdf0e10cSrcweir 	if( mpSlideController.get() == 0 )
2226cdf0e10cSrcweir 		return 0;
2227cdf0e10cSrcweir 
2228cdf0e10cSrcweir 	mbWasPaused = mbIsPaused;
2229cdf0e10cSrcweir 	if( !mbWasPaused )
2230cdf0e10cSrcweir 		pause();
2231cdf0e10cSrcweir 
2232cdf0e10cSrcweir 	PopupMenu* pMenu = new PopupMenu( SdResId( RID_SLIDESHOW_CONTEXTMENU ) );
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir 	// Adding button to display if in Pen  mode
2235cdf0e10cSrcweir 	pMenu->CheckItem( CM_PEN_MODE, mbUsePen);
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir 	const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2238cdf0e10cSrcweir 	pMenu->EnableItem( CM_NEXT_SLIDE, ( mpSlideController->getNextSlideIndex() != -1 ) );
2239cdf0e10cSrcweir 	pMenu->EnableItem( CM_PREV_SLIDE, ( mpSlideController->getPreviousSlideIndex() != -1 ) || (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) );
2240cdf0e10cSrcweir 
2241cdf0e10cSrcweir 	PopupMenu* pPageMenu = pMenu->GetPopupMenu( CM_GOTO );
2242cdf0e10cSrcweir 
2243cdf0e10cSrcweir 	SfxViewFrame* pViewFrame = getViewFrame();
2244cdf0e10cSrcweir 	if( pViewFrame )
2245cdf0e10cSrcweir 	{
2246cdf0e10cSrcweir 		Reference< ::com::sun::star::frame::XFrame > xFrame( pViewFrame->GetFrame().GetFrameInterface() );
2247cdf0e10cSrcweir 		if( xFrame.is() )
2248cdf0e10cSrcweir 		{
2249cdf0e10cSrcweir 			pMenu->SetItemImage( CM_NEXT_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10617") ), sal_False, sal_False ) );
2250cdf0e10cSrcweir 			pMenu->SetItemImage( CM_PREV_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10618") ), sal_False, sal_False ) );
2251cdf0e10cSrcweir 
2252cdf0e10cSrcweir 			if( pPageMenu )
2253cdf0e10cSrcweir 			{
2254cdf0e10cSrcweir 				pPageMenu->SetItemImage( CM_FIRST_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10616") ), sal_False, sal_False ) );
2255cdf0e10cSrcweir 				pPageMenu->SetItemImage( CM_LAST_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10619") ), sal_False, sal_False ) );
2256cdf0e10cSrcweir 			}
2257cdf0e10cSrcweir 		}
2258cdf0e10cSrcweir 	}
2259cdf0e10cSrcweir 
2260cdf0e10cSrcweir 	// populate slide goto list
2261cdf0e10cSrcweir 	if( pPageMenu )
2262cdf0e10cSrcweir 	{
2263cdf0e10cSrcweir 		const sal_Int32 nPageNumberCount = mpSlideController->getSlideNumberCount();
2264cdf0e10cSrcweir 		if( nPageNumberCount <= 1 )
2265cdf0e10cSrcweir 		{
2266cdf0e10cSrcweir 			pMenu->EnableItem( CM_GOTO, sal_False );
2267cdf0e10cSrcweir 		}
2268cdf0e10cSrcweir 		else
2269cdf0e10cSrcweir 		{
2270cdf0e10cSrcweir 			sal_Int32 nCurrentSlideNumber = mpSlideController->getCurrentSlideNumber();
2271cdf0e10cSrcweir 			if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2272cdf0e10cSrcweir 				nCurrentSlideNumber = -1;
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir 			pPageMenu->EnableItem( CM_FIRST_SLIDE, ( mpSlideController->getSlideNumber(0) != nCurrentSlideNumber ) );
2275cdf0e10cSrcweir 			pPageMenu->EnableItem( CM_LAST_SLIDE, ( mpSlideController->getSlideNumber( mpSlideController->getSlideIndexCount() - 1) != nCurrentSlideNumber ) );
2276cdf0e10cSrcweir 
2277cdf0e10cSrcweir 			sal_Int32 nPageNumber;
2278cdf0e10cSrcweir 
2279cdf0e10cSrcweir 			for( nPageNumber = 0; nPageNumber < nPageNumberCount; nPageNumber++ )
2280cdf0e10cSrcweir 			{
2281cdf0e10cSrcweir 				if( mpSlideController->isVisibleSlideNumber( nPageNumber ) )
2282cdf0e10cSrcweir 				{
2283cdf0e10cSrcweir 					SdPage* pPage = mpDoc->GetSdPage((sal_uInt16)nPageNumber, PK_STANDARD);
2284cdf0e10cSrcweir 					if (pPage)
2285cdf0e10cSrcweir 					{
2286cdf0e10cSrcweir 						pPageMenu->InsertItem( (sal_uInt16)(CM_SLIDES + nPageNumber), pPage->GetName() );
2287cdf0e10cSrcweir 						if( nPageNumber == nCurrentSlideNumber )
2288cdf0e10cSrcweir 							pPageMenu->CheckItem( (sal_uInt16)(CM_SLIDES + nPageNumber) );
2289cdf0e10cSrcweir 					}
2290cdf0e10cSrcweir 				}
2291cdf0e10cSrcweir 			}
2292cdf0e10cSrcweir 		}
2293cdf0e10cSrcweir 	}
2294cdf0e10cSrcweir 
2295cdf0e10cSrcweir 	if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
2296cdf0e10cSrcweir 	{
2297cdf0e10cSrcweir 		PopupMenu* pBlankMenu = pMenu->GetPopupMenu( CM_SCREEN );
2298cdf0e10cSrcweir 		if( pBlankMenu )
2299cdf0e10cSrcweir 		{
2300cdf0e10cSrcweir 			pBlankMenu->CheckItem( ( mpShowWindow->GetBlankColor() == Color( COL_WHITE ) ) ? CM_SCREEN_WHITE : CM_SCREEN_BLACK  );
2301cdf0e10cSrcweir 		}
2302cdf0e10cSrcweir 	}
2303cdf0e10cSrcweir 
2304cdf0e10cSrcweir 	PopupMenu* pWidthMenu = pMenu->GetPopupMenu( CM_WIDTH_PEN);
2305cdf0e10cSrcweir 
2306cdf0e10cSrcweir     // populate color width list
2307cdf0e10cSrcweir     if( pWidthMenu )
2308cdf0e10cSrcweir     {
2309cdf0e10cSrcweir         sal_Int32 nIterator;
2310cdf0e10cSrcweir         double nWidth;
2311cdf0e10cSrcweir 
2312cdf0e10cSrcweir         nWidth = 4.0;
2313cdf0e10cSrcweir         for( nIterator = 1; nIterator < 6; nIterator++)
2314cdf0e10cSrcweir         {
2315cdf0e10cSrcweir             switch(nIterator)
2316cdf0e10cSrcweir             {
2317cdf0e10cSrcweir                 case 1:
2318cdf0e10cSrcweir                     nWidth = 4.0;
2319cdf0e10cSrcweir                     break;
2320cdf0e10cSrcweir                 case 2:
2321cdf0e10cSrcweir                     nWidth = 100.0;
2322cdf0e10cSrcweir                     break;
2323cdf0e10cSrcweir                 case 3:
2324cdf0e10cSrcweir                     nWidth = 150.0;
2325cdf0e10cSrcweir                     break;
2326cdf0e10cSrcweir                 case 4:
2327cdf0e10cSrcweir                     nWidth = 200.0;
2328cdf0e10cSrcweir                     break;
2329cdf0e10cSrcweir                 case 5:
2330cdf0e10cSrcweir                     nWidth = 400.0;
2331cdf0e10cSrcweir                     break;
2332cdf0e10cSrcweir                 default:
2333cdf0e10cSrcweir                     break;
2334cdf0e10cSrcweir             }
2335cdf0e10cSrcweir 
2336cdf0e10cSrcweir             pWidthMenu->EnableItem( (sal_uInt16)(CM_WIDTH_PEN + nIterator), sal_True);
2337cdf0e10cSrcweir             if( nWidth ==  mdUserPaintStrokeWidth)
2338cdf0e10cSrcweir                 pWidthMenu->CheckItem( (sal_uInt16)(CM_WIDTH_PEN + nIterator) );
2339cdf0e10cSrcweir         }
2340cdf0e10cSrcweir     }
2341cdf0e10cSrcweir 
2342cdf0e10cSrcweir 	pMenu->SetSelectHdl( LINK( this, SlideshowImpl, ContextMenuSelectHdl ) );
2343cdf0e10cSrcweir 	pMenu->Execute( mpShowWindow, maPopupMousePos );
2344cdf0e10cSrcweir 	delete pMenu;
2345cdf0e10cSrcweir 
2346cdf0e10cSrcweir 	if( mxView.is() )
2347cdf0e10cSrcweir 		mxView->ignoreNextMouseReleased();
2348cdf0e10cSrcweir 
2349cdf0e10cSrcweir 	if( !mbWasPaused )
2350cdf0e10cSrcweir 		resume();
2351cdf0e10cSrcweir 	return 0;
2352cdf0e10cSrcweir }
2353cdf0e10cSrcweir 
2354cdf0e10cSrcweir // ---------------------------------------------------------
2355cdf0e10cSrcweir 
2356cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, ContextMenuSelectHdl, Menu *, pMenu )
2357cdf0e10cSrcweir {
2358cdf0e10cSrcweir 	if( pMenu )
2359cdf0e10cSrcweir 	{
2360cdf0e10cSrcweir 		sal_uInt16 nMenuId = pMenu->GetCurItemId();
2361cdf0e10cSrcweir 
2362cdf0e10cSrcweir 		switch( nMenuId )
2363cdf0e10cSrcweir 		{
2364cdf0e10cSrcweir 		case CM_PREV_SLIDE:
2365cdf0e10cSrcweir 			gotoPreviousSlide();
2366cdf0e10cSrcweir 			mbWasPaused = false;
2367cdf0e10cSrcweir 			break;
2368cdf0e10cSrcweir 		case CM_NEXT_SLIDE:
2369cdf0e10cSrcweir 			gotoNextSlide();
2370cdf0e10cSrcweir 			mbWasPaused = false;
2371cdf0e10cSrcweir 			break;
2372cdf0e10cSrcweir 		case CM_FIRST_SLIDE:
2373cdf0e10cSrcweir 			gotoFirstSlide();
2374cdf0e10cSrcweir 			mbWasPaused = false;
2375cdf0e10cSrcweir 			break;
2376cdf0e10cSrcweir 		case CM_LAST_SLIDE:
2377cdf0e10cSrcweir 			gotoLastSlide();
2378cdf0e10cSrcweir 			mbWasPaused = false;
2379cdf0e10cSrcweir 			break;
2380cdf0e10cSrcweir 		case CM_SCREEN_BLACK:
2381cdf0e10cSrcweir 		case CM_SCREEN_WHITE:
2382cdf0e10cSrcweir 		{
2383cdf0e10cSrcweir 			const Color aBlankColor( (nMenuId == CM_SCREEN_WHITE) ? COL_WHITE : COL_BLACK );
2384cdf0e10cSrcweir 			if( mbWasPaused )
2385cdf0e10cSrcweir 			{
2386cdf0e10cSrcweir 				if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
2387cdf0e10cSrcweir 				{
2388cdf0e10cSrcweir 					if( mpShowWindow->GetBlankColor() == aBlankColor )
2389cdf0e10cSrcweir 					{
2390cdf0e10cSrcweir 						mbWasPaused = false;
2391cdf0e10cSrcweir 						mpShowWindow->RestartShow();
2392cdf0e10cSrcweir 						break;
2393cdf0e10cSrcweir 					}
2394cdf0e10cSrcweir 				}
2395cdf0e10cSrcweir 				mpShowWindow->RestartShow();
2396cdf0e10cSrcweir 			}
2397cdf0e10cSrcweir 			if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), aBlankColor ) )
2398cdf0e10cSrcweir 			{
2399cdf0e10cSrcweir 				pause();
2400cdf0e10cSrcweir 				mbWasPaused = true;
2401cdf0e10cSrcweir 			}
2402cdf0e10cSrcweir 		}
2403cdf0e10cSrcweir 		break;
2404cdf0e10cSrcweir         case CM_COLOR_PEN:
2405cdf0e10cSrcweir             {
2406cdf0e10cSrcweir                 //Open a color picker based on SvColorDialog
2407cdf0e10cSrcweir                 ::Color aColor( mnUserPaintColor );
2408cdf0e10cSrcweir                 SvColorDialog aColorDlg( mpShowWindow);
2409cdf0e10cSrcweir                 aColorDlg.SetColor( aColor );
2410cdf0e10cSrcweir 
2411cdf0e10cSrcweir                 if (aColorDlg.Execute() )
2412cdf0e10cSrcweir                 {
2413cdf0e10cSrcweir                     aColor = aColorDlg.GetColor();
2414cdf0e10cSrcweir                     setPenColor(aColor.GetColor());
2415cdf0e10cSrcweir                 }
2416cdf0e10cSrcweir                 mbWasPaused = false;
2417cdf0e10cSrcweir             }
2418cdf0e10cSrcweir             break;
2419cdf0e10cSrcweir 
2420cdf0e10cSrcweir         case CM_WIDTH_PEN_VERY_THIN:
2421cdf0e10cSrcweir             {
2422cdf0e10cSrcweir                 setPenWidth(4.0);
2423cdf0e10cSrcweir                 mbWasPaused = false;
2424cdf0e10cSrcweir             }
2425cdf0e10cSrcweir             break;
2426cdf0e10cSrcweir 
2427cdf0e10cSrcweir         case CM_WIDTH_PEN_THIN:
2428cdf0e10cSrcweir             {
2429cdf0e10cSrcweir                 setPenWidth(100.0);
2430cdf0e10cSrcweir                 mbWasPaused = false;
2431cdf0e10cSrcweir             }
2432cdf0e10cSrcweir             break;
2433cdf0e10cSrcweir 
2434cdf0e10cSrcweir         case CM_WIDTH_PEN_NORMAL:
2435cdf0e10cSrcweir             {
2436cdf0e10cSrcweir                 setPenWidth(150.0);
2437cdf0e10cSrcweir                 mbWasPaused = false;
2438cdf0e10cSrcweir             }
2439cdf0e10cSrcweir             break;
2440cdf0e10cSrcweir 
2441cdf0e10cSrcweir         case CM_WIDTH_PEN_THICK:
2442cdf0e10cSrcweir             {
2443cdf0e10cSrcweir                 setPenWidth(200.0);
2444cdf0e10cSrcweir                 mbWasPaused = false;
2445cdf0e10cSrcweir             }
2446cdf0e10cSrcweir             break;
2447cdf0e10cSrcweir 
2448cdf0e10cSrcweir         case CM_WIDTH_PEN_VERY_THICK:
2449cdf0e10cSrcweir             {
2450cdf0e10cSrcweir                 setPenWidth(400.0);
2451cdf0e10cSrcweir                 mbWasPaused = false;
2452cdf0e10cSrcweir             }
2453cdf0e10cSrcweir             break;
2454cdf0e10cSrcweir         case CM_ERASE_ALLINK:
2455cdf0e10cSrcweir             {
2456cdf0e10cSrcweir                 setEraseAllInk(true);
2457cdf0e10cSrcweir                 mbWasPaused = false;
2458cdf0e10cSrcweir             }
2459cdf0e10cSrcweir             break;
2460cdf0e10cSrcweir         case CM_PEN_MODE:
2461cdf0e10cSrcweir             {
2462cdf0e10cSrcweir                 setUsePen(!mbUsePen);
2463cdf0e10cSrcweir                 mbWasPaused = false;
2464cdf0e10cSrcweir             }
2465cdf0e10cSrcweir             break;
2466cdf0e10cSrcweir         case CM_ENDSHOW:
2467cdf0e10cSrcweir             // in case the user cancels the presentation, switch to current slide
2468cdf0e10cSrcweir             // in edit mode
2469cdf0e10cSrcweir             if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
2470cdf0e10cSrcweir             {
2471cdf0e10cSrcweir                 if( mpSlideController->getCurrentSlideNumber() != -1 )
2472cdf0e10cSrcweir                 {
2473cdf0e10cSrcweir                     mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
2474cdf0e10cSrcweir                 }
2475cdf0e10cSrcweir             }
2476cdf0e10cSrcweir             endPresentation();
2477cdf0e10cSrcweir             break;
2478cdf0e10cSrcweir         default:
2479cdf0e10cSrcweir             sal_Int32 nPageNumber = nMenuId - CM_SLIDES;
2480cdf0e10cSrcweir             const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
2481cdf0e10cSrcweir             if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
2482cdf0e10cSrcweir             {
2483cdf0e10cSrcweir                 mpShowWindow->RestartShow( nPageNumber );
2484cdf0e10cSrcweir             }
2485cdf0e10cSrcweir             else if( nPageNumber != mpSlideController->getCurrentSlideNumber() )
2486cdf0e10cSrcweir             {
2487cdf0e10cSrcweir                 displaySlideNumber( nPageNumber );
2488cdf0e10cSrcweir             }
2489cdf0e10cSrcweir             mbWasPaused = false;
2490cdf0e10cSrcweir             break;
2491cdf0e10cSrcweir 		}
2492cdf0e10cSrcweir 	}
2493cdf0e10cSrcweir 
2494cdf0e10cSrcweir 	return 0;
2495cdf0e10cSrcweir }
2496cdf0e10cSrcweir 
2497cdf0e10cSrcweir // ---------------------------------------------------------
2498cdf0e10cSrcweir 
2499cdf0e10cSrcweir Reference< XSlideShow > SlideshowImpl::createSlideShow() const
2500cdf0e10cSrcweir {
2501cdf0e10cSrcweir 	Reference< XSlideShow > xShow;
2502cdf0e10cSrcweir 
2503cdf0e10cSrcweir 	try
2504cdf0e10cSrcweir 	{
2505cdf0e10cSrcweir 	    Reference< lang::XMultiServiceFactory > xFactory(
2506cdf0e10cSrcweir 		    ::comphelper::getProcessServiceFactory(),
2507cdf0e10cSrcweir 			UNO_QUERY_THROW );
2508cdf0e10cSrcweir 
2509cdf0e10cSrcweir 		Reference< XInterface > xInt( xFactory->createInstance(
2510cdf0e10cSrcweir 			    OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideShow")) ) );
2511cdf0e10cSrcweir 
2512cdf0e10cSrcweir 		xShow.set( xInt, UNO_QUERY_THROW );
2513cdf0e10cSrcweir 	}
2514cdf0e10cSrcweir 	catch( uno::Exception& e )
2515cdf0e10cSrcweir 	{
2516cdf0e10cSrcweir 		(void)e;
2517cdf0e10cSrcweir 		DBG_ERROR(
2518cdf0e10cSrcweir             (OString("sd::SlideshowImpl::createSlideShow(), "
2519cdf0e10cSrcweir                      "exception caught: ") +
2520cdf0e10cSrcweir              rtl::OUStringToOString(
2521cdf0e10cSrcweir                  comphelper::anyToString( cppu::getCaughtException() ),
2522cdf0e10cSrcweir                  RTL_TEXTENCODING_UTF8 )).getStr() );
2523cdf0e10cSrcweir 	}
2524cdf0e10cSrcweir 
2525cdf0e10cSrcweir 	return xShow;
2526cdf0e10cSrcweir }
2527cdf0e10cSrcweir 
2528cdf0e10cSrcweir // ---------------------------------------------------------
2529cdf0e10cSrcweir 
2530cdf0e10cSrcweir void SlideshowImpl::createSlideList( bool bAll, bool bStartWithActualSlide, const String& rPresSlide )
2531cdf0e10cSrcweir {
2532cdf0e10cSrcweir 	const long nSlideCount = mpDoc->GetSdPageCount( PK_STANDARD );
2533cdf0e10cSrcweir 
2534cdf0e10cSrcweir 	if( nSlideCount )
2535cdf0e10cSrcweir 	{
2536cdf0e10cSrcweir 		SdCustomShow*	pCustomShow;
2537cdf0e10cSrcweir 
2538cdf0e10cSrcweir 		if( !bStartWithActualSlide && mpDoc->GetCustomShowList() && maPresSettings.mbCustomShow )
2539cdf0e10cSrcweir 			pCustomShow = (SdCustomShow*) mpDoc->GetCustomShowList()->GetCurObject();
2540cdf0e10cSrcweir 		else
2541cdf0e10cSrcweir 			pCustomShow = NULL;
2542cdf0e10cSrcweir 
2543cdf0e10cSrcweir 		// create animation slide controller
2544cdf0e10cSrcweir 		AnimationSlideController::Mode eMode =
2545cdf0e10cSrcweir 			( pCustomShow && pCustomShow->Count() ) ? AnimationSlideController::CUSTOM :
2546cdf0e10cSrcweir 				(bAll ? AnimationSlideController::ALL : AnimationSlideController::FROM);
2547cdf0e10cSrcweir 
2548cdf0e10cSrcweir 		Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
2549cdf0e10cSrcweir 		Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
2550cdf0e10cSrcweir 		mpSlideController.reset( new AnimationSlideController( xSlides, eMode ) );
2551cdf0e10cSrcweir 
2552cdf0e10cSrcweir 		if( eMode != AnimationSlideController::CUSTOM )
2553cdf0e10cSrcweir 		{
2554cdf0e10cSrcweir 			sal_Int32 nFirstSlide = 0;
2555cdf0e10cSrcweir 
2556cdf0e10cSrcweir 			// normale Praesentation
2557cdf0e10cSrcweir 			if( eMode == AnimationSlideController::FROM )
2558cdf0e10cSrcweir 			{
2559cdf0e10cSrcweir 				if( rPresSlide.Len() )
2560cdf0e10cSrcweir 				{
2561cdf0e10cSrcweir 					sal_Int32 nSlide;
2562cdf0e10cSrcweir 					sal_Bool bTakeNextAvailable = sal_False;
2563cdf0e10cSrcweir 
2564cdf0e10cSrcweir 					for( nSlide = 0, nFirstSlide = -1; ( nSlide < nSlideCount ) && ( -1 == nFirstSlide ); nSlide++ )
2565cdf0e10cSrcweir 					{
2566cdf0e10cSrcweir 						SdPage* pTestSlide = mpDoc->GetSdPage( (sal_uInt16)nSlide, PK_STANDARD );
2567cdf0e10cSrcweir 
2568cdf0e10cSrcweir 						if( pTestSlide->GetName() == rPresSlide )
2569cdf0e10cSrcweir 						{
2570cdf0e10cSrcweir 							if( pTestSlide->IsExcluded() )
2571cdf0e10cSrcweir 								bTakeNextAvailable = sal_True;
2572cdf0e10cSrcweir 							else
2573cdf0e10cSrcweir 								nFirstSlide = nSlide;
2574cdf0e10cSrcweir 						}
2575cdf0e10cSrcweir 						else if( bTakeNextAvailable && !pTestSlide->IsExcluded() )
2576cdf0e10cSrcweir 							nFirstSlide = nSlide;
2577cdf0e10cSrcweir 					}
2578cdf0e10cSrcweir 
2579cdf0e10cSrcweir 					if( -1 == nFirstSlide )
2580cdf0e10cSrcweir 						nFirstSlide = 0;
2581cdf0e10cSrcweir 				}
2582cdf0e10cSrcweir 			}
2583cdf0e10cSrcweir 
2584cdf0e10cSrcweir 			for( sal_Int32 i = 0; i < nSlideCount; i++ )
2585cdf0e10cSrcweir 			{
2586cdf0e10cSrcweir 				bool bVisible = ( mpDoc->GetSdPage( (sal_uInt16)i, PK_STANDARD ) )->IsExcluded() ? false : true;
2587cdf0e10cSrcweir 				if( bVisible || (eMode == AnimationSlideController::ALL) )
2588cdf0e10cSrcweir 					mpSlideController->insertSlideNumber( i, bVisible );
2589cdf0e10cSrcweir 			}
2590cdf0e10cSrcweir 
2591cdf0e10cSrcweir 			mpSlideController->setStartSlideNumber( nFirstSlide );
2592cdf0e10cSrcweir 		}
2593cdf0e10cSrcweir 		else
2594cdf0e10cSrcweir 		{
2595cdf0e10cSrcweir 			if( meAnimationMode != ANIMATIONMODE_SHOW && rPresSlide.Len() )
2596cdf0e10cSrcweir 			{
2597cdf0e10cSrcweir 				sal_Int32 nSlide;
2598cdf0e10cSrcweir 				for( nSlide = 0; nSlide < nSlideCount; nSlide++ )
2599cdf0e10cSrcweir 					if( rPresSlide == mpDoc->GetSdPage( (sal_uInt16) nSlide, PK_STANDARD )->GetName() )
2600cdf0e10cSrcweir 						break;
2601cdf0e10cSrcweir 
2602cdf0e10cSrcweir 				if( nSlide < nSlideCount )
2603cdf0e10cSrcweir 					mpSlideController->insertSlideNumber( (sal_uInt16) nSlide );
2604cdf0e10cSrcweir 			}
2605cdf0e10cSrcweir 
2606cdf0e10cSrcweir 			void* pCustomSlide;
2607cdf0e10cSrcweir 			sal_Int32 nSlideIndex;
2608cdf0e10cSrcweir 			for( pCustomSlide = pCustomShow->First(),nSlideIndex=0; pCustomSlide; pCustomSlide = pCustomShow->Next(), nSlideIndex++ )
2609cdf0e10cSrcweir 			{
2610cdf0e10cSrcweir 				const sal_uInt16 nSdSlide = ( ( (SdPage*) pCustomSlide )->GetPageNum() - 1 ) / 2;
2611cdf0e10cSrcweir 
2612cdf0e10cSrcweir 				if( !( mpDoc->GetSdPage( nSdSlide, PK_STANDARD ) )->IsExcluded())
2613cdf0e10cSrcweir 					mpSlideController->insertSlideNumber( nSdSlide );
2614cdf0e10cSrcweir 			}
2615cdf0e10cSrcweir 		}
2616cdf0e10cSrcweir 	}
2617cdf0e10cSrcweir }
2618cdf0e10cSrcweir 
2619cdf0e10cSrcweir // ---------------------------------------------------------
2620cdf0e10cSrcweir 
2621cdf0e10cSrcweir typedef sal_uInt16 (*FncGetChildWindowId)();
2622cdf0e10cSrcweir 
2623cdf0e10cSrcweir FncGetChildWindowId aShowChilds[] =
2624cdf0e10cSrcweir {
2625cdf0e10cSrcweir 	&AnimationChildWindow::GetChildWindowId,
2626cdf0e10cSrcweir 	&Svx3DChildWindow::GetChildWindowId,
2627cdf0e10cSrcweir 	&SvxFontWorkChildWindow::GetChildWindowId,
2628cdf0e10cSrcweir 	&SvxColorChildWindow::GetChildWindowId,
2629cdf0e10cSrcweir 	&SvxSearchDialogWrapper::GetChildWindowId,
2630cdf0e10cSrcweir 	&SvxBmpMaskChildWindow::GetChildWindowId,
2631cdf0e10cSrcweir 	&SvxIMapDlgChildWindow::GetChildWindowId,
2632cdf0e10cSrcweir 	&SvxHyperlinkDlgWrapper::GetChildWindowId,
2633cdf0e10cSrcweir 	&SvxHlinkDlgWrapper::GetChildWindowId,
2634cdf0e10cSrcweir 	&SfxTemplateDialogWrapper::GetChildWindowId,
2635cdf0e10cSrcweir 	&GalleryChildWindow::GetChildWindowId
2636cdf0e10cSrcweir };
2637cdf0e10cSrcweir 
2638cdf0e10cSrcweir #define NAVIGATOR_CHILD_MASK        0x80000000UL
2639cdf0e10cSrcweir 
2640cdf0e10cSrcweir void SlideshowImpl::hideChildWindows()
2641cdf0e10cSrcweir {
2642cdf0e10cSrcweir 	mnChildMask = 0UL;
2643cdf0e10cSrcweir 
2644cdf0e10cSrcweir 	if( ANIMATIONMODE_SHOW == meAnimationMode )
2645cdf0e10cSrcweir 	{
2646cdf0e10cSrcweir 		SfxViewFrame* pViewFrame = getViewFrame();
2647cdf0e10cSrcweir 
2648cdf0e10cSrcweir 		if( pViewFrame )
2649cdf0e10cSrcweir 		{
2650cdf0e10cSrcweir 			if( pViewFrame->GetChildWindow( SID_NAVIGATOR ) != NULL )
2651cdf0e10cSrcweir 				mnChildMask |= NAVIGATOR_CHILD_MASK;
2652cdf0e10cSrcweir 
2653cdf0e10cSrcweir 			for( sal_uLong i = 0, nCount = sizeof( aShowChilds ) / sizeof( FncGetChildWindowId ); i < nCount; i++ )
2654cdf0e10cSrcweir 			{
2655cdf0e10cSrcweir 				const sal_uInt16 nId = ( *aShowChilds[ i ] )();
2656cdf0e10cSrcweir 
2657cdf0e10cSrcweir 				if( pViewFrame->GetChildWindow( nId ) )
2658cdf0e10cSrcweir 				{
2659cdf0e10cSrcweir 					pViewFrame->SetChildWindow( nId, sal_False );
2660cdf0e10cSrcweir 					mnChildMask |= 1 << i;
2661cdf0e10cSrcweir 				}
2662cdf0e10cSrcweir 			}
2663cdf0e10cSrcweir 		}
2664cdf0e10cSrcweir 	}
2665cdf0e10cSrcweir }
2666cdf0e10cSrcweir 
2667cdf0e10cSrcweir // ---------------------------------------------------------
2668cdf0e10cSrcweir 
2669cdf0e10cSrcweir void SlideshowImpl::showChildWindows()
2670cdf0e10cSrcweir {
2671cdf0e10cSrcweir 	if( ANIMATIONMODE_SHOW == meAnimationMode )
2672cdf0e10cSrcweir 	{
2673cdf0e10cSrcweir 		SfxViewFrame* pViewFrame = getViewFrame();
2674cdf0e10cSrcweir 		if( pViewFrame )
2675cdf0e10cSrcweir 		{
2676cdf0e10cSrcweir 			pViewFrame->SetChildWindow( SID_NAVIGATOR, ( mnChildMask & NAVIGATOR_CHILD_MASK ) != 0 );
2677cdf0e10cSrcweir 
2678cdf0e10cSrcweir 			for( sal_uLong i = 0, nCount = sizeof( aShowChilds ) / sizeof( FncGetChildWindowId ); i < nCount; i++ )
2679cdf0e10cSrcweir 			{
2680cdf0e10cSrcweir 				if( mnChildMask & ( 1 << i ) )
2681cdf0e10cSrcweir 					pViewFrame->SetChildWindow( ( *aShowChilds[ i ] )(), sal_True );
2682cdf0e10cSrcweir 			}
2683cdf0e10cSrcweir 		}
2684cdf0e10cSrcweir 	}
2685cdf0e10cSrcweir }
2686cdf0e10cSrcweir 
2687cdf0e10cSrcweir // ---------------------------------------------------------
2688cdf0e10cSrcweir 
2689cdf0e10cSrcweir SfxViewFrame* SlideshowImpl::getViewFrame() const
2690cdf0e10cSrcweir {
2691cdf0e10cSrcweir 	return mpViewShell ? mpViewShell->GetViewFrame() : 0;
2692cdf0e10cSrcweir }
2693cdf0e10cSrcweir 
2694cdf0e10cSrcweir // ---------------------------------------------------------
2695cdf0e10cSrcweir 
2696cdf0e10cSrcweir SfxDispatcher* SlideshowImpl::getDispatcher() const
2697cdf0e10cSrcweir {
2698cdf0e10cSrcweir 	return (mpViewShell && mpViewShell->GetViewFrame()) ? mpViewShell->GetViewFrame()->GetDispatcher() : 0;
2699cdf0e10cSrcweir }
2700cdf0e10cSrcweir 
2701cdf0e10cSrcweir // ---------------------------------------------------------
2702cdf0e10cSrcweir 
2703cdf0e10cSrcweir SfxBindings* SlideshowImpl::getBindings() const
2704cdf0e10cSrcweir {
2705cdf0e10cSrcweir 	return (mpViewShell && mpViewShell->GetViewFrame()) ? &mpViewShell->GetViewFrame()->GetBindings() : 0;
2706cdf0e10cSrcweir }
2707cdf0e10cSrcweir 
2708cdf0e10cSrcweir // ---------------------------------------------------------
2709cdf0e10cSrcweir 
2710cdf0e10cSrcweir void SlideshowImpl::resize( const Size& rSize )
2711cdf0e10cSrcweir {
2712cdf0e10cSrcweir 	maPresSize = rSize;
2713cdf0e10cSrcweir 
2714cdf0e10cSrcweir     if( mpShowWindow && (ANIMATIONMODE_VIEW != meAnimationMode) )
2715cdf0e10cSrcweir     {
2716cdf0e10cSrcweir 	    mpShowWindow->SetSizePixel( maPresSize );
2717cdf0e10cSrcweir 	    mpShowWindow->Show();
2718cdf0e10cSrcweir 
2719cdf0e10cSrcweir         // Call ToTop() to bring the window to top if
2720cdf0e10cSrcweir         // a) the old size is not degenerate (then the window will be closed
2721cdf0e10cSrcweir         // soon) and
2722cdf0e10cSrcweir         // b) the animation mode is not that of a preview (on the one hand
2723cdf0e10cSrcweir         // this leaves the old behaviour for the slide show mode unmodified
2724cdf0e10cSrcweir         // and on the other hand does not move the focus from the document
2725cdf0e10cSrcweir         // to the (preview) window; the ToTop() seems not to be necessary at
2726cdf0e10cSrcweir         // least for the preview).
2727cdf0e10cSrcweir //        if( !aOldSize.Width() && !aOldSize.Height() )
2728cdf0e10cSrcweir //			mpShowWindow->ToTop();
2729cdf0e10cSrcweir 	}
2730cdf0e10cSrcweir 
2731cdf0e10cSrcweir 	if( mxView.is() ) try
2732cdf0e10cSrcweir 	{
2733cdf0e10cSrcweir 		awt::WindowEvent aEvt;
2734cdf0e10cSrcweir 		mxView->windowResized(aEvt);
2735cdf0e10cSrcweir 	}
2736cdf0e10cSrcweir 	catch( Exception& e )
2737cdf0e10cSrcweir 	{
2738cdf0e10cSrcweir 		static_cast<void>(e);
2739cdf0e10cSrcweir 		DBG_ERROR(
2740cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::resize(), "
2741cdf0e10cSrcweir 					"exception caught: ") +
2742cdf0e10cSrcweir 			rtl::OUStringToOString(
2743cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
2744cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
2745cdf0e10cSrcweir 	}
2746cdf0e10cSrcweir }
2747cdf0e10cSrcweir 
2748cdf0e10cSrcweir // -----------------------------------------------------------------------------
2749cdf0e10cSrcweir 
2750cdf0e10cSrcweir void SlideshowImpl::setActiveXToolbarsVisible( sal_Bool bVisible )
2751cdf0e10cSrcweir {
2752cdf0e10cSrcweir     // in case of ActiveX control the toolbars should not be visible if slide show runs in window mode
2753cdf0e10cSrcweir     // actually it runs always in window mode in case of ActiveX control
2754cdf0e10cSrcweir     if ( !maPresSettings.mbFullScreen && mpDocSh && mpDocSh->GetMedium() )
2755cdf0e10cSrcweir     {
2756cdf0e10cSrcweir         SFX_ITEMSET_ARG( mpDocSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False );
2757cdf0e10cSrcweir         if ( pItem && pItem->GetValue() )
2758cdf0e10cSrcweir         {
2759cdf0e10cSrcweir             // this is a plugin/activex mode, no toolbars should be visible during slide show
2760cdf0e10cSrcweir             // after the end of slide show they should be visible again
2761cdf0e10cSrcweir             SfxViewFrame* pViewFrame = getViewFrame();
2762cdf0e10cSrcweir             if( pViewFrame )
2763cdf0e10cSrcweir             {
2764cdf0e10cSrcweir                 try
2765cdf0e10cSrcweir                 {
2766cdf0e10cSrcweir                     Reference< frame::XLayoutManager > xLayoutManager;
2767cdf0e10cSrcweir                     Reference< beans::XPropertySet > xFrameProps( pViewFrame->GetFrame().GetTopFrame().GetFrameInterface(), UNO_QUERY_THROW );
2768cdf0e10cSrcweir                     if ( ( xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) )
2769cdf0e10cSrcweir                                 >>= xLayoutManager )
2770cdf0e10cSrcweir                       && xLayoutManager.is() )
2771cdf0e10cSrcweir                     {
2772cdf0e10cSrcweir                         xLayoutManager->setVisible( bVisible );
2773cdf0e10cSrcweir                     }
2774cdf0e10cSrcweir                 }
2775cdf0e10cSrcweir                 catch( uno::Exception& )
2776cdf0e10cSrcweir                 {}
2777cdf0e10cSrcweir             }
2778cdf0e10cSrcweir         }
2779cdf0e10cSrcweir     }
2780cdf0e10cSrcweir }
2781cdf0e10cSrcweir 
2782cdf0e10cSrcweir // -----------------------------------------------------------------------------
2783cdf0e10cSrcweir 
2784cdf0e10cSrcweir void SAL_CALL SlideshowImpl::activate() throw (RuntimeException)
2785cdf0e10cSrcweir {
2786cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2787cdf0e10cSrcweir 
2788cdf0e10cSrcweir 	maDeactivateTimer.Stop();
2789cdf0e10cSrcweir 
2790cdf0e10cSrcweir 	if( !mbActive && mxShow.is() )
2791cdf0e10cSrcweir 	{
2792cdf0e10cSrcweir 		mbActive = sal_True;
2793cdf0e10cSrcweir 
2794cdf0e10cSrcweir 		if( ANIMATIONMODE_SHOW == meAnimationMode )
2795cdf0e10cSrcweir 		{
2796cdf0e10cSrcweir 			if( mbAutoSaveWasOn )
2797cdf0e10cSrcweir 				setAutoSaveState( false );
2798cdf0e10cSrcweir 
2799cdf0e10cSrcweir 			if( mpShowWindow )
2800cdf0e10cSrcweir 			{
2801cdf0e10cSrcweir 				SfxViewFrame* pViewFrame = getViewFrame();
2802cdf0e10cSrcweir 				SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : 0;
2803cdf0e10cSrcweir 
2804cdf0e10cSrcweir 				hideChildWindows();
2805cdf0e10cSrcweir 
2806cdf0e10cSrcweir 				if( pDispatcher )
2807cdf0e10cSrcweir 				{
2808cdf0e10cSrcweir 					// filter all forbiden slots
2809cdf0e10cSrcweir 					pDispatcher->SetSlotFilter( sal_True, sizeof(pAllowed) / sizeof(sal_uInt16), pAllowed );
2810cdf0e10cSrcweir 				}
2811cdf0e10cSrcweir 
2812cdf0e10cSrcweir 				if( getBindings() )
2813cdf0e10cSrcweir 					getBindings()->InvalidateAll(sal_True);
2814cdf0e10cSrcweir 
2815cdf0e10cSrcweir 				mpShowWindow->GrabFocus();
2816cdf0e10cSrcweir 			}
2817cdf0e10cSrcweir 		}
2818cdf0e10cSrcweir 
2819cdf0e10cSrcweir 		resume();
2820cdf0e10cSrcweir 	}
2821cdf0e10cSrcweir }
2822cdf0e10cSrcweir 
2823cdf0e10cSrcweir // -----------------------------------------------------------------------------
2824cdf0e10cSrcweir 
2825cdf0e10cSrcweir void SAL_CALL SlideshowImpl::deactivate() throw (RuntimeException)
2826cdf0e10cSrcweir {
2827cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2828cdf0e10cSrcweir 
2829cdf0e10cSrcweir 	if( mbActive && mxShow.is() )
2830cdf0e10cSrcweir 	{
2831cdf0e10cSrcweir 		maDeactivateTimer.Start();
2832cdf0e10cSrcweir 	}
2833cdf0e10cSrcweir }
2834cdf0e10cSrcweir 
2835cdf0e10cSrcweir // -----------------------------------------------------------------------------
2836cdf0e10cSrcweir 
2837cdf0e10cSrcweir IMPL_LINK( SlideshowImpl, deactivateHdl, Timer*, EMPTYARG )
2838cdf0e10cSrcweir {
2839cdf0e10cSrcweir 	if( mbActive && mxShow.is() )
2840cdf0e10cSrcweir 	{
2841cdf0e10cSrcweir 		mbActive = sal_False;
2842cdf0e10cSrcweir 
2843cdf0e10cSrcweir 		pause();
2844cdf0e10cSrcweir 
2845cdf0e10cSrcweir 		if( ANIMATIONMODE_SHOW == meAnimationMode )
2846cdf0e10cSrcweir 		{
2847cdf0e10cSrcweir 			if( mbAutoSaveWasOn )
2848cdf0e10cSrcweir 				setAutoSaveState( true );
2849cdf0e10cSrcweir 
2850cdf0e10cSrcweir 			if( mpShowWindow )
2851cdf0e10cSrcweir 			{
2852cdf0e10cSrcweir 				showChildWindows();
2853cdf0e10cSrcweir 			}
2854cdf0e10cSrcweir 		}
2855cdf0e10cSrcweir 	}
2856cdf0e10cSrcweir 	return 0;
2857cdf0e10cSrcweir }
2858cdf0e10cSrcweir 
2859cdf0e10cSrcweir // ---------------------------------------------------------
2860cdf0e10cSrcweir 
2861cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isActive() throw (RuntimeException)
2862cdf0e10cSrcweir {
2863cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2864cdf0e10cSrcweir 	return mbActive;
2865cdf0e10cSrcweir }
2866cdf0e10cSrcweir 
2867cdf0e10cSrcweir // -----------------------------------------------------------------------------
2868cdf0e10cSrcweir 
2869cdf0e10cSrcweir void SlideshowImpl::receiveRequest(SfxRequest& rReq)
2870cdf0e10cSrcweir {
2871cdf0e10cSrcweir 	const SfxItemSet* pArgs 	 = rReq.GetArgs();
2872cdf0e10cSrcweir 
2873cdf0e10cSrcweir 	switch ( rReq.GetSlot() )
2874cdf0e10cSrcweir 	{
2875cdf0e10cSrcweir 		case SID_NAVIGATOR_PEN:
2876cdf0e10cSrcweir             setUsePen(!mbUsePen);
2877cdf0e10cSrcweir 		break;
2878cdf0e10cSrcweir 
2879cdf0e10cSrcweir 		case SID_NAVIGATOR_PAGE:
2880cdf0e10cSrcweir 		{
2881cdf0e10cSrcweir 			PageJump	eJump = (PageJump)((SfxAllEnumItem&) pArgs->Get(SID_NAVIGATOR_PAGE)).GetValue();
2882cdf0e10cSrcweir 			switch( eJump )
2883cdf0e10cSrcweir 			{
2884cdf0e10cSrcweir 				case PAGE_FIRST:		gotoFirstSlide(); break;
2885cdf0e10cSrcweir 				case PAGE_LAST:			gotoLastSlide(); break;
2886cdf0e10cSrcweir 				case PAGE_NEXT:			gotoNextSlide(); break;
2887cdf0e10cSrcweir 				case PAGE_PREVIOUS:		gotoPreviousSlide(); break;
2888cdf0e10cSrcweir 				case PAGE_NONE:			break;
2889cdf0e10cSrcweir 			}
2890cdf0e10cSrcweir 		}
2891cdf0e10cSrcweir 		break;
2892cdf0e10cSrcweir 
2893cdf0e10cSrcweir 		case SID_NAVIGATOR_OBJECT:
2894cdf0e10cSrcweir 		{
2895cdf0e10cSrcweir 			const String aTarget( ((SfxStringItem&) pArgs->Get(SID_NAVIGATOR_OBJECT)).GetValue() );
2896cdf0e10cSrcweir 
2897cdf0e10cSrcweir 			// is the bookmark a Slide?
2898cdf0e10cSrcweir 			sal_Bool        bIsMasterPage;
2899cdf0e10cSrcweir 			sal_uInt16	    nPgNum = mpDoc->GetPageByName( aTarget, bIsMasterPage );
2900cdf0e10cSrcweir 			SdrObject*  pObj   = NULL;
2901cdf0e10cSrcweir 
2902cdf0e10cSrcweir 			if( nPgNum == SDRPAGE_NOTFOUND )
2903cdf0e10cSrcweir 			{
2904cdf0e10cSrcweir 				// is the bookmark an object?
2905cdf0e10cSrcweir 				pObj = mpDoc->GetObj( aTarget );
2906cdf0e10cSrcweir 
2907cdf0e10cSrcweir 				if( pObj )
2908cdf0e10cSrcweir 					nPgNum = pObj->GetPage()->GetPageNum();
2909cdf0e10cSrcweir 			}
2910cdf0e10cSrcweir 
2911cdf0e10cSrcweir 			if( nPgNum != SDRPAGE_NOTFOUND )
2912cdf0e10cSrcweir 			{
2913cdf0e10cSrcweir 				nPgNum = ( nPgNum - 1 ) >> 1;
2914cdf0e10cSrcweir 				displaySlideNumber( nPgNum );
2915cdf0e10cSrcweir 			}
2916cdf0e10cSrcweir 		}
2917cdf0e10cSrcweir 		break;
2918cdf0e10cSrcweir 	}
2919cdf0e10cSrcweir }
2920cdf0e10cSrcweir 
2921cdf0e10cSrcweir // ---------------------------------------------------------
2922cdf0e10cSrcweir 
2923cdf0e10cSrcweir void SlideshowImpl::setAutoSaveState( bool bOn)
2924cdf0e10cSrcweir {
2925cdf0e10cSrcweir 	try
2926cdf0e10cSrcweir 	{
2927cdf0e10cSrcweir 		uno::Reference<lang::XMultiServiceFactory> xFac( ::comphelper::getProcessServiceFactory() );
2928cdf0e10cSrcweir 
2929cdf0e10cSrcweir 		uno::Reference< util::XURLTransformer > xParser(
2930cdf0e10cSrcweir 			xFac->createInstance( OUString::createFromAscii("com.sun.star.util.URLTransformer" ) ),
2931cdf0e10cSrcweir 				uno::UNO_QUERY_THROW);
2932cdf0e10cSrcweir 		util::URL aURL;
2933cdf0e10cSrcweir 		aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/setAutoSaveState");
2934cdf0e10cSrcweir 		xParser->parseStrict(aURL);
2935cdf0e10cSrcweir 
2936cdf0e10cSrcweir 		Sequence< beans::PropertyValue > aArgs(1);
2937cdf0e10cSrcweir 		aArgs[0].Name = OUString::createFromAscii("AutoSaveState");
2938cdf0e10cSrcweir 		aArgs[0].Value <<= bOn ? sal_True : sal_False;
2939cdf0e10cSrcweir 
2940cdf0e10cSrcweir 		uno::Reference< frame::XDispatch > xAutoSave(
2941cdf0e10cSrcweir 			xFac->createInstance(OUString::createFromAscii("com.sun.star.frame.AutoRecovery")),
2942cdf0e10cSrcweir 			uno::UNO_QUERY_THROW);
2943cdf0e10cSrcweir 		xAutoSave->dispatch(aURL, aArgs);
2944cdf0e10cSrcweir 	}
2945cdf0e10cSrcweir 	catch( Exception& )
2946cdf0e10cSrcweir 	{
2947cdf0e10cSrcweir 		DBG_ERROR("sd::SlideshowImpl::setAutoSaveState(), exception caught!");
2948cdf0e10cSrcweir 	}
2949cdf0e10cSrcweir }
2950cdf0e10cSrcweir 
2951cdf0e10cSrcweir // ---------------------------------------------------------
2952cdf0e10cSrcweir 
2953cdf0e10cSrcweir Reference< XDrawPage > SAL_CALL SlideshowImpl::getCurrentSlide() throw (RuntimeException)
2954cdf0e10cSrcweir {
2955cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2956cdf0e10cSrcweir 
2957cdf0e10cSrcweir 	Reference< XDrawPage > xSlide;
2958cdf0e10cSrcweir 	if( mxShow.is() && mpSlideController.get() )
2959cdf0e10cSrcweir 	{
2960cdf0e10cSrcweir 		sal_Int32 nSlide = getCurrentSlideNumber();
2961cdf0e10cSrcweir 		if( (nSlide >= 0) && (nSlide < mpSlideController->getSlideNumberCount() ) )
2962cdf0e10cSrcweir 			xSlide = mpSlideController->getSlideByNumber( nSlide );
2963cdf0e10cSrcweir 	}
2964cdf0e10cSrcweir 
2965cdf0e10cSrcweir 	return xSlide;
2966cdf0e10cSrcweir }
2967cdf0e10cSrcweir 
2968cdf0e10cSrcweir // ---------------------------------------------------------
2969cdf0e10cSrcweir 
2970cdf0e10cSrcweir sal_Int32 SAL_CALL SlideshowImpl::getNextSlideIndex() throw (RuntimeException)
2971cdf0e10cSrcweir {
2972cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2973cdf0e10cSrcweir 
2974cdf0e10cSrcweir 	if( mxShow.is() )
2975cdf0e10cSrcweir 	{
2976cdf0e10cSrcweir         return mpSlideController->getNextSlideIndex();
2977cdf0e10cSrcweir 	}
2978cdf0e10cSrcweir 	else
2979cdf0e10cSrcweir 	{
2980cdf0e10cSrcweir 		return -1;
2981cdf0e10cSrcweir 	}
2982cdf0e10cSrcweir }
2983cdf0e10cSrcweir 
2984cdf0e10cSrcweir // ---------------------------------------------------------
2985cdf0e10cSrcweir 
2986cdf0e10cSrcweir sal_Int32 SAL_CALL SlideshowImpl::getCurrentSlideIndex() throw (RuntimeException)
2987cdf0e10cSrcweir {
2988cdf0e10cSrcweir 	return mpSlideController.get() ? mpSlideController->getCurrentSlideIndex() : -1;
2989cdf0e10cSrcweir }
2990cdf0e10cSrcweir 
2991cdf0e10cSrcweir // --------------------------------------------------------------------
2992cdf0e10cSrcweir // ::com::sun::star::presentation::XSlideShowController:
2993cdf0e10cSrcweir // --------------------------------------------------------------------
2994cdf0e10cSrcweir 
2995cdf0e10cSrcweir ::sal_Int32 SAL_CALL SlideshowImpl::getSlideCount() throw (RuntimeException)
2996cdf0e10cSrcweir {
2997cdf0e10cSrcweir 	return mpSlideController.get() ? mpSlideController->getSlideIndexCount() : 0;
2998cdf0e10cSrcweir }
2999cdf0e10cSrcweir 
3000cdf0e10cSrcweir // --------------------------------------------------------------------
3001cdf0e10cSrcweir 
3002cdf0e10cSrcweir Reference< XDrawPage > SAL_CALL SlideshowImpl::getSlideByIndex(::sal_Int32 Index) throw (RuntimeException, css::lang::IndexOutOfBoundsException)
3003cdf0e10cSrcweir {
3004cdf0e10cSrcweir 	if( (mpSlideController.get() == 0 ) || (Index < 0) || (Index >= mpSlideController->getSlideIndexCount() ) )
3005cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
3006cdf0e10cSrcweir 
3007cdf0e10cSrcweir 	return mpSlideController->getSlideByNumber( mpSlideController->getSlideNumber( Index ) );
3008cdf0e10cSrcweir }
3009cdf0e10cSrcweir 
3010cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::getAlwaysOnTop() throw (RuntimeException)
3011cdf0e10cSrcweir {
3012cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3013cdf0e10cSrcweir 	return maPresSettings.mbAlwaysOnTop;
3014cdf0e10cSrcweir }
3015cdf0e10cSrcweir 
3016cdf0e10cSrcweir // --------------------------------------------------------------------
3017cdf0e10cSrcweir 
3018cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setAlwaysOnTop( sal_Bool bAlways ) throw (RuntimeException)
3019cdf0e10cSrcweir {
3020cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3021cdf0e10cSrcweir 	if( maPresSettings.mbAlwaysOnTop != bAlways )
3022cdf0e10cSrcweir 	{
3023cdf0e10cSrcweir 		maPresSettings.mbAlwaysOnTop = bAlways;
3024cdf0e10cSrcweir 		// todo, can this be changed while running?
3025cdf0e10cSrcweir 	}
3026cdf0e10cSrcweir }
3027cdf0e10cSrcweir 
3028cdf0e10cSrcweir // --------------------------------------------------------------------
3029cdf0e10cSrcweir 
3030cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isFullScreen() throw (RuntimeException)
3031cdf0e10cSrcweir {
3032cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3033cdf0e10cSrcweir 	return maPresSettings.mbFullScreen;
3034cdf0e10cSrcweir }
3035cdf0e10cSrcweir 
3036cdf0e10cSrcweir // --------------------------------------------------------------------
3037cdf0e10cSrcweir 
3038cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::getMouseVisible() throw (RuntimeException)
3039cdf0e10cSrcweir {
3040cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3041cdf0e10cSrcweir 	return maPresSettings.mbMouseVisible;
3042cdf0e10cSrcweir }
3043cdf0e10cSrcweir 
3044cdf0e10cSrcweir // --------------------------------------------------------------------
3045cdf0e10cSrcweir 
3046cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setMouseVisible( sal_Bool bVisible ) throw (RuntimeException)
3047cdf0e10cSrcweir {
3048cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3049cdf0e10cSrcweir 	if( maPresSettings.mbMouseVisible != bVisible )
3050cdf0e10cSrcweir 	{
3051cdf0e10cSrcweir 		maPresSettings.mbMouseVisible = bVisible;
3052cdf0e10cSrcweir 		if( mpShowWindow )
3053cdf0e10cSrcweir 			mpShowWindow->SetMouseAutoHide( !maPresSettings.mbMouseVisible );
3054cdf0e10cSrcweir 	}
3055cdf0e10cSrcweir }
3056cdf0e10cSrcweir 
3057cdf0e10cSrcweir // --------------------------------------------------------------------
3058cdf0e10cSrcweir 
3059cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::getUsePen() throw (RuntimeException)
3060cdf0e10cSrcweir {
3061cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3062cdf0e10cSrcweir 	return mbUsePen;
3063cdf0e10cSrcweir }
3064cdf0e10cSrcweir 
3065cdf0e10cSrcweir // --------------------------------------------------------------------
3066cdf0e10cSrcweir 
3067cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setUsePen( sal_Bool bMouseAsPen ) throw (RuntimeException)
3068cdf0e10cSrcweir {
3069cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3070cdf0e10cSrcweir 	mbUsePen = bMouseAsPen;
3071cdf0e10cSrcweir     if( mxShow.is() ) try
3072cdf0e10cSrcweir     {
3073cdf0e10cSrcweir 		// For Pencolor;
3074cdf0e10cSrcweir         Any aValue;
3075cdf0e10cSrcweir         if( mbUsePen )
3076cdf0e10cSrcweir 		    aValue <<= mnUserPaintColor;
3077cdf0e10cSrcweir         beans::PropertyValue aPenProp;
3078cdf0e10cSrcweir         aPenProp.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "UserPaintColor" ));
3079cdf0e10cSrcweir         aPenProp.Value = aValue;
3080cdf0e10cSrcweir         mxShow->setProperty( aPenProp );
3081cdf0e10cSrcweir 
3082cdf0e10cSrcweir 		//for StrokeWidth :
3083cdf0e10cSrcweir         if( mbUsePen )
3084cdf0e10cSrcweir 		{
3085cdf0e10cSrcweir 			beans::PropertyValue aPenPropWidth;
3086cdf0e10cSrcweir 			aPenPropWidth.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "UserPaintStrokeWidth" ));
3087cdf0e10cSrcweir 			aPenPropWidth.Value <<= mdUserPaintStrokeWidth;
3088cdf0e10cSrcweir 			mxShow->setProperty( aPenPropWidth );
3089cdf0e10cSrcweir 
3090cdf0e10cSrcweir 			// for Pen Mode
3091cdf0e10cSrcweir 			beans::PropertyValue aPenPropSwitchPenMode;
3092cdf0e10cSrcweir 			aPenPropSwitchPenMode.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SwitchPenMode" ));
3093cdf0e10cSrcweir 			aPenPropSwitchPenMode.Value <<= sal_True;
3094cdf0e10cSrcweir 			mxShow->setProperty( aPenPropSwitchPenMode );
3095cdf0e10cSrcweir 		}
3096cdf0e10cSrcweir 	}
3097cdf0e10cSrcweir 	catch( Exception& e )
3098cdf0e10cSrcweir 	{
3099cdf0e10cSrcweir 		static_cast<void>(e);
3100cdf0e10cSrcweir 		DBG_ERROR(
3101cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::setUsePen(), "
3102cdf0e10cSrcweir 					"exception caught: ") +
3103cdf0e10cSrcweir 			rtl::OUStringToOString(
3104cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
3105cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
3106cdf0e10cSrcweir 	}
3107cdf0e10cSrcweir }
3108cdf0e10cSrcweir 
3109cdf0e10cSrcweir // --------------------------------------------------------------------
3110cdf0e10cSrcweir 
3111cdf0e10cSrcweir double SAL_CALL SlideshowImpl::getPenWidth() throw (RuntimeException)
3112cdf0e10cSrcweir {
3113cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3114cdf0e10cSrcweir     return mdUserPaintStrokeWidth;
3115cdf0e10cSrcweir }
3116cdf0e10cSrcweir 
3117cdf0e10cSrcweir // --------------------------------------------------------------------
3118cdf0e10cSrcweir 
3119cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setPenWidth( double dStrokeWidth ) throw (RuntimeException)
3120cdf0e10cSrcweir {
3121cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3122cdf0e10cSrcweir     mdUserPaintStrokeWidth = dStrokeWidth;
3123cdf0e10cSrcweir 	setUsePen( true ); // enable pen mode, update color and width
3124cdf0e10cSrcweir }
3125cdf0e10cSrcweir 
3126cdf0e10cSrcweir // --------------------------------------------------------------------
3127cdf0e10cSrcweir 
3128cdf0e10cSrcweir sal_Int32 SAL_CALL SlideshowImpl::getPenColor() throw (RuntimeException)
3129cdf0e10cSrcweir {
3130cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3131cdf0e10cSrcweir 	return mnUserPaintColor;
3132cdf0e10cSrcweir }
3133cdf0e10cSrcweir 
3134cdf0e10cSrcweir // --------------------------------------------------------------------
3135cdf0e10cSrcweir 
3136cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setPenColor( sal_Int32 nColor ) throw (RuntimeException)
3137cdf0e10cSrcweir {
3138cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3139cdf0e10cSrcweir 	mnUserPaintColor = nColor;
3140cdf0e10cSrcweir 	setUsePen( true ); // enable pen mode, update color
3141cdf0e10cSrcweir }
3142cdf0e10cSrcweir 
3143cdf0e10cSrcweir // --------------------------------------------------------------------
3144cdf0e10cSrcweir 
3145cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setUseEraser( ::sal_Bool /*_usepen*/ ) throw (css::uno::RuntimeException)
3146cdf0e10cSrcweir {
3147cdf0e10cSrcweir }
3148cdf0e10cSrcweir 
3149cdf0e10cSrcweir // --------------------------------------------------------------------
3150cdf0e10cSrcweir 
3151cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setPenMode( bool bSwitchPenMode ) throw (RuntimeException)
3152cdf0e10cSrcweir {
3153cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3154cdf0e10cSrcweir     setUsePen( bSwitchPenMode ); // SwitchPen Mode
3155cdf0e10cSrcweir 
3156cdf0e10cSrcweir }
3157cdf0e10cSrcweir 
3158cdf0e10cSrcweir // --------------------------------------------------------------------
3159cdf0e10cSrcweir 
3160cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setEraseAllInk(bool bEraseAllInk) throw (RuntimeException)
3161cdf0e10cSrcweir {
3162cdf0e10cSrcweir 	if( bEraseAllInk )
3163cdf0e10cSrcweir 	{
3164cdf0e10cSrcweir  		::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3165cdf0e10cSrcweir 		if( mxShow.is() ) try
3166cdf0e10cSrcweir 		{
3167cdf0e10cSrcweir 			beans::PropertyValue aPenPropEraseAllInk;
3168cdf0e10cSrcweir 			aPenPropEraseAllInk.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EraseAllInk" ));
3169cdf0e10cSrcweir 			aPenPropEraseAllInk.Value <<= bEraseAllInk;
3170cdf0e10cSrcweir 			mxShow->setProperty( aPenPropEraseAllInk );
3171cdf0e10cSrcweir 		}
3172cdf0e10cSrcweir 		catch( Exception& e )
3173cdf0e10cSrcweir 		{
3174cdf0e10cSrcweir 			static_cast<void>(e);
3175cdf0e10cSrcweir 			DBG_ERROR(
3176cdf0e10cSrcweir 				(OString("sd::SlideshowImpl::setEraseAllInk(), "
3177cdf0e10cSrcweir 						"exception caught: ") +
3178cdf0e10cSrcweir 				rtl::OUStringToOString(
3179cdf0e10cSrcweir 					comphelper::anyToString( cppu::getCaughtException() ),
3180cdf0e10cSrcweir 					RTL_TEXTENCODING_UTF8 )).getStr() );
3181cdf0e10cSrcweir 		}
3182cdf0e10cSrcweir 	}
3183cdf0e10cSrcweir }
3184cdf0e10cSrcweir 
3185cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setEraseInk( sal_Int32 /*nEraseInkSize*/ ) throw (css::uno::RuntimeException)
3186cdf0e10cSrcweir {
3187cdf0e10cSrcweir }
3188cdf0e10cSrcweir 
3189cdf0e10cSrcweir void SAL_CALL SlideshowImpl::setEraserMode( bool /*bSwitchEraserMode*/ ) throw (css::uno::RuntimeException)
3190cdf0e10cSrcweir {
3191cdf0e10cSrcweir }
3192cdf0e10cSrcweir 
3193cdf0e10cSrcweir // --------------------------------------------------------------------
3194cdf0e10cSrcweir // XSlideShowController Methods
3195cdf0e10cSrcweir // --------------------------------------------------------------------
3196cdf0e10cSrcweir 
3197cdf0e10cSrcweir sal_Bool SAL_CALL SlideshowImpl::isRunning(  ) throw (RuntimeException)
3198cdf0e10cSrcweir {
3199cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3200cdf0e10cSrcweir 	return mxShow.is();
3201cdf0e10cSrcweir }
3202cdf0e10cSrcweir 
3203cdf0e10cSrcweir // --------------------------------------------------------------------
3204cdf0e10cSrcweir 
3205cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoNextEffect(  ) throw (RuntimeException)
3206cdf0e10cSrcweir {
3207cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3208cdf0e10cSrcweir 
3209cdf0e10cSrcweir 	if( mxShow.is() && mpSlideController.get() && mpShowWindow )
3210cdf0e10cSrcweir 	{
3211cdf0e10cSrcweir 		if( mbIsPaused )
3212cdf0e10cSrcweir 			resume();
3213cdf0e10cSrcweir 
3214cdf0e10cSrcweir 		const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
3215cdf0e10cSrcweir 		if( eMode == SHOWWINDOWMODE_END )
3216cdf0e10cSrcweir 		{
3217cdf0e10cSrcweir 			endPresentation();
3218cdf0e10cSrcweir 		}
3219cdf0e10cSrcweir 		else if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
3220cdf0e10cSrcweir 		{
3221cdf0e10cSrcweir 			mpShowWindow->RestartShow();
3222cdf0e10cSrcweir 		}
3223cdf0e10cSrcweir 		else
3224cdf0e10cSrcweir 		{
3225cdf0e10cSrcweir 			mxShow->nextEffect();
3226cdf0e10cSrcweir 			update();
3227cdf0e10cSrcweir 		}
3228cdf0e10cSrcweir 	}
3229cdf0e10cSrcweir }
3230cdf0e10cSrcweir 
3231cdf0e10cSrcweir // --------------------------------------------------------------------
3232cdf0e10cSrcweir 
3233cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoPreviousEffect(  ) throw (RuntimeException)
3234cdf0e10cSrcweir {
3235cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3236cdf0e10cSrcweir 
3237cdf0e10cSrcweir 	if( mxShow.is() && mpSlideController.get() && mpShowWindow )
3238cdf0e10cSrcweir 	{
3239cdf0e10cSrcweir 		if( mbIsPaused )
3240cdf0e10cSrcweir 			resume();
3241cdf0e10cSrcweir 
3242cdf0e10cSrcweir 		const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
3243cdf0e10cSrcweir 		if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
3244cdf0e10cSrcweir 		{
3245cdf0e10cSrcweir 			mpShowWindow->RestartShow();
3246cdf0e10cSrcweir 		}
3247cdf0e10cSrcweir 		else
3248cdf0e10cSrcweir 		{
3249cdf0e10cSrcweir 			mxShow->previousEffect();
3250cdf0e10cSrcweir 			update();
3251cdf0e10cSrcweir 		}
3252cdf0e10cSrcweir 	}
3253cdf0e10cSrcweir }
3254cdf0e10cSrcweir 
3255cdf0e10cSrcweir // --------------------------------------------------------------------
3256cdf0e10cSrcweir 
3257cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoFirstSlide(  ) throw (RuntimeException)
3258cdf0e10cSrcweir {
3259cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3260cdf0e10cSrcweir 
3261cdf0e10cSrcweir 	if( mpShowWindow && mpSlideController.get() )
3262cdf0e10cSrcweir 	{
3263cdf0e10cSrcweir 		if( mbIsPaused )
3264cdf0e10cSrcweir 			resume();
3265cdf0e10cSrcweir 
3266cdf0e10cSrcweir 		if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_END )
3267cdf0e10cSrcweir 		{
3268cdf0e10cSrcweir 			if( mpSlideController->getSlideIndexCount() )
3269cdf0e10cSrcweir 				mpShowWindow->RestartShow( 0);
3270cdf0e10cSrcweir 		}
3271cdf0e10cSrcweir 		else
3272cdf0e10cSrcweir 		{
3273cdf0e10cSrcweir 			displaySlideIndex( 0 );
3274cdf0e10cSrcweir 		}
3275cdf0e10cSrcweir 	}
3276cdf0e10cSrcweir }
3277cdf0e10cSrcweir 
3278cdf0e10cSrcweir // --------------------------------------------------------------------
3279cdf0e10cSrcweir 
3280cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoNextSlide(  ) throw (RuntimeException)
3281cdf0e10cSrcweir {
3282cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3283cdf0e10cSrcweir 
3284cdf0e10cSrcweir 	if( mbIsPaused )
3285cdf0e10cSrcweir 		resume();
3286cdf0e10cSrcweir 
3287cdf0e10cSrcweir 	const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
3288cdf0e10cSrcweir 	if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
3289cdf0e10cSrcweir 	{
3290cdf0e10cSrcweir 		mpShowWindow->RestartShow();
3291cdf0e10cSrcweir 	}
3292cdf0e10cSrcweir 	else
3293cdf0e10cSrcweir 	{
3294cdf0e10cSrcweir 		// if this is a show, ignore user inputs and
3295cdf0e10cSrcweir 		// start 20ms timer to reenable inputs to fiter
3296cdf0e10cSrcweir 		// buffered inputs during slide transition
3297cdf0e10cSrcweir 		if( meAnimationMode == ANIMATIONMODE_SHOW )
3298cdf0e10cSrcweir 		{
3299cdf0e10cSrcweir 			mbInputFreeze = true;
3300cdf0e10cSrcweir 			maInputFreezeTimer.Start();
3301cdf0e10cSrcweir 		}
3302cdf0e10cSrcweir 
3303cdf0e10cSrcweir 		if( mpSlideController.get() )
3304cdf0e10cSrcweir 		{
3305cdf0e10cSrcweir 			if( mpSlideController->nextSlide() )
3306cdf0e10cSrcweir 			{
3307cdf0e10cSrcweir 				displayCurrentSlide();
3308cdf0e10cSrcweir 			}
3309cdf0e10cSrcweir 			else
3310cdf0e10cSrcweir 			{
3311cdf0e10cSrcweir 				stopSound();
3312cdf0e10cSrcweir 
3313cdf0e10cSrcweir 				if( meAnimationMode == ANIMATIONMODE_PREVIEW )
3314cdf0e10cSrcweir 				{
3315cdf0e10cSrcweir 					endPresentation();
3316cdf0e10cSrcweir 				}
3317cdf0e10cSrcweir 				else if( maPresSettings.mbEndless )
3318cdf0e10cSrcweir 				{
3319cdf0e10cSrcweir 					if( maPresSettings.mnPauseTimeout )
3320cdf0e10cSrcweir 					{
3321cdf0e10cSrcweir 						if( mpShowWindow )
3322cdf0e10cSrcweir 						{
3323cdf0e10cSrcweir 							Graphic aGraphic( SfxApplication::GetApplicationLogo().GetBitmapEx() );
3324cdf0e10cSrcweir 							mpShowWindow->SetPauseMode( 0, maPresSettings.mnPauseTimeout, &aGraphic );
3325cdf0e10cSrcweir 						}
3326cdf0e10cSrcweir 					}
3327cdf0e10cSrcweir 					else
3328cdf0e10cSrcweir 					{
3329cdf0e10cSrcweir 						displaySlideIndex( 0 );
3330cdf0e10cSrcweir 					}
3331cdf0e10cSrcweir 				}
3332cdf0e10cSrcweir 				else
3333cdf0e10cSrcweir 				{
3334cdf0e10cSrcweir 					if( mpShowWindow )
3335cdf0e10cSrcweir 					{
3336cdf0e10cSrcweir 						mpShowWindow->SetEndMode();
3337cdf0e10cSrcweir 						pause();
3338cdf0e10cSrcweir 					}
3339cdf0e10cSrcweir 				}
3340cdf0e10cSrcweir 			}
3341cdf0e10cSrcweir 		}
3342cdf0e10cSrcweir 	}
3343cdf0e10cSrcweir }
3344cdf0e10cSrcweir 
3345cdf0e10cSrcweir // --------------------------------------------------------------------
3346cdf0e10cSrcweir 
3347cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoPreviousSlide(  ) throw (RuntimeException)
3348cdf0e10cSrcweir {
3349cdf0e10cSrcweir     gotoPreviousSlide(false);
3350cdf0e10cSrcweir }
3351cdf0e10cSrcweir 
3352cdf0e10cSrcweir void SlideshowImpl::gotoPreviousSlide (const bool bSkipAllMainSequenceEffects)
3353cdf0e10cSrcweir {
3354cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3355cdf0e10cSrcweir 
3356cdf0e10cSrcweir 	if( mxShow.is() && mpSlideController.get() ) try
3357cdf0e10cSrcweir 	{
3358cdf0e10cSrcweir 		if( mbIsPaused )
3359cdf0e10cSrcweir 			resume();
3360cdf0e10cSrcweir 
3361cdf0e10cSrcweir 		const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
3362cdf0e10cSrcweir 		if( eMode == SHOWWINDOWMODE_END )
3363cdf0e10cSrcweir 		{
3364cdf0e10cSrcweir 			const sal_Int32 nLastSlideIndex = mpSlideController->getSlideIndexCount() - 1;
3365cdf0e10cSrcweir 			if( nLastSlideIndex >= 0 )
3366cdf0e10cSrcweir 				mpShowWindow->RestartShow( nLastSlideIndex );
3367cdf0e10cSrcweir 		}
3368cdf0e10cSrcweir 		else if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
3369cdf0e10cSrcweir 		{
3370cdf0e10cSrcweir 			mpShowWindow->RestartShow();
3371cdf0e10cSrcweir 		}
3372cdf0e10cSrcweir 		else
3373cdf0e10cSrcweir 		{
3374cdf0e10cSrcweir             if( mpSlideController->previousSlide())
3375cdf0e10cSrcweir                 displayCurrentSlide(bSkipAllMainSequenceEffects);
3376cdf0e10cSrcweir             else if (bSkipAllMainSequenceEffects)
3377cdf0e10cSrcweir             {
3378cdf0e10cSrcweir                 // We could not go to the previous slide (probably because
3379cdf0e10cSrcweir                 // the current slide is already the first one).  We still
3380cdf0e10cSrcweir                 // have to call displayCurrentSlide because the calling
3381cdf0e10cSrcweir                 // slideshow can not determine whether there is a previous
3382cdf0e10cSrcweir                 // slide or not and has already prepared for a slide change.
3383cdf0e10cSrcweir                 // This slide change has to be completed now, even when
3384cdf0e10cSrcweir                 // changing to the same slide.
3385cdf0e10cSrcweir                 // Note that in this special case we do NOT pass
3386cdf0e10cSrcweir                 // bSkipAllMainSequenceEffects because we display the same
3387cdf0e10cSrcweir                 // slide as before and do not want to show all its effects.
3388cdf0e10cSrcweir 				displayCurrentSlide(false);
3389cdf0e10cSrcweir             }
3390cdf0e10cSrcweir 		}
3391cdf0e10cSrcweir 	}
3392cdf0e10cSrcweir 	catch( Exception& e )
3393cdf0e10cSrcweir 	{
3394cdf0e10cSrcweir 		static_cast<void>(e);
3395cdf0e10cSrcweir 		DBG_ERROR(
3396cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::gotoPreviousSlide(), "
3397cdf0e10cSrcweir 					"exception caught: ") +
3398cdf0e10cSrcweir 			rtl::OUStringToOString(
3399cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
3400cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
3401cdf0e10cSrcweir 	}
3402cdf0e10cSrcweir }
3403cdf0e10cSrcweir 
3404cdf0e10cSrcweir // --------------------------------------------------------------------
3405cdf0e10cSrcweir 
3406cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoLastSlide() throw (RuntimeException)
3407cdf0e10cSrcweir {
3408cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3409cdf0e10cSrcweir 
3410cdf0e10cSrcweir 	if( mpSlideController.get() )
3411cdf0e10cSrcweir 	{
3412cdf0e10cSrcweir 		if( mbIsPaused )
3413cdf0e10cSrcweir 			resume();
3414cdf0e10cSrcweir 
3415cdf0e10cSrcweir 		const sal_Int32 nLastSlideIndex = mpSlideController->getSlideIndexCount() - 1;
3416cdf0e10cSrcweir 		if( nLastSlideIndex >= 0 )
3417cdf0e10cSrcweir 		{
3418cdf0e10cSrcweir 			if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_END )
3419cdf0e10cSrcweir 			{
3420cdf0e10cSrcweir 				mpShowWindow->RestartShow( nLastSlideIndex );
3421cdf0e10cSrcweir 			}
3422cdf0e10cSrcweir 			else
3423cdf0e10cSrcweir 			{
3424cdf0e10cSrcweir 				displaySlideIndex( nLastSlideIndex );
3425cdf0e10cSrcweir 			}
3426cdf0e10cSrcweir 		}
3427cdf0e10cSrcweir 	}
3428cdf0e10cSrcweir }
3429cdf0e10cSrcweir 
3430cdf0e10cSrcweir // --------------------------------------------------------------------
3431cdf0e10cSrcweir 
3432cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoBookmark( const OUString& rBookmark ) throw (RuntimeException)
3433cdf0e10cSrcweir {
3434cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3435cdf0e10cSrcweir 
3436cdf0e10cSrcweir 	if( mbIsPaused )
3437cdf0e10cSrcweir 		resume();
3438cdf0e10cSrcweir 
3439cdf0e10cSrcweir 	sal_Int32 nSlideNumber = getSlideNumberForBookmark( rBookmark );
3440cdf0e10cSrcweir 	if( nSlideNumber != -1 )
3441cdf0e10cSrcweir 		displaySlideNumber( nSlideNumber );
3442cdf0e10cSrcweir }
3443cdf0e10cSrcweir 
3444cdf0e10cSrcweir // --------------------------------------------------------------------
3445cdf0e10cSrcweir 
3446cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoSlide( const Reference< XDrawPage >& xSlide )
3447cdf0e10cSrcweir     throw(IllegalArgumentException, RuntimeException)
3448cdf0e10cSrcweir {
3449cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3450cdf0e10cSrcweir 
3451cdf0e10cSrcweir 	if( mpSlideController.get() && xSlide.is() )
3452cdf0e10cSrcweir 	{
3453cdf0e10cSrcweir 		if( mbIsPaused )
3454cdf0e10cSrcweir 			resume();
3455cdf0e10cSrcweir 
3456cdf0e10cSrcweir 		const sal_Int32 nSlideCount = mpSlideController->getSlideNumberCount();
3457cdf0e10cSrcweir 		for( sal_Int32 nSlide = 0; nSlide < nSlideCount; nSlide++ )
3458cdf0e10cSrcweir 		{
3459cdf0e10cSrcweir 			if( mpSlideController->getSlideByNumber( nSlide ) == xSlide )
3460cdf0e10cSrcweir 			{
3461cdf0e10cSrcweir 				displaySlideNumber( nSlide );
3462cdf0e10cSrcweir 			}
3463cdf0e10cSrcweir 		}
3464cdf0e10cSrcweir 	}
3465cdf0e10cSrcweir }
3466cdf0e10cSrcweir 
3467cdf0e10cSrcweir // --------------------------------------------------------------------
3468cdf0e10cSrcweir 
3469cdf0e10cSrcweir void SAL_CALL SlideshowImpl::gotoSlideIndex( sal_Int32 nIndex ) throw (RuntimeException)
3470cdf0e10cSrcweir {
3471cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3472cdf0e10cSrcweir 
3473cdf0e10cSrcweir 	if( mbIsPaused )
3474cdf0e10cSrcweir 		resume();
3475cdf0e10cSrcweir 
3476cdf0e10cSrcweir 	displaySlideIndex( nIndex );
3477cdf0e10cSrcweir }
3478cdf0e10cSrcweir 
3479cdf0e10cSrcweir // --------------------------------------------------------------------
3480cdf0e10cSrcweir 
3481cdf0e10cSrcweir void SAL_CALL SlideshowImpl::stopSound(  ) throw (RuntimeException)
3482cdf0e10cSrcweir {
3483cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3484cdf0e10cSrcweir 
3485cdf0e10cSrcweir 	try
3486cdf0e10cSrcweir 	{
3487cdf0e10cSrcweir 		if( mxPlayer.is() )
3488cdf0e10cSrcweir 		{
3489cdf0e10cSrcweir 			mxPlayer->stop();
3490cdf0e10cSrcweir 			mxPlayer.clear();
3491cdf0e10cSrcweir 		}
3492cdf0e10cSrcweir 	}
3493cdf0e10cSrcweir 	catch( Exception& e )
3494cdf0e10cSrcweir 	{
3495cdf0e10cSrcweir 		static_cast<void>(e);
3496cdf0e10cSrcweir 		DBG_ERROR(
3497cdf0e10cSrcweir 			(OString("sd::SlideshowImpl::stopSound(), "
3498cdf0e10cSrcweir 					"exception caught: ") +
3499cdf0e10cSrcweir 			rtl::OUStringToOString(
3500cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
3501cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
3502cdf0e10cSrcweir 	}
3503cdf0e10cSrcweir }
3504cdf0e10cSrcweir 
3505cdf0e10cSrcweir // --------------------------------------------------------------------
3506cdf0e10cSrcweir // XIndexAccess
3507cdf0e10cSrcweir // --------------------------------------------------------------------
3508cdf0e10cSrcweir 
3509cdf0e10cSrcweir ::sal_Int32 SAL_CALL SlideshowImpl::getCount(  ) throw (::com::sun::star::uno::RuntimeException)
3510cdf0e10cSrcweir {
3511cdf0e10cSrcweir 	return getSlideCount();
3512cdf0e10cSrcweir }
3513cdf0e10cSrcweir 
3514cdf0e10cSrcweir // --------------------------------------------------------------------
3515cdf0e10cSrcweir 
3516cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL SlideshowImpl::getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
3517cdf0e10cSrcweir {
3518cdf0e10cSrcweir 	return Any( getSlideByIndex( Index ) );
3519cdf0e10cSrcweir }
3520cdf0e10cSrcweir 
3521cdf0e10cSrcweir // --------------------------------------------------------------------
3522cdf0e10cSrcweir 
3523cdf0e10cSrcweir ::com::sun::star::uno::Type SAL_CALL SlideshowImpl::getElementType(  ) throw (::com::sun::star::uno::RuntimeException)
3524cdf0e10cSrcweir {
3525cdf0e10cSrcweir 	return XDrawPage::static_type();
3526cdf0e10cSrcweir }
3527cdf0e10cSrcweir 
3528cdf0e10cSrcweir // --------------------------------------------------------------------
3529cdf0e10cSrcweir 
3530cdf0e10cSrcweir ::sal_Bool SAL_CALL SlideshowImpl::hasElements(  ) throw (::com::sun::star::uno::RuntimeException)
3531cdf0e10cSrcweir {
3532cdf0e10cSrcweir 	return getSlideCount() != 0;
3533cdf0e10cSrcweir }
3534cdf0e10cSrcweir 
3535cdf0e10cSrcweir // --------------------------------------------------------------------
3536cdf0e10cSrcweir 
3537cdf0e10cSrcweir Reference< XSlideShow > SAL_CALL SlideshowImpl::getSlideShow() throw (RuntimeException)
3538cdf0e10cSrcweir {
3539cdf0e10cSrcweir 	return mxShow;
3540cdf0e10cSrcweir }
3541cdf0e10cSrcweir 
3542cdf0e10cSrcweir // --------------------------------------------------------------------
3543cdf0e10cSrcweir 
3544cdf0e10cSrcweir 
3545cdf0e10cSrcweir PresentationSettingsEx::PresentationSettingsEx( const PresentationSettingsEx& r )
3546cdf0e10cSrcweir : PresentationSettings( r )
3547cdf0e10cSrcweir , mbRehearseTimings(r.mbRehearseTimings)
3548cdf0e10cSrcweir , mbPreview(r.mbPreview)
3549cdf0e10cSrcweir , mpParentWindow( 0 )
3550cdf0e10cSrcweir {
3551cdf0e10cSrcweir }
3552cdf0e10cSrcweir 
3553cdf0e10cSrcweir PresentationSettingsEx::PresentationSettingsEx( PresentationSettings& r )
3554cdf0e10cSrcweir : PresentationSettings( r )
3555cdf0e10cSrcweir , mbRehearseTimings(sal_False)
3556cdf0e10cSrcweir , mbPreview(sal_False)
3557cdf0e10cSrcweir , mpParentWindow(0)
3558cdf0e10cSrcweir {
3559cdf0e10cSrcweir }
3560cdf0e10cSrcweir 
3561cdf0e10cSrcweir void PresentationSettingsEx::SetArguments( const Sequence< PropertyValue >& rArguments ) throw (IllegalArgumentException)
3562cdf0e10cSrcweir {
3563cdf0e10cSrcweir 	sal_Int32 nArguments = rArguments.getLength();
3564cdf0e10cSrcweir 	const PropertyValue* pValue = rArguments.getConstArray();
3565cdf0e10cSrcweir 
3566cdf0e10cSrcweir 	while( nArguments-- )
3567cdf0e10cSrcweir 	{
3568cdf0e10cSrcweir 		SetPropertyValue( pValue->Name, pValue->Value );
3569cdf0e10cSrcweir 		pValue++;
3570cdf0e10cSrcweir 	}
3571cdf0e10cSrcweir }
3572cdf0e10cSrcweir 
3573cdf0e10cSrcweir void PresentationSettingsEx::SetPropertyValue( const OUString& rProperty, const Any& rValue ) throw (IllegalArgumentException)
3574cdf0e10cSrcweir {
3575cdf0e10cSrcweir 	if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RehearseTimings") ) )
3576cdf0e10cSrcweir 	{
3577cdf0e10cSrcweir 		if( rValue >>= mbRehearseTimings )
3578cdf0e10cSrcweir 			return;
3579cdf0e10cSrcweir 	}
3580cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Preview") ) )
3581cdf0e10cSrcweir 	{
3582cdf0e10cSrcweir 		if( rValue >>= mbPreview )
3583cdf0e10cSrcweir 			return;
3584cdf0e10cSrcweir 	}
3585cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AnimationNode") ) )
3586cdf0e10cSrcweir 	{
3587cdf0e10cSrcweir 		if( rValue >>= mxAnimationNode )
3588cdf0e10cSrcweir 			return;
3589cdf0e10cSrcweir 	}
3590cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ParentWindow") ) )
3591cdf0e10cSrcweir 	{
3592cdf0e10cSrcweir 		Reference< XWindow > xWindow;
3593cdf0e10cSrcweir 		if( rValue >>= xWindow )
3594cdf0e10cSrcweir 		{
3595cdf0e10cSrcweir 			mpParentWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow ) : 0;
3596cdf0e10cSrcweir 			return;
3597cdf0e10cSrcweir 		}
3598cdf0e10cSrcweir 	}
3599cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AllowAnimations") ) )
3600cdf0e10cSrcweir 	{
3601cdf0e10cSrcweir 		if( rValue >>= mbAnimationAllowed )
3602cdf0e10cSrcweir 			return;
3603cdf0e10cSrcweir 	}
3604cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AllowAnimations") ) )
3605cdf0e10cSrcweir 	{
3606cdf0e10cSrcweir 		if( rValue >>= mbAnimationAllowed )
3607cdf0e10cSrcweir 			return;
3608cdf0e10cSrcweir 	}
3609cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FirstPage") ) )
3610cdf0e10cSrcweir 	{
3611cdf0e10cSrcweir 		OUString aPresPage;
3612cdf0e10cSrcweir 		if( rValue >>= aPresPage )
3613cdf0e10cSrcweir 		{
3614cdf0e10cSrcweir 			maPresPage = getUiNameFromPageApiNameImpl(aPresPage);
3615cdf0e10cSrcweir 			mbCustomShow = sal_False;
3616cdf0e10cSrcweir 			mbAll = sal_False;
3617cdf0e10cSrcweir 			return;
3618cdf0e10cSrcweir 		}
3619cdf0e10cSrcweir 		else
3620cdf0e10cSrcweir 		{
3621cdf0e10cSrcweir 			if( rValue >>= mxStartPage )
3622cdf0e10cSrcweir 				return;
3623cdf0e10cSrcweir 		}
3624cdf0e10cSrcweir 	}
3625cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsAlwaysOnTop") ) )
3626cdf0e10cSrcweir 	{
3627cdf0e10cSrcweir 		if( rValue >>= mbAlwaysOnTop )
3628cdf0e10cSrcweir 			return;
3629cdf0e10cSrcweir 	}
3630cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsAutomatic") ) )
3631cdf0e10cSrcweir 	{
3632cdf0e10cSrcweir 		if( rValue >>= mbManual )
3633cdf0e10cSrcweir 			return;
3634cdf0e10cSrcweir 	}
3635cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsEndless") ) )
3636cdf0e10cSrcweir 	{
3637cdf0e10cSrcweir 		if( rValue >>= mbEndless )
3638cdf0e10cSrcweir 			return;
3639cdf0e10cSrcweir 	}
3640cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsFullScreen") ) )
3641cdf0e10cSrcweir 	{
3642cdf0e10cSrcweir 		if( rValue >>= mbFullScreen )
3643cdf0e10cSrcweir 			return;
3644cdf0e10cSrcweir 	}
3645cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsMouseVisible") ) )
3646cdf0e10cSrcweir 	{
3647cdf0e10cSrcweir 		if( rValue >>= mbMouseVisible )
3648cdf0e10cSrcweir 			return;
3649cdf0e10cSrcweir 	}
3650cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Pause") ) )
3651cdf0e10cSrcweir 	{
3652cdf0e10cSrcweir 		sal_Int32 nPause = -1;
3653cdf0e10cSrcweir 		if( (rValue >>= nPause) && (nPause >= 0) )
3654cdf0e10cSrcweir 		{
3655cdf0e10cSrcweir 			mnPauseTimeout = nPause;
3656cdf0e10cSrcweir 			return;
3657cdf0e10cSrcweir 		}
3658cdf0e10cSrcweir 	}
3659cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("StartWithNavigator") ) )
3660cdf0e10cSrcweir 	{
3661cdf0e10cSrcweir 		if( rValue >>= mbStartWithNavigator )
3662cdf0e10cSrcweir 			return;
3663cdf0e10cSrcweir 	}
3664cdf0e10cSrcweir 	else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UsePen") ) )
3665cdf0e10cSrcweir 	{
3666cdf0e10cSrcweir 		if( rValue >>= mbMouseAsPen )
3667cdf0e10cSrcweir 			return;
3668cdf0e10cSrcweir 	}
3669cdf0e10cSrcweir 	throw IllegalArgumentException();
3670cdf0e10cSrcweir }
3671cdf0e10cSrcweir 
3672cdf0e10cSrcweir ////////////////////////////////
3673cdf0e10cSrcweir 
3674cdf0e10cSrcweir // ---------------------------------------------------------
3675cdf0e10cSrcweir // XAnimationListener
3676cdf0e10cSrcweir // ---------------------------------------------------------
3677cdf0e10cSrcweir 
3678cdf0e10cSrcweir SlideShowListenerProxy::SlideShowListenerProxy( const rtl::Reference< SlideshowImpl >& xController, const css::uno::Reference< css::presentation::XSlideShow >& xSlideShow )
3679cdf0e10cSrcweir : maListeners( m_aMutex )
3680cdf0e10cSrcweir , mxController( xController )
3681cdf0e10cSrcweir , mxSlideShow( xSlideShow )
3682cdf0e10cSrcweir {
3683cdf0e10cSrcweir }
3684cdf0e10cSrcweir 
3685cdf0e10cSrcweir // ---------------------------------------------------------
3686cdf0e10cSrcweir 
3687cdf0e10cSrcweir SlideShowListenerProxy::~SlideShowListenerProxy()
3688cdf0e10cSrcweir {
3689cdf0e10cSrcweir }
3690cdf0e10cSrcweir 
3691cdf0e10cSrcweir // ---------------------------------------------------------
3692cdf0e10cSrcweir 
3693cdf0e10cSrcweir void SlideShowListenerProxy::addAsSlideShowListener()
3694cdf0e10cSrcweir {
3695cdf0e10cSrcweir 	if( mxSlideShow.is() )
3696cdf0e10cSrcweir 	{
3697cdf0e10cSrcweir 		Reference< XSlideShowListener > xSlideShowListener( this );
3698cdf0e10cSrcweir 		mxSlideShow->addSlideShowListener( xSlideShowListener );
3699cdf0e10cSrcweir 	}
3700cdf0e10cSrcweir }
3701cdf0e10cSrcweir 
3702cdf0e10cSrcweir // ---------------------------------------------------------
3703cdf0e10cSrcweir 
3704cdf0e10cSrcweir void SlideShowListenerProxy::removeAsSlideShowListener()
3705cdf0e10cSrcweir {
3706cdf0e10cSrcweir 	if( mxSlideShow.is() )
3707cdf0e10cSrcweir 	{
3708cdf0e10cSrcweir 		Reference< XSlideShowListener > xSlideShowListener( this );
3709cdf0e10cSrcweir 		mxSlideShow->removeSlideShowListener( xSlideShowListener );
3710cdf0e10cSrcweir 	}
3711cdf0e10cSrcweir }
3712cdf0e10cSrcweir 
3713cdf0e10cSrcweir // ---------------------------------------------------------
3714cdf0e10cSrcweir 
3715cdf0e10cSrcweir void SlideShowListenerProxy::addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape )
3716cdf0e10cSrcweir {
3717cdf0e10cSrcweir 	if( mxSlideShow.is() )
3718cdf0e10cSrcweir 	{
3719cdf0e10cSrcweir 		Reference< XShapeEventListener > xListener( this );
3720cdf0e10cSrcweir 		mxSlideShow->addShapeEventListener( xListener, xShape );
3721cdf0e10cSrcweir 	}
3722cdf0e10cSrcweir }
3723cdf0e10cSrcweir 
3724cdf0e10cSrcweir // ---------------------------------------------------------
3725cdf0e10cSrcweir 
3726cdf0e10cSrcweir void SlideShowListenerProxy::removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape )
3727cdf0e10cSrcweir {
3728cdf0e10cSrcweir 	if( mxSlideShow.is() )
3729cdf0e10cSrcweir 	{
3730cdf0e10cSrcweir 		Reference< XShapeEventListener > xListener( this );
3731cdf0e10cSrcweir 		mxSlideShow->removeShapeEventListener( xListener, xShape );
3732cdf0e10cSrcweir 	}
3733cdf0e10cSrcweir }
3734cdf0e10cSrcweir 
3735cdf0e10cSrcweir // ---------------------------------------------------------
3736cdf0e10cSrcweir 
3737cdf0e10cSrcweir void SlideShowListenerProxy::addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& xListener )
3738cdf0e10cSrcweir {
3739cdf0e10cSrcweir 	maListeners.addInterface(xListener);
3740cdf0e10cSrcweir }
3741cdf0e10cSrcweir 
3742cdf0e10cSrcweir // ---------------------------------------------------------
3743cdf0e10cSrcweir 
3744cdf0e10cSrcweir void SlideShowListenerProxy::removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& xListener )
3745cdf0e10cSrcweir {
3746cdf0e10cSrcweir 	maListeners.removeInterface(xListener);
3747cdf0e10cSrcweir }
3748cdf0e10cSrcweir 
3749cdf0e10cSrcweir // ---------------------------------------------------------
3750cdf0e10cSrcweir 
3751cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::beginEvent( const Reference< XAnimationNode >& xNode ) throw (RuntimeException)
3752cdf0e10cSrcweir {
3753cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
3754cdf0e10cSrcweir 
3755cdf0e10cSrcweir 	if( maListeners.getLength() >= 0 )
3756cdf0e10cSrcweir 		maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::beginEvent, _1,  boost::cref(xNode) ));
3757cdf0e10cSrcweir }
3758cdf0e10cSrcweir 
3759cdf0e10cSrcweir // ---------------------------------------------------------
3760cdf0e10cSrcweir 
3761cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::endEvent( const Reference< XAnimationNode >& xNode ) throw (RuntimeException)
3762cdf0e10cSrcweir {
3763cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
3764cdf0e10cSrcweir 
3765cdf0e10cSrcweir 	if( maListeners.getLength() >= 0 )
3766cdf0e10cSrcweir 		maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::endEvent, _1, boost::cref(xNode) ));
3767cdf0e10cSrcweir }
3768cdf0e10cSrcweir 
3769cdf0e10cSrcweir // ---------------------------------------------------------
3770cdf0e10cSrcweir 
3771cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::repeat( const Reference< XAnimationNode >& xNode, ::sal_Int32 nRepeat ) throw (RuntimeException)
3772cdf0e10cSrcweir {
3773cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
3774cdf0e10cSrcweir 
3775cdf0e10cSrcweir 	if( maListeners.getLength() >= 0 )
3776cdf0e10cSrcweir 		maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::repeat, _1,  boost::cref(xNode), boost::cref(nRepeat) ));
3777cdf0e10cSrcweir }
3778cdf0e10cSrcweir 
3779cdf0e10cSrcweir // ---------------------------------------------------------
3780cdf0e10cSrcweir // ::com::sun::star::presentation::XSlideShowListener:
3781cdf0e10cSrcweir // ---------------------------------------------------------
3782cdf0e10cSrcweir 
3783cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::paused(  ) throw (::com::sun::star::uno::RuntimeException)
3784cdf0e10cSrcweir {
3785cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
3786cdf0e10cSrcweir 
3787cdf0e10cSrcweir 	if( maListeners.getLength() >= 0 )
3788cdf0e10cSrcweir 		maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::paused ) );
3789cdf0e10cSrcweir }
3790cdf0e10cSrcweir 
3791cdf0e10cSrcweir // ---------------------------------------------------------
3792cdf0e10cSrcweir 
3793cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::resumed(  ) throw (::com::sun::star::uno::RuntimeException)
3794cdf0e10cSrcweir {
3795cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
3796cdf0e10cSrcweir 
3797cdf0e10cSrcweir 	if( maListeners.getLength() >= 0 )
3798cdf0e10cSrcweir 		maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::resumed ) );
3799cdf0e10cSrcweir }
3800cdf0e10cSrcweir 
3801cdf0e10cSrcweir // ---------------------------------------------------------
3802cdf0e10cSrcweir 
3803cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::slideTransitionStarted( ) throw (RuntimeException)
3804cdf0e10cSrcweir {
3805cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
3806cdf0e10cSrcweir 
3807cdf0e10cSrcweir 	if( maListeners.getLength() >= 0 )
3808cdf0e10cSrcweir 		maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideTransitionStarted ) );
3809cdf0e10cSrcweir }
3810cdf0e10cSrcweir 
3811cdf0e10cSrcweir // ---------------------------------------------------------
3812cdf0e10cSrcweir 
3813cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::slideTransitionEnded( ) throw (::com::sun::star::uno::RuntimeException)
3814cdf0e10cSrcweir {
3815cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
3816cdf0e10cSrcweir 
3817cdf0e10cSrcweir 	if( maListeners.getLength() >= 0 )
3818cdf0e10cSrcweir 		maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideTransitionEnded ) );
3819cdf0e10cSrcweir }
3820cdf0e10cSrcweir 
3821cdf0e10cSrcweir // ---------------------------------------------------------
3822cdf0e10cSrcweir 
3823cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::slideAnimationsEnded(  ) throw (::com::sun::star::uno::RuntimeException)
3824cdf0e10cSrcweir {
3825cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
3826cdf0e10cSrcweir 
3827cdf0e10cSrcweir 	if( maListeners.getLength() >= 0 )
3828cdf0e10cSrcweir 		maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideAnimationsEnded ) );
3829cdf0e10cSrcweir }
3830cdf0e10cSrcweir 
3831cdf0e10cSrcweir // ---------------------------------------------------------
3832cdf0e10cSrcweir 
3833cdf0e10cSrcweir void SlideShowListenerProxy::slideEnded(sal_Bool bReverse) throw (RuntimeException)
3834cdf0e10cSrcweir {
3835cdf0e10cSrcweir 	{
3836cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aMutex );
3837cdf0e10cSrcweir 
3838cdf0e10cSrcweir 		if( maListeners.getLength() >= 0 )
3839cdf0e10cSrcweir 			maListeners.forEach<XSlideShowListener>(
3840cdf0e10cSrcweir                 boost::bind( &XSlideShowListener::slideEnded, _1, bReverse) );
3841cdf0e10cSrcweir 	}
3842cdf0e10cSrcweir 
3843cdf0e10cSrcweir 	{
3844cdf0e10cSrcweir 		::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3845cdf0e10cSrcweir 		if( mxController.is() )
3846cdf0e10cSrcweir 			mxController->slideEnded(bReverse);
3847cdf0e10cSrcweir 	}
3848cdf0e10cSrcweir }
3849cdf0e10cSrcweir 
3850cdf0e10cSrcweir // ---------------------------------------------------------
3851cdf0e10cSrcweir 
3852cdf0e10cSrcweir void SlideShowListenerProxy::hyperLinkClicked( rtl::OUString const& aHyperLink ) throw (RuntimeException)
3853cdf0e10cSrcweir {
3854cdf0e10cSrcweir 	{
3855cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aMutex );
3856cdf0e10cSrcweir 
3857cdf0e10cSrcweir 		if( maListeners.getLength() >= 0 )
3858cdf0e10cSrcweir 			maListeners.forEach<XSlideShowListener>( boost::bind( &XSlideShowListener::hyperLinkClicked, _1, boost::cref(aHyperLink) ));
3859cdf0e10cSrcweir 	}
3860cdf0e10cSrcweir 
3861cdf0e10cSrcweir 	{
3862cdf0e10cSrcweir 		::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3863cdf0e10cSrcweir 		if( mxController.is() )
3864cdf0e10cSrcweir 			mxController->hyperLinkClicked(aHyperLink);
3865cdf0e10cSrcweir 	}
3866cdf0e10cSrcweir }
3867cdf0e10cSrcweir 
3868cdf0e10cSrcweir // ---------------------------------------------------------
3869cdf0e10cSrcweir // XEventListener
3870cdf0e10cSrcweir // ---------------------------------------------------------
3871cdf0e10cSrcweir 
3872cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::disposing( const ::com::sun::star::lang::EventObject& aDisposeEvent ) throw (RuntimeException)
3873cdf0e10cSrcweir {
3874cdf0e10cSrcweir 	maListeners.disposeAndClear( aDisposeEvent );
3875cdf0e10cSrcweir 	mxController.clear();
3876cdf0e10cSrcweir 	mxSlideShow.clear();
3877cdf0e10cSrcweir }
3878cdf0e10cSrcweir 
3879cdf0e10cSrcweir // ---------------------------------------------------------
3880cdf0e10cSrcweir // XShapeEventListener
3881cdf0e10cSrcweir // ---------------------------------------------------------
3882cdf0e10cSrcweir 
3883cdf0e10cSrcweir void SAL_CALL SlideShowListenerProxy::click( const Reference< XShape >& xShape, const ::com::sun::star::awt::MouseEvent& aOriginalEvent ) throw (RuntimeException)
3884cdf0e10cSrcweir {
3885cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
3886cdf0e10cSrcweir 	if( mxController.is() )
3887cdf0e10cSrcweir 		mxController->click(xShape, aOriginalEvent );
3888cdf0e10cSrcweir }
3889cdf0e10cSrcweir 
3890cdf0e10cSrcweir } // namespace ::sd
3891