summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-01-21 11:39:19 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-01-21 13:55:46 +0100
commit08e633d777f1d2cf11a93ccb55f231d084f3220c (patch)
tree19fa8e7bc840d42614a330251ac48f17fedd63f9 /svx
parentb4b6daf8b70a5448d3e7aea440d56d95e19e7d2d (diff)
Related: tdf#130035 let SvxLineEndWindow have a menubutton parent
Change-Id: Id658dc0ac88d98ade67bdeb233eca6c912a3b253 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87133 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/linectrl.cxx70
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx2
2 files changed, 40 insertions, 32 deletions
diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx
index 80c36beb55d5..bb4ef331de16 100644
--- a/svx/source/tbxctrls/linectrl.cxx
+++ b/svx/source/tbxctrls/linectrl.cxx
@@ -19,6 +19,7 @@
#include <string>
+#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
@@ -263,39 +264,20 @@ public:
private:
virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
virtual VclPtr<vcl::Window> createVclPopupWindow( vcl::Window* pParent ) override;
-};
-class SvxLineEndWindow final : public WeldToolbarPopup
-{
-private:
- XLineEndListRef mpLineEndList;
- rtl::Reference<SvxLineEndToolBoxControl> mxControl;
- std::unique_ptr<SvtValueSet> mxLineEndSet;
- std::unique_ptr<weld::CustomWeld> mxLineEndSetWin;
- sal_uInt16 mnLines;
- Size maBmpSize;
-
- DECL_LINK( SelectHdl, SvtValueSet*, void );
- void FillValueSet();
- void SetSize();
-
- virtual void GrabFocus() override
- {
- mxLineEndSet->GrabFocus();
- }
-
-public:
- SvxLineEndWindow(SvxLineEndToolBoxControl* pControl, weld::Widget* pParent);
- virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
+ void dispatch(const Sequence<PropertyValue>& rArgs);
};
}
static constexpr sal_uInt16 gnCols = 2;
-SvxLineEndWindow::SvxLineEndWindow(SvxLineEndToolBoxControl* pControl, weld::Widget* pParent)
- : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/floatinglineend.ui", "FloatingLineEnd")
- , mxControl(pControl)
+SvxLineEndWindow::SvxLineEndWindow(const Reference<XFrame>& rFrame, weld::Window* pParent,
+ const MenuOrToolMenuButton &rMenuButton,
+ const LineEndSelectFunction& rLineEndSelectFunction)
+ : WeldToolbarPopup(rFrame, pParent, "svx/ui/floatinglineend.ui", "FloatingLineEnd")
+ , maMenuButton(rMenuButton)
+ , maLineEndSelectFunction(rLineEndSelectFunction)
, mxLineEndSet(new SvtValueSet(m_xBuilder->weld_scrolled_window("valuesetwin")))
, mxLineEndSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxLineEndSet))
, mnLines(12)
@@ -322,6 +304,11 @@ SvxLineEndWindow::SvxLineEndWindow(SvxLineEndToolBoxControl* pControl, weld::Wid
AddStatusListener( ".uno:LineEndListState");
}
+void SvxLineEndWindow::GrabFocus()
+{
+ mxLineEndSet->GrabFocus();
+}
+
IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl, SvtValueSet*, void)
{
std::unique_ptr<XLineEndItem> pLineEndItem;
@@ -368,9 +355,9 @@ IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl, SvtValueSet*, void)
while in Dispatch()), accessing members will crash in this case. */
mxLineEndSet->SetNoSelection();
- mxControl->dispatchCommand(mxControl->getCommandURL(), aArgs);
+ maLineEndSelectFunction(aArgs);
- mxControl->EndPopupMode();
+ maMenuButton.set_inactive();
}
void SvxLineEndWindow::FillValueSet()
@@ -478,6 +465,11 @@ void SAL_CALL SvxLineEndToolBoxControl::execute(sal_Int16 /*KeyModifier*/)
}
}
+void SvxLineEndToolBoxControl::dispatch(const Sequence<PropertyValue>& rArgs)
+{
+ dispatchCommand(getCommandURL(), rArgs);
+}
+
void SvxLineEndToolBoxControl::initialize( const css::uno::Sequence<css::uno::Any>& rArguments )
{
svt::PopupWindowController::initialize( rArguments );
@@ -496,13 +488,29 @@ void SvxLineEndToolBoxControl::initialize( const css::uno::Sequence<css::uno::An
std::unique_ptr<WeldToolbarPopup> SvxLineEndToolBoxControl::weldPopupWindow()
{
- return std::make_unique<SvxLineEndWindow>(this, m_pToolbar);
+ const css::uno::Reference<css::awt::XWindow> xParent = m_xFrame->getContainerWindow();
+ weld::Window* pParentFrame = Application::GetFrameWeld(xParent);
+
+ const OString aId(m_aCommandURL.toUtf8());
+ return std::make_unique<SvxLineEndWindow>(m_xFrame, pParentFrame,
+ MenuOrToolMenuButton(m_pToolbar, aId),
+ std::bind(&SvxLineEndToolBoxControl::dispatch, this, std::placeholders::_1));
}
VclPtr<vcl::Window> SvxLineEndToolBoxControl::createVclPopupWindow( vcl::Window* pParent )
{
- mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
- std::make_unique<SvxLineEndWindow>(this, pParent->GetFrameWeld()));
+ ToolBox* pToolBox = nullptr;
+ sal_uInt16 nId = 0;
+ if (!getToolboxId(nId, &pToolBox))
+ return nullptr;
+
+ const css::uno::Reference<css::awt::XWindow> xParent = m_xFrame->getContainerWindow();
+ weld::Window* pParentFrame = Application::GetFrameWeld(xParent);
+
+ mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(m_xFrame, pParent,
+ std::make_unique<SvxLineEndWindow>(m_xFrame, pParentFrame,
+ MenuOrToolMenuButton(this, pToolBox, nId),
+ std::bind(&SvxLineEndToolBoxControl::dispatch, this, std::placeholders::_1)));
mxInterimPopover->Show();
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index fcd99c90d8fc..129e2b90c82b 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -4363,7 +4363,7 @@ MenuOrToolMenuButton::MenuOrToolMenuButton(weld::Toolbar* pToolbar, const OStrin
{
}
-MenuOrToolMenuButton::MenuOrToolMenuButton(SvxColorToolBoxControl* pControl, ToolBox* pToolbar, sal_uInt16 nId)
+MenuOrToolMenuButton::MenuOrToolMenuButton(svt::PopupWindowController* pControl, ToolBox* pToolbar, sal_uInt16 nId)
: m_pMenuButton(nullptr)
, m_pToolbar(nullptr)
, m_pControl(pControl)