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/content.hxx | 2 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 | 34 +++++++ sw/source/uibase/utlui/content.cxx | 45 ++++++++++ sw/source/uibase/utlui/navipi.cxx | 19 ---- 12 files changed, 137 insertions(+), 19 deletions(-)
New commits: commit 539b4285e44db5f24407df7a6d0220d02ee69f6e Author: Sahil Gautam <sahil.gau...@collabora.com> AuthorDate: Wed Aug 13 14:33:47 2025 +0530 Commit: Sahil Gautam <sahil.gau...@collabora.com> CommitDate: Mon Aug 18 21:19:51 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 (cherry picked from commit 15f7be5f73a3141d875824a1167e3b452fc1f898) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189855 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 8d50cdb430e1..4f1340fcfe80 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -1027,6 +1027,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 00474669ec90..490cb4de4c76 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -4437,6 +4437,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 c132400c9340..2d8c7814f3bd 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -531,6 +531,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 378cc09cfa0c..7a6f5a1ae5ec 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 b0c8176596ee..7e42790fef0d 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -2519,6 +2519,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/content.hxx b/sw/source/uibase/inc/content.hxx index f0aad555619c..c0dc644133dc 100644 --- a/sw/source/uibase/inc/content.hxx +++ b/sw/source/uibase/inc/content.hxx @@ -22,6 +22,7 @@ #include "swcont.hxx" #include <ndarr.hxx> +#include <docufld.hxx> #include <tools/long.hxx> #include <utility> @@ -140,6 +141,7 @@ public: const SwFormatField* GetPostIt() const { return m_pField; } virtual bool IsProtect() const override; + SwPostItField const* GetPostItField() const; }; class SwGraphicContent final : public SwContent diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 4a732f4e56ca..897da77464e5 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -279,6 +279,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 5068c10315fd..985abff25678 100644 --- a/sw/source/uibase/inc/navipi.hxx +++ b/sw/source/uibase/inc/navipi.hxx @@ -46,6 +46,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; @@ -166,6 +167,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 57908b106834..99416ac125ed 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 a2f4fa8c4b64..8a7b172a8423 100644 --- a/sw/source/uibase/uiview/view0.cxx +++ b/sw/source/uibase/uiview/view0.cxx @@ -46,6 +46,8 @@ #include <comphelper/servicehelper.hxx> #include <osl/diagnose.h> +#include <navicfg.hxx> +#include <navipi.hxx> #include <sfx2/objface.hxx> #include <wrtsh.hxx> #include <edtwin.hxx> @@ -817,4 +819,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 872232152e64..8457cc6920b9 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -299,6 +299,13 @@ bool SwPostItContent::IsProtect() const return m_pField->IsProtect(); } +SwPostItField const* SwPostItContent::GetPostItField() const +{ + return m_pField + ? static_cast<SwPostItField const*>(m_pField->GetField()) + : nullptr; +} + bool SwURLFieldContent::IsProtect() const { return m_pINetAttr->IsProtect(); @@ -6957,6 +6964,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 9502061c7762..99022e66155e 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)