sw/source/uibase/inc/workctrl.hxx | 13 +++++++++---- sw/source/uibase/ribbar/workctrl.cxx | 22 ++++++++++++++-------- sw/source/uibase/utlui/navipi.cxx | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-)
New commits: commit 779ea1768a28a7042f5e931732f43864565c3c18 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Jan 15 19:47:34 2020 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Jan 16 10:24:06 2020 +0100 listen to FN_NAV_ELEMENT and update based on that broadcast Change-Id: Ide11751dcb7bd53a956df499799fe4a60ce09d65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86880 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/uibase/inc/workctrl.hxx b/sw/source/uibase/inc/workctrl.hxx index 80c9fa157592..80c7ff80dd05 100644 --- a/sw/source/uibase/inc/workctrl.hxx +++ b/sw/source/uibase/inc/workctrl.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_WORKCTRL_HXX #include <sfx2/tbxctrl.hxx> +#include <sfx2/ctrlitem.hxx> #include <vcl/toolbox.hxx> class PopupMenu; @@ -68,7 +69,8 @@ public: DECL_STATIC_LINK(SwTbxAutoTextCtrl, PopupHdl, Menu*, bool); }; -class SwScrollNaviPopup : public DockingWindow +class SwScrollNaviPopup final : public DockingWindow + , public SfxControllerItem { VclPtr<ToolBox> m_xToolBox1; VclPtr<ToolBox> m_xToolBox2; @@ -81,11 +83,13 @@ class SwScrollNaviPopup : public DockingWindow OUString sQuickHelp[2 * NID_COUNT]; -protected: + void syncFromDoc(); + DECL_LINK(SelectHdl, ToolBox*, void); + using DockingWindow::StateChanged; public: - SwScrollNaviPopup(vcl::Window *pParent); + SwScrollNaviPopup(vcl::Window *pParent, SfxBindings& rBindings); virtual ~SwScrollNaviPopup() override; virtual void dispose() override; @@ -93,7 +97,8 @@ public: void GrabFocus() { m_xToolBox1->GrabFocus(); } - void syncFromDoc(); + virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) override; }; class SwPreviewZoomControl : public SfxToolBoxControl diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx index ac3cdff611b0..8a75e85d2ca5 100644 --- a/sw/source/uibase/ribbar/workctrl.cxx +++ b/sw/source/uibase/ribbar/workctrl.cxx @@ -306,8 +306,9 @@ static const char* STR_IMGBTN_ARY[] = STR_IMGBTN_TBLFML_ERR_UP }; -SwScrollNaviPopup::SwScrollNaviPopup(vcl::Window *pParent) +SwScrollNaviPopup::SwScrollNaviPopup(vcl::Window *pParent, SfxBindings& rBindings) : DockingWindow(pParent, "FloatingNavigation", "modules/swriter/ui/floatingnavigation.ui") + , SfxControllerItem(FN_NAV_ELEMENT, rBindings) , m_xToolBox1(get<ToolBox>("line1")) , m_xToolBox2(get<ToolBox>("line2")) , m_xInfoField(get<FixedText>("label")) @@ -358,7 +359,6 @@ IMPL_LINK_NOARG(SwScrollNaviPopup, SelectHdl, ToolBox*, void) SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty ); SwView::SetMoveType( nSet ); GetActiveView()->GetViewFrame()->GetDispatcher()->Execute(FN_NAV_ELEMENT); - syncFromDoc(); } else { @@ -369,6 +369,12 @@ IMPL_LINK_NOARG(SwScrollNaviPopup, SelectHdl, ToolBox*, void) } } +void SwScrollNaviPopup::StateChanged(sal_uInt16 /*nSID*/, SfxItemState /*eState*/, + const SfxPoolItem* /*pState*/) +{ + syncFromDoc(); +} + OUString SwScrollNaviPopup::GetToolTip(bool bNext) { sal_uInt16 nResId = SwView::GetMoveType(); @@ -497,9 +503,9 @@ sal_uInt16 SwScrollNaviPopup::GetCurItemId() const return IdToIdent(sItemId); } -OUString SwScrollNaviPopup::GetItemText(sal_uInt16 nId) const +OUString SwScrollNaviPopup::GetItemText(sal_uInt16 nNaviId) const { - const OUString sId(IdentToId(nId)); + const OUString sId(IdentToId(nNaviId)); sal_uInt16 nItemId = m_xToolBox1->GetItemId(sId); if (nItemId) return m_xToolBox1->GetItemText(nItemId); @@ -507,9 +513,9 @@ OUString SwScrollNaviPopup::GetItemText(sal_uInt16 nId) const return m_xToolBox2->GetItemText(nItemId); } -void SwScrollNaviPopup::SetItemText(sal_uInt16 nId, const OUString &rText) +void SwScrollNaviPopup::SetItemText(sal_uInt16 nNaviId, const OUString &rText) { - const OUString sId(IdentToId(nId)); + const OUString sId(IdentToId(nNaviId)); sal_uInt16 nItemId = m_xToolBox1->GetItemId(sId); if (nItemId) { @@ -520,9 +526,9 @@ void SwScrollNaviPopup::SetItemText(sal_uInt16 nId, const OUString &rText) m_xToolBox2->SetItemText(nItemId, rText); } -void SwScrollNaviPopup::CheckItem(sal_uInt16 nId, bool bOn) +void SwScrollNaviPopup::CheckItem(sal_uInt16 nNaviId, bool bOn) { - const OUString sId(IdentToId(nId)); + const OUString sId(IdentToId(nNaviId)); sal_uInt16 nItemId = m_xToolBox1->GetItemId(sId); if (nItemId) { diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index 88acee99df44..9355b773c7cf 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -398,7 +398,7 @@ VCL_BUILDER_FACTORY(SwNavHelpToolBox) void SwNavigationPI::CreateNavigationTool() { - auto xPopup = VclPtr<SwScrollNaviPopup>::Create(m_aContentToolBox.get()); + auto xPopup = VclPtr<SwScrollNaviPopup>::Create(m_aContentToolBox.get(), GetBindings()); xPopup->EnableDocking(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits