sw/source/uibase/utlui/glbltree.cxx |   28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 2a05fd0fd2b6c4ad8fd900565f3640f1ef47a165
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Mon Oct 9 20:22:04 2023 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Tue Oct 17 07:24:37 2023 +0200

    tdf#144349 related: Make master document navigator track Text content
    
    Done, with a related patch to make the master document navigator track TOX 
content, to make the Navigator less likely not to have an item selected, which 
may be enough to resolve tdf#155741 - Allow insertion of items into master 
without a selected item
    
    Change-Id: I1a9d2a12a01ca2c5f3f162e8da932c04ced9a461
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157741
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/sw/source/uibase/utlui/glbltree.cxx 
b/sw/source/uibase/utlui/glbltree.cxx
index fe18195e7c22..8c8fef089161 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -787,12 +787,12 @@ IMPL_LINK_NOARG(SwGlobalTree, Timeout, Timer *, void)
     }
 }
 
+// track GlobalDocContentType at the cursor position in the document
 void SwGlobalTree::UpdateTracking()
 {
     if (!m_pActiveShell)
         return;
 
-    // track section at cursor position in document
     m_xTreeView->unselect_all();
 
     const SwSection* pActiveShellCurrSection = 
m_pActiveShell->GetCurrSection();
@@ -816,6 +816,32 @@ void SwGlobalTree::UpdateTracking()
             }
         }
     }
+    else
+    {
+        const SwCursor* pCursor = m_pActiveShell->GetCursor();
+        const SwNode& rNode = pCursor->GetPoint()->GetNode();
+        if (rNode.IsTextNode())
+        {
+            // only the first text node in each series of text nodes is stored 
in the
+            // SwGlblDocContents array
+            SwNodeIndex aIdx(rNode);
+            do
+            {
+                --aIdx;
+            } while (aIdx.GetNode().IsTextNode());
+            ++aIdx;
+            SwNodeOffset aTextNodeIndex(aIdx.GetNode().GetIndex());
+            for (const std::unique_ptr<SwGlblDocContent>& rGlblDocContent : 
*m_pSwGlblDocContents)
+            {
+                if (rGlblDocContent->GetType() == 
GlobalDocContentType::GLBLDOC_UNKNOWN
+                        && rGlblDocContent->GetDocPos() == aTextNodeIndex)
+                {
+                    const OUString& rId(weld::toId(rGlblDocContent.get()));
+                    m_xTreeView->select(m_xTreeView->find_id(rId));
+                }
+            }
+        }
+    }
 
     Select();
 }

Reply via email to