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