[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - sc/source

Henry Castro hcastro at collabora.com
Tue Oct 25 12:28:59 UTC 2016


 sc/source/ui/app/inputwin.cxx  |   27 ++++++++++++++++++++++++++-
 sc/source/ui/inc/tabvwsh.hxx   |    2 +-
 sc/source/ui/view/cellsh1.cxx  |   28 ++++++++++++++++++----------
 sc/source/ui/view/tabvwshc.cxx |   37 +++++--------------------------------
 4 files changed, 50 insertions(+), 44 deletions(-)

New commits:
commit 4cb70d641e06f1252da15e194f98d4aa2835d56a
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Oct 24 22:15:45 2016 -0400

    tdf#103409: No selection outline displayed when SUM button is clicked
    
    Change-Id: I8a1bb22bd0be9717a56a90732b17c4ed8f230bf3
    Reviewed-on: https://gerrit.libreoffice.org/30254
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index a306bd2..dfa3a98 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -335,10 +335,35 @@ void ScInputWindow::Select()
                 ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current()  );
                 if ( pViewSh )
                 {
-                    const OUString aFormula = pViewSh->DoAutoSum();
+                    bool bSubTotal = false;
+                    bool bRangeFinder = false;
+                    const OUString aFormula = pViewSh->DoAutoSum(bRangeFinder, bSubTotal);
                     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 );
+                                }
+                            }
+                        }
                     }
                 }
             }
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 6a6c3bb..6d24e07 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -383,7 +383,7 @@ public:
     bool IsActive() const { return bIsActive; }
     OUString GetFormula(ScAddress& rAddress);
     bool    UseSubTotal(ScRangeList* pRangeList);
-    const   OUString DoAutoSum();
+    const   OUString DoAutoSum(bool& rRangeFinder, bool& rSubTotal);
 
     // ugly hack to call Define Names from Manage Names
     void    SwitchBetweenRefDialogs(SfxModelessDialog* pDialog);
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 426ff9a..d2ff687 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2531,19 +2531,24 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
         case SID_AUTO_SUM:
             {
-                const OUString aFormula = pTabViewShell->DoAutoSum();
-                if (!aFormula.isEmpty())
+                bool bSubTotal = false;
+                bool bRangeFinder = false;
+                const OUString aFormula = pTabViewShell->DoAutoSum( bRangeFinder, bSubTotal );
+                if ( !aFormula.isEmpty() )
                 {
-                    ScInputHandler* pHdl = pScMod->GetInputHdl(pTabViewShell);
-                    if (pHdl)
+                    const sal_Int32 nPar = aFormula.indexOf( '(' );
+                    const sal_Int32 nLen = aFormula.getLength();
+                    ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
+
+                    if ( pHdl && nPar != -1 )
                     {
-                        if (!pScMod->IsEditMode())
+                        if ( !pScMod->IsEditMode() )
                         {
-                            pScMod->SetInputMode(SC_INPUT_TABLE);
+                            pScMod->SetInputMode( SC_INPUT_TABLE );
                         }
 
                         EditView *pEditView=pHdl->GetActiveView();
-                        if (pEditView)
+                        if ( pEditView )
                         {
                             ESelection aTextSel = pEditView->GetSelection();
                             aTextSel.nStartPos = 0;
@@ -2551,10 +2556,13 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                             pHdl->DataChanging();
                             pEditView->SetSelection(aTextSel);
                             pEditView->InsertText(aFormula);
-                            aTextSel.nStartPos = aFormula.getLength() - 1;
-                            aTextSel.nEndPos = aFormula.getLength() - 1;
-                            pEditView->SetSelection(aTextSel);
+                            pEditView->SetSelection( bRangeFinder ? ESelection( 0, nPar + ( bSubTotal ? 3 : 1 ), 0, nLen - 1 ) : ESelection( 0, nLen - 1, 0, nLen - 1 ) );
                             pHdl->DataChanged();
+
+                            if ( bRangeFinder )
+                            {
+                                pHdl->InitRangeFinder( aFormula );
+                            }
                         }
                     }
                 }
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 09dfdd8..f91d965 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -625,14 +625,14 @@ bool ScTabViewShell::UseSubTotal(ScRangeList* pRangeList)
     return bSubTotal;
 }
 
-const OUString ScTabViewShell::DoAutoSum()
+const OUString ScTabViewShell::DoAutoSum(bool& rRangeFinder, bool& rSubTotal)
 {
     OUString aFormula;
-    ScModule* pScMod = SC_MOD();
     const ScMarkData& rMark = GetViewData().GetMarkData();
     if ( rMark.IsMarked() || rMark.IsMultiMarked() )
     {
         ScRangeList aMarkRangeList;
+        rRangeFinder = rSubTotal = false;
         rMark.FillRangeListWithMarks( &aMarkRangeList, false );
         ScDocument* pDoc = GetViewData().GetDocument();
 
@@ -687,37 +687,10 @@ const OUString ScTabViewShell::DoAutoSum()
     else // Only insert into input row
     {
         ScRangeList aRangeList;
-        const bool bDataFound = GetAutoSumArea( aRangeList );
-        const bool bSubTotal( UseSubTotal( &aRangeList ) );
+        rRangeFinder = GetAutoSumArea( aRangeList );
+        rSubTotal = UseSubTotal( &aRangeList );
         ScAddress aAddr = GetViewData().GetCurPos();
-        aFormula = GetAutoSumFormula( aRangeList, bSubTotal, aAddr );
-
-        if ( bDataFound && pScMod->IsEditMode() )
-        {
-            ScInputHandler* pHdl = pScMod->GetInputHdl( this );
-            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 )
-                {
-                    sal_uInt8 nAdd(1);
-                    if (bSubTotal)
-                        nAdd = 3;
-                    ESelection aSel(0,nOpen+nAdd,0,nLen-1);
-                    EditView* pTableView = pHdl->GetTableView();
-                    if (pTableView)
-                        pTableView->SetSelection(aSel);
-                    EditView* pTopView = pHdl->GetTopView();
-                    if (pTopView)
-                        pTopView->SetSelection(aSel);
-                }
-            }
-        }
+        aFormula = GetAutoSumFormula( aRangeList, rSubTotal, aAddr );
     }
     return aFormula;
 }


More information about the Libreoffice-commits mailing list