From 3649dc202bedf72e37c77993a1f7027bfdfc6d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Sz=C5=B1cs?= Date: Thu, 29 Jun 2023 18:32:27 +0200 Subject: [PATCH] LOK: Navigator: fix expand problems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Save/load content types' expanded status to view, and make sure it is synchronized with client. Treeviews now receive/send collapse event/status from/to client. I've rewritten the way how headings are opened by default (because synch of collapsed status broke that, as sub-headings were not expanded at core side). Change-Id: I80f5b4d99fe5224391a92c4609f94ddbcf37b8ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153771 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar (cherry picked from commit b95750af717e0693a13c3ef35277779e1394e0ae) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158016 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sw/inc/view.hxx | 1 + sw/source/uibase/inc/conttree.hxx | 2 ++ sw/source/uibase/utlui/content.cxx | 21 +++++++++++++++++++++ sw/source/uibase/utlui/navipi.cxx | 9 ++++----- vcl/jsdialog/executor.cxx | 10 ++++++++++ vcl/source/treelist/svtabbx.cxx | 4 ++++ 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index c5967bb4e213..523f86cc8468 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -355,6 +355,7 @@ class SW_DLLPUBLIC SwView: public SfxViewShell public: // #i123922# Needs to be called from a 2nd place now as a helper method SAL_DLLPRIVATE bool InsertGraphicDlg( SfxRequest& ); + sal_Int32 m_nNaviExpandedStatus = -1; protected: diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 495cdfa91353..9c6db5b5a5eb 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -274,6 +274,8 @@ public: // return true if it has any children bool RequestingChildren(const weld::TreeIter& rParent); + void ExpandAllHeadings(); + virtual void Notify(SfxBroadcaster& rBC, SfxHint const& rHint) override; sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt); diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index d047251ea958..02d3a661e4d1 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1135,6 +1135,12 @@ SwContentTree::SwContentTree(std::unique_ptr xTreeView, SwNaviga OUString sDocTitle = pView->GetDocShell()->GetTitle(); if (lcl_DocOutLineExpandStateMap.find(sDocTitle) != lcl_DocOutLineExpandStateMap.end()) mOutLineNodeMap = lcl_DocOutLineExpandStateMap[sDocTitle]; + if (comphelper::LibreOfficeKit::isActive()) { + if (pView->m_nNaviExpandedStatus < 0) + m_nActiveBlock = 1; + else + m_nActiveBlock = pView->m_nNaviExpandedStatus; + } } m_aUpdTimer.SetInvokeHandler(LINK(this, SwContentTree, TimerUpdate)); @@ -1149,6 +1155,8 @@ SwContentTree::~SwContentTree() { OUString sDocTitle = pView->GetDocShell()->GetTitle(); lcl_DocOutLineExpandStateMap[sDocTitle] = mOutLineNodeMap; + if (comphelper::LibreOfficeKit::isActive()) + pView->m_nNaviExpandedStatus = m_nActiveBlock; } clear(); // If applicable erase content types previously. m_aUpdTimer.Stop(); @@ -2225,6 +2233,19 @@ bool SwContentTree::RequestingChildren(const weld::TreeIter& rParent) return false; } +void SwContentTree::ExpandAllHeadings() +{ + if (HasHeadings()) + { + std::unique_ptr xEntry = GetEntryAtAbsPos(0); + if (xEntry) + { + if (!IsAllExpanded(*m_xTreeView, *xEntry)) + ExpandOrCollapseAll(*m_xTreeView, *xEntry); + } + } +} + SdrObject* SwContentTree::GetDrawingObjectsByContent(const SwContent *pCnt) { SdrObject *pRetObj = nullptr; diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index c868592e904d..3fd5b7f9b682 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -736,12 +736,11 @@ SwNavigationPI::SwNavigationPI(weld::Widget* pParent, m_xGlobalTree->HideTree(); //Open Headings by default - if (m_xContentTree->HasHeadings()) + SwView *pView = GetCreateView(); + if (pView->m_nNaviExpandedStatus < 0) { - auto& pTreeView = m_xContentTree->get_widget(); - std::unique_ptr itEntry(pTreeView.make_iterator()); - pTreeView.get_iter_first(*itEntry); - pTreeView.expand_row(*itEntry); + pView->m_nNaviExpandedStatus = 1; + m_xContentTree->ExpandAllHeadings(); } } } diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 17c56d78e61e..46d5fb675366 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -498,6 +498,16 @@ bool ExecuteAction(const OUString& nWindowId, const OUString& rWidget, StringMap pTreeView->expand_row(*itEntry); return true; } + else if (sAction == "collapse") + { + sal_Int32 nAbsPos = o3tl::toInt32(rData["data"]); + std::unique_ptr itEntry(pTreeView->make_iterator()); + pTreeView->get_iter_abs_pos(*itEntry, nAbsPos); + pTreeView->set_cursor_without_notify(*itEntry); + pTreeView->grab_focus(); + pTreeView->collapse_row(*itEntry); + return true; + } else if (sAction == "dragstart") { sal_Int32 nRow = o3tl::toInt32(rData["data"]); diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx index 0c3a179f0adf..81f0f4e8b078 100644 --- a/vcl/source/treelist/svtabbx.cxx +++ b/vcl/source/treelist/svtabbx.cxx @@ -104,6 +104,10 @@ static void lcl_DumpEntryAndSiblings(tools::JsonWriter& rJsonWriter, rJsonWriter.put("ondemand", true); } } + if (rChildren.size() > 0 && !pTabListBox->IsExpanded(pEntry)) + { + rJsonWriter.put("collapsed", true); + } if (bCheckButtons) {