sc/source/ui/navipi/content.cxx |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

New commits:
commit 4fb84ed4808a21da56772763561434ced8924588
Author:     Caolán McNamara <[email protected]>
AuthorDate: Fri Oct 31 20:51:00 2025 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat Nov 1 15:01:13 2025 +0100

    we can avoid pulling all the notes from the document here
    
    if we store the comment id when we insert it
    
    Change-Id: Ib15a682ebfb328c0420422cf9bd345475283d450
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193285
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 520fd947a661..8d9433d84115 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -1001,7 +1001,8 @@ void ScContentTree::GetNoteStrings()
     for (const auto& rEntry : aEntries)
     {
         OUString aValue = lcl_NoteString(*rEntry.mpNote);
-        m_xTreeView->insert(pParent, -1, &aValue, nullptr, nullptr, nullptr, 
false, m_xScratchIter.get());
+        OUString aId = OUString::number(rEntry.mpNote->GetId());
+        m_xTreeView->insert(pParent, -1, &aValue, &aId, nullptr, nullptr, 
false, m_xScratchIter.get());
         m_xTreeView->set_sensitive(*m_xScratchIter, true);
     }
 }
@@ -1546,21 +1547,11 @@ void ScContentTree::BringCommentToAttention(sal_uInt16 
nCommentId)
             m_xTreeView->select(*xIter);
             m_xTreeView->expand_row(*xIter);
 
-            std::vector<sc::NoteEntry> aEntries;
-            ScDocument* pDoc = GetSourceDocument();
-            pDoc->GetAllNoteEntries(aEntries);
-
-            if (aEntries.size() != 
static_cast<size_t>(m_xTreeView->iter_n_children(*xIter))) {
-                SAL_WARN("sc", "number of comments and children count does not 
match.");
-                return;
-            }
-
-            size_t i = 0;
+            OUString aCommentId(OUString::number(nCommentId));
             for (bool bChild = m_xTreeView->iter_children(*xIter); bChild;
                  bChild = m_xTreeView->iter_next_sibling(*xIter))
             {
-                const ScPostIt* pPostIt = aEntries[i++].mpNote;
-                if (pPostIt && pPostIt->GetId() == nCommentId)
+                if (m_xTreeView->get_id(*xIter) == aCommentId)
                 {
                     m_xTreeView->select(*xIter);
                     break;

Reply via email to