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