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