summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2016-10-24 22:15:45 -0400
committerHenry Castro <hcastro@collabora.com>2016-10-25 07:22:11 -0400
commit4cb70d641e06f1252da15e194f98d4aa2835d56a (patch)
treec3be36ed3b626ec424e5511fbc73b77e0a863fdd
parentb1ec4d7377ccc4facd46743ee63815fc5745afa2 (diff)
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@libreoffice.org> Reviewed-by: Henry Castro <hcastro@collabora.com>
-rw-r--r--sc/source/ui/app/inputwin.cxx27
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx2
-rw-r--r--sc/source/ui/view/cellsh1.cxx28
-rw-r--r--sc/source/ui/view/tabvwshc.cxx37
4 files changed, 50 insertions, 44 deletions
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index a306bd293617..dfa3a9892d19 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 6a6c3bb08296..6d24e071d0c4 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 426ff9a48827..d2ff6875783f 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 09dfdd82d33e..f91d965279a6 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;
}