diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-01-14 10:06:30 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-01-14 13:14:36 +0100 |
commit | 3afc718eddcd81232392d46fccc24b8ec626c8df (patch) | |
tree | 9d8a13ba74f8f83c06f418a5f71762d87218d16a /sw | |
parent | 998a9470f1d5728b3f9702ef7aca77aa53bff96b (diff) |
rework PageSizePopup to be a PopupWindowController
Change-Id: Ib8a0acbceca607b0820437d66e18c7cd8c16904e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86748
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/PageSizePopup.hxx | 18 | ||||
-rw-r--r-- | sw/source/uibase/app/swmodule.cxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizeControl.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizeControl.hxx | 11 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizePopup.cxx | 38 | ||||
-rw-r--r-- | sw/util/sw.component | 4 |
6 files changed, 57 insertions, 23 deletions
diff --git a/sw/inc/PageSizePopup.hxx b/sw/inc/PageSizePopup.hxx index 5315863bf2b2..5f7354bb3da1 100644 --- a/sw/inc/PageSizePopup.hxx +++ b/sw/inc/PageSizePopup.hxx @@ -19,18 +19,24 @@ #ifndef INCLUDED_SW_INC_PAGESIZEPOPUP_HXX #define INCLUDED_SW_INC_PAGESIZEPOPUP_HXX -#include <sfx2/tbxctrl.hxx> +#include <svtools/popupwindowcontroller.hxx> #include "swdllapi.h" -class PageSizePopup final : public SfxToolBoxControl +class PageSizePopup final : public svt::PopupWindowController { public: - SFX_DECL_TOOLBOX_CONTROL(); - - PageSizePopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); + PageSizePopup(const css::uno::Reference<css::uno::XComponentContext>& rContext); virtual ~PageSizePopup() 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 diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index dd596895786e..613dda8d345f 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -282,7 +282,6 @@ void SwDLL::RegisterControls() PageMarginPopup::RegisterControl(SID_ATTR_PAGE_MARGIN, pMod); PageOrientationPopup::RegisterControl(SID_ATTR_PAGE_ORIENTATION, pMod); PageColumnPopup::RegisterControl(SID_ATTR_PAGE_COLUMN, pMod); - PageSizePopup::RegisterControl(SID_ATTR_PAGE_SIZE, pMod); SvxClipBoardControl::RegisterControl(SID_PASTE, pMod ); SvxUndoRedoControl::RegisterControl(SID_UNDO, pMod ); diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx index cd38ccf29953..dc33541466b9 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.cxx +++ b/sw/source/uibase/sidebar/PageSizeControl.cxx @@ -39,6 +39,8 @@ #include <svtools/unitconv.hxx> #include <editeng/sizeitem.hxx> +#include <PageSizePopup.hxx> + namespace { FieldUnit lcl_GetFieldUnit() @@ -68,8 +70,8 @@ namespace namespace sw { namespace sidebar { -PageSizeControl::PageSizeControl( sal_uInt16 nId, vcl::Window* pParent ) - : SfxPopupWindow( nId, pParent, "PageSizeControl", "modules/swriter/ui/pagesizecontrol.ui" ) +PageSizeControl::PageSizeControl(PageSizePopup* pControl, vcl::Window* pParent) + : ToolbarPopup(pControl->getFrameInterface(), pParent, "PageSizeControl", "modules/swriter/ui/pagesizecontrol.ui") , maPaperList() { get(maMoreButton, "moreoptions"); @@ -200,7 +202,7 @@ void PageSizeControl::dispose() maMoreButton.disposeAndClear(); maWidthHeightField.disposeAndClear(); maContainer.disposeAndClear(); - SfxPopupWindow::dispose(); + ToolbarPopup::dispose(); } void PageSizeControl::ExecuteSizeChange( const Paper ePaper ) diff --git a/sw/source/uibase/sidebar/PageSizeControl.hxx b/sw/source/uibase/sidebar/PageSizeControl.hxx index e67f624998e4..695140f6a4f6 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.hxx +++ b/sw/source/uibase/sidebar/PageSizeControl.hxx @@ -23,23 +23,26 @@ #include <vcl/button.hxx> #include <vcl/field.hxx> -#include <sfx2/tbxctrl.hxx> #include <vcl/layout.hxx> -#include <vector> +#include <svtools/toolbarmenu.hxx> #include <svtools/valueset.hxx> +#include <vector> + namespace svx { namespace sidebar { class ValueSetWithTextControl; } } + +class PageSizePopup; class ValueSet; namespace sw { namespace sidebar { -class PageSizeControl : public SfxPopupWindow +class PageSizeControl final : public svtools::ToolbarPopup { public: - explicit PageSizeControl(sal_uInt16 nId, vcl::Window* pParent); + explicit PageSizeControl(PageSizePopup* pControl, vcl::Window* pParent); virtual ~PageSizeControl() override; virtual void dispose() override; diff --git a/sw/source/uibase/sidebar/PageSizePopup.cxx b/sw/source/uibase/sidebar/PageSizePopup.cxx index b94ae4dfda0f..b68e714d1713 100644 --- a/sw/source/uibase/sidebar/PageSizePopup.cxx +++ b/sw/source/uibase/sidebar/PageSizePopup.cxx @@ -21,26 +21,46 @@ #include <editeng/sizeitem.hxx> #include <vcl/toolbox.hxx> -SFX_IMPL_TOOLBOX_CONTROL(PageSizePopup, SvxSizeItem); +PageSizePopup::PageSizePopup(const css::uno::Reference<css::uno::XComponentContext>& rContext) + : PopupWindowController(rContext, nullptr, OUString()) +{ +} -PageSizePopup::PageSizePopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) - : SfxToolBoxControl(nSlotId, nId, rTbx) +void PageSizePopup::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)); } PageSizePopup::~PageSizePopup() { } -VclPtr<SfxPopupWindow> PageSizePopup::CreatePopupWindow() +VclPtr<vcl::Window> PageSizePopup::createPopupWindow(vcl::Window* pParent) +{ + return VclPtr<sw::sidebar::PageSizeControl>::Create(this, pParent); +} + +OUString PageSizePopup::getImplementationName() { - VclPtr<sw::sidebar::PageSizeControl> pControl = VclPtr<sw::sidebar::PageSizeControl>::Create(GetSlotId(), &GetToolBox()); - pControl->StartPopupMode(&GetToolBox(), FloatWinPopupFlags::GrabFocus); - SetPopupWindow(pControl); + return "lo.writer.PageSizeToolBoxControl"; +} - return pControl; +css::uno::Sequence<OUString> PageSizePopup::getSupportedServiceNames() +{ + return { "com.sun.star.frame.ToolbarController" }; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +lo_writer_PageSizeToolBoxControl_get_implementation( + css::uno::XComponentContext* rContext, + css::uno::Sequence<css::uno::Any> const & ) +{ + return cppu::acquire(new PageSizePopup(rContext)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/util/sw.component b/sw/util/sw.component index ef96a6943230..f05b81a2e71a 100644 --- a/sw/util/sw.component +++ b/sw/util/sw.component @@ -47,6 +47,10 @@ constructor="lo_writer_MMExcludeEntryController_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> + <implementation name="lo.writer.PageSizeToolBoxControl" + constructor="lo_writer_PageSizeToolBoxControl_get_implementation"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> <implementation name="SwXModule" constructor="SwXModule_get_implementation"> <service name="com.sun.star.text.GlobalSettings"/> |