From adad59c6f71532488b54804c09f0ecb7663b3a22 Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Thu, 27 Jun 2024 19:50:57 -0800 Subject: tdf#161717 Enhancement to identify click on tracked change in the document by highlighting the corrosponding entry in the "Manage Changes" dialog and sidebar panel Change-Id: I1f31580a4fe764dd800c6db1e9a4e2024db14c6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169692 Reviewed-by: Jim Raykowski Tested-by: Jenkins --- include/svl/hint.hxx | 1 + sw/source/uibase/docvw/edtwin.cxx | 10 ++++++++++ sw/source/uibase/inc/redlndlg.hxx | 4 +++- sw/source/uibase/misc/redlndlg.cxx | 39 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index 3dd3db1763ea..fe636a89ec55 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -166,6 +166,7 @@ enum class SfxHintId { SwRedlineDelText, SwRedlineUnDelText, SwMoveText, + SwRedlineContentAtPos, ThisIsAnSdrHint, ThisIsAnSfxEventHint diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 28339dde0d42..1abf300f3d86 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -5364,6 +5364,16 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) if (bCallBase) Window::MouseButtonUp(rMEvt); + // tdf#161717 - Track changes: Clicking on change in document should highlight related change + // in "Manage Changes" window/sidebar + if (SwContentAtPos aRedlineContentAtPos(IsAttrAtPos::Redline); + rSh.GetContentAtPos(aDocPt, aRedlineContentAtPos)) + { + SwDocShell* pDocSh = m_rView.GetDocShell(); + if (pDocSh) + pDocSh->Broadcast(SfxHint(SfxHintId::SwRedlineContentAtPos)); + } + if (!(pSdrView && rMEvt.GetClicks() == 1 && comphelper::LibreOfficeKit::isActive())) return; diff --git a/sw/source/uibase/inc/redlndlg.hxx b/sw/source/uibase/inc/redlndlg.hxx index 6330d194fb13..b0c53e00f350 100644 --- a/sw/source/uibase/inc/redlndlg.hxx +++ b/sw/source/uibase/inc/redlndlg.hxx @@ -53,7 +53,7 @@ struct SwRedlineDataParent class SwRedlineDataParentSortArr : public o3tl::sorted_vector {}; -class SW_DLLPUBLIC SwRedlineAcceptDlg final +class SW_DLLPUBLIC SwRedlineAcceptDlg final : public SfxListener { std::shared_ptr m_xParentDlg; std::vector> m_RedlineParents; @@ -124,6 +124,8 @@ public: void FillInfo(OUString &rExtraData) const; void Activate(); + + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; }; class SwModelessRedlineAcceptDlg final : public SfxModelessDialogController diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx index 9a5a144b4426..5efd064889ab 100644 --- a/sw/source/uibase/misc/redlndlg.cxx +++ b/sw/source/uibase/misc/redlndlg.cxx @@ -207,6 +207,9 @@ SwRedlineAcceptDlg::SwRedlineAcceptDlg(std::shared_ptr xParent, we // avoid multiple selection of the same texts: m_aSelectTimer.SetTimeout(100); m_aSelectTimer.SetInvokeHandler(LINK(this, SwRedlineAcceptDlg, GotoHdl)); + + // we want to receive SfxHintId::SwRedlineContentAtPos + StartListening(*(SW_MOD()->GetView()->GetDocShell())); } SwRedlineAcceptDlg::~SwRedlineAcceptDlg() @@ -495,6 +498,42 @@ void SwRedlineAcceptDlg::Activate() InitAuthors(); } +void SwRedlineAcceptDlg::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) +{ + if (rHint.GetId() == SfxHintId::SwRedlineContentAtPos) + { + SwView* pView = GetActiveView(); + if (!pView) + return; + + SwWrtShell* pSh = pView->GetWrtShellPtr(); + if (!pSh) + return; + + const SwRangeRedline* pRangeRedline = pSh->GetCurrRedline(); + if (!pRangeRedline) + return; + + const SwRedlineData& rRedlineData = pRangeRedline->GetRedlineData(); + + weld::TreeView& rTreeView = m_pTable->GetWidget(); + rTreeView.all_foreach([&rTreeView, &rRedlineData](weld::TreeIter& rIter) { + RedlinData* pRedlinData = weld::fromId(rTreeView.get_id(rIter)); + const SwRedlineData* pRedlineData; + if (rTreeView.iter_has_child(rIter)) + pRedlineData = static_cast(pRedlinData->pData)->pData; + else + pRedlineData = static_cast(pRedlinData->pData)->pChild; + if (pRedlineData == &rRedlineData) + { + rTreeView.set_cursor(rIter); + return true; + } + return false; + }); + } +} + SwRedlineTable::size_type SwRedlineAcceptDlg::CalcDiff(SwRedlineTable::size_type nStart, bool bChild) { if (!nStart || m_bHasTrackedColumn) -- cgit