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