[Libreoffice-commits] core.git: sc/source
Martin van Zijl (via logerrit)
logerrit at kemper.freedesktop.org
Thu May 28 14:06:38 UTC 2020
sc/source/ui/app/inputwin.cxx | 116 +++++++++++++++++++++--------------------
sc/source/ui/inc/inputwin.hxx | 3 +
sc/source/ui/view/tabvwsh4.cxx | 21 +++++++
3 files changed, 84 insertions(+), 56 deletions(-)
New commits:
commit fef7a9e67b44c2c269f25ee211c3efd01d215a47
Author: Martin van Zijl <martin.vanzijl at gmail.com>
AuthorDate: Mon May 18 05:32:32 2020 +1200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Thu May 28 16:05:58 2020 +0200
tdf#39302 add "alt + =" shortcut for autosum
Change-Id: I11e2f77e8d8ec81d9ea6d5bc4e8ef31ec7dedc67
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94386
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index bdbf32321d44..cb2b00b51d58 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -63,7 +63,6 @@
#include <rangeutl.hxx>
#include <docfunc.hxx>
#include <funcdesc.hxx>
-#include <formula/opcode.hxx>
#include <editeng/fontitem.hxx>
#include <AccessibleEditObject.hxx>
#include <AccessibleText.hxx>
@@ -821,6 +820,43 @@ void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt )
ToolBox::MouseButtonUp( rMEvt );
}
+void ScInputWindow::AutoSum( bool& bRangeFinder, bool& bSubTotal, OpCode eCode )
+{
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
+ if ( pViewSh )
+ {
+ const OUString aFormula = pViewSh->DoAutoSum(bRangeFinder, bSubTotal, eCode);
+ if ( !aFormula.isEmpty() )
+ {
+ SetFuncString( aFormula );
+ const sal_Int32 aOpen = aFormula.indexOf('(');
+ const sal_Int32 aLen = aFormula.getLength();
+ if (bRangeFinder && pScMod->IsEditMode())
+ {
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
+ if ( pHdl )
+ {
+ pHdl->InitRangeFinder( aFormula );
+
+ //! SetSelection at the InputHandler?
+ //! Set bSelIsRef?
+ if ( aOpen != -1 && aLen > aOpen )
+ {
+ ESelection aSel( 0, aOpen + (bSubTotal ? 3 : 1), 0, aLen-1 );
+ EditView* pTableView = pHdl->GetTableView();
+ if ( pTableView )
+ pTableView->SetSelection( aSel );
+ EditView* pTopView = pHdl->GetTopView();
+ if ( pTopView )
+ pTopView->SetSelection( aSel );
+ }
+ }
+ }
+ }
+ }
+}
+
ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, ScTabViewShell* pViewSh)
: ScTextWndBase(pParent, WinBits(WB_HIDE | WB_TABSTOP)),
maTextWndGroup(VclPtr<ScTextWndGroup>::Create(this, pViewSh)),
@@ -962,63 +998,31 @@ IMPL_LINK( ScInputWindow, MenuHdl, Menu *, pMenu, bool )
OString aCommand = pMenu->GetCurItemIdent();
if (!aCommand.isEmpty())
{
- ScModule* pScMod = SC_MOD();
- ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
- if ( pViewSh )
+ bool bSubTotal = false;
+ bool bRangeFinder = false;
+ OpCode eCode = ocSum;
+ if ( aCommand == "sum" )
{
- bool bSubTotal = false;
- bool bRangeFinder = false;
- OpCode eCode = ocSum;
- if ( aCommand == "sum" )
- {
- eCode = ocSum;
- }
- else if ( aCommand == "average" )
- {
- eCode = ocAverage;
- }
- else if ( aCommand == "max" )
- {
- eCode = ocMax;
- }
- else if ( aCommand == "min" )
- {
- eCode = ocMin;
- }
- else if ( aCommand == "count" )
- {
- eCode = ocCount;
- }
-
- const OUString aFormula = pViewSh->DoAutoSum(bRangeFinder, bSubTotal, eCode);
- if ( !aFormula.isEmpty() )
- {
- SetFuncString( aFormula );
- const sal_Int32 aOpen = aFormula.indexOf('(');
- const sal_Int32 aLen = aFormula.getLength();
- if (bRangeFinder && pScMod->IsEditMode())
- {
- ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
- if ( pHdl )
- {
- pHdl->InitRangeFinder( aFormula );
-
- //! SetSelection at the InputHandler?
- //! Set bSelIsRef?
- if ( aOpen != -1 && aLen > aOpen )
- {
- ESelection aSel( 0, aOpen + (bSubTotal ? 3 : 1), 0, aLen-1 );
- EditView* pTableView = pHdl->GetTableView();
- if ( pTableView )
- pTableView->SetSelection( aSel );
- EditView* pTopView = pHdl->GetTopView();
- if ( pTopView )
- pTopView->SetSelection( aSel );
- }
- }
- }
- }
+ eCode = ocSum;
+ }
+ else if ( aCommand == "average" )
+ {
+ eCode = ocAverage;
+ }
+ else if ( aCommand == "max" )
+ {
+ eCode = ocMax;
+ }
+ else if ( aCommand == "min" )
+ {
+ eCode = ocMin;
}
+ else if ( aCommand == "count" )
+ {
+ eCode = ocCount;
+ }
+
+ AutoSum( bRangeFinder, bSubTotal, eCode );
}
return false;
}
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 30eb93bcb398..c461c8fdb732 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -31,6 +31,7 @@
#include <vcl/window.hxx>
#include <vcl/transfer.hxx>
#include <vcl/menu.hxx>
+#include <formula/opcode.hxx>
class EditView;
class ScAccessibleEditLineTextData;
@@ -309,6 +310,8 @@ public:
DECL_LINK( MenuHdl, Menu *, bool );
DECL_LINK( DropdownClickHdl, ToolBox*, void );
+ void AutoSum( bool& bRangeFinder, bool& bSubTotal, OpCode eCode );
+
private:
bool IsPointerAtResizePos();
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index b00cebcdfa28..e57caf3c2c33 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1344,6 +1344,27 @@ bool ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt)
case KEY_PAGEDOWN:
nSlotId = bShift ? SID_CURSORPAGERIGHT_SEL : SID_CURSORPAGERIGHT_;
break;
+ case KEY_EQUAL:
+ {
+ // #tdf39302: Use "Alt + =" for autosum
+ if ( !bAnyEdit ) // Ignore shortcut if currently editing a cell
+ {
+ ScInputHandler* pHdl = pScMod->GetInputHdl(this);
+ if ( pHdl )
+ {
+ ScInputWindow* pWin = pHdl->GetInputWindow();
+ if ( pWin )
+ {
+ bool bRangeFinder = false;
+ bool bSubTotal = false;
+ pWin->AutoSum( bRangeFinder, bSubTotal, ocSum );
+ }
+ }
+
+ bUsed = true;
+ break;
+ }
+ }
}
if ( nSlotId )
{
More information about the Libreoffice-commits
mailing list