add select sheet menu to calc prev/next area

This commit is contained in:
Caolán McNamara 2013-09-13 20:17:29 +01:00
parent 61a49a8b1e
commit 3a595515b0
2 changed files with 244 additions and 0 deletions

View File

@ -0,0 +1,239 @@
From f4bfce94abc10fbd2d8b37113e27b36c1e79fc61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Fri, 13 Sep 2013 20:13:25 +0100
Subject: [PATCH] select sheet menu as a right-click popup to the prev/next
sheet dingus
Change-Id: Ifc9baeabedeab526d040220e9e45f171b5353bcf
---
include/svtools/tabbar.hxx | 6 ++++
sc/source/ui/inc/tabcont.hxx | 3 ++
sc/source/ui/view/tabcont.cxx | 69 ++++++++++++++++++++++++++++++---------
svtools/source/control/tabbar.cxx | 34 +++++++++++++++++--
4 files changed, 93 insertions(+), 19 deletions(-)
diff --git a/include/svtools/tabbar.hxx b/include/svtools/tabbar.hxx
index 0bf3be6..44bcc48 100644
--- a/include/svtools/tabbar.hxx
+++ b/include/svtools/tabbar.hxx
@@ -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();
diff --git a/sc/source/ui/inc/tabcont.hxx b/sc/source/ui/inc/tabcont.hxx
index c0bde9e..2c87f89 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 4fce113..4056748 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();
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index 4152f9d..c0b8059 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -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 )
--
1.8.3.1

View File

@ -256,6 +256,7 @@ Patch15: 0002-Related-rhbz-968892-discard-impossible-languages-for.patch
Patch16: 0001-Resolves-fdo-48835-application-menu-for-LibreOffice.patch
Patch17: 0001-Make-charmap.cxx-compile-with-icu-4.4.patch
Patch18: 0001-Resolves-rhbz-1006850-crash-in-SwCommentRuler-GetCom.patch
Patch19: 0001-select-sheet-menu-as-a-right-click-popup-to-the-prev.patch
%define instdir %{_libdir}
%define baseinstdir %{instdir}/libreoffice
@ -1006,6 +1007,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc
%patch16 -p1 -b .fdo-48835-application-menu-for-LibreOffice.patch
%patch17 -p1 -b .Make-charmap.cxx-compile-with-icu-4.4.patch
%patch18 -p1 -b .rhbz-1006850-crash-in-SwCommentRuler-GetCom.patch
%patch19 -p1 -b .select-sheet-menu-as-a-right-click-popup-to-the-prev.patch
# TODO: check this
# these are horribly incomplete--empty translations and copied english
@ -2096,6 +2098,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
%endif
%changelog
* Fri Sep 13 2013 Caolán McNamara <caolanm@redhat.com> - 1:4.1.2.1-3.UNBUILT
- add select sheet menu to calc prev/next area
* Thu Sep 12 2013 Caolán McNamara <caolanm@redhat.com> - 1:4.1.2.1-2
- Resolves: rhbz#1006850 crash in SwCommentRuler