sw/source/uibase/inc/conttree.hxx | 3 + sw/source/uibase/utlui/content.cxx | 68 ++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 32 deletions(-)
New commits: commit 454436a92e19aa3cc02b001bd61befe19eb02966 Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Thu Oct 21 09:09:51 2021 -0800 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Feb 9 11:08:17 2022 +0100 SwNavigator: Improve detection of when the content tree needs refreshed Makes the check that determines if the content tree needs refreshed be done only when the content tree is visible AND (the document has been modified since previous check OR an action has been made within the content tree that requires the tree to be refreshed) AND there is no writer shell action pending AND the content tree is not in a DnD. Change-Id: Ie67472d44573df6afafb08b7b3229a4e07fc9db5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124036 Tested-by: Jenkins Reviewed-by: Jim Raykowski <rayk...@gmail.com> (cherry picked from commit 5c5f36aa73b11356a3bff0a9cc8b5fe8d1a776b9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129616 Tested-by: Gabor Kelemen <kelem...@ubuntu.com> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index f572bc76a983..5a52954e3da4 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -124,7 +124,8 @@ class SwContentTree final : public SfxListener // outline root mode drag & drop std::vector<std::unique_ptr<weld::TreeIter>> m_aDndOutlinesSelected; - bool m_bIgnoreViewChange = false; + bool m_bDocHasChanged = true; + bool m_bIgnoreDocChange = false; // used to prevent tracking update /** * Before any data will be deleted, the last active entry has to be found. diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 5985e21c41dd..31508a7aedf1 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -2388,7 +2388,7 @@ void SwContentTree::Display( bool bActive ) } } - if (!m_bIgnoreViewChange && GetEntryCount() == nOldEntryCount) + if (!m_bIgnoreDocChange && GetEntryCount() == nOldEntryCount) { m_xTreeView->vadjustment_set_value(nOldScrollPos); } @@ -2917,9 +2917,9 @@ void SwContentTree::Notify(SfxBroadcaster & rBC, SfxHint const& rHint) break; } case SfxHintId::DocChanged: - if (!m_bIgnoreViewChange) + if (!m_bIgnoreDocChange) { - m_bViewHasChanged = true; + m_bDocHasChanged = true; TimerUpdate(&m_aUpdTimer); } break; @@ -2964,7 +2964,7 @@ void SwContentTree::ExecCommand(std::string_view rCmd, bool bOutlineWithChildren return; } - m_bIgnoreViewChange = true; + m_bIgnoreDocChange = true; SwWrtShell *const pShell = GetWrtShell(); sal_Int8 nActOutlineLevel = m_nOutlineLevel; @@ -3253,7 +3253,7 @@ void SwContentTree::ExecCommand(std::string_view rCmd, bool bOutlineWithChildren } } } - m_bIgnoreViewChange = false; + m_bIgnoreDocChange = false; } void SwContentTree::ShowTree() @@ -3333,37 +3333,43 @@ static void lcl_SelectDrawObjectByName(weld::TreeView& rContentTree, std::u16str /** No idle with focus or while dragging */ IMPL_LINK_NOARG(SwContentTree, TimerUpdate, Timer *, void) { + // No need to update if content tree is not visible + if (!m_xTreeView->is_visible()) + return; + // No update while focus is not in document. // No update while drag and drop. // Query view because the Navigator is cleared too late. SwView* pView = GetParentWindow()->GetCreateView(); if(pView && pView->GetWrtShellPtr() && pView->GetWrtShellPtr()->GetWin() && - (pView->GetWrtShellPtr()->GetWin()->HasFocus() || m_bViewHasChanged) && + (pView->GetWrtShellPtr()->GetWin()->HasFocus() || m_bDocHasChanged || m_bViewHasChanged) && !IsInDrag() && !pView->GetWrtShellPtr()->ActionPend()) { - m_bViewHasChanged = false; - m_bIsIdleClear = false; - SwWrtShell* pActShell = pView->GetWrtShellPtr(); - if (State::CONSTANT == m_eState && !lcl_FindShell(m_pActiveShell)) - { - SetActiveShell(pActShell); - GetParentWindow()->UpdateListBox(); - } - - if (State::ACTIVE == m_eState && pActShell != GetWrtShell()) - { - SetActiveShell(pActShell); - } - else if ((State::ACTIVE == m_eState || (State::CONSTANT == m_eState && pActShell == GetWrtShell())) && - HasContentChanged()) + if (m_bDocHasChanged || m_bViewHasChanged) { - FindActiveTypeAndRemoveUserData(); - Display(true); + SwWrtShell* pActShell = pView->GetWrtShellPtr(); + if (State::CONSTANT == m_eState && !lcl_FindShell(m_pActiveShell)) + { + SetActiveShell(pActShell); + GetParentWindow()->UpdateListBox(); + } + if (State::ACTIVE == m_eState && pActShell != GetWrtShell()) + { + SetActiveShell(pActShell); + } + else if ((State::ACTIVE == m_eState || (State::CONSTANT == m_eState && pActShell == GetWrtShell())) && + HasContentChanged()) + { + FindActiveTypeAndRemoveUserData(); + Display(true); + } } - UpdateTracking(); + m_bIsIdleClear = false; + m_bDocHasChanged = false; + m_bViewHasChanged = false; } - else if (!pView && State::ACTIVE == m_eState && !m_bIsIdleClear) + else if (!pView && State::ACTIVE == m_eState && !m_bIsIdleClear) // this block seems never to be entered { if(m_pActiveShell) { @@ -3379,10 +3385,10 @@ void SwContentTree::UpdateTracking() if (State::HIDDEN == m_eState || !m_pActiveShell) return; - // m_bIgnoreViewChange is set on delete - if (m_bIgnoreViewChange) + // m_bIgnoreDocChange is set on delete and outline visibility toggle + if (m_bIgnoreDocChange) { - m_bIgnoreViewChange = false; + m_bIgnoreDocChange = false; return; } @@ -3995,7 +4001,7 @@ void SwContentTree::ExecuteContextMenuAction(const OString& rSelectedPopupEntry) case SHOW_OUTLINE_CONTENT_VISIBILITY: { m_pActiveShell->EnterStdMode(); - m_bIgnoreViewChange = true; + m_bIgnoreDocChange = true; SwOutlineContent* pCntFirst = reinterpret_cast<SwOutlineContent*>(m_xTreeView->get_id(*xFirst).toInt64()); // toggle the outline node outline content visible attribute @@ -4032,7 +4038,7 @@ void SwContentTree::ExecuteContextMenuAction(const OString& rSelectedPopupEntry) else m_pActiveShell->GotoOutline(pCntFirst->GetOutlinePos()); grab_focus(); - m_bIgnoreViewChange = false; + m_bIgnoreDocChange = false; } break; case 11: @@ -4324,7 +4330,7 @@ void SwContentTree::EditEntry(const weld::TreeIter& rEntry, EditEntryMode nMode) sal_uInt16 nSlot = 0; if(EditEntryMode::DELETE == nMode) - m_bIgnoreViewChange = true; + m_bIgnoreDocChange = true; uno::Reference< container::XNameAccess > xNameAccess, xSecond, xThird; switch(nType)