diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-14 12:55:54 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-14 21:21:47 +0100 |
commit | 1b2fcca411d410c6cd1fd46fa8f26fa0191f4b05 (patch) | |
tree | 0f34949efc6170070e303a907a6603631f69291d /sw | |
parent | e30caebf76ccd088840b870ecb8929ce132baed0 (diff) |
rework SwNavigationPI to listen to two properties
SID_DOCFULLNAME as before, and FN_STAT_PAGE to keep track
of the current number of pages to always keep the page spinbutton
up to date instead of waiting until its focusin signal to change it.
a true gtk spinbutton will have its + disabled unless it can be increased
so it will need to have the current max uptodate before focusing in
Change-Id: I29a5d93ae38c6a3d0e74994a466102af234bfd48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88707
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/inc/navipi.hxx | 15 | ||||
-rw-r--r-- | sw/source/uibase/utlui/navipi.cxx | 43 |
2 files changed, 29 insertions, 29 deletions
diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx index 103dd6ac6255..2b49a0ce6c88 100644 --- a/sw/source/uibase/inc/navipi.hxx +++ b/sw/source/uibase/inc/navipi.hxx @@ -28,6 +28,7 @@ #include <sfx2/childwin.hxx> #include <sfx2/ctrlitem.hxx> #include <sfx2/tbxctrl.hxx> +#include <sfx2/sidebar/ControllerItem.hxx> #include <sfx2/sidebar/SidebarToolBox.hxx> #include <svx/sidebar/PanelLayout.hxx> #include "conttree.hxx" @@ -46,14 +47,18 @@ class SfxChildWindowContext; enum class RegionMode; class SpinField; -class SwNavigationPI : public PanelLayout, - public SfxControllerItem, public SfxListener +class SwNavigationPI : public PanelLayout + , public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface + , public SfxListener { friend class SwNavigationChild; friend class SwContentTree; friend class SwGlobalTree; friend class SwNavigationPIUIObject; + ::sfx2::sidebar::ControllerItem m_aDocFullName; + ::sfx2::sidebar::ControllerItem m_aPageStats; + VclPtr<sfx2::sidebar::SidebarToolBox> m_aContentToolBox; VclPtr<ToolBox> m_aGlobalToolBox; VclPtr<NumEditAction> m_xEdit; @@ -93,7 +98,6 @@ class SwNavigationPI : public PanelLayout, DECL_LINK( ToolBoxClickHdl, ToolBox *, void ); DECL_LINK( ToolBoxDropdownClickHdl, ToolBox*, void ); DECL_LINK( EditAction, NumEditAction&, void ); - DECL_LINK( EditGetFocus, Control&, void ); DECL_LINK( DoneLink, SfxPoolItem const *, void ); DECL_LINK( MenuSelectHdl, Menu *, bool ); DECL_LINK( ChangePageHdl, Timer*, void ); @@ -123,8 +127,9 @@ public: void UpdateListBox(); void MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget, bool bWithCilds); - virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState ) override; + virtual void NotifyItemUpdate(const sal_uInt16 nSId, + const SfxItemState eState, + const SfxPoolItem* pState) override; virtual void StateChanged(StateChangedType nStateChange) override; diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index cdda8dbe783b..466c65b39d9d 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -403,21 +403,6 @@ IMPL_LINK( SwNavigationPI, EditAction, NumEditAction&, rEdit, void ) } } -// If the page can be set here, the maximum is set. - -IMPL_LINK( SwNavigationPI, EditGetFocus, Control&, rControl, void ) -{ - NumEditAction* pEdit = static_cast<NumEditAction*>(&rControl); - SwView *pView = GetCreateView(); - if (!pView) - return; - SwWrtShell &rSh = pView->GetWrtShell(); - - const sal_uInt16 nPageCnt = rSh.GetPageCnt(); - pEdit->SetMax(nPageCnt); - pEdit->SetLast(nPageCnt); -} - void SwNavigationPI::ZoomOut() { if (!IsZoomedIn()) @@ -510,7 +495,8 @@ SwNavigationPI::SwNavigationPI(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, SfxBindings* _pBindings) : PanelLayout(pParent, "NavigatorPanel", "modules/swriter/ui/navigatorpanel.ui", rxFrame/*, true*/) - , SfxControllerItem(SID_DOCFULLNAME, *_pBindings) + , m_aDocFullName(SID_DOCFULLNAME, *_pBindings, *this) + , m_aPageStats(FN_STAT_PAGE, *_pBindings, *this) , m_pContentView(nullptr) , m_pContentWrtShell(nullptr) , m_pActContView(nullptr) @@ -548,7 +534,6 @@ SwNavigationPI::SwNavigationPI(vcl::Window* pParent, m_xEdit->SetMin(1); m_xEdit->SetFirst(1); m_xEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction)); - m_xEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus)); m_xEdit->SetAccessibleName(m_xEdit->GetQuickHelpText()); m_xEdit->SetUpHdl(LINK(this, SwNavigationPI, PageEditModifyHdl)); m_xEdit->SetDownHdl(LINK(this, SwNavigationPI, PageEditModifyHdl)); @@ -692,9 +677,6 @@ void SwNavigationPI::dispose() m_pxObjectShell.reset(); } - if (IsBound()) - m_rBindings.Release(*this); - m_aDocListBox.clear(); m_aGlobalTree.disposeAndClear(); m_aGlobalBox.clear(); @@ -706,15 +688,16 @@ void SwNavigationPI::dispose() m_aPageChgIdle.Stop(); - ::SfxControllerItem::dispose(); + m_aDocFullName.dispose(); + m_aPageStats.dispose(); PanelLayout::dispose(); } -void SwNavigationPI::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/, - const SfxPoolItem* /*pState*/ ) +void SwNavigationPI::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState /*eState*/, + const SfxPoolItem* /*pState*/) { - if(nSID == SID_DOCFULLNAME) + if (nSID == SID_DOCFULLNAME) { SwView *pActView = GetCreateView(); if(pActView) @@ -738,6 +721,18 @@ void SwNavigationPI::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/, } UpdateListBox(); } + else if (nSID == FN_STAT_PAGE) + { + SwView *pActView = GetCreateView(); + if(pActView) + { + SwWrtShell &rSh = pActView->GetWrtShell(); + NumEditAction& rEdit = GetPageEdit(); + const sal_uInt16 nPageCnt = rSh.GetPageCnt(); + rEdit.SetMax(nPageCnt); + rEdit.SetLast(nPageCnt); + } + } } void SwNavigationPI::StateChanged(StateChangedType nStateChange) |