LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterProtocolHandler.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 245 0.8 %
Date: 2014-04-11 Functions: 1 68 1.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "PresenterProtocolHandler.hxx"
      21             : #include "PresenterConfigurationAccess.hxx"
      22             : #include "PresenterController.hxx"
      23             : #include "PresenterHelper.hxx"
      24             : #include "PresenterNotesView.hxx"
      25             : #include "PresenterPaneContainer.hxx"
      26             : #include "PresenterPaneFactory.hxx"
      27             : #include "PresenterViewFactory.hxx"
      28             : #include "PresenterWindowManager.hxx"
      29             : #include <com/sun/star/frame/XController.hpp>
      30             : #include <com/sun/star/drawing/SlideSorter.hpp>
      31             : #include <com/sun/star/drawing/framework/Configuration.hpp>
      32             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      33             : #include <com/sun/star/drawing/framework/ResourceId.hpp>
      34             : #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp>
      35             : #include <com/sun/star/presentation/XSlideShow.hpp>
      36             : #include <com/sun/star/presentation/XSlideShowView.hpp>
      37             : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
      38             : #include <cppuhelper/compbase2.hxx>
      39             : 
      40             : using namespace ::com::sun::star;
      41             : using namespace ::com::sun::star::uno;
      42             : using namespace ::com::sun::star::drawing::framework;
      43             : 
      44             : namespace sdext { namespace presenter {
      45             : 
      46             : namespace {
      47           0 :     class Command
      48             :     {
      49             :     public:
      50           0 :         virtual ~Command() {}
      51             :         virtual void Execute (void) = 0;
      52           0 :         virtual bool IsEnabled (void) const { return true; }
      53           0 :         virtual Any GetState (void) const { return Any(sal_False); }
      54             :     };
      55             : 
      56             :     class GotoPreviousSlideCommand : public Command
      57             :     {
      58             :     public:
      59             :         GotoPreviousSlideCommand (
      60             :             const rtl::Reference<PresenterController>& rpPresenterController);
      61           0 :         virtual ~GotoPreviousSlideCommand (void) {}
      62             :         virtual void Execute (void) SAL_OVERRIDE;
      63             :         virtual bool IsEnabled (void) const SAL_OVERRIDE;
      64             :     private:
      65             :         rtl::Reference<PresenterController> mpPresenterController;
      66             :     };
      67             : 
      68             :     class GotoNextSlideCommand : public Command
      69             :     {
      70             :     public:
      71             :         GotoNextSlideCommand (
      72             :             const rtl::Reference<PresenterController>& rpPresenterController);
      73           0 :         virtual ~GotoNextSlideCommand (void) {}
      74             :         virtual void Execute (void) SAL_OVERRIDE;
      75             :         // The next slide command is always enabled, even when the current slide
      76             :         // is the last slide:  from the last slide it goes to the pause slide,
      77             :         // and from there it ends the slide show.
      78           0 :         virtual bool IsEnabled (void) const SAL_OVERRIDE { return true; }
      79             :     private:
      80             :         rtl::Reference<PresenterController> mpPresenterController;
      81             :     };
      82             : 
      83             :     class GotoNextEffectCommand : public Command
      84             :     {
      85             :     public:
      86             :         GotoNextEffectCommand (
      87             :             const rtl::Reference<PresenterController>& rpPresenterController);
      88           0 :         virtual ~GotoNextEffectCommand (void) {}
      89             :         virtual void Execute (void) SAL_OVERRIDE;
      90             :     private:
      91             :         rtl::Reference<PresenterController> mpPresenterController;
      92             :     };
      93             : 
      94             :     class SwitchMonitorCommand : public Command
      95             :     {
      96             :     public:
      97             :         SwitchMonitorCommand (
      98             :             const rtl::Reference<PresenterController>& rpPresenterController);
      99           0 :         virtual ~SwitchMonitorCommand (void) {}
     100             :         virtual void Execute (void) SAL_OVERRIDE;
     101             :     private:
     102             :         rtl::Reference<PresenterController> mpPresenterController;
     103             :     };
     104             : 
     105             :     class SetNotesViewCommand : public Command
     106             :     {
     107             :     public:
     108             :         SetNotesViewCommand (
     109             :             const bool bOn,
     110             :             const rtl::Reference<PresenterController>& rpPresenterController);
     111           0 :         virtual ~SetNotesViewCommand (void) {}
     112             :         virtual void Execute (void) SAL_OVERRIDE;
     113             :         virtual Any GetState (void) const SAL_OVERRIDE;
     114             :     private:
     115             :         bool mbOn;
     116             :         rtl::Reference<PresenterController> mpPresenterController;
     117             :         bool IsActive (const ::rtl::Reference<PresenterWindowManager>& rpWindowManager) const;
     118             :     };
     119             : 
     120             :     class SetSlideSorterCommand : public Command
     121             :     {
     122             :     public:
     123             :         SetSlideSorterCommand (
     124             :             const bool bOn,
     125             :             const rtl::Reference<PresenterController>& rpPresenterController);
     126           0 :         virtual ~SetSlideSorterCommand (void) {}
     127             :         virtual void Execute (void) SAL_OVERRIDE;
     128             :         virtual Any GetState (void) const SAL_OVERRIDE;
     129             :     private:
     130             :         bool mbOn;
     131             :         rtl::Reference<PresenterController> mpPresenterController;
     132             :     };
     133             : 
     134             :     class SetHelpViewCommand : public Command
     135             :     {
     136             :     public:
     137             :         SetHelpViewCommand (
     138             :             const bool bOn,
     139             :             const rtl::Reference<PresenterController>& rpPresenterController);
     140           0 :         virtual ~SetHelpViewCommand (void) {}
     141             :         virtual void Execute (void) SAL_OVERRIDE;
     142             :         virtual Any GetState (void) const SAL_OVERRIDE;
     143             :     private:
     144             :         bool mbOn;
     145             :         rtl::Reference<PresenterController> mpPresenterController;
     146             :     };
     147             : 
     148             :     class NotesFontSizeCommand : public Command
     149             :     {
     150             :     public:
     151             :         NotesFontSizeCommand(
     152             :             const rtl::Reference<PresenterController>& rpPresenterController,
     153             :             const sal_Int32 nSizeChange);
     154           0 :         virtual ~NotesFontSizeCommand (void) {}
     155             :         virtual void Execute (void) SAL_OVERRIDE;
     156             :         virtual Any GetState (void) const SAL_OVERRIDE;
     157             :     protected:
     158             :         ::rtl::Reference<PresenterNotesView> GetNotesView (void) const;
     159             :     private:
     160             :         rtl::Reference<PresenterController> mpPresenterController;
     161             :         const sal_Int32 mnSizeChange;
     162             :     };
     163             : 
     164             : } // end of anonymous namespace
     165             : 
     166             : namespace {
     167             :     typedef ::cppu::WeakComponentImplHelper2 <
     168             :         css::frame::XDispatch,
     169             :         css::document::XEventListener
     170             :         > PresenterDispatchInterfaceBase;
     171             : }
     172             : 
     173             : class PresenterProtocolHandler::Dispatch
     174             :     : protected ::cppu::BaseMutex,
     175             :       public PresenterDispatchInterfaceBase
     176             : {
     177             : public:
     178             :     typedef void (PresenterProtocolHandler::Dispatch::* Action)(void);
     179             : 
     180             :     /** Create a new Dispatch object.  When the given command name
     181             :         (rsURLPath) is not known then an empty reference is returned.
     182             :     */
     183             :     static Reference<frame::XDispatch> Create (
     184             :         const OUString& rsURLPath,
     185             :         const ::rtl::Reference<PresenterController>& rpPresenterController);
     186             : 
     187             :     void SAL_CALL disposing (void) SAL_OVERRIDE;
     188             :     static Command* CreateCommand (
     189             :         const OUString& rsURLPath,
     190             :         const ::rtl::Reference<PresenterController>& rpPresenterController);
     191             : 
     192             :     // XDispatch
     193             :     virtual void SAL_CALL dispatch(
     194             :         const css::util::URL& aURL,
     195             :         const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
     196             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     197             : 
     198             :     virtual void SAL_CALL addStatusListener(
     199             :         const css::uno::Reference<css::frame::XStatusListener>& rxListener,
     200             :         const css::util::URL& rURL)
     201             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     202             : 
     203             :     virtual void SAL_CALL removeStatusListener (
     204             :         const css::uno::Reference<css::frame::XStatusListener>& rxListener,
     205             :         const css::util::URL& rURL)
     206             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     207             : 
     208             :     // document::XEventListener
     209             : 
     210             :     virtual void SAL_CALL notifyEvent (const css::document::EventObject& rEvent)
     211             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     212             : 
     213             :     // lang::XEventListener
     214             : 
     215             :     virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
     216             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     217             : 
     218             : private:
     219             :     OUString msURLPath;
     220             :     ::boost::scoped_ptr<Command> mpCommand;
     221             :     ::rtl::Reference<PresenterController> mpPresenterController;
     222             :     typedef ::std::vector<Reference<frame::XStatusListener> > StatusListenerContainer;
     223             :     StatusListenerContainer maStatusListenerContainer;
     224             :     bool mbIsListeningToWindowManager;
     225             : 
     226             :     Dispatch (
     227             :         const OUString& rsURLPath,
     228             :         const ::rtl::Reference<PresenterController>& rpPresenterController);
     229             :     virtual ~Dispatch (void);
     230             : 
     231             :     void ThrowIfDisposed (void) const throw (css::lang::DisposedException);
     232             : };
     233             : 
     234             : //----- Service ---------------------------------------------------------------
     235             : 
     236           4 : OUString PresenterProtocolHandler::getImplementationName_static (void)
     237             : {
     238           4 :     return OUString("org.libreoffice.comp.PresenterScreenProtocolHandler");
     239             : }
     240             : 
     241           0 : Sequence<OUString> PresenterProtocolHandler::getSupportedServiceNames_static (void)
     242             : {
     243           0 :     static const OUString sServiceName("com.sun.star.frame.ProtocolHandler");
     244           0 :     return Sequence<OUString>(&sServiceName, 1);
     245             : }
     246             : 
     247           0 : Reference<XInterface> PresenterProtocolHandler::Create (
     248             :     const Reference<uno::XComponentContext>& rxContext)
     249             :     SAL_THROW((Exception))
     250             : {
     251           0 :     return Reference<XInterface>(static_cast<XWeak*>(new PresenterProtocolHandler(rxContext)));
     252             : }
     253             : 
     254             : //===== PresenterProtocolHandler =========================================================
     255             : 
     256           0 : PresenterProtocolHandler::PresenterProtocolHandler (const Reference<XComponentContext>& rxContext)
     257           0 :     : PresenterProtocolHandlerInterfaceBase(m_aMutex)
     258             : {
     259             :     (void)rxContext;
     260           0 : }
     261             : 
     262           0 : PresenterProtocolHandler::~PresenterProtocolHandler (void)
     263             : {
     264           0 : }
     265             : 
     266           0 : void SAL_CALL PresenterProtocolHandler::disposing (void)
     267             : {
     268           0 : }
     269             : 
     270             : //----- XInitialize -----------------------------------------------------------
     271             : 
     272           0 : void SAL_CALL PresenterProtocolHandler::initialize (const Sequence<Any>& aArguments)
     273             :     throw (Exception, RuntimeException, std::exception)
     274             : {
     275           0 :     ThrowIfDisposed();
     276           0 :     if (aArguments.getLength() > 0)
     277             :     {
     278             :         try
     279             :         {
     280           0 :             Reference<frame::XFrame> xFrame;
     281           0 :             if (aArguments[0] >>= xFrame)
     282             :             {
     283           0 :                 mpPresenterController = PresenterController::Instance(xFrame);
     284           0 :             }
     285             :         }
     286           0 :         catch (RuntimeException&)
     287             :         {
     288             :             OSL_ASSERT(false);
     289             :         }
     290             :     }
     291           0 : }
     292             : 
     293             : //----- XDispatchProvider -----------------------------------------------------
     294             : 
     295           0 : Reference<frame::XDispatch> SAL_CALL PresenterProtocolHandler::queryDispatch (
     296             :     const css::util::URL& rURL,
     297             :     const OUString& rsTargetFrameName,
     298             :     sal_Int32 nSearchFlags)
     299             :     throw(RuntimeException, std::exception)
     300             : {
     301             :     (void)rsTargetFrameName;
     302             :     (void)nSearchFlags;
     303           0 :     ThrowIfDisposed();
     304             : 
     305           0 :     Reference<frame::XDispatch> xDispatch;
     306             : 
     307           0 :     if (rURL.Protocol == "vnd.org.libreoffice.presenterscreen:")
     308             :     {
     309           0 :         xDispatch.set(Dispatch::Create(rURL.Path, mpPresenterController));
     310             :     }
     311             : 
     312           0 :     return xDispatch;
     313             : }
     314             : 
     315           0 : Sequence<Reference<frame::XDispatch> > SAL_CALL PresenterProtocolHandler::queryDispatches(
     316             :     const Sequence<frame::DispatchDescriptor>& rDescriptors)
     317             :     throw(RuntimeException, std::exception)
     318             : {
     319             :     (void)rDescriptors;
     320           0 :     ThrowIfDisposed();
     321           0 :     return Sequence<Reference<frame::XDispatch> >();
     322             : }
     323             : 
     324             : 
     325             : 
     326           0 : void PresenterProtocolHandler::ThrowIfDisposed (void) const
     327             :     throw (::com::sun::star::lang::DisposedException)
     328             : {
     329           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     330             :     {
     331             :         throw lang::DisposedException (
     332             :             OUString(
     333             :                 "PresenterProtocolHandler object has already been disposed"),
     334           0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
     335             :     }
     336           0 : }
     337             : 
     338             : //===== PresenterProtocolHandler::Dispatch ====================================
     339             : 
     340           0 : Reference<frame::XDispatch> PresenterProtocolHandler::Dispatch::Create (
     341             :     const OUString& rsURLPath,
     342             :     const ::rtl::Reference<PresenterController>& rpPresenterController)
     343             : {
     344           0 :     ::rtl::Reference<Dispatch> pDispatch (new Dispatch (rsURLPath, rpPresenterController));
     345           0 :     if (pDispatch->mpCommand.get() != NULL)
     346           0 :         return Reference<frame::XDispatch>(pDispatch.get());
     347             :     else
     348           0 :         return NULL;
     349             : }
     350             : 
     351           0 : PresenterProtocolHandler::Dispatch::Dispatch (
     352             :     const OUString& rsURLPath,
     353             :     const ::rtl::Reference<PresenterController>& rpPresenterController)
     354             :     : PresenterDispatchInterfaceBase(m_aMutex),
     355             :       msURLPath(rsURLPath),
     356             :       mpCommand(CreateCommand(rsURLPath, rpPresenterController)),
     357             :       mpPresenterController(rpPresenterController),
     358             :       maStatusListenerContainer(),
     359           0 :       mbIsListeningToWindowManager(false)
     360             : {
     361           0 :     if (mpCommand.get() != NULL)
     362             :     {
     363           0 :         mpPresenterController->GetWindowManager()->AddLayoutListener(this);
     364           0 :         mbIsListeningToWindowManager = true;
     365             :     }
     366           0 : }
     367             : 
     368           0 : Command* PresenterProtocolHandler::Dispatch::CreateCommand (
     369             :     const OUString& rsURLPath,
     370             :     const ::rtl::Reference<PresenterController>& rpPresenterController)
     371             : {
     372           0 :     if (rsURLPath.getLength() <= 5)
     373           0 :         return NULL;
     374             : 
     375           0 :     if (rsURLPath == "CloseNotes")
     376           0 :         return new SetNotesViewCommand(false, rpPresenterController);
     377           0 :     if (rsURLPath == "CloseSlideSorter")
     378           0 :         return new SetSlideSorterCommand(false, rpPresenterController);
     379           0 :     if (rsURLPath == "CloseHelp")
     380           0 :         return new SetHelpViewCommand(false, rpPresenterController);
     381           0 :     if (rsURLPath == "GrowNotesFont")
     382           0 :         return new NotesFontSizeCommand(rpPresenterController, +1);
     383           0 :     if (rsURLPath == "NextEffect")
     384           0 :         return new GotoNextEffectCommand(rpPresenterController);
     385           0 :     if (rsURLPath == "NextSlide")
     386           0 :         return new GotoNextSlideCommand(rpPresenterController);
     387           0 :     if (rsURLPath == "PrevSlide")
     388           0 :         return new GotoPreviousSlideCommand(rpPresenterController);
     389           0 :     if (rsURLPath == "SwitchMonitor")
     390           0 :         return new SwitchMonitorCommand(rpPresenterController);
     391           0 :     if (rsURLPath == "ShowNotes")
     392           0 :         return new SetNotesViewCommand(true, rpPresenterController);
     393           0 :     if (rsURLPath == "ShowSlideSorter")
     394           0 :         return new SetSlideSorterCommand(true, rpPresenterController);
     395           0 :     if (rsURLPath == "ShowHelp")
     396           0 :         return new SetHelpViewCommand(true, rpPresenterController);
     397           0 :     if (rsURLPath == "ShrinkNotesFont")
     398           0 :         return new NotesFontSizeCommand(rpPresenterController, -1);
     399             : 
     400           0 :     return NULL;
     401             : }
     402             : 
     403           0 : PresenterProtocolHandler::Dispatch::~Dispatch (void)
     404             : {
     405           0 : }
     406             : 
     407           0 : void PresenterProtocolHandler::Dispatch::disposing (void)
     408             : {
     409           0 :     if (mbIsListeningToWindowManager)
     410             :     {
     411           0 :         if (mpPresenterController.get() != NULL)
     412           0 :             mpPresenterController->GetWindowManager()->RemoveLayoutListener(this);
     413           0 :         mbIsListeningToWindowManager = false;
     414             :     }
     415             : 
     416           0 :     msURLPath = OUString();
     417           0 :     mpCommand.reset();
     418           0 : }
     419             : 
     420             : //----- XDispatch -------------------------------------------------------------
     421             : 
     422           0 : void SAL_CALL PresenterProtocolHandler::Dispatch::dispatch(
     423             :     const css::util::URL& rURL,
     424             :     const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
     425             :     throw(css::uno::RuntimeException, std::exception)
     426             : {
     427             :     (void)rArguments;
     428           0 :     ThrowIfDisposed();
     429             : 
     430           0 :     if (rURL.Protocol == "vnd.org.libreoffice.presenterscreen:"
     431           0 :         && rURL.Path == msURLPath)
     432             :     {
     433           0 :         if (mpCommand.get() != NULL)
     434           0 :             mpCommand->Execute();
     435             :     }
     436             :     else
     437             :     {
     438             :         // We can not throw an IllegalArgumentException
     439           0 :         throw RuntimeException();
     440             :     }
     441           0 : }
     442             : 
     443           0 : void SAL_CALL PresenterProtocolHandler::Dispatch::addStatusListener(
     444             :     const css::uno::Reference<css::frame::XStatusListener>& rxListener,
     445             :     const css::util::URL& rURL)
     446             :     throw(css::uno::RuntimeException, std::exception)
     447             : {
     448           0 :     if (rURL.Path == msURLPath)
     449             :     {
     450           0 :         maStatusListenerContainer.push_back(rxListener);
     451             : 
     452           0 :         frame::FeatureStateEvent aEvent;
     453           0 :         aEvent.FeatureURL = rURL;
     454           0 :         aEvent.IsEnabled = mpCommand->IsEnabled();
     455           0 :         aEvent.Requery = sal_False;
     456           0 :         aEvent.State = mpCommand->GetState();
     457           0 :         rxListener->statusChanged(aEvent);
     458             :     }
     459             :     else
     460           0 :         throw RuntimeException();
     461           0 : }
     462             : 
     463           0 : void SAL_CALL PresenterProtocolHandler::Dispatch::removeStatusListener (
     464             :     const css::uno::Reference<css::frame::XStatusListener>& rxListener,
     465             :     const css::util::URL& rURL)
     466             :     throw(css::uno::RuntimeException, std::exception)
     467             : {
     468           0 :     if (rURL.Path == msURLPath)
     469             :     {
     470             :         StatusListenerContainer::iterator iListener (
     471             :             ::std::find(
     472             :                 maStatusListenerContainer.begin(),
     473             :                 maStatusListenerContainer.end(),
     474           0 :                 rxListener));
     475           0 :         if (iListener != maStatusListenerContainer.end())
     476           0 :             maStatusListenerContainer.erase(iListener);
     477             :     }
     478             :     else
     479           0 :         throw RuntimeException();
     480           0 : }
     481             : 
     482           0 : void PresenterProtocolHandler::Dispatch::ThrowIfDisposed (void) const
     483             :     throw (::com::sun::star::lang::DisposedException)
     484             : {
     485           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     486             :     {
     487             :         throw lang::DisposedException (
     488             :             OUString(
     489             :                 "PresenterProtocolHandler::Dispatch object has already been disposed"),
     490           0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
     491             :     }
     492           0 : }
     493             : 
     494             : //----- document::XEventListener ----------------------------------------------
     495             : 
     496           0 : void SAL_CALL PresenterProtocolHandler::Dispatch::notifyEvent (
     497             :     const css::document::EventObject& rEvent)
     498             :     throw(css::uno::RuntimeException, std::exception)
     499             : {
     500             :     (void)rEvent;
     501             : 
     502           0 :     mpCommand->GetState();
     503           0 : }
     504             : 
     505             : //----- lang::XEventListener --------------------------------------------------
     506             : 
     507           0 : void SAL_CALL PresenterProtocolHandler::Dispatch::disposing (const css::lang::EventObject& rEvent)
     508             :     throw(css::uno::RuntimeException, std::exception)
     509             : {
     510             :     (void)rEvent;
     511           0 :     mbIsListeningToWindowManager = false;
     512           0 : }
     513             : 
     514             : //===== GotoPreviousSlideCommand ==============================================
     515             : 
     516           0 : GotoPreviousSlideCommand::GotoPreviousSlideCommand (
     517             :     const rtl::Reference<PresenterController>& rpPresenterController)
     518           0 :     : mpPresenterController(rpPresenterController)
     519             : {
     520           0 : }
     521             : 
     522           0 : void GotoPreviousSlideCommand::Execute (void)
     523             : {
     524           0 :     if ( ! mpPresenterController.is())
     525           0 :         return;
     526             : 
     527           0 :     if ( ! mpPresenterController->GetSlideShowController().is())
     528           0 :         return;
     529             : 
     530           0 :     mpPresenterController->GetSlideShowController()->gotoPreviousSlide();
     531             : }
     532             : 
     533           0 : bool GotoPreviousSlideCommand::IsEnabled (void) const
     534             : {
     535           0 :     if ( ! mpPresenterController.is())
     536           0 :         return false;
     537             : 
     538           0 :     if ( ! mpPresenterController->GetSlideShowController().is())
     539           0 :         return false;
     540             : 
     541           0 :     return mpPresenterController->GetSlideShowController()->getCurrentSlideIndex()>0;
     542             : }
     543             : 
     544             : //===== GotoNextEffect ========================================================
     545             : 
     546           0 : GotoNextEffectCommand::GotoNextEffectCommand (
     547             :     const rtl::Reference<PresenterController>& rpPresenterController)
     548           0 :     : mpPresenterController(rpPresenterController)
     549             : {
     550           0 : }
     551             : 
     552           0 : void GotoNextEffectCommand::Execute (void)
     553             : {
     554           0 :     if ( ! mpPresenterController.is())
     555           0 :         return;
     556             : 
     557           0 :     if ( ! mpPresenterController->GetSlideShowController().is())
     558           0 :         return;
     559             : 
     560           0 :     mpPresenterController->GetSlideShowController()->gotoNextEffect();
     561             : }
     562             : 
     563             : //===== GotoNextSlide =========================================================
     564             : 
     565           0 : GotoNextSlideCommand::GotoNextSlideCommand (
     566             :     const rtl::Reference<PresenterController>& rpPresenterController)
     567           0 :     : mpPresenterController(rpPresenterController)
     568             : {
     569           0 : }
     570             : 
     571           0 : void GotoNextSlideCommand::Execute (void)
     572             : {
     573           0 :     if ( ! mpPresenterController.is())
     574           0 :         return;
     575             : 
     576           0 :     if ( ! mpPresenterController->GetSlideShowController().is())
     577           0 :         return;
     578             : 
     579           0 :     mpPresenterController->GetSlideShowController()->gotoNextSlide();
     580             : }
     581             : 
     582             : //===== SwitchMonitorCommand ==============================================
     583             : 
     584           0 : SwitchMonitorCommand::SwitchMonitorCommand (
     585             :     const rtl::Reference<PresenterController>& rpPresenterController)
     586           0 :     : mpPresenterController(rpPresenterController)
     587             : {
     588           0 : }
     589             : 
     590           0 : void SwitchMonitorCommand::Execute (void)
     591             : {
     592           0 :     mpPresenterController->SwitchMonitors();
     593           0 : }
     594             : 
     595             : //===== SetNotesViewCommand ===================================================
     596             : 
     597           0 : SetNotesViewCommand::SetNotesViewCommand (
     598             :     const bool bOn,
     599             :     const rtl::Reference<PresenterController>& rpPresenterController)
     600             :     : mbOn(bOn),
     601           0 :       mpPresenterController(rpPresenterController)
     602             : {
     603           0 : }
     604             : 
     605           0 : void SetNotesViewCommand::Execute (void)
     606             : {
     607           0 :     if ( ! mpPresenterController.is())
     608           0 :         return;
     609             : 
     610             :     ::rtl::Reference<PresenterWindowManager> pWindowManager (
     611           0 :         mpPresenterController->GetWindowManager());
     612           0 :     if ( ! pWindowManager.is())
     613           0 :         return;
     614             : 
     615           0 :     if (mbOn)
     616           0 :         pWindowManager->SetViewMode(PresenterWindowManager::VM_Notes);
     617             :     else
     618           0 :         pWindowManager->SetViewMode(PresenterWindowManager::VM_Standard);
     619             : }
     620             : 
     621           0 : Any SetNotesViewCommand::GetState (void) const
     622             : {
     623           0 :     if ( ! mpPresenterController.is())
     624           0 :         return Any(false);
     625             : 
     626             :     ::rtl::Reference<PresenterWindowManager> pWindowManager (
     627           0 :         mpPresenterController->GetWindowManager());
     628           0 :     if ( ! pWindowManager.is())
     629           0 :         return Any(false);
     630             : 
     631           0 :     return Any(IsActive(pWindowManager));
     632             : }
     633             : 
     634           0 : bool SetNotesViewCommand::IsActive (
     635             :     const ::rtl::Reference<PresenterWindowManager>& rpWindowManager) const
     636             : {
     637           0 :     return rpWindowManager->GetViewMode() == PresenterWindowManager::VM_Notes;
     638             : }
     639             : 
     640             : //===== SetSlideSorterCommand =================================================
     641             : 
     642           0 : SetSlideSorterCommand::SetSlideSorterCommand (
     643             :     const bool bOn,
     644             :     const rtl::Reference<PresenterController>& rpPresenterController)
     645             :     : mbOn(bOn),
     646           0 :       mpPresenterController(rpPresenterController)
     647             : {
     648           0 : }
     649             : 
     650           0 : void SetSlideSorterCommand::Execute (void)
     651             : {
     652           0 :     if ( ! mpPresenterController.is())
     653           0 :         return;
     654             : 
     655             :     ::rtl::Reference<PresenterWindowManager> pWindowManager (
     656           0 :         mpPresenterController->GetWindowManager());
     657           0 :     if ( ! pWindowManager.is())
     658           0 :         return;
     659             : 
     660           0 :     pWindowManager->SetSlideSorterState(mbOn);
     661             : }
     662             : 
     663           0 : Any SetSlideSorterCommand::GetState (void) const
     664             : {
     665           0 :     if ( ! mpPresenterController.is())
     666           0 :         return Any(false);
     667             : 
     668             :     ::rtl::Reference<PresenterWindowManager> pWindowManager (
     669           0 :         mpPresenterController->GetWindowManager());
     670           0 :     if ( ! pWindowManager.is())
     671           0 :         return Any(false);
     672             : 
     673           0 :     return Any(pWindowManager->GetViewMode()==PresenterWindowManager::VM_SlideOverview);
     674             : }
     675             : 
     676             : //===== SetHelpViewCommand ===================================================
     677             : 
     678           0 : SetHelpViewCommand::SetHelpViewCommand (
     679             :     const bool bOn,
     680             :     const rtl::Reference<PresenterController>& rpPresenterController)
     681             :     : mbOn(bOn),
     682           0 :       mpPresenterController(rpPresenterController)
     683             : {
     684           0 : }
     685             : 
     686           0 : void SetHelpViewCommand::Execute (void)
     687             : {
     688           0 :     if ( ! mpPresenterController.is())
     689           0 :         return;
     690             : 
     691             :     ::rtl::Reference<PresenterWindowManager> pWindowManager (
     692           0 :         mpPresenterController->GetWindowManager());
     693           0 :     if ( ! pWindowManager.is())
     694           0 :         return;
     695             : 
     696           0 :     pWindowManager->SetHelpViewState(mbOn);
     697             : }
     698             : 
     699           0 : Any SetHelpViewCommand::GetState (void) const
     700             : {
     701           0 :     if ( ! mpPresenterController.is())
     702           0 :         return Any(false);
     703             : 
     704             :     ::rtl::Reference<PresenterWindowManager> pWindowManager (
     705           0 :         mpPresenterController->GetWindowManager());
     706           0 :     if ( ! pWindowManager.is())
     707           0 :         return Any(false);
     708             : 
     709           0 :     return Any(pWindowManager->GetViewMode()==PresenterWindowManager::VM_Help);
     710             : }
     711             : 
     712             : //===== NotesFontSizeCommand ==================================================
     713             : 
     714           0 : NotesFontSizeCommand::NotesFontSizeCommand(
     715             :     const rtl::Reference<PresenterController>& rpPresenterController,
     716             :     const sal_Int32 nSizeChange)
     717             :     : mpPresenterController(rpPresenterController),
     718           0 :       mnSizeChange(nSizeChange)
     719             : {
     720           0 : }
     721             : 
     722           0 : ::rtl::Reference<PresenterNotesView> NotesFontSizeCommand::GetNotesView (void) const
     723             : {
     724           0 :     if (mpPresenterController.get() == NULL)
     725           0 :         return NULL;
     726             : 
     727             :     PresenterPaneContainer::SharedPaneDescriptor pDescriptor (
     728             :         mpPresenterController->GetPaneContainer()->FindViewURL(
     729           0 :             PresenterViewFactory::msNotesViewURL));
     730           0 :     if (pDescriptor.get() == NULL)
     731           0 :         return NULL;
     732             : 
     733           0 :     return dynamic_cast<PresenterNotesView*>(pDescriptor->mxView.get());
     734             : }
     735             : 
     736           0 : void NotesFontSizeCommand::Execute (void)
     737             : {
     738           0 :     ::rtl::Reference<PresenterNotesView> pView (GetNotesView());
     739           0 :     if (pView.is())
     740           0 :         pView->ChangeFontSize(mnSizeChange);
     741           0 : }
     742             : 
     743           0 : Any NotesFontSizeCommand::GetState (void) const
     744             : {
     745           0 :     return Any();
     746             : }
     747             : 
     748             : } } // end of namespace ::sdext::presenter
     749             : 
     750             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10