From c81afdb5118536b2e2365a9a9af6b6e162c87aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 13 Jan 2020 14:53:51 +0000 Subject: [PATCH] rework TextUnderlinePopup to be a PopupWindowController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I149777b827dd00e00e62b461836122861864f829 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86697 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- include/svx/TextUnderlinePopup.hxx | 19 +++++---- .../org/openoffice/Office/UI/Controller.xcu | 11 +++++ sc/source/ui/app/scdll.cxx | 1 - sd/source/ui/app/sddll.cxx | 2 - .../sidebar/text/TextUnderlineControl.cxx | 7 ++-- .../sidebar/text/TextUnderlineControl.hxx | 8 ++-- .../sidebar/text/TextUnderlinePopup.cxx | 42 ++++++++++++------- svx/util/svx.component | 4 ++ sw/source/uibase/app/swmodule.cxx | 1 - 9 files changed, 63 insertions(+), 32 deletions(-) diff --git a/include/svx/TextUnderlinePopup.hxx b/include/svx/TextUnderlinePopup.hxx index 994664a621d4..6dc64face2b1 100644 --- a/include/svx/TextUnderlinePopup.hxx +++ b/include/svx/TextUnderlinePopup.hxx @@ -19,23 +19,26 @@ #ifndef INCLUDED_SVX_SIDEBAR_TEXT_TEXTUNDERLINEPOPUP_HXX #define INCLUDED_SVX_SIDEBAR_TEXT_TEXTUNDERLINEPOPUP_HXX -#include +#include #include namespace svx { -class SVX_DLLPUBLIC TextUnderlinePopup final : public SfxToolBoxControl +class SVX_DLLPUBLIC TextUnderlinePopup final : public svt::PopupWindowController { public: - SFX_DECL_TOOLBOX_CONTROL(); - - TextUnderlinePopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); + TextUnderlinePopup(const css::uno::Reference& rContext); virtual ~TextUnderlinePopup() override; - // XInitialization - virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + using svt::ToolboxController::createPopupWindow; + virtual VclPtr createPopupWindow( vcl::Window* pParent ) override; - virtual VclPtr CreatePopupWindow() override; + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) override; }; } // end of namespace svx diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index e89903cd0149..a0bd1450d0e0 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -1404,6 +1404,17 @@ com.sun.star.comp.svx.ColorToolBoxControl + + + .uno:Underline + + + + + + com.sun.star.comp.svx.UnderlineToolBoxControl + + .uno:XLineColor diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx index 07ae6ae2894b..df8a4319ea01 100644 --- a/sc/source/ui/app/scdll.cxx +++ b/sc/source/ui/app/scdll.cxx @@ -153,7 +153,6 @@ void ScDLL::Init() SvxClipBoardControl ::RegisterControl(SID_PASTE_UNFORMATTED, pMod ); SvxUndoRedoControl ::RegisterControl(SID_UNDO, pMod ); SvxUndoRedoControl ::RegisterControl(SID_REDO, pMod ); - svx::TextUnderlinePopup ::RegisterControl(SID_ATTR_CHAR_UNDERLINE, pMod ); svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod ); sc::ScNumberFormatControl ::RegisterControl(SID_NUMBER_TYPE_FORMAT, pMod ); diff --git a/sd/source/ui/app/sddll.cxx b/sd/source/ui/app/sddll.cxx index 281e96ef1831..b83882bd764b 100644 --- a/sd/source/ui/app/sddll.cxx +++ b/sd/source/ui/app/sddll.cxx @@ -215,8 +215,6 @@ void SdDLL::RegisterControllers(SdModule* pMod) SvxClipBoardControl::RegisterControl( SID_PASTE, pMod ); SvxClipBoardControl::RegisterControl( SID_PASTE_UNFORMATTED, pMod ); - svx::TextUnderlinePopup::RegisterControl(SID_ATTR_CHAR_UNDERLINE, pMod); - #if HAVE_FEATURE_AVMEDIA ::avmedia::MediaToolBoxControl::RegisterControl( SID_AVMEDIA_TOOLBOX, pMod ); #endif diff --git a/svx/source/sidebar/text/TextUnderlineControl.cxx b/svx/source/sidebar/text/TextUnderlineControl.cxx index c509998e0b49..f8bac8dc99d4 100644 --- a/svx/source/sidebar/text/TextUnderlineControl.cxx +++ b/svx/source/sidebar/text/TextUnderlineControl.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -29,8 +30,8 @@ namespace svx { -TextUnderlineControl::TextUnderlineControl(sal_uInt16 nId, vcl::Window* pParent) -: SfxPopupWindow(nId, pParent, "TextUnderlineControl", "svx/ui/textunderlinecontrol.ui") +TextUnderlineControl::TextUnderlineControl(TextUnderlinePopup* pControl, vcl::Window* pParent) + : ToolbarPopup(pControl->getFrameInterface(), pParent, "TextUnderlineControl", "svx/ui/textunderlinecontrol.ui") { get(maNone, "none"); get(maSingle, "single"); @@ -82,7 +83,7 @@ void TextUnderlineControl::dispose() maWave.clear(); maMoreOptions.clear(); - SfxPopupWindow::dispose(); + ToolbarPopup::dispose(); } FontLineStyle TextUnderlineControl::getLineStyle(Button const * pButton) diff --git a/svx/source/sidebar/text/TextUnderlineControl.hxx b/svx/source/sidebar/text/TextUnderlineControl.hxx index ec1df4bbb696..48ba6d63e059 100644 --- a/svx/source/sidebar/text/TextUnderlineControl.hxx +++ b/svx/source/sidebar/text/TextUnderlineControl.hxx @@ -23,15 +23,17 @@ #include #include #include +#include #include -#include namespace svx { -class TextUnderlineControl : public SfxPopupWindow +class TextUnderlinePopup; + +class TextUnderlineControl final : public svtools::ToolbarPopup { public: - explicit TextUnderlineControl(sal_uInt16 nId, vcl::Window* pParent); + explicit TextUnderlineControl(TextUnderlinePopup* pControl, vcl::Window* pParent); virtual ~TextUnderlineControl() override; virtual void dispose() override; diff --git a/svx/source/sidebar/text/TextUnderlinePopup.cxx b/svx/source/sidebar/text/TextUnderlinePopup.cxx index a06012f18e25..5aebdbbdb4e1 100644 --- a/svx/source/sidebar/text/TextUnderlinePopup.cxx +++ b/svx/source/sidebar/text/TextUnderlinePopup.cxx @@ -23,10 +23,8 @@ using namespace svx; -SFX_IMPL_TOOLBOX_CONTROL(TextUnderlinePopup, SvxUnderlineItem); - -TextUnderlinePopup::TextUnderlinePopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) - : SfxToolBoxControl(nSlotId, nId, rTbx) +TextUnderlinePopup::TextUnderlinePopup(const css::uno::Reference& rContext) + : PopupWindowController(rContext, nullptr, OUString()) { } @@ -34,21 +32,37 @@ TextUnderlinePopup::~TextUnderlinePopup() { } -void TextUnderlinePopup::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) +void TextUnderlinePopup::initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) { - SfxToolBoxControl::initialize(aArguments); - if (GetToolBox().GetItemCommand(GetId()) == m_aCommandURL) - GetToolBox().SetItemBits(GetId(), ToolBoxItemBits::DROPDOWN | GetToolBox().GetItemBits(GetId())); + 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)); } -VclPtr TextUnderlinePopup::CreatePopupWindow() +VclPtr TextUnderlinePopup::createPopupWindow(vcl::Window* pParent) { - VclPtr pControl = VclPtr::Create(GetSlotId(), &GetToolBox()); - pControl->StartPopupMode(&GetToolBox(), FloatWinPopupFlags::GrabFocus); - SetPopupWindow(pControl); - - return pControl; + return VclPtr::Create(this, pParent); } +OUString TextUnderlinePopup::getImplementationName() +{ + return "com.sun.star.comp.svx.UnderlineToolBoxControl"; +} + +css::uno::Sequence TextUnderlinePopup::getSupportedServiceNames() +{ + return { "com.sun.star.frame.ToolbarController" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +com_sun_star_comp_svx_UnderlineToolBoxControl_get_implementation( + css::uno::XComponentContext* rContext, + css::uno::Sequence const & ) +{ + return cppu::acquire(new TextUnderlinePopup(rContext)); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/util/svx.component b/svx/util/svx.component index a27f47063d68..e195f023bae1 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -112,4 +112,8 @@ constructor="com_sun_star_comp_svx_CharacterSpacingToolBoxControl_get_implementation"> + + + diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 67c492e66192..2bb64eff605c 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -274,7 +274,6 @@ void SwDLL::RegisterControls() SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod ); SvxTbxCtlDraw::RegisterControl(SID_TRACK_CHANGES_BAR, pMod ); SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod ); - svx::TextUnderlinePopup::RegisterControl(SID_ATTR_CHAR_UNDERLINE, pMod); svx::ParaAboveSpacingControl::RegisterControl(SID_ATTR_PARA_ABOVESPACE, pMod); svx::ParaBelowSpacingControl::RegisterControl(SID_ATTR_PARA_BELOWSPACE, pMod); svx::ParaLeftSpacingControl::RegisterControl(SID_ATTR_PARA_LEFTSPACE, pMod);