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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sdext.hxx" 26 27 #include "PresenterProtocolHandler.hxx" 28 #include "PresenterConfigurationAccess.hxx" 29 #include "PresenterController.hxx" 30 #include "PresenterHelper.hxx" 31 #include "PresenterNotesView.hxx" 32 #include "PresenterPaneContainer.hxx" 33 #include "PresenterPaneFactory.hxx" 34 #include "PresenterViewFactory.hxx" 35 #include "PresenterWindowManager.hxx" 36 #include <com/sun/star/frame/XController.hpp> 37 #include <com/sun/star/drawing/SlideSorter.hpp> 38 #include <com/sun/star/drawing/framework/Configuration.hpp> 39 #include <com/sun/star/drawing/framework/XControllerManager.hpp> 40 #include <com/sun/star/drawing/framework/ResourceId.hpp> 41 #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> 42 #include <com/sun/star/presentation/XSlideShow.hpp> 43 #include <com/sun/star/presentation/XSlideShowView.hpp> 44 #include <com/sun/star/presentation/XPresentationSupplier.hpp> 45 #include <cppuhelper/compbase2.hxx> 46 #include <boost/bind.hpp> 47 #include <tools/debug.hxx> 48 49 using namespace ::com::sun::star; 50 using namespace ::com::sun::star::uno; 51 using namespace ::com::sun::star::drawing::framework; 52 using ::rtl::OUString; 53 54 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 55 56 namespace sdext { namespace presenter { 57 58 namespace { 59 const static OUString gsProtocol (A2S("vnd.com.sun.star.comp.PresenterScreen:")); 60 61 class Command 62 { 63 public: 64 virtual void Execute (void) = 0; 65 virtual bool IsEnabled (void) const = 0; 66 virtual Any GetState (void) const = 0; 67 }; 68 69 class GotoPreviousSlideCommand : public Command 70 { 71 public: 72 GotoPreviousSlideCommand ( 73 const rtl::Reference<PresenterController>& rpPresenterController); 74 virtual ~GotoPreviousSlideCommand (void) {} 75 virtual void Execute (void); 76 virtual bool IsEnabled (void) const; 77 virtual Any GetState (void) const; 78 private: 79 rtl::Reference<PresenterController> mpPresenterController; 80 }; 81 82 class GotoNextSlideCommand : public Command 83 { 84 public: 85 GotoNextSlideCommand ( 86 const rtl::Reference<PresenterController>& rpPresenterController); 87 virtual ~GotoNextSlideCommand (void) {} 88 virtual void Execute (void); 89 virtual bool IsEnabled (void) const; 90 virtual Any GetState (void) const; 91 private: 92 rtl::Reference<PresenterController> mpPresenterController; 93 }; 94 95 class GotoNextEffectCommand : public Command 96 { 97 public: 98 GotoNextEffectCommand ( 99 const rtl::Reference<PresenterController>& rpPresenterController); 100 virtual ~GotoNextEffectCommand (void) {} 101 virtual void Execute (void); 102 virtual bool IsEnabled (void) const; 103 virtual Any GetState (void) const; 104 private: 105 rtl::Reference<PresenterController> mpPresenterController; 106 }; 107 108 class SetNotesViewCommand : public Command 109 { 110 public: 111 SetNotesViewCommand ( 112 const bool bOn, 113 const rtl::Reference<PresenterController>& rpPresenterController); 114 virtual ~SetNotesViewCommand (void) {} 115 virtual void Execute (void); 116 virtual bool IsEnabled (void) const; 117 virtual Any GetState (void) const; 118 private: 119 bool mbOn; 120 rtl::Reference<PresenterController> mpPresenterController; 121 bool IsActive (const ::rtl::Reference<PresenterWindowManager>& rpWindowManager) const; 122 }; 123 124 class SetSlideSorterCommand : public Command 125 { 126 public: 127 SetSlideSorterCommand ( 128 const bool bOn, 129 const rtl::Reference<PresenterController>& rpPresenterController); 130 virtual ~SetSlideSorterCommand (void) {} 131 virtual void Execute (void); 132 virtual bool IsEnabled (void) const; 133 virtual Any GetState (void) const; 134 private: 135 bool mbOn; 136 rtl::Reference<PresenterController> mpPresenterController; 137 }; 138 139 class SetHelpViewCommand : public Command 140 { 141 public: 142 SetHelpViewCommand ( 143 const bool bOn, 144 const rtl::Reference<PresenterController>& rpPresenterController); 145 virtual ~SetHelpViewCommand (void) {} 146 virtual void Execute (void); 147 virtual bool IsEnabled (void) const; 148 virtual Any GetState (void) const; 149 private: 150 bool mbOn; 151 rtl::Reference<PresenterController> mpPresenterController; 152 }; 153 154 class NotesFontSizeCommand : public Command 155 { 156 public: 157 NotesFontSizeCommand( 158 const rtl::Reference<PresenterController>& rpPresenterController, 159 const sal_Int32 nSizeChange); 160 virtual ~NotesFontSizeCommand (void) {} 161 virtual void Execute (void); 162 virtual bool IsEnabled (void) const; 163 virtual Any GetState (void) const; 164 protected: 165 ::rtl::Reference<PresenterNotesView> GetNotesView (void) const; 166 private: 167 rtl::Reference<PresenterController> mpPresenterController; 168 const sal_Int32 mnSizeChange; 169 }; 170 171 } // end of anonymous namespace 172 173 174 namespace { 175 typedef ::cppu::WeakComponentImplHelper2 < 176 css::frame::XDispatch, 177 css::document::XEventListener 178 > PresenterDispatchInterfaceBase; 179 } 180 181 class PresenterProtocolHandler::Dispatch 182 : protected ::cppu::BaseMutex, 183 public PresenterDispatchInterfaceBase 184 { 185 public: 186 typedef void (PresenterProtocolHandler::Dispatch::* Action)(void); 187 188 /** Create a new Dispatch object. When the given command name 189 (rsURLPath) is not known then an empty reference is returned. 190 */ 191 static Reference<frame::XDispatch> Create ( 192 const OUString& rsURLPath, 193 const ::rtl::Reference<PresenterController>& rpPresenterController); 194 195 void SAL_CALL disposing (void); 196 static Command* CreateCommand ( 197 const OUString& rsURLPath, 198 const ::rtl::Reference<PresenterController>& rpPresenterController); 199 200 201 // XDispatch 202 virtual void SAL_CALL dispatch( 203 const css::util::URL& aURL, 204 const css::uno::Sequence<css::beans::PropertyValue>& rArguments) 205 throw(css::uno::RuntimeException); 206 207 virtual void SAL_CALL addStatusListener( 208 const css::uno::Reference<css::frame::XStatusListener>& rxListener, 209 const css::util::URL& rURL) 210 throw(css::uno::RuntimeException); 211 212 virtual void SAL_CALL removeStatusListener ( 213 const css::uno::Reference<css::frame::XStatusListener>& rxListener, 214 const css::util::URL& rURL) 215 throw(css::uno::RuntimeException); 216 217 218 // document::XEventListener 219 220 virtual void SAL_CALL notifyEvent (const css::document::EventObject& rEvent) 221 throw(css::uno::RuntimeException); 222 223 224 // lang::XEventListener 225 226 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) 227 throw(css::uno::RuntimeException); 228 229 private: 230 OUString msURLPath; 231 ::boost::scoped_ptr<Command> mpCommand; 232 ::rtl::Reference<PresenterController> mpPresenterController; 233 typedef ::std::vector<Reference<frame::XStatusListener> > StatusListenerContainer; 234 StatusListenerContainer maStatusListenerContainer; 235 bool mbIsListeningToWindowManager; 236 237 Dispatch ( 238 const OUString& rsURLPath, 239 const ::rtl::Reference<PresenterController>& rpPresenterController); 240 virtual ~Dispatch (void); 241 242 void ThrowIfDisposed (void) const throw (css::lang::DisposedException); 243 }; 244 245 246 247 248 //----- Service --------------------------------------------------------------- 249 250 OUString PresenterProtocolHandler::getImplementationName_static (void) 251 { 252 return A2S("vnd.sun.star.sdext.presenter.PresenterProtocolHandler"); 253 } 254 255 256 257 258 Sequence<OUString> PresenterProtocolHandler::getSupportedServiceNames_static (void) 259 { 260 static const ::rtl::OUString sServiceName(A2S("com.sun.star.frame.ProtocolHandler")); 261 return Sequence<rtl::OUString>(&sServiceName, 1); 262 } 263 264 265 266 267 Reference<XInterface> PresenterProtocolHandler::Create ( 268 const Reference<uno::XComponentContext>& rxContext) 269 SAL_THROW((Exception)) 270 { 271 return Reference<XInterface>(static_cast<XWeak*>(new PresenterProtocolHandler(rxContext))); 272 } 273 274 275 276 277 //===== PresenterProtocolHandler ========================================================= 278 279 280 PresenterProtocolHandler::PresenterProtocolHandler (const Reference<XComponentContext>& rxContext) 281 : PresenterProtocolHandlerInterfaceBase(m_aMutex) 282 { 283 (void)rxContext; 284 } 285 286 287 288 289 PresenterProtocolHandler::~PresenterProtocolHandler (void) 290 { 291 } 292 293 294 295 296 void SAL_CALL PresenterProtocolHandler::disposing (void) 297 { 298 } 299 300 301 302 303 //----- XInitialize ----------------------------------------------------------- 304 305 void SAL_CALL PresenterProtocolHandler::initialize (const Sequence<Any>& aArguments) 306 throw (Exception, RuntimeException) 307 { 308 ThrowIfDisposed(); 309 if (aArguments.getLength() > 0) 310 { 311 try 312 { 313 Reference<frame::XFrame> xFrame; 314 if (aArguments[0] >>= xFrame) 315 { 316 mpPresenterController = PresenterController::Instance(xFrame); 317 } 318 } 319 catch (RuntimeException&) 320 { 321 OSL_ASSERT(false); 322 } 323 } 324 } 325 326 327 328 329 //----- XDispatchProvider ----------------------------------------------------- 330 331 Reference<frame::XDispatch> SAL_CALL PresenterProtocolHandler::queryDispatch ( 332 const css::util::URL& rURL, 333 const rtl::OUString& rsTargetFrameName, 334 sal_Int32 nSearchFlags) 335 throw(RuntimeException) 336 { 337 (void)rsTargetFrameName; 338 (void)nSearchFlags; 339 ThrowIfDisposed(); 340 341 Reference<frame::XDispatch> xDispatch; 342 343 if (rURL.Protocol == gsProtocol) 344 { 345 xDispatch.set(Dispatch::Create(rURL.Path, mpPresenterController)); 346 } 347 348 return xDispatch; 349 } 350 351 352 353 354 Sequence<Reference<frame::XDispatch> > SAL_CALL PresenterProtocolHandler::queryDispatches( 355 const Sequence<frame::DispatchDescriptor>& rDescriptors) 356 throw(RuntimeException) 357 { 358 (void)rDescriptors; 359 ThrowIfDisposed(); 360 return Sequence<Reference<frame::XDispatch> >(); 361 } 362 363 364 365 366 //----------------------------------------------------------------------------- 367 368 void PresenterProtocolHandler::ThrowIfDisposed (void) const 369 throw (::com::sun::star::lang::DisposedException) 370 { 371 if (rBHelper.bDisposed || rBHelper.bInDispose) 372 { 373 throw lang::DisposedException ( 374 OUString(RTL_CONSTASCII_USTRINGPARAM( 375 "PresenterProtocolHandler object has already been disposed")), 376 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this))); 377 } 378 } 379 380 381 382 383 //===== PresenterProtocolHandler::Dispatch ==================================== 384 385 Reference<frame::XDispatch> PresenterProtocolHandler::Dispatch::Create ( 386 const OUString& rsURLPath, 387 const ::rtl::Reference<PresenterController>& rpPresenterController) 388 { 389 ::rtl::Reference<Dispatch> pDispatch (new Dispatch (rsURLPath, rpPresenterController)); 390 if (pDispatch->mpCommand.get() != NULL) 391 return Reference<frame::XDispatch>(pDispatch.get()); 392 else 393 return NULL; 394 } 395 396 397 398 399 PresenterProtocolHandler::Dispatch::Dispatch ( 400 const OUString& rsURLPath, 401 const ::rtl::Reference<PresenterController>& rpPresenterController) 402 : PresenterDispatchInterfaceBase(m_aMutex), 403 msURLPath(rsURLPath), 404 mpCommand(CreateCommand(rsURLPath, rpPresenterController)), 405 mpPresenterController(rpPresenterController), 406 maStatusListenerContainer(), 407 mbIsListeningToWindowManager(false) 408 { 409 if (mpCommand.get() != NULL) 410 { 411 mpPresenterController->GetWindowManager()->AddLayoutListener(this); 412 mbIsListeningToWindowManager = true; 413 } 414 } 415 416 417 418 419 Command* PresenterProtocolHandler::Dispatch::CreateCommand ( 420 const OUString& rsURLPath, 421 const ::rtl::Reference<PresenterController>& rpPresenterController) 422 { 423 if (rsURLPath.getLength() <= 5) 424 return NULL; 425 switch (rsURLPath[0]) 426 { 427 case sal_Char('C') : 428 switch (rsURLPath[5]) 429 { 430 case sal_Char('N'): 431 if (rsURLPath == A2S("CloseNotes")) 432 return new SetNotesViewCommand(false, rpPresenterController); 433 break; 434 case sal_Char('S'): 435 if (rsURLPath == A2S("CloseSlideSorter")) 436 return new SetSlideSorterCommand(false, rpPresenterController); 437 break; 438 case sal_Char('H'): 439 if (rsURLPath == A2S("CloseHelp")) 440 return new SetHelpViewCommand(false, rpPresenterController); 441 break; 442 } 443 break; 444 case sal_Char('G') : 445 if (rsURLPath == A2S("GrowNotesFont")) 446 return new NotesFontSizeCommand(rpPresenterController, +1); 447 break; 448 449 case sal_Char('N') : 450 switch (rsURLPath[4]) 451 { 452 case sal_Char('E'): 453 if (rsURLPath == A2S("NextEffect")) 454 return new GotoNextEffectCommand(rpPresenterController); 455 case sal_Char('S'): 456 if (rsURLPath == A2S("NextSlide")) 457 return new GotoNextSlideCommand(rpPresenterController); 458 break; 459 } 460 break; 461 462 case sal_Char('P') : 463 if (rsURLPath == A2S("PrevSlide")) 464 return new GotoPreviousSlideCommand(rpPresenterController); 465 break; 466 467 case sal_Char('S') : 468 switch (rsURLPath[4]) 469 { 470 case sal_Char('N'): 471 if (rsURLPath == A2S("ShowNotes")) 472 return new SetNotesViewCommand(true, rpPresenterController); 473 break; 474 475 case sal_Char('S'): 476 if (rsURLPath == A2S("ShowSlideSorter")) 477 return new SetSlideSorterCommand(true, rpPresenterController); 478 break; 479 480 case sal_Char('H'): 481 if (rsURLPath == A2S("ShowHelp")) 482 return new SetHelpViewCommand(true, rpPresenterController); 483 break; 484 485 case sal_Char('n'): 486 if (rsURLPath == A2S("ShrinkNotesFont")) 487 return new NotesFontSizeCommand(rpPresenterController, -1); 488 break; 489 } 490 break; 491 492 default: 493 break; 494 } 495 496 return NULL; 497 } 498 499 500 501 502 PresenterProtocolHandler::Dispatch::~Dispatch (void) 503 { 504 } 505 506 507 508 509 void PresenterProtocolHandler::Dispatch::disposing (void) 510 { 511 if (mbIsListeningToWindowManager) 512 { 513 if (mpPresenterController.get() != NULL) 514 mpPresenterController->GetWindowManager()->RemoveLayoutListener(this); 515 mbIsListeningToWindowManager = false; 516 } 517 518 msURLPath = OUString(); 519 mpCommand.reset(); 520 } 521 522 523 524 525 //----- XDispatch ------------------------------------------------------------- 526 527 void SAL_CALL PresenterProtocolHandler::Dispatch::dispatch( 528 const css::util::URL& rURL, 529 const css::uno::Sequence<css::beans::PropertyValue>& rArguments) 530 throw(css::uno::RuntimeException) 531 { 532 (void)rArguments; 533 ThrowIfDisposed(); 534 535 if (rURL.Protocol == gsProtocol 536 && rURL.Path == msURLPath) 537 { 538 if (mpCommand.get() != NULL) 539 mpCommand->Execute(); 540 } 541 else 542 { 543 // We can not throw an IllegalArgumentException 544 throw RuntimeException(); 545 } 546 } 547 548 549 550 551 void SAL_CALL PresenterProtocolHandler::Dispatch::addStatusListener( 552 const css::uno::Reference<css::frame::XStatusListener>& rxListener, 553 const css::util::URL& rURL) 554 throw(css::uno::RuntimeException) 555 { 556 if (rURL.Path == msURLPath) 557 { 558 maStatusListenerContainer.push_back(rxListener); 559 560 frame::FeatureStateEvent aEvent; 561 aEvent.FeatureURL = rURL; 562 aEvent.IsEnabled = mpCommand->IsEnabled(); 563 aEvent.Requery = sal_False; 564 aEvent.State = mpCommand->GetState(); 565 rxListener->statusChanged(aEvent); 566 } 567 else 568 throw RuntimeException(); 569 } 570 571 572 573 574 void SAL_CALL PresenterProtocolHandler::Dispatch::removeStatusListener ( 575 const css::uno::Reference<css::frame::XStatusListener>& rxListener, 576 const css::util::URL& rURL) 577 throw(css::uno::RuntimeException) 578 { 579 if (rURL.Path == msURLPath) 580 { 581 StatusListenerContainer::iterator iListener ( 582 ::std::find( 583 maStatusListenerContainer.begin(), 584 maStatusListenerContainer.end(), 585 rxListener)); 586 if (iListener != maStatusListenerContainer.end()) 587 maStatusListenerContainer.erase(iListener); 588 } 589 else 590 throw RuntimeException(); 591 } 592 593 594 595 596 //----------------------------------------------------------------------------- 597 598 void PresenterProtocolHandler::Dispatch::ThrowIfDisposed (void) const 599 throw (::com::sun::star::lang::DisposedException) 600 { 601 if (rBHelper.bDisposed || rBHelper.bInDispose) 602 { 603 throw lang::DisposedException ( 604 OUString(RTL_CONSTASCII_USTRINGPARAM( 605 "PresenterProtocolHandler::Dispatch object has already been disposed")), 606 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this))); 607 } 608 } 609 610 611 612 613 //----- document::XEventListener ---------------------------------------------- 614 615 void SAL_CALL PresenterProtocolHandler::Dispatch::notifyEvent ( 616 const css::document::EventObject& rEvent) 617 throw(css::uno::RuntimeException) 618 { 619 (void)rEvent; 620 621 mpCommand->GetState(); 622 } 623 624 625 626 627 //----- lang::XEventListener -------------------------------------------------- 628 629 void SAL_CALL PresenterProtocolHandler::Dispatch::disposing (const css::lang::EventObject& rEvent) 630 throw(css::uno::RuntimeException) 631 { 632 (void)rEvent; 633 mbIsListeningToWindowManager = false; 634 } 635 636 637 638 639 640 //===== GotoPreviousSlideCommand ============================================== 641 642 GotoPreviousSlideCommand::GotoPreviousSlideCommand ( 643 const rtl::Reference<PresenterController>& rpPresenterController) 644 : mpPresenterController(rpPresenterController) 645 { 646 } 647 648 649 650 void GotoPreviousSlideCommand::Execute (void) 651 { 652 if ( ! mpPresenterController.is()) 653 return; 654 655 if ( ! mpPresenterController->GetSlideShowController().is()) 656 return; 657 658 mpPresenterController->GetSlideShowController()->gotoPreviousSlide(); 659 } 660 661 662 663 664 bool GotoPreviousSlideCommand::IsEnabled (void) const 665 { 666 if ( ! mpPresenterController.is()) 667 return false; 668 669 if ( ! mpPresenterController->GetSlideShowController().is()) 670 return false; 671 672 return mpPresenterController->GetSlideShowController()->getCurrentSlideIndex()>0; 673 } 674 675 676 677 678 Any GotoPreviousSlideCommand::GetState (void) const 679 { 680 return Any(sal_False); 681 } 682 683 684 685 686 //===== GotoNextEffect ======================================================== 687 688 GotoNextEffectCommand::GotoNextEffectCommand ( 689 const rtl::Reference<PresenterController>& rpPresenterController) 690 : mpPresenterController(rpPresenterController) 691 { 692 } 693 694 695 696 void GotoNextEffectCommand::Execute (void) 697 { 698 if ( ! mpPresenterController.is()) 699 return; 700 701 if ( ! mpPresenterController->GetSlideShowController().is()) 702 return; 703 704 mpPresenterController->GetSlideShowController()->gotoNextEffect(); 705 } 706 707 708 709 710 bool GotoNextEffectCommand::IsEnabled (void) const 711 { 712 // The next slide command is always enabled, even when the current slide 713 // is the last slide: from the last slide it goes to the pause slide, 714 // and from there it ends the slide show. 715 return true; 716 } 717 718 719 720 721 Any GotoNextEffectCommand::GetState (void) const 722 { 723 return Any(sal_False); 724 } 725 726 727 728 729 //===== GotoNextSlide ========================================================= 730 731 GotoNextSlideCommand::GotoNextSlideCommand ( 732 const rtl::Reference<PresenterController>& rpPresenterController) 733 : mpPresenterController(rpPresenterController) 734 { 735 } 736 737 738 739 void GotoNextSlideCommand::Execute (void) 740 { 741 if ( ! mpPresenterController.is()) 742 return; 743 744 if ( ! mpPresenterController->GetSlideShowController().is()) 745 return; 746 747 mpPresenterController->GetSlideShowController()->gotoNextSlide(); 748 } 749 750 751 752 753 bool GotoNextSlideCommand::IsEnabled (void) const 754 { 755 // The next slide command is always enabled, even when the current slide 756 // is the last slide: from the last slide it goes to the pause slide, 757 // and from there it ends the slide show. 758 return true; 759 } 760 761 762 763 764 Any GotoNextSlideCommand::GetState (void) const 765 { 766 return Any(sal_False); 767 } 768 769 770 771 772 //===== SetNotesViewCommand =================================================== 773 774 SetNotesViewCommand::SetNotesViewCommand ( 775 const bool bOn, 776 const rtl::Reference<PresenterController>& rpPresenterController) 777 : mbOn(bOn), 778 mpPresenterController(rpPresenterController) 779 { 780 } 781 782 783 784 785 void SetNotesViewCommand::Execute (void) 786 { 787 if ( ! mpPresenterController.is()) 788 return; 789 790 ::rtl::Reference<PresenterWindowManager> pWindowManager ( 791 mpPresenterController->GetWindowManager()); 792 if ( ! pWindowManager.is()) 793 return; 794 795 if (mbOn) 796 pWindowManager->SetViewMode(PresenterWindowManager::VM_Notes); 797 else 798 pWindowManager->SetViewMode(PresenterWindowManager::VM_Standard); 799 } 800 801 802 803 804 bool SetNotesViewCommand::IsEnabled (void) const 805 { 806 return true; 807 } 808 809 810 811 812 Any SetNotesViewCommand::GetState (void) const 813 { 814 if ( ! mpPresenterController.is()) 815 return Any(false); 816 817 ::rtl::Reference<PresenterWindowManager> pWindowManager ( 818 mpPresenterController->GetWindowManager()); 819 if ( ! pWindowManager.is()) 820 return Any(false); 821 822 return Any(IsActive(pWindowManager)); 823 } 824 825 826 827 828 bool SetNotesViewCommand::IsActive ( 829 const ::rtl::Reference<PresenterWindowManager>& rpWindowManager) const 830 { 831 return rpWindowManager->GetViewMode() == PresenterWindowManager::VM_Notes; 832 } 833 834 835 836 837 //===== SetSlideSorterCommand ================================================= 838 839 SetSlideSorterCommand::SetSlideSorterCommand ( 840 const bool bOn, 841 const rtl::Reference<PresenterController>& rpPresenterController) 842 : mbOn(bOn), 843 mpPresenterController(rpPresenterController) 844 { 845 } 846 847 848 849 850 void SetSlideSorterCommand::Execute (void) 851 { 852 if ( ! mpPresenterController.is()) 853 return; 854 855 ::rtl::Reference<PresenterWindowManager> pWindowManager ( 856 mpPresenterController->GetWindowManager()); 857 if ( ! pWindowManager.is()) 858 return; 859 860 pWindowManager->SetSlideSorterState(mbOn); 861 } 862 863 864 865 866 bool SetSlideSorterCommand::IsEnabled (void) const 867 { 868 return true; 869 } 870 871 872 873 874 Any SetSlideSorterCommand::GetState (void) const 875 { 876 if ( ! mpPresenterController.is()) 877 return Any(false); 878 879 ::rtl::Reference<PresenterWindowManager> pWindowManager ( 880 mpPresenterController->GetWindowManager()); 881 if ( ! pWindowManager.is()) 882 return Any(false); 883 884 return Any(pWindowManager->GetViewMode()==PresenterWindowManager::VM_SlideOverview); 885 } 886 887 888 889 890 //===== SetHelpViewCommand =================================================== 891 892 SetHelpViewCommand::SetHelpViewCommand ( 893 const bool bOn, 894 const rtl::Reference<PresenterController>& rpPresenterController) 895 : mbOn(bOn), 896 mpPresenterController(rpPresenterController) 897 { 898 } 899 900 901 902 903 void SetHelpViewCommand::Execute (void) 904 { 905 if ( ! mpPresenterController.is()) 906 return; 907 908 ::rtl::Reference<PresenterWindowManager> pWindowManager ( 909 mpPresenterController->GetWindowManager()); 910 if ( ! pWindowManager.is()) 911 return; 912 913 pWindowManager->SetHelpViewState(mbOn); 914 } 915 916 917 918 919 bool SetHelpViewCommand::IsEnabled (void) const 920 { 921 return true; 922 } 923 924 925 926 927 Any SetHelpViewCommand::GetState (void) const 928 { 929 if ( ! mpPresenterController.is()) 930 return Any(false); 931 932 ::rtl::Reference<PresenterWindowManager> pWindowManager ( 933 mpPresenterController->GetWindowManager()); 934 if ( ! pWindowManager.is()) 935 return Any(false); 936 937 return Any(pWindowManager->GetViewMode()==PresenterWindowManager::VM_Help); 938 } 939 940 941 942 943 //===== NotesFontSizeCommand ================================================== 944 945 NotesFontSizeCommand::NotesFontSizeCommand( 946 const rtl::Reference<PresenterController>& rpPresenterController, 947 const sal_Int32 nSizeChange) 948 : mpPresenterController(rpPresenterController), 949 mnSizeChange(nSizeChange) 950 { 951 } 952 953 954 955 956 ::rtl::Reference<PresenterNotesView> NotesFontSizeCommand::GetNotesView (void) const 957 { 958 if (mpPresenterController.get() == NULL) 959 return NULL; 960 961 PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 962 mpPresenterController->GetPaneContainer()->FindViewURL( 963 PresenterViewFactory::msNotesViewURL)); 964 if (pDescriptor.get() == NULL) 965 return NULL; 966 967 return dynamic_cast<PresenterNotesView*>(pDescriptor->mxView.get()); 968 } 969 970 971 972 973 void NotesFontSizeCommand::Execute (void) 974 { 975 ::rtl::Reference<PresenterNotesView> pView (GetNotesView()); 976 if (pView.is()) 977 pView->ChangeFontSize(mnSizeChange); 978 } 979 980 981 982 983 bool NotesFontSizeCommand::IsEnabled (void) const 984 { 985 return true; 986 } 987 988 989 990 991 Any NotesFontSizeCommand::GetState (void) const 992 { 993 return Any(); 994 } 995 996 997 } } // end of namespace ::sdext::presenter 998