diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-09-13 20:13:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-13 20:14:24 +0100 |
commit | f4bfce94abc10fbd2d8b37113e27b36c1e79fc61 (patch) | |
tree | 87f31b265a76abed74c917a9c8cf9cf324c9205c /sc/source | |
parent | d90fa3890d18ca554ec48cb78fcc7bf410dabb85 (diff) |
select sheet menu as a right-click popup to the prev/next sheet dingus
Change-Id: Ifc9baeabedeab526d040220e9e45f171b5353bcf
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/inc/tabcont.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/tabcont.cxx | 69 |
2 files changed, 56 insertions, 16 deletions
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; i<nCount; ++i) + { + if (pDoc->IsVisible(i)) + { + OUString aString; + if (pDoc->GetName(i, aString)) + { + sal_uInt16 nId = static_cast<sal_uInt16>(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(); |