From f4bfce94abc10fbd2d8b37113e27b36c1e79fc61 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 13 Sep 2013 20:13:25 +0100 Subject: select sheet menu as a right-click popup to the prev/next sheet dingus Change-Id: Ifc9baeabedeab526d040220e9e45f171b5353bcf --- sc/source/ui/inc/tabcont.hxx | 3 ++ sc/source/ui/view/tabcont.cxx | 69 +++++++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 16 deletions(-) (limited to 'sc/source') diff --git a/sc/source/ui/inc/tabcont.hxx b/sc/source/ui/inc/tabcont.hxx index c0bde9e604ad..2c87f89c729b 100644 --- a/sc/source/ui/inc/tabcont.hxx +++ b/sc/source/ui/inc/tabcont.hxx @@ -46,6 +46,9 @@ private: sal_uInt16 GetMaxId() const; SCTAB GetPrivatDropPos(const Point& rPos ); + DECL_LINK(ShowPageList, const CommandEvent*); + + void SwitchToPageId(sal_uInt16 nId); protected: virtual void Select(); virtual void Command( const CommandEvent& rCEvt ); diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index 4fce1138d80d..4056748c5a9f 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -81,6 +81,39 @@ ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) : EnableEditMode(); UpdateInputContext(); + + SetScrollAlwaysEnabled(true); + + SetScrollAreaContextHdl( LINK( this, ScTabControl, ShowPageList ) ); +} + +IMPL_LINK(ScTabControl, ShowPageList, const CommandEvent *, pEvent) +{ + PopupMenu aPopup; + + sal_uInt16 nCurPageId = GetCurPageId(); + + ScDocument* pDoc = pViewData->GetDocument(); + SCTAB nCount = pDoc->GetTableCount(); + for (SCTAB i=0; iIsVisible(i)) + { + OUString aString; + if (pDoc->GetName(i, aString)) + { + sal_uInt16 nId = static_cast(i)+1; + aPopup.InsertItem(nId, aString, MIB_CHECKABLE); + if (nId == nCurPageId) + aPopup.CheckItem(nId); + } + } + } + + sal_uInt16 nItemId = aPopup.Execute( this, pEvent->GetMousePosPixel() ); + SwitchToPageId(nItemId); + + return 0; } ScTabControl::~ScTabControl() @@ -368,6 +401,25 @@ void ScTabControl::SetSheetLayoutRTL( sal_Bool bSheetRTL ) nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND; } +void ScTabControl::SwitchToPageId(sal_uInt16 nId) +{ + if (nId) + { + sal_Bool bAlreadySelected = IsPageSelected( nId ); + //make the clicked page the current one + SetCurPageId( nId ); + //change the selection when the current one is not already + //selected or part of a multi selection + if(!bAlreadySelected) + { + sal_uInt16 nCount = GetMaxId(); + + for (sal_uInt16 i=1; i<=nCount; i++) + SelectPage( i, i==nId ); + Select(); + } + } +} void ScTabControl::Command( const CommandEvent& rCEvt ) { @@ -387,22 +439,7 @@ void ScTabControl::Command( const CommandEvent& rCEvt ) // if multiple tables are selected and the one under the cursor // is not part of them then unselect them sal_uInt16 nId = GetPageId( rCEvt.GetMousePosPixel() ); - if (nId) - { - sal_Bool bAlreadySelected = IsPageSelected( nId ); - //make the clicked page the current one - SetCurPageId( nId ); - //change the selection when the current one is not already - //selected or part of a multi selection - if(!bAlreadySelected) - { - sal_uInt16 nCount = GetMaxId(); - - for (sal_uInt16 i=1; i<=nCount; i++) - SelectPage( i, i==nId ); - Select(); - } - } + SwitchToPageId(nId); // #i52073# OLE inplace editing has to be stopped before showing the sheet tab context menu pViewSh->DeactivateOle(); -- cgit