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