sc/source/ui/view/cellsh1.cxx |   36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

New commits:
commit f382fb59ab4065b38d0db5660940bd45e850bc5a
Author: Serge Krot <serge.k...@cib.de>
Date:   Thu Apr 5 11:43:07 2018 +0200

    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.
    
    Reviewed-on: https://gerrit.libreoffice.org/52451
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    
    Conflicts:
            sc/source/ui/view/cellsh1.cxx
    
    Change-Id: I6a65dc974af7d62430c6f48a9061dcb2594fea00
    Reviewed-on: https://gerrit.libreoffice.org/52996
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    Tested-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 14f8b8b14fea..01e153b47f7b 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2282,31 +2282,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 );
 
-                    for ( size_t i = 0; i < nRangeSize; ++i )
+                    for (auto const& rTab : rMark.GetSelectedTabs())
                     {
-                        const ScRange * pRange = aRanges[i];
-                        const SCROW nRow0 = pRange->aStart.Row();
-                        const SCROW nRow1 = pRange->aEnd.Row();
-                        const SCCOL nCol0 = pRange->aStart.Col();
-                        const SCCOL nCol1 = pRange->aEnd.Col();
-                        const SCTAB nRangeTab = pRange->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;
                             }
                         }
                     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to