summaryrefslogtreecommitdiff
path: root/sc/source/ui/app
diff options
context:
space:
mode:
authorMartin van Zijl <martin.vanzijl@gmail.com>2020-05-18 05:32:32 +1200
committerEike Rathke <erack@redhat.com>2020-05-28 19:03:10 +0200
commitc44ea3d7d55bc309a078fb01a09994e6098c3ff4 (patch)
tree8baf0379cb1c0001f796c6ef36d4182f7c45ace8 /sc/source/ui/app
parentd19ee8bcd6ae496c2268362fd61e34914f61ac13 (diff)
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@redhat.com> (cherry picked from commit f4b47f7d335227d037c2c2e9f662724d4b8c73d4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94964
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r--sc/source/ui/app/inputwin.cxx116
1 files changed, 60 insertions, 56 deletions
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;
}