diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-01-14 16:47:45 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-01-14 21:26:49 +0100 |
commit | 74a6e101927d97aa216b1b1a6d395c56c65cfd32 (patch) | |
tree | 010f1cbdb3e0caf7022fdf32fad7fc879495543b /sw | |
parent | 0b87cacaedf47c49065df284f8d10d40d664f9bd (diff) |
rework PageOrientationPopup to be a PopupWindowController
Change-Id: I5930d6e16b99754a60e3bb22a70fadfc5d673aa5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86786
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/PageOrientationPopup.hxx | 19 | ||||
-rw-r--r-- | sw/source/uibase/app/swmodule.cxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageOrientationControl.cxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageOrientationControl.hxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageOrientationPopup.cxx | 38 | ||||
-rw-r--r-- | sw/util/sw.component | 4 |
6 files changed, 53 insertions, 23 deletions
diff --git a/sw/inc/PageOrientationPopup.hxx b/sw/inc/PageOrientationPopup.hxx index b1390e5b544d..5b0f3927b950 100644 --- a/sw/inc/PageOrientationPopup.hxx +++ b/sw/inc/PageOrientationPopup.hxx @@ -19,21 +19,26 @@ #ifndef INCLUDED_SW_INC_PAGEORIENTATIONPOPUP_HXX #define INCLUDED_SW_INC_PAGEORIENTATIONPOPUP_HXX -#include <sfx2/tbxctrl.hxx> +#include <svtools/popupwindowcontroller.hxx> #include "swdllapi.h" -class PageOrientationPopup final : public SfxToolBoxControl +class PageOrientationPopup final : public svt::PopupWindowController { public: - SFX_DECL_TOOLBOX_CONTROL(); - - PageOrientationPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); + PageOrientationPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext); virtual ~PageOrientationPopup() 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 88a0a53fdf39..936370d89bb8 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); - PageOrientationPopup::RegisterControl(SID_ATTR_PAGE_ORIENTATION, pMod); SvxClipBoardControl::RegisterControl(SID_PASTE, pMod ); SvxUndoRedoControl::RegisterControl(SID_UNDO, pMod ); diff --git a/sw/source/uibase/sidebar/PageOrientationControl.cxx b/sw/source/uibase/sidebar/PageOrientationControl.cxx index dcf7ffa862b4..f002a3bd9e40 100644 --- a/sw/source/uibase/sidebar/PageOrientationControl.cxx +++ b/sw/source/uibase/sidebar/PageOrientationControl.cxx @@ -19,6 +19,7 @@ #include "PageOrientationControl.hxx" #include "PageMarginControl.hxx" +#include <PageOrientationPopup.hxx> #include <com/sun/star/document/XUndoManager.hpp> #include <com/sun/star/document/XUndoManagerSupplier.hpp> #include <com/sun/star/frame/XFrame.hpp> @@ -49,8 +50,8 @@ namespace { namespace sw { namespace sidebar { -PageOrientationControl::PageOrientationControl( sal_uInt16 nId, vcl::Window* pParent ) - : SfxPopupWindow( nId, pParent, "PageOrientationControl", "modules/swriter/ui/pageorientationcontrol.ui" ) +PageOrientationControl::PageOrientationControl(PageOrientationPopup* pControl, vcl::Window* pParent) + : ToolbarPopup(pControl->getFrameInterface(), pParent, "PageOrientationControl", "modules/swriter/ui/pageorientationcontrol.ui" ) , mpPageItem( new SvxPageItem(SID_ATTR_PAGE) ) , mpPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) ) , mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) ) @@ -78,7 +79,7 @@ void PageOrientationControl::dispose() mpPageULMarginItem.reset(); mpPageSizeItem.reset(); - SfxPopupWindow::dispose(); + ToolbarPopup::dispose(); } void PageOrientationControl::ExecuteMarginLRChange( diff --git a/sw/source/uibase/sidebar/PageOrientationControl.hxx b/sw/source/uibase/sidebar/PageOrientationControl.hxx index 1e34a62bc1ab..af844bbc8e5b 100644 --- a/sw/source/uibase/sidebar/PageOrientationControl.hxx +++ b/sw/source/uibase/sidebar/PageOrientationControl.hxx @@ -20,19 +20,20 @@ #define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEORIENTATIONCONTROL_HXX #include <memory> -#include <sfx2/tbxctrl.hxx> +#include <svtools/toolbarmenu.hxx> #include <svx/pageitem.hxx> #include <svx/rulritem.hxx> #include <editeng/sizeitem.hxx> class Button; +class PageOrientationPopup; namespace sw { namespace sidebar { -class PageOrientationControl : public SfxPopupWindow +class PageOrientationControl final : public svtools::ToolbarPopup { public: - explicit PageOrientationControl(sal_uInt16 nId, vcl::Window* pParent); + explicit PageOrientationControl(PageOrientationPopup* pControl, vcl::Window* pParent); virtual ~PageOrientationControl() override; virtual void dispose() override; diff --git a/sw/source/uibase/sidebar/PageOrientationPopup.cxx b/sw/source/uibase/sidebar/PageOrientationPopup.cxx index 9b4f3fcb0f22..0816d03afbc8 100644 --- a/sw/source/uibase/sidebar/PageOrientationPopup.cxx +++ b/sw/source/uibase/sidebar/PageOrientationPopup.cxx @@ -21,26 +21,46 @@ #include <svx/pageitem.hxx> #include <vcl/toolbox.hxx> -SFX_IMPL_TOOLBOX_CONTROL(PageOrientationPopup, SvxPageItem); +PageOrientationPopup::PageOrientationPopup(const css::uno::Reference<css::uno::XComponentContext>& rContext) + : PopupWindowController(rContext, nullptr, OUString()) +{ +} -PageOrientationPopup::PageOrientationPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) - : SfxToolBoxControl(nSlotId, nId, rTbx) +void PageOrientationPopup::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)); } PageOrientationPopup::~PageOrientationPopup() { } -VclPtr<SfxPopupWindow> PageOrientationPopup::CreatePopupWindow() +VclPtr<vcl::Window> PageOrientationPopup::createPopupWindow(vcl::Window* pParent) +{ + return VclPtr<sw::sidebar::PageOrientationControl>::Create(this, pParent); +} + +OUString PageOrientationPopup::getImplementationName() { - VclPtr<sw::sidebar::PageOrientationControl> pControl = VclPtr<sw::sidebar::PageOrientationControl>::Create(GetSlotId(), &GetToolBox()); - pControl->StartPopupMode(&GetToolBox(), FloatWinPopupFlags::GrabFocus); - SetPopupWindow(pControl); + return "lo.writer.PageOrientationToolBoxControl"; +} - return pControl; +css::uno::Sequence<OUString> PageOrientationPopup::getSupportedServiceNames() +{ + return { "com.sun.star.frame.ToolbarController" }; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +lo_writer_PageOrientationToolBoxControl_get_implementation( + css::uno::XComponentContext* rContext, + css::uno::Sequence<css::uno::Any> const & ) +{ + return cppu::acquire(new PageOrientationPopup(rContext)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/util/sw.component b/sw/util/sw.component index 18cbdc07a5e9..8d988dc93503 100644 --- a/sw/util/sw.component +++ b/sw/util/sw.component @@ -59,6 +59,10 @@ constructor="lo_writer_PageMarginToolBoxControl_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> + <implementation name="lo.writer.PageOrientationToolBoxControl" + constructor="lo_writer_PageOrientationToolBoxControl_get_implementation"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> <implementation name="SwXModule" constructor="SwXModule_get_implementation"> <service name="com.sun.star.text.GlobalSettings"/> |