Kaydet (Commit) f4bfce94 authored tarafından Caolán McNamara's avatar Caolán McNamara

select sheet menu as a right-click popup to the prev/next sheet dingus

Change-Id: Ifc9baeabedeab526d040220e9e45f171b5353bcf
üst d90fa389
......@@ -369,6 +369,7 @@ private:
sal_Bool mbSelTextColor;
bool mbMirrored;
bool mbHasInsertTab; // if true, the tab bar has an extra tab at the end.
bool mbScrollAlwaysEnabled;
Link maSelectHdl;
Link maDoubleClickHdl;
Link maSplitHdl;
......@@ -377,6 +378,7 @@ private:
Link maStartRenamingHdl;
Link maAllowRenamingHdl;
Link maEndRenamingHdl;
Link maScrollAreaContextHdl;
size_t maCurrentItemList;
using Window::ImplInit;
......@@ -529,6 +531,8 @@ public:
void SetStyle( WinBits nStyle );
WinBits GetStyle() const { return mnWinStyle; }
void SetScrollAlwaysEnabled(bool bScrollAlwaysEnabled);
Size CalcWindowSizePixel() const;
void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
......@@ -547,6 +551,8 @@ public:
const Link& GetAllowRenamingHdl() const { return maAllowRenamingHdl; }
void SetEndRenamingHdl( const Link& rLink ) { maEndRenamingHdl = rLink; }
const Link& GetEndRenamingHdl() const { return maEndRenamingHdl; }
void SetScrollAreaContextHdl( const Link& rLink ) { maScrollAreaContextHdl = rLink; }
const Link& GetScrollAreaContextHdl() const { return maScrollAreaContextHdl; }
// accessibility
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
......
......@@ -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 );
......
......@@ -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();
......
......@@ -100,13 +100,33 @@ class ImplTabButton : public PushButton
{
public:
ImplTabButton( TabBar* pParent, WinBits nWinStyle = 0 ) :
PushButton( pParent, nWinStyle | WB_RECTSTYLE | WB_SMALLSTYLE | WB_NOLIGHTBORDER | WB_NOPOINTERFOCUS ) {}
PushButton( pParent, nWinStyle | WB_RECTSTYLE | WB_SMALLSTYLE | WB_NOLIGHTBORDER | WB_NOPOINTERFOCUS ) {}
TabBar* GetParent() const { return (TabBar*)Window::GetParent(); }
virtual long PreNotify( NotifyEvent& rNEvt );
virtual void MouseButtonDown( const MouseEvent& rMEvt );
virtual void Command( const CommandEvent& rCEvt );
};
void ImplTabButton::MouseButtonDown( const MouseEvent& rMEvt )
{
PushButton::MouseButtonDown(rMEvt);
}
void ImplTabButton::Command( const CommandEvent& rCEvt )
{
sal_uInt16 nCmd = rCEvt.GetCommand();
if ( nCmd == COMMAND_CONTEXTMENU )
{
TabBar *pParent = GetParent();
pParent->maScrollAreaContextHdl.Call((void*)&rCEvt);
}
PushButton::Command(rCEvt);
}
// =======================================================================
long ImplTabButton::PreNotify( NotifyEvent& rNEvt )
......@@ -398,6 +418,8 @@ void TabBar::ImplInit( WinBits nWinStyle )
mbSelColor = sal_False;
mbSelTextColor = sal_False;
mbMirrored = sal_False;
mbMirrored = sal_False;
mbScrollAlwaysEnabled = false;
if ( nWinStyle & WB_3DTAB )
mnOffY++;
......@@ -752,19 +774,25 @@ void TabBar::ImplEnableControls()
return;
// Buttons enablen/disblen
sal_Bool bEnableBtn = mnFirstPos > 0;
sal_Bool bEnableBtn = mbScrollAlwaysEnabled || mnFirstPos > 0;
if ( mpFirstBtn )
mpFirstBtn->Enable( bEnableBtn );
if ( mpPrevBtn )
mpPrevBtn->Enable( bEnableBtn );
bEnableBtn = mnFirstPos < ImplGetLastFirstPos();
bEnableBtn = mbScrollAlwaysEnabled || mnFirstPos < ImplGetLastFirstPos();
if ( mpNextBtn )
mpNextBtn->Enable( bEnableBtn );
if ( mpLastBtn )
mpLastBtn->Enable( bEnableBtn );
}
void TabBar::SetScrollAlwaysEnabled(bool bScrollAlwaysEnabled)
{
mbScrollAlwaysEnabled = bScrollAlwaysEnabled;
ImplEnableControls();
}
// -----------------------------------------------------------------------
void TabBar::ImplShowPage( sal_uInt16 nPos )
......
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