diff options
author | Jim Raykowski <raykowj@gmail..com> | 2020-03-03 12:08:20 -0900 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2020-03-08 03:28:53 +0100 |
commit | 4bca67d21e418eb3981cd63390bf2cb401dabe13 (patch) | |
tree | 5770224c1976b136dc84d3461bba4fb739bab604 | |
parent | f61fa885ed929e7d4aea4d84b2ddadea4825eb18 (diff) |
tdf#131067 Only outline track if an outline entry is selected
This patch ignores outline tracking when other than Headings/outline
content is navigated to from the Navigator.
Change-Id: I3ecbe508b5d641e8f9bd8fe2e70d8ae23f0bf879
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89928
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 250b588a00b0..bce33ac6aaba 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -2793,50 +2793,54 @@ IMPL_LINK_NOARG(SwContentTree, TimerUpdate, Timer *, void) // track document outline position at cursor if (m_nOutlineTracking == 3) // no outline tracking return; + const SwOutlineNodes::size_type nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL); // find out where the cursor is if (nActPos == SwOutlineNodes::npos) + return; + + // only track if selection is already an outline + SvTreeListEntry* pFirstSelected = FirstSelected(); + if (pFirstSelected && lcl_IsContent(pFirstSelected) && + static_cast<SwContent*>(pFirstSelected->GetUserData())->GetParent()->GetType() != ContentTypeId::OUTLINE) + return; + if (pFirstSelected && lcl_IsContentType(pFirstSelected) && + static_cast<SwContentType*>(pFirstSelected->GetUserData())->GetType() != ContentTypeId::OUTLINE) + return; + + // find the outline in the tree and select it + for (SvTreeListEntry* pEntry = First(); pEntry; pEntry = Next(pEntry)) { - // cursor is not in an outline position so clear any selections in the tree list - if (FirstSelected()) - SelectAll(false); - } - else - { - SvTreeListEntry* pFirstSelected = FirstSelected(); - for (SvTreeListEntry* pEntry = First(); pEntry; pEntry = Next(pEntry)) + if (lcl_IsContent(pEntry) && + static_cast<SwContent*>(pEntry->GetUserData())->GetParent()->GetType() == ContentTypeId::OUTLINE) { - if (lcl_IsContent(pEntry) && - static_cast<SwContent*>(pEntry->GetUserData())->GetParent()->GetType() == ContentTypeId::OUTLINE) + // might have been scrolled out of view by the user so leave it that way + if (static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos() == nActPos) { - // might have been scrolled out of view by the user so leave it that way - if (static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos() == nActPos) + // only select if not already selected or tree has multiple entries selected + if (pEntry != pFirstSelected || GetSelectionCount() > 1) { - // only select if not already selected or tree has multiple entries selected - if (pEntry != pFirstSelected || GetSelectionCount() > 1) + if (m_nOutlineTracking == 2) // focused outline tracking { - if (m_nOutlineTracking == 2) // focused outline tracking + // collapse to children of root node + for (SvTreeListEntry* pChildEntry = FirstChild(First()); pChildEntry; pChildEntry = Next(pChildEntry)) { - // collapse to children of root node - for (SvTreeListEntry* pChildEntry = FirstChild(First()); pChildEntry; pChildEntry = Next(pChildEntry)) - { - if (static_cast<SwContent*>(pChildEntry->GetUserData())->GetParent()->GetType() == ContentTypeId::OUTLINE) - Collapse(pChildEntry); - else - break; - } + if (static_cast<SwContent*>(pChildEntry->GetUserData())->GetParent()->GetType() == ContentTypeId::OUTLINE) + Collapse(pChildEntry); + else + break; } - SetCurEntry(pEntry); // unselect all entries, make pEntry visible, and select } - break; + SetCurEntry(pEntry); // unselect all entries, make pEntry visible, and select } + break; } - else - { - // use of this break assumes outline content type is first in tree - if (lcl_IsContentType(pEntry) && - static_cast<SwContentType*>(pEntry->GetUserData())->GetType() != ContentTypeId::OUTLINE) - break; - } + } + else + { + // use of this break assumes outline content type is first in tree + if (lcl_IsContentType(pEntry) && + static_cast<SwContentType*>(pEntry->GetUserData())->GetType() != ContentTypeId::OUTLINE) + break; } } } |