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