From 0143805a565418d2a114c16b7eeba3b784176d9e Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Mon, 27 May 2013 11:18:04 +0000 Subject: Resolves: #i122332# Don't change sidebar context when switching... to other application window (cherry picked from commit 604502e2a4b53f35aedbf0205598a9b691c0d532) Conflicts: sd/source/ui/view/drviewsa.cxx sfx2/inc/sfx2/shell.hxx sfx2/source/control/shell.cxx svx/inc/svx/sidebar/SelectionAnalyzer.hxx svx/inc/svx/sidebar/SelectionChangeHandler.hxx Change-Id: Id3c427e02714ef0d6686a78094e2f7f3b390a693 --- include/sfx2/shell.hxx | 15 +++++- include/svx/sidebar/SelectionAnalyzer.hxx | 16 +++++-- include/svx/sidebar/SelectionChangeHandler.hxx | 4 +- sc/source/ui/drawfunc/drawsh2.cxx | 26 +++++++++-- sc/source/ui/inc/drawsh.hxx | 4 +- sd/source/ui/inc/DrawViewShell.hxx | 5 +- .../ui/slidesorter/shell/SlideSorterViewShell.cxx | 18 +++----- sd/source/ui/view/drviews1.cxx | 12 ++--- sd/source/ui/view/drviewsa.cxx | 36 +++++++++------ sd/source/ui/view/outlnvsh.cxx | 2 + sd/source/ui/view/viewshel.cxx | 2 +- sfx2/source/control/shell.cxx | 25 +++++----- svx/source/sidebar/SelectionAnalyzer.cxx | 54 +++++++++++++--------- svx/source/sidebar/SelectionChangeHandler.cxx | 5 +- 14 files changed, 139 insertions(+), 85 deletions(-) diff --git a/include/sfx2/shell.hxx b/include/sfx2/shell.hxx index cb5b149714df..ddeb677e3127 100644 --- a/include/sfx2/shell.hxx +++ b/include/sfx2/shell.hxx @@ -238,7 +238,20 @@ public: virtual SfxItemSet* CreateItemSet( sal_uInt16 nId ); virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ); - void SetContextName (const ::rtl::OUString& rsContextName); + /** Set the name of the sidebar context that is broadcast on calls + to Activation(). + */ + void SetContextName (const ::rtl::OUString& rsContextName); + + /** Broadcast a sidebar context change. + This method is typically called from Activate() or + Deactivate(). + @param bIsActivated + When then broadcast the context name that was + defined with an earlier call to SetContextName(). + When then broadcast the 'default' context. + */ + void BroadcastContextForActivation (const bool bIsActivated); #ifndef _SFXSH_HXX SAL_DLLPRIVATE bool CanExecuteSlot_Impl( const SfxSlot &rSlot ); diff --git a/include/svx/sidebar/SelectionAnalyzer.hxx b/include/svx/sidebar/SelectionAnalyzer.hxx index 601a96e977f9..1a3623265b69 100644 --- a/include/svx/sidebar/SelectionAnalyzer.hxx +++ b/include/svx/sidebar/SelectionAnalyzer.hxx @@ -37,19 +37,25 @@ class SVX_DLLPUBLIC SelectionAnalyzer public : static sfx2::sidebar::EnumContext::Context GetContextForSelection_SC ( const SdrMarkList& rMarkList); + + enum ViewType + { + VT_Standard, + VT_Master, + VT_Handout, + VT_Notes, + VT_Outline + }; static sfx2::sidebar::EnumContext::Context GetContextForSelection_SD ( const SdrMarkList& rMarkList, - const bool bIsMasterPage, - const bool bIsHandoutPage, - const bool bIsNotesPage); + const ViewType eViewType); private: static sfx2::sidebar::EnumContext::Context GetContextForObjectId_SC ( const sal_uInt16 nObjectId); static sfx2::sidebar::EnumContext::Context GetContextForObjectId_SD ( const sal_uInt16 nObjectId, - const bool bIsHandoutPage, - const bool bIsNotesPage); + const ViewType eViewType); static sal_uInt32 GetInventorTypeFromMark ( const SdrMarkList& rMarkList); static sal_uInt16 GetObjectTypeFromMark ( diff --git a/include/svx/sidebar/SelectionChangeHandler.hxx b/include/svx/sidebar/SelectionChangeHandler.hxx index 29116e5249b8..da1e4e703a12 100644 --- a/include/svx/sidebar/SelectionChangeHandler.hxx +++ b/include/svx/sidebar/SelectionChangeHandler.hxx @@ -53,7 +53,7 @@ class SVX_DLLPUBLIC SelectionChangeHandler { public: SelectionChangeHandler ( - const boost::function& rSelectionChangeCallback, + const boost::function& rSelectionChangeCallback, const cssu::Reference& rxController, const sfx2::sidebar::EnumContext::Context eDefaultContext); virtual ~SelectionChangeHandler (void); @@ -71,7 +71,7 @@ public: void Disconnect (void); private: - const boost::function maSelectionChangeCallback; + const boost::function maSelectionChangeCallback; cssu::Reference mxController; const sfx2::sidebar::EnumContext::Context meDefaultContext; bool mbIsConnected; diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index 47df366fdf93..94c685275957 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include "drawsh.hxx" #include "drawview.hxx" @@ -61,7 +62,7 @@ ScDrawShell::ScDrawShell( ScViewData* pData ) : SfxShell(pData->GetViewShell()), pViewData( pData ), mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler( - ::boost::bind(&ScDrawShell::GetContextForSelection, this), + ::boost::bind(&ScDrawShell::GetSidebarContextName, this), GetFrame()->GetFrame().GetController(), sfx2::sidebar::EnumContext::Context_Cell)) { @@ -396,10 +397,27 @@ void ScDrawShell::GetDrawAttrStateForIFBX( SfxItemSet& rSet ) } } -sfx2::sidebar::EnumContext::Context ScDrawShell::GetContextForSelection (void) + + + +void ScDrawShell::Activate (const sal_Bool bMDI) +{ + (void)bMDI; + + ContextChangeEventMultiplexer::NotifyContextChange( + GetFrame()->GetFrame().GetController(), + ::sfx2::sidebar::EnumContext::GetContextEnum( + GetSidebarContextName())); +} + + + + +::rtl::OUString ScDrawShell::GetSidebarContextName (void) { - return ::svx::sidebar::SelectionAnalyzer::GetContextForSelection_SC( - GetDrawView()->GetMarkedObjectList()); + return sfx2::sidebar::EnumContext::GetContextName( + ::svx::sidebar::SelectionAnalyzer::GetContextForSelection_SC( + GetDrawView()->GetMarkedObjectList())); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/drawsh.hxx b/sc/source/ui/inc/drawsh.hxx index d251eee63d77..34050b1375d7 100644 --- a/sc/source/ui/inc/drawsh.hxx +++ b/sc/source/ui/inc/drawsh.hxx @@ -23,7 +23,6 @@ #include #include "shellids.hxx" #include -#include #include #include #include @@ -45,6 +44,7 @@ class ScDrawShell : public SfxShell void SetHlinkForObject( SdrObject* pObj, const OUString& rHlnk ); protected: + virtual void Activate(sal_Bool bMDI); ScViewData* GetViewData() { return pViewData; } public: @@ -83,7 +83,7 @@ public: sal_Bool AreAllObjectsOnLayer(sal_uInt16 nLayerNo,const SdrMarkList& rMark); void GetDrawAttrStateForIFBX( SfxItemSet& rSet ); - ::sfx2::sidebar::EnumContext::Context GetContextForSelection (void); + ::rtl::OUString GetSidebarContextName (void); }; diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 6d91b187e81f..8dfdea6af7cf 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -24,7 +24,6 @@ #include "tools/AsynchronousCall.hxx" #include #include -#include #include "TabControl.hxx" #include "pres.hxx" #include @@ -362,6 +361,8 @@ public: */ virtual bool RelocateToParentWindow (::Window* pParentWindow); + ::rtl::OUString GetSidebarContextName (void) const; + protected: DrawView* mpDrawView; SdPage* mpActualPage; @@ -487,8 +488,6 @@ private: const sal_uInt16 nSnapLineIndex, const Point& rMouseLocation); - ::sfx2::sidebar::EnumContext::Context GetContextForSelection (void) const; - using ViewShell::Notify; ::std::auto_ptr< AnnotationManager > mpAnnotationManager; diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx index 43ff8248132e..e9c627f5e460 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx @@ -51,6 +51,7 @@ #include "SdUnoSlideView.hxx" #include "ViewShellManager.hxx" #include "Window.hxx" +#include "drawview.hxx" #include #include #include @@ -62,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -563,23 +565,20 @@ void SlideSorterViewShell::Activate (sal_Bool bIsMDIActivate) switch (eMainViewShellType) { case ViewShell::ST_IMPRESS: + case ViewShell::ST_SLIDE_SORTER: + case ViewShell::ST_NOTES: eContext = EnumContext::Context_DrawPage; if (pMainViewShell->ISA(DrawViewShell)) { - DrawViewShell* pDrawViewShell = static_cast(pMainViewShell.get()); - if (pDrawViewShell && (pDrawViewShell->GetEditMode()== EM_MASTERPAGE)) - eContext = EnumContext::Context_MasterPage; + DrawViewShell* pDrawViewShell = dynamic_cast(pMainViewShell.get()); + if (pDrawViewShell != NULL) + eContext = EnumContext::GetContextEnum(pDrawViewShell->GetSidebarContextName()); } break; - case ViewShell::ST_SLIDE_SORTER: eContext = EnumContext::Context_SlidesorterPage; break; - case ViewShell::ST_NOTES: - eContext = EnumContext::Context_NotesPage; - break; - default: break; } @@ -593,9 +592,6 @@ void SlideSorterViewShell::Activate (sal_Bool bIsMDIActivate) void SlideSorterViewShell::Deactivate (sal_Bool /*bIsMDIActivate*/) { - ContextChangeEventMultiplexer::NotifyContextChange( - &GetViewShellBase(), - EnumContext::Context_Default); } diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 876eab309070..26ad764b4fbe 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -114,9 +114,9 @@ void DrawViewShell::UIDeactivated( SfxInPlaceClient* pCli ) } -void DrawViewShell::Deactivate(sal_Bool bIsMDIActivate) +void DrawViewShell::Deactivate(sal_Bool /*bIsMDIActivate*/) { - ViewShell::Deactivate(bIsMDIActivate); + // Do not forward to ViewShell::Deactivate() to prevent a context change. } namespace @@ -459,13 +459,7 @@ void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive) Invalidate( SID_NOTES_MASTERPAGE ); Invalidate( SID_HANDOUT_MASTERPAGE ); - if (meEditMode == EM_PAGE) - SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawPage)); - else if (mePageKind == PK_HANDOUT) - - SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_HandoutPage)); - else - SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_MasterPage)); + SetContextName(GetSidebarContextName()); } } diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx index 22872581c7f3..1caab1a55f7e 100644 --- a/sd/source/ui/view/drviewsa.cxx +++ b/sd/source/ui/view/drviewsa.cxx @@ -125,7 +125,7 @@ DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBas , mbIsLayerModeActive(false) , mbIsInSwitchPage(false) , mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler( - ::boost::bind(&DrawViewShell::GetContextForSelection, this), + ::boost::bind(&DrawViewShell::GetSidebarContextName, this), uno::Reference(&rViewShellBase.GetDrawController()), sfx2::sidebar::EnumContext::Context_Default)) { @@ -137,12 +137,7 @@ DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBas mpSelectionChangeHandler->Connect(); - if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE) - SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawPage)); - else if (mePageKind == PK_HANDOUT) - SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_HandoutPage)); - else - SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_MasterPage)); + SetContextName(GetSidebarContextName()); doShow(); } @@ -833,13 +828,28 @@ void DrawViewShell::GetAnnotationState (SfxItemSet& rItemSet ) -EnumContext::Context DrawViewShell::GetContextForSelection (void) const +::rtl::OUString DrawViewShell::GetSidebarContextName (void) const { - return ::svx::sidebar::SelectionAnalyzer::GetContextForSelection_SD( - mpDrawView->GetMarkedObjectList(), - meEditMode == EM_MASTERPAGE, - mePageKind == PK_HANDOUT, - mePageKind == PK_NOTES); + ::svx::sidebar::SelectionAnalyzer::ViewType eViewType (::svx::sidebar::SelectionAnalyzer::VT_Standard); + switch (mePageKind) + { + case PK_HANDOUT: + eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Handout; + break; + case PK_NOTES: + eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Notes; + break; + case PK_STANDARD: + if (meEditMode == EM_MASTERPAGE) + eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Master; + else + eViewType = ::svx::sidebar::SelectionAnalyzer::VT_Standard; + break; + } + return EnumContext::GetContextName( + ::svx::sidebar::SelectionAnalyzer::GetContextForSelection_SD( + mpDrawView->GetMarkedObjectList(), + eViewType)); } diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 494101834ce8..80f8b3d6ed42 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -363,6 +363,8 @@ void OutlineViewShell::Activate( sal_Bool bIsMDIActivate ) } ViewShell::Activate( bIsMDIActivate ); + SfxShell::BroadcastContextForActivation(true); + pOlView->SetLinks(); pOlView->ConnectToApplication(); diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 6fe1ba2cded2..19ab22046487 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -304,7 +304,7 @@ void ViewShell::Exit (void) */ void ViewShell::Activate(sal_Bool bIsMDIActivate) { - SfxShell::Activate(bIsMDIActivate); + // Do not forward to SfxShell::Activate() /* According to MI, nobody is allowed to call GrabFocus, who does not exactly know from which window the focus is grabbed. Since Activate() diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index 6822af7e8d2c..bbbe3f541533 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -638,17 +638,13 @@ void SfxShell::Activate in order to give the Subclasses the opportunity to respond to the to the enabling. - The base implementation is empty and does not need to be called. - [Cross-reference] StarView SystemWindow::Activate(sal_Bool) */ { - SfxViewFrame* pViewFrame = GetFrame(); - if (pViewFrame != NULL) - pImp->maContextChangeBroadcaster.Activate(pViewFrame->GetFrame().GetFrameInterface()); + BroadcastContextForActivation(true); } //-------------------------------------------------------------------- @@ -673,19 +669,16 @@ void SfxShell::Deactivate Virtual method that is called when disabling the SfxShell instance, to give the Subclasses the opportunity to respond to the disabling. - The base implementation is empty and does not need to be called. - [Cross-reference] StarView SystemWindow::Dectivate(sal_Bool) */ { - SfxViewFrame* pViewFrame = GetFrame(); - if (pViewFrame != NULL) - pImp->maContextChangeBroadcaster.Deactivate(pViewFrame->GetFrame().GetFrameInterface()); + BroadcastContextForActivation(false); } + void SfxShell::ParentActivate ( ) @@ -1171,6 +1164,16 @@ void SfxShell::SetViewShell_Impl( SfxViewShell* pView ) pImp->pViewSh = pView; } - +void SfxShell::BroadcastContextForActivation (const bool bIsActivated) +{ + SfxViewFrame* pViewFrame = GetFrame(); + if (pViewFrame != NULL) + { + if (bIsActivated) + pImp->maContextChangeBroadcaster.Activate(pViewFrame->GetFrame().GetFrameInterface()); + else + pImp->maContextChangeBroadcaster.Deactivate(pViewFrame->GetFrame().GetFrameInterface()); + } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/SelectionAnalyzer.cxx b/svx/source/sidebar/SelectionAnalyzer.cxx index 5924c6f94060..6e0a419a360b 100644 --- a/svx/source/sidebar/SelectionAnalyzer.cxx +++ b/svx/source/sidebar/SelectionAnalyzer.cxx @@ -93,9 +93,7 @@ EnumContext::Context SelectionAnalyzer::GetContextForSelection_SC (const SdrMark EnumContext::Context SelectionAnalyzer::GetContextForSelection_SD ( const SdrMarkList& rMarkList, - const bool bIsMasterPage, - const bool bIsHandoutPage, - const bool bIsNotesPage) + const ViewType eViewType) { EnumContext::Context eContext = EnumContext::Context_Unknown; @@ -104,14 +102,24 @@ EnumContext::Context SelectionAnalyzer::GetContextForSelection_SD ( switch (rMarkList.GetMarkCount()) { case 0: - if (bIsHandoutPage) - eContext = EnumContext::Context_HandoutPage; - else if (bIsNotesPage) - eContext = EnumContext::Context_NotesPage; - else if (bIsMasterPage) - eContext = EnumContext::Context_MasterPage; - else - eContext = EnumContext::Context_DrawPage; + switch(eViewType) + { + case VT_Standard: + eContext = EnumContext::Context_DrawPage; + break; + case VT_Master: + eContext = EnumContext::Context_MasterPage; + break; + case VT_Handout: + eContext = EnumContext::Context_HandoutPage; + break; + case VT_Notes: + eContext = EnumContext::Context_NotesPage; + break; + case VT_Outline: + eContext = EnumContext::Context_OutlineText; + break; + } break; case 1: @@ -141,7 +149,7 @@ EnumContext::Context SelectionAnalyzer::GetContextForSelection_SD ( if (nObjId == 0) nObjId = OBJ_GRUP; } - eContext = GetContextForObjectId_SD(nObjId, bIsHandoutPage, bIsNotesPage); + eContext = GetContextForObjectId_SD(nObjId, eViewType); } else if (nInv == E3dInventor) { @@ -165,7 +173,7 @@ EnumContext::Context SelectionAnalyzer::GetContextForSelection_SD ( if (nObjId == 0) eContext = EnumContext::Context_MultiObject; else - eContext = GetContextForObjectId_SD(nObjId, bIsHandoutPage, bIsNotesPage); + eContext = GetContextForObjectId_SD(nObjId, eViewType); break; } @@ -238,8 +246,7 @@ EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SC (const sal_uInt EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SD ( const sal_uInt16 nObjectId, - const bool bIsHandoutPage, - const bool bIsNotesPage) + const ViewType eViewType) { switch (nObjectId) { @@ -281,12 +288,17 @@ EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SD ( return EnumContext::Context_Table; case OBJ_PAGE: - if (bIsHandoutPage) - return EnumContext::Context_HandoutPage; - else if (bIsNotesPage) - return EnumContext::Context_NotesPage; - else - return EnumContext::Context_Unknown; + switch (eViewType) + { + case VT_Handout: + return EnumContext::Context_HandoutPage; + case VT_Notes: + return EnumContext::Context_NotesPage; + case VT_Outline: + return EnumContext::Context_OutlineText; + default: + return EnumContext::Context_Unknown; + } default: return EnumContext::Context_Unknown; diff --git a/svx/source/sidebar/SelectionChangeHandler.cxx b/svx/source/sidebar/SelectionChangeHandler.cxx index 275812fc35e5..b6f6d9b68728 100644 --- a/svx/source/sidebar/SelectionChangeHandler.cxx +++ b/svx/source/sidebar/SelectionChangeHandler.cxx @@ -32,7 +32,7 @@ using namespace sfx2::sidebar; namespace svx { namespace sidebar { SelectionChangeHandler::SelectionChangeHandler ( - const boost::function& rSelectionChangeCallback, + const boost::function& rSelectionChangeCallback, const Reference& rxController, const EnumContext::Context eDefaultContext) : SelectionChangeHandlerInterfaceBase(m_aMutex), @@ -58,7 +58,8 @@ void SAL_CALL SelectionChangeHandler::selectionChanged (const lang::EventObject& { if (maSelectionChangeCallback) { - const EnumContext::Context eContext (maSelectionChangeCallback()); + const EnumContext::Context eContext ( + EnumContext::GetContextEnum(maSelectionChangeCallback())); ContextChangeEventMultiplexer::NotifyContextChange( mxController, eContext==EnumContext::Context_Unknown -- cgit