diff options
author | Jim Raykowski <raykowj@gmail.com> | 2023-10-09 20:22:04 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2023-10-17 07:24:37 +0200 |
commit | 2a05fd0fd2b6c4ad8fd900565f3640f1ef47a165 (patch) | |
tree | 563257e1fac5b9fc9d629586701856d88497e3a6 | |
parent | b97aa4eada3164b20f663a9817e92af78495109f (diff) |
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 <raykowj@gmail.com>
-rw-r--r-- | sw/source/uibase/utlui/glbltree.cxx | 28 |
1 files changed, 27 insertions, 1 deletions
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(); } |