include/svx/svxids.hrc | 1 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 8 ++ sw/inc/view.hxx | 1 sw/sdi/_viewsh.sdi | 5 + sw/sdi/swriter.sdi | 18 ++++ sw/source/uibase/inc/conttree.hxx | 1 sw/source/uibase/inc/navipi.hxx | 21 +++++ sw/source/uibase/inc/swcont.hxx | 1 sw/source/uibase/uiview/view0.cxx | 33 ++++++++ sw/source/uibase/utlui/content.cxx | 38 ++++++++++ sw/source/uibase/utlui/navipi.cxx | 19 ----- 11 files changed, 127 insertions(+), 19 deletions(-)
New commits: commit 15f7be5f73a3141d875824a1167e3b452fc1f898 Author: Sahil Gautam <sahil.gau...@collabora.com> AuthorDate: Wed Aug 13 14:33:47 2025 +0530 Commit: Sahil Gautam <sahil.gau...@collabora.com> CommitDate: Fri Aug 15 10:26:52 2025 +0200 add uno command to select a comment in the navigator Change-Id: Ifa79b2357af28f25810049cc5af4773914387d67 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189057 Reviewed-by: Sahil Gautam <sahil.gau...@collabora.com> Tested-by: Jenkins diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 9179d14a76c0..8ea1617c628b 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -1028,6 +1028,7 @@ class XFillGradientItem; #define SID_EDIT_SIGNATURELINE ( SID_SVX_START + 1174 ) #define SID_SIGN_SIGNATURELINE ( SID_SVX_START + 1175 ) #define SID_MEASURE_DLG ( SID_SVX_START + 1176 ) +#define SID_NAVIGATOR_SELECT_COMMENT ( SID_SVX_START + 1177 ) // free slots - available for use #define SID_TABLE_DELETE_TABLE ( SID_SVX_START + 1184 ) #define SID_TABLE_MINIMAL_COLUMN_WIDTH ( SID_SVX_START + 1185 ) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index ad2df1ecb49a..9bfd80aec647 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -4554,6 +4554,14 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 <value>9</value> </prop> </node> + <node oor:name=".uno:NavigatorSelectComment" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Nav~igator select comment.</value> + </prop> + <prop oor:name="TooltipLabel" oor:type="xs:string"> + <value xml:lang="en-US">Select Comment In The Navigator Window/Sidebar</value> + </prop> + </node> <node oor:name=".uno:Notebookbar" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Notebookbar</value> diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index 4b83f10a01e9..1ebd27a390bf 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -536,6 +536,7 @@ public: DECL_DLLPRIVATE_LINK( ExecRulerClick, Ruler *, void ); void ExecSearch(SfxRequest&); void ExecViewOptions(SfxRequest &); + void ExecNavigatorWin(SfxRequest &); virtual bool IsConditionalFastCall( const SfxRequest &rReq ) override; diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi index 6f8a4f5e5dd2..a5493e781cfd 100644 --- a/sw/sdi/_viewsh.sdi +++ b/sw/sdi/_viewsh.sdi @@ -1014,6 +1014,11 @@ interface BaseTextEditView StateMethod = StateViewOptions ; ] + SID_NAVIGATOR_SELECT_COMMENT + [ + ExecMethod = ExecNavigatorWin ; + ] + FN_VLINEAL // status() [ ExecMethod = ExecViewOptions ; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index c454415d15ed..43041dad49dd 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -2537,6 +2537,24 @@ SfxVoidItem IndexMarkToIndex FN_IDX_MARK_TO_IDX GroupId = SfxGroupId::Navigator; ] +SfxVoidItem NavigatorSelectComment SID_NAVIGATOR_SELECT_COMMENT +(SfxUInt16Item CommentId FN_PARAM_1) +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Navigator; +] + SfxVoidItem InsertAnnotation FN_POSTIT (SvxPostItTextItem Text SID_ATTR_POSTIT_TEXT, SvxPostItTextItem Html SID_ATTR_POSTIT_HTML, diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 7512c574d178..6b39a8f0303c 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -282,6 +282,7 @@ public: void UpdateTracking(); void SelectOutlinesWithSelection(); void SelectContentType(std::u16string_view rContentTypeName); + void BringCommentToAttention(sal_uInt16 nCommentId); // return true if it has any children bool RequestingChildren(const weld::TreeIter& rParent); diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx index a266da2f9868..164676c0743b 100644 --- a/sw/source/uibase/inc/navipi.hxx +++ b/sw/source/uibase/inc/navipi.hxx @@ -45,6 +45,7 @@ class SwNavigationPI final : public PanelLayout friend class SwNavigatorWin; friend class SwContentTree; friend class SwGlobalTree; + friend class SwView; ::sfx2::sidebar::ControllerItem m_aDocFullName; ::sfx2::sidebar::ControllerItem m_aPageStats; @@ -165,6 +166,26 @@ public: void SelectNavigateByContentType(const OUString& rContentTypeName); }; +class SwNavigatorWin : public SfxNavigator +{ + friend class SwView; +private: + std::unique_ptr<SwNavigationPI> m_xNavi; +public: + SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, + vcl::Window* pParent, SfxChildWinInfo* pInfo); + virtual void StateChanged(StateChangedType nStateChange) override; + virtual void dispose() override + { + m_xNavi.reset(); + SfxNavigator::dispose(); + } + virtual ~SwNavigatorWin() override + { + disposeOnce(); + } +}; + class SwNavigatorWrapper final : public SfxNavigatorWrapper { public: diff --git a/sw/source/uibase/inc/swcont.hxx b/sw/source/uibase/inc/swcont.hxx index 89f09ca84f45..0ffcd49218d5 100644 --- a/sw/source/uibase/inc/swcont.hxx +++ b/sw/source/uibase/inc/swcont.hxx @@ -78,6 +78,7 @@ public: virtual bool IsProtect() const; const SwContentType* GetParent() const {return m_pParent;} const OUString& GetName() const {return m_sContentName;} + double GetPosition() const { return m_nYPosition; } bool operator==(const SwContent& /*rCont*/) const { // they're never equal, otherwise they'd fall out of the array diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx index ce383783b428..c263e1bad11d 100644 --- a/sw/source/uibase/uiview/view0.cxx +++ b/sw/source/uibase/uiview/view0.cxx @@ -46,6 +46,7 @@ #include <comphelper/servicehelper.hxx> #include <osl/diagnose.h> +#include <navicfg.hxx> #include <sfx2/objface.hxx> #include <wrtsh.hxx> #include <edtwin.hxx> @@ -879,4 +880,36 @@ void SwView::ExecNumberingOutline(SfxItemPool & rPool) ); } +void SwView::ExecNavigatorWin(SfxRequest& rReq) +{ + const SfxItemSet *pArgs = rReq.GetArgs(); + sal_uInt16 nSlot = rReq.GetSlot(); + + switch (nSlot) + { + case SID_NAVIGATOR_SELECT_COMMENT: + { + const SfxPoolItem* pItem; + if (pArgs && pArgs->HasItem(FN_PARAM_1, &pItem)) + { + sal_uInt16 aCommentId = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if (SfxChildWindow* pWin = GetViewFrame().GetChildWindow(SID_NAVIGATOR)) + { + SwNavigatorWin* pNavWin = static_cast<SwNavigatorWin*>(pWin->GetWindow()); + if (pNavWin->m_xNavi && pNavWin->m_xNavi->m_xContentTree) + pNavWin->m_xNavi->m_xContentTree->BringCommentToAttention(aCommentId); + } + else + SAL_WARN("sw.ui", "GetChildWindow(SID_NAVIGATOR) == nullptr"); + } + else + SAL_WARN("sw.ui", "failed to extract FN_PARAM_1 i.e. CommentNumber"); + } + break; + default: + assert(false && "invalid slot!"); + break; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 6536bf6d532d..a541d0207477 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -7106,6 +7106,44 @@ void SwContentTree::OverlayObject(std::vector<basegfx::B2DRange>&& aRanges) } } +void SwContentTree::BringCommentToAttention(sal_uInt16 nCommentId) +{ + std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator()); + if (!m_xTreeView->get_iter_first(*xIter)) + return; + do + { + SwContentType* pCntType = weld::fromId<SwContentType*>(m_xTreeView->get_id(*xIter)); + if (pCntType && pCntType->GetType() == ContentTypeId::POSTIT) + { + m_xTreeView->set_cursor(*xIter); + m_xTreeView->select(*xIter); + m_xTreeView->expand_row(*xIter); + UpdateContentFunctionsToolbar(); + + int nCount = m_xTreeView->iter_n_children(*xIter); + m_xTreeView->iter_children(*xIter); + for (int i = 0; i < nCount; ++i) + { + if (const SwPostItContent* pPostIt = weld::fromId<SwPostItContent*>(m_xTreeView->get_id(*xIter))) + { + if (nCommentId == pPostIt->GetPostItField()->GetPostItId()) + { + GotoContent(weld::fromId<SwContent*>(m_xTreeView->get_id(*xIter))); + m_xTreeView->grab_focus(); + break; + } + } + m_xTreeView->iter_next(*xIter); + } + break; + } + else + m_xTreeView->collapse_row(*xIter); + + } while (m_xTreeView->iter_next_sibling(*xIter)); +} + void SwContentTree::BringEntryToAttention(const weld::TreeIter& rEntry) { if (lcl_IsContent(rEntry, *m_xTreeView)) // content entry diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index 26a49f3cb774..11b732114acb 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -1262,25 +1262,6 @@ SwView* SwNavigationPI::GetCreateView() const return m_pCreateView; } -class SwNavigatorWin : public SfxNavigator -{ -private: - std::unique_ptr<SwNavigationPI> m_xNavi; -public: - SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, - vcl::Window* pParent, SfxChildWinInfo* pInfo); - virtual void StateChanged(StateChangedType nStateChange) override; - virtual void dispose() override - { - m_xNavi.reset(); - SfxNavigator::dispose(); - } - virtual ~SwNavigatorWin() override - { - disposeOnce(); - } -}; - SwNavigatorWin::SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, vcl::Window* pParent, SfxChildWinInfo* pInfo) : SfxNavigator(_pBindings, _pMgr, pParent, pInfo)