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