diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-01-25 20:04:13 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-01-25 22:44:57 +0100 |
commit | eeb2d19e77d6dc47c68e8ba0920a02cf64a1247b (patch) | |
tree | 48b058b83abd59d61047d91afe43c6a190412acf /svx | |
parent | 9ce254a7797405b3b655ba4e5be2190cddad2902 (diff) |
Resolves: tdf#130159 hide writedirection unless CTL is enabled
rework as ToolboxControllers registered in Controller.xcu
Change-Id: I3e7fea09fe83d1ed6400218c41384f82b38b07a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87419
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/tbxctrls/verttexttbxctrl.cxx | 120 | ||||
-rw-r--r-- | svx/util/svx.component | 8 |
2 files changed, 93 insertions, 35 deletions
diff --git a/svx/source/tbxctrls/verttexttbxctrl.cxx b/svx/source/tbxctrls/verttexttbxctrl.cxx index 24dda13495e9..7fbb87c245d7 100644 --- a/svx/source/tbxctrls/verttexttbxctrl.cxx +++ b/svx/source/tbxctrls/verttexttbxctrl.cxx @@ -17,81 +17,131 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - +#include <cppuhelper/supportsservice.hxx> #include <svx/svxids.hrc> #include <svx/verttexttbxctrl.hxx> #include <svl/languageoptions.hxx> #include <sfx2/app.hxx> #include <svl/eitem.hxx> #include <vcl/toolbox.hxx> +#include <vcl/weld.hxx> #include <rtl/ustring.hxx> -SFX_IMPL_TOOLBOX_CONTROL(SvxCTLTextTbxCtrl, SfxBoolItem); -SFX_IMPL_TOOLBOX_CONTROL(SvxVertTextTbxCtrl, SfxBoolItem); +SvxCTLTextTbxCtrl::SvxCTLTextTbxCtrl(const css::uno::Reference<css::uno::XComponentContext>& rContext) + : SvxVertCTLTextTbxCtrl(rContext) +{ + addStatusListener(".uno:CTLFontState"); +} -SvxCTLTextTbxCtrl::SvxCTLTextTbxCtrl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : - SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx ) +OUString SvxCTLTextTbxCtrl::getImplementationName() { - addStatusListener( ".uno:CTLFontState"); + return "com.sun.star.comp.svx.CTLToolBoxControl"; } -SvxVertTextTbxCtrl::SvxVertTextTbxCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : - SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +com_sun_star_comp_svx_CTLToolBoxControl_get_implementation( + css::uno::XComponentContext* rContext, + css::uno::Sequence<css::uno::Any> const & ) { - addStatusListener( ".uno:VerticalTextState"); + return cppu::acquire(new SvxCTLTextTbxCtrl(rContext)); } -SvxVertCTLTextTbxCtrl::SvxVertCTLTextTbxCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : - SfxToolBoxControl( nSlotId, nId, rTbx ) +SvxVertTextTbxCtrl::SvxVertTextTbxCtrl(const css::uno::Reference<css::uno::XComponentContext>& rContext) + : SvxVertCTLTextTbxCtrl(rContext) { + addStatusListener(".uno:VerticalTextState"); } -SvxVertCTLTextTbxCtrl::~SvxVertCTLTextTbxCtrl( ) +OUString SvxVertTextTbxCtrl::getImplementationName() +{ + return "com.sun.star.comp.svx.VertTextToolBoxControl"; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +com_sun_star_comp_svx_VertTextToolBoxControl_get_implementation( + css::uno::XComponentContext* rContext, + css::uno::Sequence<css::uno::Any> const & ) +{ + return cppu::acquire(new SvxVertTextTbxCtrl(rContext)); +} + +SvxVertCTLTextTbxCtrl::SvxVertCTLTextTbxCtrl(const css::uno::Reference<css::uno::XComponentContext>& rContext) + : SvxVertCTLTextTbxCtrl_Base(rContext, nullptr, OUString()) { } -void SvxVertCTLTextTbxCtrl::initialize(const css::uno::Sequence<css::uno::Any>& rArguments) +SvxVertCTLTextTbxCtrl::~SvxVertCTLTextTbxCtrl( ) { - SfxToolBoxControl::initialize(rArguments); - setFastPropertyValue_NoBroadcast(1, css::uno::makeAny(true)); } -void SvxVertCTLTextTbxCtrl::StateChanged( - sal_uInt16 nSID, - SfxItemState eState, - const SfxPoolItem* pState ) +void SAL_CALL SvxVertCTLTextTbxCtrl::statusChanged(const css::frame::FeatureStateEvent& rEvent) { - SvtLanguageOptions aLangOptions; - bool bCalc = false; + ToolBox* pToolBox = nullptr; + sal_uInt16 nItemId = 0; + bool bVclToolBox = getToolboxId(nItemId, &pToolBox); + bool bEnabled = false; - if ( nSID == SID_VERTICALTEXT_STATE ) + if (rEvent.FeatureURL.Complete == ".uno:VerticalTextState") + { + SvtLanguageOptions aLangOptions; bEnabled = aLangOptions.IsVerticalTextEnabled(); - else if ( nSID == SID_CTLFONT_STATE ) + } + else if (rEvent.FeatureURL.Complete == ".uno:CTLFontState") + { + SvtLanguageOptions aLangOptions; bEnabled = aLangOptions.IsCTLFontEnabled(); + } else { - SfxToolBoxControl::StateChanged(nSID, eState, pState); + // normal command + bool bValue = false; + rEvent.State >>= bValue; + + if (m_pToolbar) + { + OString sId = m_aCommandURL.toUtf8(); + m_pToolbar->set_item_active(sId, bValue); + m_pToolbar->set_item_sensitive(sId, rEvent.IsEnabled); + } + + if (bVclToolBox) + { + pToolBox->CheckItem(nItemId, bValue); + pToolBox->EnableItem(nItemId, rEvent.IsEnabled); + } + return; } - if(!bEnabled) + if (m_pToolbar) { - // always hide if either IsVerticalTextEnabled or IsCTLFontEnabled - // is false - GetToolBox().HideItem( GetId() ); - bCalc = true; + m_pToolbar->set_item_visible(m_aCommandURL.toUtf8(), bEnabled); + return; } - if(bCalc) + + if (bVclToolBox) { - ToolBox& rTbx = GetToolBox(); - vcl::Window* pParent = rTbx.GetParent(); - if(WindowType::FLOATINGWINDOW == pParent->GetType()) + pToolBox->ShowItem(nItemId, bEnabled); + + vcl::Window* pParent = pToolBox->GetParent(); + if (WindowType::FLOATINGWINDOW == pParent->GetType()) { - Size aSize(rTbx.CalcWindowSizePixel()); - rTbx.SetPosSizePixel( Point(), aSize ); + Size aSize(pToolBox->CalcWindowSizePixel()); + pToolBox->SetPosSizePixel( Point(), aSize ); pParent->SetOutputSizePixel( aSize ); } } } +// XServiceInfo +sal_Bool SAL_CALL SvxVertCTLTextTbxCtrl::supportsService( const OUString& ServiceName ) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence< OUString > SvxVertCTLTextTbxCtrl::getSupportedServiceNames() +{ + return { "com.sun.star.frame.ToolbarController" }; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/util/svx.component b/svx/util/svx.component index 81cae7623bd2..ff8d802394ac 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -124,4 +124,12 @@ constructor="com_sun_star_comp_svx_UndoRedoToolBoxControl_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> + <implementation name="com.sun.star.comp.svx.CTLToolBoxControl" + constructor="com_sun_star_comp_svx_CTLToolBoxControl_get_implementation"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> + <implementation name="com.sun.star.comp.svx.VertTextToolBoxControl" + constructor="com_sun_star_comp_svx_VertTextToolBoxControl_get_implementation"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> </component> |