sc/source/ui/app/inputwin.cxx |   39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

New commits:
commit b247630d8b5e81041e0ed515572dfede49ccdf46
Author:     Matt K <matt...@gmail.com>
AuthorDate: Thu Jul 13 18:12:16 2023 -0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Jul 14 06:40:06 2023 +0200

    tdf#150262 Split Autosum button and default to sum on click
    
    This change follows with comments in the bug report by
    changing the Button Type to dropdown and adding back
    the code to do the autosum on default click of the
    sigma button.
    
    Change-Id: Ibe7afa1c7b8346b6a6de5d1db8223dab17ee720a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154405
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 005b29e3b573..2c46b93db54d 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -197,7 +197,7 @@ ScInputWindow::ScInputWindow( vcl::Window* pParent, const 
SfxBindings* pBind ) :
     // sigma and equal buttons
     if (!bIsLOKMobilePhone)
     {
-        InsertItem      (SID_INPUT_SUM,      Image(StockImage::Yes, 
RID_BMP_INPUT_SUM), ToolBoxItemBits::DROPDOWNONLY, 3);
+        InsertItem      (SID_INPUT_SUM,      Image(StockImage::Yes, 
RID_BMP_INPUT_SUM), ToolBoxItemBits::DROPDOWN, 3);
         InsertItem      (SID_INPUT_EQUAL,    Image(StockImage::Yes, 
RID_BMP_INPUT_EQUAL), ToolBoxItemBits::NONE, 4);
         InsertItem      (SID_INPUT_CANCEL,   Image(StockImage::Yes, 
RID_BMP_INPUT_CANCEL), ToolBoxItemBits::NONE, 5);
         InsertItem      (SID_INPUT_OK,       Image(StockImage::Yes, 
RID_BMP_INPUT_OK), ToolBoxItemBits::NONE, 6);
@@ -366,6 +366,43 @@ void ScInputWindow::Select()
         SetSumAssignMode();
         mxTextWindow->Invalidate(); // Or else the Selection remains
     }
+    else if (curItemId == SID_INPUT_SUM)
+    {
+        ScTabViewShell* pViewSh = 
dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+        if (pViewSh)
+        {
+            bool bSubTotal = false;
+            bool bRangeFinder = false;
+            const OUString aFormula = pViewSh->DoAutoSum(bRangeFinder, 
bSubTotal, ocSum);
+            if (!aFormula.isEmpty())
+            {
+                SetFuncString(aFormula);
+                if (bRangeFinder && pScMod->IsEditMode())
+                {
+                    ScInputHandler* pHdl = pScMod->GetInputHdl(pViewSh);
+                    if (pHdl)
+                    {
+                        pHdl->InitRangeFinder(aFormula);
+
+                        //! SetSelection at the InputHandler?
+                        //! Set bSelIsRef?
+                        const sal_Int32 nOpen = aFormula.indexOf('(');
+                        const sal_Int32 nLen = aFormula.getLength();
+                        if (nOpen != -1 && nLen > nOpen)
+                        {
+                            ESelection aSel(0, nOpen + (bSubTotal ? 3 : 1), 0, 
nLen - 1);
+                            EditView* pTableView = pHdl->GetTableView();
+                            if (pTableView)
+                                pTableView->SetSelection(aSel);
+                            EditView* pTopView = pHdl->GetTopView();
+                            if (pTopView)
+                                pTopView->SetSelection(aSel);
+                        }
+                    }
+                }
+            }
+        }
+    }
     else if (curItemId == SID_INPUT_EQUAL)
     {
         StartFormula();

Reply via email to