From 03b52b540549d6e5c61fd7c8c1bf05c43eac0ddd Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Wed, 2 Oct 2013 08:52:09 +0000 Subject: [PATCH] Resolves: #i123276# Properly forward Deactivate() call... and still don't broadcast context change. (cherry picked from commit 520cc667c80cea6bb48422825250b72ff36bb4ef) Conflicts: sd/source/ui/view/drviews1.cxx sfx2/inc/sfx2/shell.hxx sfx2/inc/sfx2/sidebar/ContextChangeBroadcaster.hxx sfx2/source/control/shell.cxx sfx2/source/sidebar/ContextChangeBroadcaster.cxx Change-Id: I753009041a999bc31a0528e37f0a499897f311c5 --- include/sfx2/shell.hxx | 4 ++++ .../sfx2/sidebar/ContextChangeBroadcaster.hxx | 9 +++++++++ sd/source/ui/view/drviews1.cxx | 10 ++++++++-- sfx2/source/control/shell.cxx | 5 +++++ sfx2/source/sidebar/ContextChangeBroadcaster.cxx | 16 +++++++++++++++- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/include/sfx2/shell.hxx b/include/sfx2/shell.hxx index b5455a8216ad..7bde39f915da 100644 --- a/include/sfx2/shell.hxx +++ b/include/sfx2/shell.hxx @@ -249,6 +249,10 @@ public: */ void BroadcastContextForActivation (const bool bIsActivated); + /** Enabled or disable the context broadcaster. Returns the old state. + */ + bool SetContextBroadcasterEnabled (const bool bIsEnabled); + SAL_DLLPRIVATE bool CanExecuteSlot_Impl( const SfxSlot &rSlot ); SAL_DLLPRIVATE void DoActivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI); SAL_DLLPRIVATE void DoDeactivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI); diff --git a/include/sfx2/sidebar/ContextChangeBroadcaster.hxx b/include/sfx2/sidebar/ContextChangeBroadcaster.hxx index 25701d3d9f8f..b1012da342b8 100644 --- a/include/sfx2/sidebar/ContextChangeBroadcaster.hxx +++ b/include/sfx2/sidebar/ContextChangeBroadcaster.hxx @@ -41,8 +41,17 @@ public: void Activate (const cssu::Reference& rxFrame); void Deactivate (const cssu::Reference& rxFrame); + /** Enable or disable the broadcaster. + @param bIsEnabled + The new value of the "enabled" state. + @return + The old value of the "enabled" state is returned. + */ + bool SetBroadcasterEnabled (const bool bIsEnabled); + private: rtl::OUString msContextName; + bool mbIsBroadcasterEnabled; void BroadcastContextChange ( const cssu::Reference& rxFrame, diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 54ea09a3cff0..2df556dd7413 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -114,9 +114,15 @@ void DrawViewShell::UIDeactivated( SfxInPlaceClient* pCli ) } -void DrawViewShell::Deactivate(sal_Bool /*bIsMDIActivate*/) +void DrawViewShell::Deactivate(sal_Bool bIsMDIActivate) { - // Do not forward to ViewShell::Deactivate() to prevent a context change. + // Temporarily disable context broadcasting while the Deactivate() + // call is forwarded to our base class. + const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false)); + + ViewShell::Deactivate(bIsMDIActivate); + + SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled); } namespace diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index 8ffef2ca3a2f..eaed943daa84 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -1176,4 +1176,9 @@ void SfxShell::BroadcastContextForActivation (const bool bIsActivated) } } +bool SfxShell::SetContextBroadcasterEnabled (const bool bIsEnabled) +{ + return pImp->maContextChangeBroadcaster.SetBroadcasterEnabled(bIsEnabled); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/ContextChangeBroadcaster.cxx b/sfx2/source/sidebar/ContextChangeBroadcaster.cxx index 0e40f352b1fb..57d820f1c2c1 100644 --- a/sfx2/source/sidebar/ContextChangeBroadcaster.cxx +++ b/sfx2/source/sidebar/ContextChangeBroadcaster.cxx @@ -32,7 +32,8 @@ namespace sfx2 { namespace sidebar { ContextChangeBroadcaster::ContextChangeBroadcaster (void) - : msContextName() + : msContextName(), + mbIsBroadcasterEnabled(true) { } @@ -76,11 +77,24 @@ void ContextChangeBroadcaster::Deactivate (const cssu::Reference& rxFrame, const ::rtl::OUString& rsModuleName, const ::rtl::OUString& rsContextName) { + if ( ! mbIsBroadcasterEnabled) + return; + if (rsContextName.getLength() == 0) return;