[Libreoffice-commits] core.git: 2 commits - sw/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 16 09:24:55 UTC 2020
sw/source/uibase/inc/navipi.hxx | 22 +++++++++-----
sw/source/uibase/inc/workctrl.hxx | 10 +-----
sw/source/uibase/ribbar/workctrl.cxx | 9 -----
sw/source/uibase/utlui/content.cxx | 2 -
sw/source/uibase/utlui/navipi.cxx | 53 ++++++++++++++++++++++-------------
5 files changed, 53 insertions(+), 43 deletions(-)
New commits:
commit fc7a485b7e1c460a7b2e7aa2f1db28873cabda3c
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jan 15 20:21:52 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jan 16 10:24:34 2020 +0100
merge the two things listening to FN_NAV_ELEMENT
Change-Id: Ie9a36ca1eb8ec6b9cea4b1da3381e53443441696
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86883
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx
index 74aae40af6e4..2aba488ef4be 100644
--- a/sw/source/uibase/inc/navipi.hxx
+++ b/sw/source/uibase/inc/navipi.hxx
@@ -48,12 +48,23 @@ class SpinField;
class SwNavHelpToolBox : public ToolBox
{
- virtual void RequestHelp( const HelpEvent& rHEvt ) override;
public:
SwNavHelpToolBox(Window* pParent);
~SwNavHelpToolBox() override;
};
+class NaviStateListener final : public SfxControllerItem
+{
+private:
+ VclPtr<SwNavigationPI> m_xNavigation;
+public:
+ NaviStateListener(SfxBindings& rBindings, SwNavigationPI* pNavigation);
+ virtual ~NaviStateListener() override;
+
+ virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState) override;
+};
+
class SwNavigationPI : public PanelLayout,
public SfxControllerItem, public SfxListener
{
@@ -63,6 +74,7 @@ class SwNavigationPI : public PanelLayout,
friend class SwNavigationPIUIObject;
VclPtr<SwNavHelpToolBox> m_aContentToolBox;
+ std::unique_ptr<NaviStateListener> m_xNaviListener;
VclPtr<ToolBox> m_aGlobalToolBox;
VclPtr<NumEditAction> m_xEdit;
VclPtr<VclContainer> m_aContentBox;
@@ -149,6 +161,8 @@ public:
SwView* GetCreateView() const;
void CreateNavigationTool();
+ void NaviStateChanged();
+
FactoryFunction GetUITestFactory() const override;
};
diff --git a/sw/source/uibase/inc/workctrl.hxx b/sw/source/uibase/inc/workctrl.hxx
index 80c7ff80dd05..34a8c1796030 100644
--- a/sw/source/uibase/inc/workctrl.hxx
+++ b/sw/source/uibase/inc/workctrl.hxx
@@ -20,7 +20,6 @@
#define INCLUDED_SW_SOURCE_UIBASE_INC_WORKCTRL_HXX
#include <sfx2/tbxctrl.hxx>
-#include <sfx2/ctrlitem.hxx>
#include <vcl/toolbox.hxx>
class PopupMenu;
@@ -70,7 +69,6 @@ public:
};
class SwScrollNaviPopup final : public DockingWindow
- , public SfxControllerItem
{
VclPtr<ToolBox> m_xToolBox1;
VclPtr<ToolBox> m_xToolBox2;
@@ -83,13 +81,10 @@ class SwScrollNaviPopup final : public DockingWindow
OUString sQuickHelp[2 * NID_COUNT];
- void syncFromDoc();
-
DECL_LINK(SelectHdl, ToolBox*, void);
- using DockingWindow::StateChanged;
public:
- SwScrollNaviPopup(vcl::Window *pParent, SfxBindings& rBindings);
+ SwScrollNaviPopup(vcl::Window *pParent);
virtual ~SwScrollNaviPopup() override;
virtual void dispose() override;
@@ -97,8 +92,7 @@ public:
void GrabFocus() { m_xToolBox1->GrabFocus(); }
- virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState,
- const SfxPoolItem* pState) override;
+ void syncFromDoc();
};
class SwPreviewZoomControl : public SfxToolBoxControl
diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx
index 8a75e85d2ca5..87bf21e93725 100644
--- a/sw/source/uibase/ribbar/workctrl.cxx
+++ b/sw/source/uibase/ribbar/workctrl.cxx
@@ -306,9 +306,8 @@ static const char* STR_IMGBTN_ARY[] =
STR_IMGBTN_TBLFML_ERR_UP
};
-SwScrollNaviPopup::SwScrollNaviPopup(vcl::Window *pParent, SfxBindings& rBindings)
+SwScrollNaviPopup::SwScrollNaviPopup(vcl::Window *pParent)
: 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"))
@@ -369,12 +368,6 @@ 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();
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index e6184a9d9311..38710bab0dc8 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -2068,7 +2068,7 @@ void SwContentTree::ToggleToRoot()
}
}
m_pConfig->SetRootType( m_nRootType );
- VclPtr<SwNavHelpToolBox> xBox = GetParentWindow()->m_aContentToolBox;
+ VclPtr<ToolBox> xBox = GetParentWindow()->m_aContentToolBox;
xBox->CheckItem(xBox->GetItemId("root"), m_bIsRoot);
}
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index c74c49f5a2ce..79edfb9d18e0 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(), GetBindings());
+ auto xPopup = VclPtr<SwScrollNaviPopup>::Create(m_aContentToolBox.get());
xPopup->EnableDocking();
@@ -413,17 +413,6 @@ FactoryFunction SwNavigationPI::GetUITestFactory() const
return SwNavigationPIUIObject::create;
}
-void SwNavHelpToolBox::RequestHelp(const HelpEvent& rHEvt)
-{
- const sal_uInt16 nItemId = GetItemId(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
- const OUString sCommand(GetItemCommand(nItemId));
- if (sCommand == "back")
- SetQuickHelpText(nItemId, SwScrollNaviPopup::GetToolTip(false));
- else if (sCommand == "forward")
- SetQuickHelpText(nItemId, SwScrollNaviPopup::GetToolTip(true));
- ToolBox::RequestHelp(rHEvt);
-}
-
SwNavHelpToolBox::~SwNavHelpToolBox()
{
disposeOnce();
@@ -691,6 +680,9 @@ SwNavigationPI::SwNavigationPI(SfxBindings* _pBindings,
m_aDocListBox->SetAccessibleName(m_aStatusArr[3]);
m_aExpandedSize = GetOptimalSize();
+
+ m_xNaviListener.reset(new NaviStateListener(GetBindings(), this));
+ NaviStateChanged();
}
SwNavigationPI::~SwNavigationPI()
@@ -700,6 +692,8 @@ SwNavigationPI::~SwNavigationPI()
void SwNavigationPI::dispose()
{
+ m_xNaviListener.reset();
+
if (IsGlobalDoc() && !IsGlobalMode())
{
SwView *pView = GetCreateView();
@@ -1171,4 +1165,32 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent,
SetWindow(pNavi);
}
+NaviStateListener::NaviStateListener(SfxBindings& rBindings, SwNavigationPI* pNavigation)
+ : SfxControllerItem(FN_NAV_ELEMENT, rBindings)
+ , m_xNavigation(pNavigation)
+{
+}
+
+NaviStateListener::~NaviStateListener()
+{
+}
+
+void NaviStateListener::StateChanged(sal_uInt16 /*nSID*/, SfxItemState /*eState*/,
+ const SfxPoolItem* /*pState*/)
+{
+ m_xNavigation->NaviStateChanged();
+}
+
+void SwNavigationPI::NaviStateChanged()
+{
+ if (m_xPopupWindow)
+ m_xPopupWindow->syncFromDoc();
+
+ if (m_aContentToolBox)
+ {
+ m_aContentToolBox->SetQuickHelpText(m_aContentToolBox->GetItemId("back"), SwScrollNaviPopup::GetToolTip(false));
+ m_aContentToolBox->SetQuickHelpText(m_aContentToolBox->GetItemId("forward"), SwScrollNaviPopup::GetToolTip(true));
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 612618d55c751bef15150c74a0f5903b6eabd056
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jan 15 19:51:39 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jan 16 10:24:22 2020 +0100
m_xDialog field now unused
Change-Id: Ic909d6b0102a9e276da2ea8efe86c20cf1aa01cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86881
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx
index 7bee0d2e0197..74aae40af6e4 100644
--- a/sw/source/uibase/inc/navipi.hxx
+++ b/sw/source/uibase/inc/navipi.hxx
@@ -48,15 +48,9 @@ class SpinField;
class SwNavHelpToolBox : public ToolBox
{
- VclPtr<SwNavigationPI> m_xDialog;
virtual void RequestHelp( const HelpEvent& rHEvt ) override;
- virtual void dispose() override;
public:
SwNavHelpToolBox(Window* pParent);
- void SetDialog(SwNavigationPI* pDialog)
- {
- m_xDialog = pDialog;
- }
~SwNavHelpToolBox() override;
};
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index 9355b773c7cf..c74c49f5a2ce 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -424,12 +424,6 @@ void SwNavHelpToolBox::RequestHelp(const HelpEvent& rHEvt)
ToolBox::RequestHelp(rHEvt);
}
-void SwNavHelpToolBox::dispose()
-{
- m_xDialog.clear();
- ToolBox::dispose();
-}
-
SwNavHelpToolBox::~SwNavHelpToolBox()
{
disposeOnce();
@@ -558,7 +552,6 @@ SwNavigationPI::SwNavigationPI(SfxBindings* _pBindings,
get(m_aContentToolBox, "content");
m_aContentToolBox->SetLineCount(2);
m_aContentToolBox->InsertBreak(8);
- m_aContentToolBox->SetDialog(this);
get(m_aGlobalToolBox, "global");
get(m_aDocListBox, "documents");
More information about the Libreoffice-commits
mailing list