summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-01-14 15:56:36 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-01-14 21:25:50 +0100
commit776797b6a46fa545a661cc81f51a2be555ecd7fe (patch)
tree32a09756b1864297f349852785669bb31f12774e
parent2c80cf671ead686300ea0ece491435c0c67dfc77 (diff)
rework PageMarginPopup to be a PopupWindowController
Change-Id: I60a66b9be14f79cd2968f4bd3d91740137ee9d85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86782 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu11
-rw-r--r--sw/inc/PageMarginPopup.hxx19
-rw-r--r--sw/source/uibase/app/swmodule.cxx1
-rw-r--r--sw/source/uibase/sidebar/PageMarginControl.cxx7
-rw-r--r--sw/source/uibase/sidebar/PageMarginControl.hxx8
-rw-r--r--sw/source/uibase/sidebar/PageMarginPopup.cxx38
-rw-r--r--sw/util/sw.component4
7 files changed, 65 insertions, 23 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index 228fff941557..e2b1a8c9382d 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -1206,6 +1206,17 @@
<value>lo.writer.PageColumnToolBoxControl</value>
</prop>
</node>
+ <node oor:name="PageMarginToolBoxControl" oor:op="replace">
+ <prop oor:name="Command">
+ <value>.uno:PageMargin</value>
+ </prop>
+ <prop oor:name="Module">
+ <value/>
+ </prop>
+ <prop oor:name="Controller">
+ <value>lo.writer.PageMarginToolBoxControl</value>
+ </prop>
+ </node>
<node oor:name="com.sun.star.svx.FindTextToolboxController" oor:op="replace">
<prop oor:name="Command">
<value>.uno:FindText</value>
diff --git a/sw/inc/PageMarginPopup.hxx b/sw/inc/PageMarginPopup.hxx
index d06dc3364069..3a31544b74a1 100644
--- a/sw/inc/PageMarginPopup.hxx
+++ b/sw/inc/PageMarginPopup.hxx
@@ -19,21 +19,26 @@
#ifndef INCLUDED_SW_INC_PAGEMARGINPOPUP_HXX
#define INCLUDED_SW_INC_PAGEMARGINPOPUP_HXX
-#include <sfx2/tbxctrl.hxx>
+#include <svtools/popupwindowcontroller.hxx>
#include "swdllapi.h"
-class PageMarginPopup final : public SfxToolBoxControl
+class PageMarginPopup final : public svt::PopupWindowController
{
public:
- SFX_DECL_TOOLBOX_CONTROL();
-
- PageMarginPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx);
+ PageMarginPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext);
virtual ~PageMarginPopup() override;
- virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override;
+ using svt::ToolboxController::createPopupWindow;
+ virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override;
};
#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index 9355dcb3f0ec..88a0a53fdf39 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -279,7 +279,6 @@ void SwDLL::RegisterControls()
svx::ParaLeftSpacingControl::RegisterControl(SID_ATTR_PARA_LEFTSPACE, pMod);
svx::ParaRightSpacingControl::RegisterControl(SID_ATTR_PARA_RIGHTSPACE, pMod);
svx::ParaFirstLineSpacingControl::RegisterControl(SID_ATTR_PARA_FIRSTLINESPACE, pMod);
- PageMarginPopup::RegisterControl(SID_ATTR_PAGE_MARGIN, pMod);
PageOrientationPopup::RegisterControl(SID_ATTR_PAGE_ORIENTATION, pMod);
SvxClipBoardControl::RegisterControl(SID_PASTE, pMod );
diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx
index 69aa012d7340..587f0262ff13 100644
--- a/sw/source/uibase/sidebar/PageMarginControl.cxx
+++ b/sw/source/uibase/sidebar/PageMarginControl.cxx
@@ -37,6 +37,7 @@
#include <swtypes.hxx>
#include <cmdid.h>
+#include <PageMarginPopup.hxx>
#include <com/sun/star/document/XUndoManagerSupplier.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
@@ -93,8 +94,8 @@ namespace
namespace sw { namespace sidebar {
-PageMarginControl::PageMarginControl( sal_uInt16 nId, vcl::Window* pParent )
- : SfxPopupWindow( nId, pParent, "PageMarginControl", "modules/swriter/ui/pagemargincontrol.ui" )
+PageMarginControl::PageMarginControl(PageMarginPopup* pControl, vcl::Window* pParent)
+ : ToolbarPopup(pControl->getFrameInterface(), pParent, "PageMarginControl", "modules/swriter/ui/pagemargincontrol.ui")
, m_nPageLeftMargin(0)
, m_nPageRightMargin(0)
, m_nPageTopMargin(0)
@@ -255,7 +256,7 @@ void PageMarginControl::dispose()
m_pWidthHeightField.disposeAndClear();
m_pContainer.disposeAndClear();
- SfxPopupWindow::dispose();
+ ToolbarPopup::dispose();
}
void PageMarginControl::SetMetricFieldMaxValues( const Size& rPageSize )
diff --git a/sw/source/uibase/sidebar/PageMarginControl.hxx b/sw/source/uibase/sidebar/PageMarginControl.hxx
index fe54b4ecf7dd..77f4cdb01593 100644
--- a/sw/source/uibase/sidebar/PageMarginControl.hxx
+++ b/sw/source/uibase/sidebar/PageMarginControl.hxx
@@ -19,7 +19,7 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEMARGINCONTROL_HXX
#define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEMARGINCONTROL_HXX
-#include <sfx2/tbxctrl.hxx>
+#include <svtools/toolbarmenu.hxx>
#include <vcl/fixed.hxx>
#include <vcl/field.hxx>
#include <vcl/layout.hxx>
@@ -33,12 +33,14 @@
// #i19922# - tdf#126051 see cui/source/tabpages/page.cxx and svx/source/dialog/hdft.cxx
static const long MINBODY = 56; // 1mm in twips rounded
+class PageMarginPopup;
+
namespace sw { namespace sidebar {
-class PageMarginControl : public SfxPopupWindow
+class PageMarginControl final : public svtools::ToolbarPopup
{
public:
- explicit PageMarginControl( sal_uInt16 nId, vcl::Window* pParent );
+ explicit PageMarginControl(PageMarginPopup* pControl, vcl::Window* pParent);
virtual ~PageMarginControl() override;
virtual void dispose() override;
diff --git a/sw/source/uibase/sidebar/PageMarginPopup.cxx b/sw/source/uibase/sidebar/PageMarginPopup.cxx
index 29a27c3106d8..f22604a70a08 100644
--- a/sw/source/uibase/sidebar/PageMarginPopup.cxx
+++ b/sw/source/uibase/sidebar/PageMarginPopup.cxx
@@ -20,26 +20,46 @@
#include "PageMarginControl.hxx"
#include <vcl/toolbox.hxx>
-SFX_IMPL_TOOLBOX_CONTROL(PageMarginPopup, SfxVoidItem);
+PageMarginPopup::PageMarginPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext)
+ : PopupWindowController(rContext, nullptr, OUString())
+{
+}
-PageMarginPopup::PageMarginPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
- : SfxToolBoxControl(nSlotId, nId, rTbx)
+void PageMarginPopup::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
{
- rTbx.SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits(nId));
+ PopupWindowController::initialize(rArguments);
+
+ ToolBox* pToolBox = nullptr;
+ sal_uInt16 nId = 0;
+ if (getToolboxId(nId, &pToolBox) && pToolBox->GetItemCommand(nId) == m_aCommandURL)
+ pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
}
PageMarginPopup::~PageMarginPopup()
{
}
-VclPtr<SfxPopupWindow> PageMarginPopup::CreatePopupWindow()
+VclPtr<vcl::Window> PageMarginPopup::createPopupWindow(vcl::Window* pParent)
+{
+ return VclPtr<sw::sidebar::PageMarginControl>::Create(this, pParent);
+}
+
+OUString PageMarginPopup::getImplementationName()
{
- VclPtr<sw::sidebar::PageMarginControl> pControl = VclPtr<sw::sidebar::PageMarginControl>::Create(GetSlotId(), &GetToolBox());
- pControl->StartPopupMode(&GetToolBox(), FloatWinPopupFlags::GrabFocus);
- SetPopupWindow(pControl);
+ return "lo.writer.PageMarginToolBoxControl";
+}
- return pControl;
+css::uno::Sequence<OUString> PageMarginPopup::getSupportedServiceNames()
+{
+ return { "com.sun.star.frame.ToolbarController" };
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+lo_writer_PageMarginToolBoxControl_get_implementation(
+ css::uno::XComponentContext* rContext,
+ css::uno::Sequence<css::uno::Any> const & )
+{
+ return cppu::acquire(new PageMarginPopup(rContext));
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/util/sw.component b/sw/util/sw.component
index a6fac075e4f9..18cbdc07a5e9 100644
--- a/sw/util/sw.component
+++ b/sw/util/sw.component
@@ -55,6 +55,10 @@
constructor="lo_writer_PageColumnToolBoxControl_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
+ <implementation name="lo.writer.PageMarginToolBoxControl"
+ constructor="lo_writer_PageMarginToolBoxControl_get_implementation">
+ <service name="com.sun.star.frame.ToolbarController"/>
+ </implementation>
<implementation name="SwXModule"
constructor="SwXModule_get_implementation">
<service name="com.sun.star.text.GlobalSettings"/>