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