summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2018-04-05 11:43:07 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-04-08 23:59:34 +0200
commitca5a01e7cfa2db9b1c7a0537e09ddf69c28acd57 (patch)
tree1ac43d6e324d79a47f0d800b4c9df5392c083b3f
parent5f349801d546db1ded1fcc9a2880004bc25f7add (diff)
tdf#116816: Show/hide notes takes too much time to run
The commands show/hide notes take too much time to run, while they check all cells for notes, it is better to check registered notes and then check if they are in selected range. Change-Id: I6a65dc974af7d62430c6f48a9061dcb2594fea00 Reviewed-on: https://gerrit.libreoffice.org/52451 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--sc/source/ui/view/cellsh1.cxx41
1 files changed, 20 insertions, 21 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 97892de03912..a7b28e26fafd 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2281,31 +2281,31 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
bool bDone = false;
ScRangeListRef aRangesRef;
pData->GetMultiArea(aRangesRef);
- ScRangeList aRanges = *aRangesRef;
- size_t nRangeSize = aRanges.size();
+ const ScRangeList aRanges = *aRangesRef;
OUString aUndo = ScGlobal::GetRscString( bShowNote ? STR_UNDO_SHOWNOTE : STR_UNDO_HIDENOTE );
pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() );
- for ( size_t i = 0; i < nRangeSize; ++i )
+ for (auto const& rTab : rMark.GetSelectedTabs())
{
- const ScRange & rRange = aRanges[i];
- const SCROW nRow0 = rRange.aStart.Row();
- const SCROW nRow1 = rRange.aEnd.Row();
- const SCCOL nCol0 = rRange.aStart.Col();
- const SCCOL nCol1 = rRange.aEnd.Col();
- const SCTAB nRangeTab = rRange.aStart.Tab();
- // Check by each cell
- for ( SCROW nRow = nRow0; nRow <= nRow1; ++nRow )
+ // get notes
+ std::vector<sc::NoteEntry> aNotes;
+ pDoc->GetAllNoteEntries(rTab, aNotes);
+
+ for (const sc::NoteEntry& rNote : aNotes)
{
- for ( SCCOL nCol = nCol0; nCol <= nCol1; ++nCol )
+ // check if note is in our selection range
+ const ScAddress& rAdr = rNote.maPos;
+ const ScRange* rRange = aRanges.Find(rAdr);
+ if (! rRange)
+ continue;
+
+ // check if cell is editable
+ const SCTAB nRangeTab = rRange->aStart.Tab();
+ if (pDoc->IsBlockEditable( nRangeTab, rAdr.Col(), rAdr.Row(), rAdr.Col(), rAdr.Row() ))
{
- if ( pDoc->HasNote(nCol, nRow, nRangeTab) && pDoc->IsBlockEditable( nRangeTab, nCol,nRow, nCol,nRow ) )
- {
- ScAddress aPos( nCol, nRow, nRangeTab );
- pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote );
- bDone = true;
- }
+ pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
+ bDone = true;
}
}
}
@@ -2341,10 +2341,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
pDoc->GetAllNoteEntries(rTab, aNotes);
}
- for(std::vector<sc::NoteEntry>::const_iterator itr = aNotes.begin(),
- itrEnd = aNotes.end(); itr != itrEnd; ++itr)
+ for (const sc::NoteEntry& rNote : aNotes)
{
- const ScAddress& rAdr = itr->maPos;
+ const ScAddress& rAdr = rNote.maPos;
pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote );
}