LibreOffice Module sd (master) 1
FrameworkHelper.cxx
Go to the documentation of this file.
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 <osl/time.h>
21
23
27#include <ViewShellBase.hxx>
28#include <DrawViewShell.hxx>
29#include <ViewShellHint.hxx>
30#include <app.hrc>
31#include <com/sun/star/drawing/framework/XControllerManager.hpp>
32#include <com/sun/star/frame/XController.hpp>
35#include <svl/lstner.hxx>
36#include <rtl/ustrbuf.hxx>
37
38#include <sfx2/request.hxx>
39
40#include <utility>
41#include <vcl/svapp.hxx>
43#include <memory>
44#include <unordered_map>
45
46using namespace ::com::sun::star;
47using namespace ::com::sun::star::uno;
49
50namespace {
51
52//----- CallbackCaller --------------------------------------------------------
53
55 css::drawing::framework::XConfigurationChangeListener
56 > CallbackCallerInterfaceBase;
57
64class CallbackCaller
65 : public CallbackCallerInterfaceBase
66{
67public:
86 CallbackCaller (
87 const ::sd::ViewShellBase& rBase,
88 OUString sEventType,
91
92 virtual void disposing(std::unique_lock<std::mutex>&) override;
93 // XEventListener
94 virtual void SAL_CALL disposing (const lang::EventObject& rEvent) override;
95 // XConfigurationChangeListener
96 virtual void SAL_CALL notifyConfigurationChange (const ConfigurationChangeEvent& rEvent) override;
97
98private:
99 OUString msEventType;
100 Reference<XConfigurationController> mxConfigurationController;
103};
104
105//----- LifetimeController ----------------------------------------------------
106
108 css::lang::XEventListener
109 > LifetimeControllerInterfaceBase;
110
116class LifetimeController
117 : public LifetimeControllerInterfaceBase,
118 public SfxListener
119{
120public:
121 explicit LifetimeController (::sd::ViewShellBase& rBase);
122 virtual ~LifetimeController() override;
123
127 using WeakComponentImplHelperBase::disposing;
128 virtual void SAL_CALL disposing (const lang::EventObject& rEvent) override;
129
132 virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) override;
133
134private:
135 ::sd::ViewShellBase& mrBase;
136 bool mbListeningToViewShellBase;
137 bool mbListeningToController;
138
143 void Update();
144};
145
146} // end of anonymous namespace
147
148namespace sd::framework {
149
150namespace {
151
152 class FrameworkHelperAllPassFilter
153 {
154 public:
155 bool operator() (const css::drawing::framework::ConfigurationChangeEvent&) { return true; }
156 };
157
158 class FrameworkHelperResourceIdFilter
159 {
160 public:
161 explicit FrameworkHelperResourceIdFilter (
162 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
163 bool operator() (const css::drawing::framework::ConfigurationChangeEvent& rEvent)
164 { return mxResourceId.is() && rEvent.ResourceId.is()
165 && mxResourceId->compareTo(rEvent.ResourceId) == 0; }
166 private:
167 css::uno::Reference<css::drawing::framework::XResourceId> mxResourceId;
168 };
169
170} // end of anonymous namespace
171
172// Pane URLS.
173
174const OUString FrameworkHelper::msCenterPaneURL( msPaneURLPrefix + "CenterPane");
175const OUString FrameworkHelper::msFullScreenPaneURL( msPaneURLPrefix + "FullScreenPane");
176const OUString FrameworkHelper::msLeftImpressPaneURL( msPaneURLPrefix + "LeftImpressPane");
177const OUString FrameworkHelper::msLeftDrawPaneURL( msPaneURLPrefix + "LeftDrawPane");
178
179// View URLs.
180
181const OUString FrameworkHelper::msImpressViewURL( msViewURLPrefix + "ImpressView");
182const OUString FrameworkHelper::msDrawViewURL( msViewURLPrefix + "GraphicView");
183const OUString FrameworkHelper::msOutlineViewURL( msViewURLPrefix + "OutlineView");
184const OUString FrameworkHelper::msNotesViewURL( msViewURLPrefix + "NotesView");
185const OUString FrameworkHelper::msHandoutViewURL( msViewURLPrefix + "HandoutView");
186const OUString FrameworkHelper::msSlideSorterURL( msViewURLPrefix + "SlideSorter");
187const OUString FrameworkHelper::msPresentationViewURL( msViewURLPrefix + "PresentationView");
188const OUString FrameworkHelper::msSidebarViewURL( msViewURLPrefix + "SidebarView");
189
190// Tool bar URLs.
191
192const OUString FrameworkHelper::msViewTabBarURL( msToolBarURLPrefix + "ViewTabBar");
193
194//----- helper ----------------------------------------------------------------
195namespace
196{
197 ::std::shared_ptr< ViewShell > lcl_getViewShell( const Reference< XResource >& i_rViewShellWrapper )
198 {
199 ::std::shared_ptr< ViewShell > pViewShell;
200 try
201 {
202 if (auto pWrapper = dynamic_cast<ViewShellWrapper*>(i_rViewShellWrapper.get()))
203 pViewShell = pWrapper->GetViewShell();
204 }
205 catch( const Exception& )
206 {
208 }
209 return pViewShell;
210 }
211 Reference< XResource > lcl_getFirstViewInPane( const Reference< XConfigurationController >& i_rConfigController,
212 const Reference< XResourceId >& i_rPaneId )
213 {
214 try
215 {
216 Reference< XConfiguration > xConfiguration( i_rConfigController->getRequestedConfiguration(), UNO_SET_THROW );
217 Sequence< Reference< XResourceId > > aViewIds( xConfiguration->getResources(
218 i_rPaneId, FrameworkHelper::msViewURLPrefix, AnchorBindingMode_DIRECT ) );
219 if ( aViewIds.hasElements() )
220 return i_rConfigController->getResource( aViewIds[0] );
221 }
222 catch( const Exception& )
223 {
225 }
226 return nullptr;
227 }
228}
229
230//----- FrameworkHelper::ViewURLMap -------------------------------------------
231
236 : public std::unordered_map<
237 OUString,
238 ViewShell::ShellType>
239{
240public:
242};
243
244//----- Framework::DisposeListener ---------------------------------------------
245
246namespace {
248 css::lang::XEventListener
249 > FrameworkHelperDisposeListenerInterfaceBase;
250}
251
253 : public FrameworkHelperDisposeListenerInterfaceBase
254{
255public:
256 explicit DisposeListener (::std::shared_ptr<FrameworkHelper> pHelper);
257
258 virtual void disposing(std::unique_lock<std::mutex>&) override;
259
260 virtual void SAL_CALL disposing (const lang::EventObject& rEventObject) override;
261
262private:
263 ::std::shared_ptr<FrameworkHelper> mpHelper;
264};
265
266//----- FrameworkHelper::Deleter ----------------------------------------------
267
269{
270public:
272 {
273 delete pObject;
274 }
275};
276
277//----- FrameworkHelper -------------------------------------------------------
278
280
283
284::std::shared_ptr<FrameworkHelper> FrameworkHelper::Instance (ViewShellBase& rBase)
285{
286 std::unique_lock aGuard(maInstanceMapMutex);
287
288 InstanceMap::const_iterator iHelper (maInstanceMap.find(&rBase));
289 if (iHelper != maInstanceMap.end())
290 return iHelper->second;
291
292 ::std::shared_ptr<FrameworkHelper> pHelper(
293 new FrameworkHelper(rBase),
295 pHelper->Initialize();
296 maInstanceMap[&rBase] = pHelper;
297
298 return pHelper;
299}
300
302{
303 InstanceMap::iterator iHelper (maInstanceMap.find(&rBase));
304 if (iHelper != maInstanceMap.end())
305 {
306 iHelper->second->Dispose();
307 }
308}
309
311{
312 InstanceMap::iterator iHelper (maInstanceMap.find(&rBase));
313 if (iHelper != maInstanceMap.end())
314 maInstanceMap.erase(iHelper);
315}
316
318 : mrBase(rBase)
319{
320 Reference<XControllerManager> xControllerManager (rBase.GetController(), UNO_QUERY);
321 if (xControllerManager.is())
322 {
323 mxConfigurationController = xControllerManager->getConfigurationController();
324 }
325
326 new LifetimeController(mrBase);
327}
328
330{
331 mxDisposeListener = new DisposeListener(shared_from_this());
332}
333
335{
336}
337
339{
340 if (mxDisposeListener.is())
341 mxDisposeListener->dispose();
343}
344
346{
347 return mxConfigurationController.is();
348}
349
350::std::shared_ptr<ViewShell> FrameworkHelper::GetViewShell (const OUString& rsPaneURL)
351{
352 if ( !mxConfigurationController.is() )
353 return ::std::shared_ptr<ViewShell>();
354
355 Reference<XResourceId> xPaneId( CreateResourceId( rsPaneURL ) );
356 return lcl_getViewShell( lcl_getFirstViewInPane( mxConfigurationController, xPaneId ) );
357}
358
359::std::shared_ptr<ViewShell> FrameworkHelper::GetViewShell (const Reference<XView>& rxView)
360{
361 return lcl_getViewShell( rxView );
362}
363
364Reference<XView> FrameworkHelper::GetView (const Reference<XResourceId>& rxPaneOrViewId)
365{
366 Reference<XView> xView;
367
368 if ( ! rxPaneOrViewId.is() || ! mxConfigurationController.is())
369 return nullptr;
370
371 try
372 {
373 if (rxPaneOrViewId->getResourceURL().match(msViewURLPrefix))
374 {
375 xView.set( mxConfigurationController->getResource( rxPaneOrViewId ), UNO_QUERY );
376 }
377 else
378 {
379 xView.set( lcl_getFirstViewInPane( mxConfigurationController, rxPaneOrViewId ), UNO_QUERY );
380 }
381 }
382 catch (lang::DisposedException&)
383 {
384 Dispose();
385 }
386 catch (RuntimeException&)
387 {
388 }
389
390 return xView;
391}
392
393Reference<XResourceId> FrameworkHelper::RequestView (
394 const OUString& rsResourceURL,
395 const OUString& rsAnchorURL)
396{
397 Reference<XResourceId> xViewId;
398
399 try
400 {
402 {
403 mxConfigurationController->requestResourceActivation(
404 CreateResourceId(rsAnchorURL),
405 ResourceActivationMode_ADD);
406 xViewId = CreateResourceId(rsResourceURL, rsAnchorURL);
407 mxConfigurationController->requestResourceActivation(
408 xViewId,
409 ResourceActivationMode_REPLACE);
410 }
411 }
412 catch (lang::DisposedException&)
413 {
414 Dispose();
415 xViewId = nullptr;
416 }
417 catch (RuntimeException&)
418 {
419 xViewId = nullptr;
420 }
421
422 return xViewId;
423}
424
426{
427 if (maViewURLMap.empty())
428 {
437 }
438 ViewURLMap::const_iterator iView (maViewURLMap.find(rsViewURL));
439 if (iView != maViewURLMap.end())
440 return iView->second;
441 else
442 return ViewShell::ST_NONE;
443}
444
446{
447 switch (eType)
448 {
450 case ViewShell::ST_DRAW : return msDrawViewURL;
457 default:
458 return OUString();
459 }
460}
461
462namespace
463{
464
465void updateEditMode(const Reference<XView> &xView, const EditMode eEMode, bool updateFrameView)
466{
467 // Ensure we have the expected edit mode
468 // The check is only for DrawViewShell as OutlineViewShell
469 // and SlideSorterViewShell have no master mode
470 const ::std::shared_ptr<ViewShell> pCenterViewShell (FrameworkHelper::GetViewShell(xView));
471 DrawViewShell* pDrawViewShell
472 = dynamic_cast<DrawViewShell*>(pCenterViewShell.get());
473 if (pDrawViewShell != nullptr)
474 {
475 pCenterViewShell->Broadcast (
477
478 pDrawViewShell->ChangeEditMode(eEMode, pDrawViewShell->IsLayerModeActive());
479 if (updateFrameView)
480 pDrawViewShell->WriteFrameViewData();
481
482 pCenterViewShell->Broadcast (
484 }
485}
486
487void asyncUpdateEditMode(FrameworkHelper* const pHelper, const EditMode eEMode)
488{
489 Reference<XResourceId> xPaneId (
491 Reference<XView> xView (pHelper->GetView(xPaneId));
492 updateEditMode(xView, eEMode, true);
493}
494
495}
496
498 sal_uInt16 nSlotId,
499 SfxRequest const & rRequest)
500{
501 if ( ! mxConfigurationController.is())
502 return;
503
504 // Parameters are allowed for NotesMasterPage and SlideMasterPage
505 // for these command, transfor xxxxMasterPage with param = false
506 // to ActivatexxxxxMode
507 if (nSlotId == SID_NOTES_MASTER_MODE || nSlotId == SID_SLIDE_MASTER_MODE)
508 {
509 const SfxItemSet* pRequestArguments = rRequest.GetArgs();
510 if (pRequestArguments)
511 {
512 const SfxBoolItem* pIsActive = rRequest.GetArg<SfxBoolItem>(nSlotId);
513 if (!pIsActive->GetValue ())
514 {
515 if (nSlotId == SID_NOTES_MASTER_MODE)
516 nSlotId = SID_NOTES_MODE;
517 else
518 nSlotId = SID_NORMAL_MULTI_PANE_GUI;
519 }
520 }
521 }
522
523 try
524 {
525 if ( ! mxConfigurationController.is())
526 throw RuntimeException();
527
528 Reference<XResourceId> xPaneId (
530 Reference<XView> xView (GetView(xPaneId));
531
532 // Compute requested view
533 OUString sRequestedView;
534 switch (nSlotId)
535 {
536 // draw
537 case SID_DRAWINGMODE:
538 // impress
539 case SID_NORMAL_MULTI_PANE_GUI:
540 case SID_SLIDE_MASTER_MODE:
541 sRequestedView = FrameworkHelper::msImpressViewURL;
542 break;
543
544 case SID_NOTES_MODE:
545 case SID_NOTES_MASTER_MODE:
546 sRequestedView = FrameworkHelper::msNotesViewURL;
547 break;
548
549 case SID_HANDOUT_MASTER_MODE:
550 sRequestedView = FrameworkHelper::msHandoutViewURL;
551 break;
552
553 case SID_SLIDE_SORTER_MULTI_PANE_GUI:
554 case SID_SLIDE_SORTER_MODE:
555 sRequestedView = FrameworkHelper::msSlideSorterURL;
556 break;
557
558 case SID_OUTLINE_MODE:
559 sRequestedView = FrameworkHelper::msOutlineViewURL;
560 break;
561 }
562
563 // Compute requested mode
564 EditMode eEMode = EditMode::Page;
565 if (nSlotId == SID_SLIDE_MASTER_MODE
566 || nSlotId == SID_NOTES_MASTER_MODE
567 || nSlotId == SID_HANDOUT_MASTER_MODE)
568 eEMode = EditMode::MasterPage;
569 // Ensure we have the expected view shell
570 if (!(xView.is() && xView->getResourceId()->getResourceURL() == sRequestedView))
571
572 {
573 const auto xId = CreateResourceId(sRequestedView, msCenterPaneURL);
574 mxConfigurationController->requestResourceActivation(
575 xId,
576 ResourceActivationMode_REPLACE);
577 RunOnResourceActivation(xId, std::bind(&asyncUpdateEditMode, this, eEMode));
578 }
579 else
580 {
581 updateEditMode(xView, eEMode, false);
582 }
583 }
584 catch (RuntimeException&)
585 {
587 }
588}
589
591 const OUString& rsEventType,
592 const Callback& rCallback)
593{
595 rsEventType,
596 FrameworkHelperAllPassFilter(),
597 rCallback);
598}
599
601 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
602 const Callback& rCallback)
603{
605 && mxConfigurationController->getResource(rxResourceId).is())
606 {
607 rCallback(false);
608 }
609 else
610 {
613 FrameworkHelperResourceIdFilter(rxResourceId),
614 rCallback);
615 }
616}
617
618namespace {
619
623class FlagUpdater
624{
625public:
626 explicit FlagUpdater (bool& rFlag) : mrFlag(rFlag) {}
627 void operator() (bool) const {mrFlag = true;}
628private:
629 bool& mrFlag;
630};
631
632}
633
635{
638 if (pCC.is())
639 pCC->RequestSynchronousUpdate();
640}
641
642void FrameworkHelper::WaitForEvent (const OUString& rsEventType) const
643{
644 bool bConfigurationUpdateSeen (false);
645
647 rsEventType,
648 FrameworkHelperAllPassFilter(),
649 FlagUpdater(bConfigurationUpdateSeen));
650
651 sal_uInt32 nStartTime = osl_getGlobalTimer();
652 while ( ! bConfigurationUpdateSeen)
653 {
655
656 if( (osl_getGlobalTimer() - nStartTime) > 60000 )
657 {
658 OSL_FAIL("FrameworkHelper::WaitForEvent(), no event for a minute? giving up!");
659 break;
660 }
661 }
662}
663
665{
667}
668
670 const OUString& rsEventType,
671 const ConfigurationChangeEventFilter& rFilter,
672 const Callback& rCallback) const
673{
674 new CallbackCaller(mrBase,rsEventType,rFilter,rCallback);
675}
676
677void FrameworkHelper::disposing (const lang::EventObject& rEventObject)
678{
679 if (rEventObject.Source == mxConfigurationController)
681}
682
684{
686 return;
687
688 try
689 {
692 }
693 catch (lang::DisposedException&)
694 {
695 Dispose();
696 }
697 catch (RuntimeException&)
698 {
700 }
701}
702
703OUString FrameworkHelper::ResourceIdToString (const Reference<XResourceId>& rxResourceId)
704{
705 OUStringBuffer sString;
706 if (rxResourceId.is())
707 {
708 sString.append(rxResourceId->getResourceURL());
709 if (rxResourceId->hasAnchor())
710 {
711 const Sequence<OUString> aAnchorURLs (rxResourceId->getAnchorURLs());
712 for (const auto& rAnchorURL : aAnchorURLs)
713 {
714 sString.append(" | " + rAnchorURL);
715 }
716 }
717 }
718 return sString.makeStringAndClear();
719}
720
721Reference<XResourceId> FrameworkHelper::CreateResourceId (const OUString& rsResourceURL)
722{
723 return new ::sd::framework::ResourceId(rsResourceURL);
724}
725
726Reference<XResourceId> FrameworkHelper::CreateResourceId (
727 const OUString& rsResourceURL,
728 const OUString& rsAnchorURL)
729{
730 return new ::sd::framework::ResourceId(rsResourceURL, rsAnchorURL);
731}
732
733Reference<XResourceId> FrameworkHelper::CreateResourceId (
734 const OUString& rsResourceURL,
735 const Reference<XResourceId>& rxAnchorId)
736{
737 if (rxAnchorId.is())
738 return new ::sd::framework::ResourceId(
739 rsResourceURL,
740 rxAnchorId->getResourceURL(),
741 rxAnchorId->getAnchorURLs());
742 else
743 return new ::sd::framework::ResourceId(rsResourceURL);
744}
745
746//----- FrameworkHelper::DisposeListener --------------------------------------
747
749 ::std::shared_ptr<FrameworkHelper> pHelper)
750 : mpHelper(std::move(pHelper))
751{
752 Reference<XComponent> xComponent (mpHelper->mxConfigurationController, UNO_QUERY);
753 if (xComponent.is())
754 xComponent->addEventListener(this);
755}
756
757void FrameworkHelper::DisposeListener::disposing(std::unique_lock<std::mutex>&)
758{
759 Reference<XComponent> xComponent (mpHelper->mxConfigurationController, UNO_QUERY);
760 if (xComponent.is())
761 xComponent->removeEventListener(this);
762
763 mpHelper.reset();
764}
765
766void SAL_CALL FrameworkHelper::DisposeListener::disposing (const lang::EventObject& rEventObject)
767{
768 if (mpHelper != nullptr)
769 mpHelper->disposing(rEventObject);
770}
771
772//===== FrameworkHelperResourceIdFilter =======================================
773
774FrameworkHelperResourceIdFilter::FrameworkHelperResourceIdFilter (
775 const Reference<XResourceId>& rxResourceId)
776 : mxResourceId(rxResourceId)
777{
778}
779
780} // end of namespace sd::framework
781
782namespace {
783
784//===== CallbackCaller ========================================================
785
786CallbackCaller::CallbackCaller (
787 const ::sd::ViewShellBase& rBase,
788 OUString rsEventType,
791 : msEventType(std::move(rsEventType)),
792 maFilter(std::move(aFilter)),
793 maCallback(std::move(aCallback))
794{
795 try
796 {
797 Reference<XControllerManager> xControllerManager (rBase.GetController(), UNO_QUERY_THROW);
798 mxConfigurationController = xControllerManager->getConfigurationController();
800 {
801 if (mxConfigurationController->hasPendingRequests())
802 mxConfigurationController->addConfigurationChangeListener(this,msEventType,Any());
803 else
804 {
805 // There are no requests waiting to be processed. Therefore
806 // no event, especially not the one we are waiting for, will
807 // be sent in the near future and the callback would never be
808 // called.
809 // Call the callback now and tell him that the event it is
810 // waiting for was not sent.
812 maCallback(false);
813 }
814 }
815 }
816 catch (RuntimeException&)
817 {
819 }
820}
821
822void CallbackCaller::disposing(std::unique_lock<std::mutex>&)
823{
824 try
825 {
827 {
828 Reference<XConfigurationController> xCC (mxConfigurationController);
830 xCC->removeConfigurationChangeListener(this);
831 }
832 }
833 catch (RuntimeException&)
834 {
836 }
837}
838
839void SAL_CALL CallbackCaller::disposing (const lang::EventObject& rEvent)
840{
841 if (rEvent.Source == mxConfigurationController)
842 {
844 maCallback(false);
845 }
846}
847
848void SAL_CALL CallbackCaller::notifyConfigurationChange (
849 const ConfigurationChangeEvent& rEvent)
850{
851 if (!(rEvent.Type == msEventType && maFilter(rEvent)))
852 return;
853
854 maCallback(true);
856 {
857 // Reset the reference to the configuration controller so that
858 // dispose() will not try to remove the listener a second time.
859 Reference<XConfigurationController> xCC (mxConfigurationController);
861
862 // Removing this object from the controller may very likely lead
863 // to its destruction, so no calls after that.
864 xCC->removeConfigurationChangeListener(this);
865 }
866}
867
868//----- LifetimeController -------------------------------------------------
869
870LifetimeController::LifetimeController (::sd::ViewShellBase& rBase)
871 : mrBase(rBase),
872 mbListeningToViewShellBase(false),
873 mbListeningToController(false)
874{
875 // Register as listener at the ViewShellBase. Because that is not done
876 // via a reference we have to increase the reference count manually.
877 // This is necessary even though listening to the XController did
878 // increase the reference count because the controller may release its
879 // reference to us before the ViewShellBase is destroyed.
881 acquire();
882 mbListeningToViewShellBase = true;
883
884 Reference<XComponent> xComponent = rBase.GetController();
885 if (xComponent.is())
886 {
887 xComponent->addEventListener(this);
888 mbListeningToController = true;
889 }
890}
891
892LifetimeController::~LifetimeController()
893{
894 OSL_ASSERT(!mbListeningToController && !mbListeningToViewShellBase);
895}
896
897void SAL_CALL LifetimeController::disposing (const lang::EventObject&)
898{
899 mbListeningToController = false;
900 Update();
901}
902
903void LifetimeController::Notify (SfxBroadcaster&, const SfxHint& rHint)
904{
905 if (rHint.GetId() == SfxHintId::Dying)
906 {
907 mbListeningToViewShellBase = false;
908 Update();
909 release();
910 }
911}
912
913void LifetimeController::Update()
914{
915 if (mbListeningToViewShellBase && mbListeningToController)
916 {
917 // Both the controller and the ViewShellBase are alive. Keep
918 // waiting for their destruction.
919 }
920 else if (mbListeningToViewShellBase)
921 {
922 // The controller has been destroyed but the ViewShellBase is still
923 // alive. Dispose the associated FrameworkHelper but keep it around
924 // so that no new instance is created for the dying framework.
926 }
927 else
928 {
929 // Both the controller and the ViewShellBase have been destroyed.
930 // Remove the FrameworkHelper so that the next call its Instance()
931 // method can create a new instance.
933 }
934}
935
936} // end of anonymous namespace.
937
938/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::drawing::framework::XResourceId > mxResourceId
bool & mrFlag
static bool Reschedule(bool bHandleAllCurrentEvents=false)
bool GetValue() const
SfxHintId GetId() const
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
css::uno::Reference< css::frame::XController > GetController() const
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
bool IsLayerModeActive() const
virtual void WriteFrameViewData() override
Apply data of the current view on the FrameView.
Definition: drviews5.cxx:311
virtual void ChangeEditMode(EditMode eMode, bool bIsLayerModeActive)
Set status (enabled/disabled) of menu SfxSlots.
Definition: drviews1.cxx:333
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
Local derivation of the SfxHint class that defines some hint ids that are used by the ViewShell class...
The configuration controller is responsible for maintaining the current configuration.
void operator()(FrameworkHelper *pObject)
::std::shared_ptr< FrameworkHelper > mpHelper
virtual void disposing(std::unique_lock< std::mutex > &) override
DisposeListener(::std::shared_ptr< FrameworkHelper > pHelper)
The ViewURLMap is used to translate between the view URLs used by the drawing framework and the enums...
The FrameworkHelper is a convenience class that simplifies the access to the drawing framework.
FrameworkHelper(ViewShellBase &rBase)
void disposing(const css::lang::EventObject &rEventObject)
This disposing method is forwarded from the inner DisposeListener class.
static ::std::shared_ptr< ViewShell > GetViewShell(const css::uno::Reference< css::drawing::framework::XView > &rxView)
Return a ViewShell pointer for the given XView reference.
css::uno::Reference< css::drawing::framework::XResourceId > RequestView(const OUString &rsResourceURL, const OUString &rsAnchorURL)
Request the specified view to be displayed in the specified pane.
void UpdateConfiguration()
Explicit request for an update of the current configuration.
static css::uno::Reference< css::drawing::framework::XResourceId > CreateResourceId(const OUString &rsResourceURL)
Create a new XResourceId object for the given resource URL.
static InstanceMap maInstanceMap
The instance map holds (at least) one FrameworkHelper instance for every ViewShellBase object.
::std::map< const ViewShellBase *, ::std::shared_ptr< FrameworkHelper > > InstanceMap
static const OUString msHandoutViewURL
static OUString GetViewURL(ViewShell::ShellType eType)
Return a view URL for the given identifier.
static const OUString msCenterPaneURL
void RunOnEvent(const OUString &rsEventType, const ConfigurationChangeEventFilter &rFilter, const Callback &rCallback) const
Run the given callback when an event of the specified type is received from the ConfigurationControll...
static const OUString msLeftDrawPaneURL
void HandleModeChangeSlot(sal_uInt16 nSlotId, SfxRequest const &rRequest)
Process a slot call that requests a view shell change.
void RunOnResourceActivation(const css::uno::Reference< css::drawing::framework::XResourceId > &rxResourceId, const Callback &rCallback)
Run the given callback when the specified resource has been activated.
static const OUString msNotesViewURL
static ViewShell::ShellType GetViewId(const OUString &rsViewURL)
Return an identifier for the given view URL.
static const OUString msOutlineViewURL
static constexpr OUStringLiteral msConfigurationUpdateEndEvent
void RunOnConfigurationEvent(const OUString &rsEventType, const Callback &rCallback)
Run the given callback when the specified event is notified by the ConfigurationManager.
void RequestSynchronousUpdate()
Normally the requested changes of the configuration are executed asynchronously.
::std::function< void(bool bEventSeen)> Callback
static const OUString msPresentationViewURL
static const OUString msSlideSorterURL
css::uno::Reference< css::drawing::framework::XView > GetView(const css::uno::Reference< css::drawing::framework::XResourceId > &rxPaneOrViewId)
Return a reference to the view that is displayed in the specified pane.
css::uno::Reference< css::lang::XComponent > mxDisposeListener
static const OUString msSidebarViewURL
static OUString ResourceIdToString(const css::uno::Reference< css::drawing::framework::XResourceId > &rxResourceId)
Return a string representation of the given XResourceId object.
static ::std::shared_ptr< FrameworkHelper > Instance(ViewShellBase &rBase)
Return the FrameworkHelper object that is associated with the given ViewShellBase.
static const OUString msLeftImpressPaneURL
void WaitForUpdate() const
This is a short cut for WaitForEvent(msConfigurationUpdateEndEvent).
static void ReleaseInstance(const ViewShellBase &rBase)
Destroy the FrameworkHelper object for the given ViewShellBase.
static const OUString msDrawViewURL
static constexpr OUStringLiteral msResourceActivationEvent
css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
::std::function< bool(const css::drawing::framework::ConfigurationChangeEvent &)> ConfigurationChangeEventFilter
static constexpr OUStringLiteral msViewURLPrefix
static const OUString msImpressViewURL
static const OUString msViewTabBarURL
static const OUString msFullScreenPaneURL
void WaitForEvent(const OUString &rsEventName) const
Block until the specified event is notified by the configuration controller.
static void DisposeInstance(const ViewShellBase &rBase)
Mark the FrameworkHelper object for the given ViewShellBase as disposed.
bool IsValid() const
Test whether the called FrameworkHelper object is valid.
#define DBG_UNHANDLED_EXCEPTION(...)
EmbeddedObjectRef * pObject
DocumentType eType
constexpr OUStringLiteral msPaneURLPrefix(u"private:resource/pane/")
EditMode
Definition: pres.hxx:53