summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/app/inputwin.cxx116
-rw-r--r--sc/source/ui/inc/inputwin.hxx3
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx21
3 files changed, 84 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;
}
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 )
{