Kaydet (Commit) 0143805a authored tarafından Andre Fischer's avatar Andre Fischer Kaydeden (comit) Caolán McNamara

Resolves: #i122332# Don't change sidebar context when switching...

to other application window

(cherry picked from commit 604502e2)

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
üst ec3fafa6
......@@ -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 <TRUE/> then broadcast the context name that was
defined with an earlier call to SetContextName().
When <FALSE/> then broadcast the 'default' context.
*/
void BroadcastContextForActivation (const bool bIsActivated);
#ifndef _SFXSH_HXX
SAL_DLLPRIVATE bool CanExecuteSlot_Impl( const SfxSlot &rSlot );
......
......@@ -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 (
......
......@@ -53,7 +53,7 @@ class SVX_DLLPUBLIC SelectionChangeHandler
{
public:
SelectionChangeHandler (
const boost::function<sfx2::sidebar::EnumContext::Context(void)>& rSelectionChangeCallback,
const boost::function<rtl::OUString(void)>& rSelectionChangeCallback,
const cssu::Reference<css::frame::XController>& rxController,
const sfx2::sidebar::EnumContext::Context eDefaultContext);
virtual ~SelectionChangeHandler (void);
......@@ -71,7 +71,7 @@ public:
void Disconnect (void);
private:
const boost::function<sfx2::sidebar::EnumContext::Context(void)> maSelectionChangeCallback;
const boost::function<rtl::OUString(void)> maSelectionChangeCallback;
cssu::Reference<css::frame::XController> mxController;
const sfx2::sidebar::EnumContext::Context meDefaultContext;
bool mbIsConnected;
......
......@@ -35,6 +35,7 @@
#include <svx/fontworkbar.hxx>
#include <svx/sidebar/SelectionChangeHandler.hxx>
#include <svx/sidebar/SelectionAnalyzer.hxx>
#include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
#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: */
......@@ -23,7 +23,6 @@
#include <sfx2/shell.hxx>
#include "shellids.hxx"
#include <sfx2/module.hxx>
#include <sfx2/sidebar/EnumContext.hxx>
#include <svx/svdmark.hxx>
#include <tools/link.hxx>
#include <rtl/ref.hxx>
......@@ -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);
};
......
......@@ -24,7 +24,6 @@
#include "tools/AsynchronousCall.hxx"
#include <sfx2/viewfac.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/sidebar/EnumContext.hxx>
#include "TabControl.hxx"
#include "pres.hxx"
#include <svx/sidebar/SelectionChangeHandler.hxx>
......@@ -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;
......
......@@ -51,6 +51,7 @@
#include "SdUnoSlideView.hxx"
#include "ViewShellManager.hxx"
#include "Window.hxx"
#include "drawview.hxx"
#include <sfx2/app.hxx>
#include <sfx2/msg.hxx>
#include <sfx2/objface.hxx>
......@@ -62,6 +63,7 @@
#include <svx/svxids.hrc>
#include <sfx2/sidebar/EnumContext.hxx>
#include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
#include <svx/sidebar/SelectionAnalyzer.hxx>
#include <com/sun/star/drawing/framework/XControllerManager.hpp>
#include <com/sun/star/drawing/framework/ResourceId.hpp>
#include <cppuhelper/bootstrap.hxx>
......@@ -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<DrawViewShell*>(pMainViewShell.get());
if (pDrawViewShell && (pDrawViewShell->GetEditMode()== EM_MASTERPAGE))
eContext = EnumContext::Context_MasterPage;
DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(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);
}
......
......@@ -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());
}
}
......
......@@ -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<frame::XController>(&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));
}
......
......@@ -363,6 +363,8 @@ void OutlineViewShell::Activate( sal_Bool bIsMDIActivate )
}
ViewShell::Activate( bIsMDIActivate );
SfxShell::BroadcastContextForActivation(true);
pOlView->SetLinks();
pOlView->ConnectToApplication();
......
......@@ -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()
......
......@@ -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: */
......@@ -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;
......
......@@ -32,7 +32,7 @@ using namespace sfx2::sidebar;
namespace svx { namespace sidebar {
SelectionChangeHandler::SelectionChangeHandler (
const boost::function<sfx2::sidebar::EnumContext::Context(void)>& rSelectionChangeCallback,
const boost::function<rtl::OUString(void)>& rSelectionChangeCallback,
const Reference<frame::XController>& 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment