From e0bf78d6f572000cf5f9dda2a85dd15a8b350e18 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 4 Oct 2010 17:27:20 -0400 Subject: Ported calc-insert-new-sheet-tab-sc.diff from ooo-build. Display a 'plus' button at the right end of the sheet tabs, to allow quick insertion of new sheets. --- sc/source/ui/view/tabcont.cxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx index 073ab3064..2f122da37 100644 --- a/sc/source/ui/view/tabcont.cxx +++ b/sc/source/ui/view/tabcont.cxx @@ -54,7 +54,7 @@ //================================================================== ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) : - TabBar( pParent, WinBits( WB_BORDER | WB_3DLOOK | WB_SCROLL | + TabBar( pParent, WinBits( WB_BORDER | WB_3DLOOK | WB_SCROLL | WB_INSERTTAB | WB_RANGESELECT | WB_MULTISELECT | WB_DRAG | WB_SIZEABLE ) ), DropTargetHelper( this ), DragSourceHelper( this ), @@ -161,7 +161,7 @@ void ScTabControl::MouseButtonDown( const MouseEvent& rMEvt ) Needing clean left click without modifiers (may be context menu). #106948# Remember clicks to all pages, to be able to move mouse pointer later. */ if( rMEvt.IsLeft() && (rMEvt.GetModifier() == 0) ) - nMouseClickPageId = GetPageId( rMEvt.GetPosPixel() ); + nMouseClickPageId = GetPageId( rMEvt.GetPosPixel(), true ); else nMouseClickPageId = TabBar::PAGE_NOT_FOUND; @@ -173,13 +173,25 @@ void ScTabControl::MouseButtonUp( const MouseEvent& rMEvt ) Point aPos = PixelToLogic( rMEvt.GetPosPixel() ); // mouse button down and up on same page? - if( nMouseClickPageId != GetPageId( aPos ) ) + if( nMouseClickPageId != GetPageId( aPos, true ) ) nMouseClickPageId = TabBar::PAGE_NOT_FOUND; + if (nMouseClickPageId == TabBar::INSERT_TAB_POS) + { + // Insert a new sheet at the right end, with default name. + ScDocument* pDoc = pViewData->GetDocument(); + String aName; + pDoc->CreateValidTabName(aName); + SCTAB nTabCount = pDoc->GetTableCount(); + pViewData->GetViewShell()->InsertTable(aName, nTabCount); + return; + } + if ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && nMouseClickPageId != 0 && nMouseClickPageId != TAB_PAGE_NOTFOUND ) { SfxDispatcher* pDispatcher = pViewData->GetViewShell()->GetViewFrame()->GetDispatcher(); pDispatcher->Execute( FID_TAB_MENU_RENAME, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD ); + return; } if( nMouseClickPageId == 0 ) -- cgit v1.2.3