include/svx/tbcontrl.hxx | 11 - officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu | 6 reportdesign/source/ui/inc/toolboxcontroller.hxx | 2 reportdesign/source/ui/misc/toolboxcontroller.cxx | 75 ------- sc/source/ui/app/scdll.cxx | 1 sd/source/ui/app/sddll.cxx | 1 svx/source/tbxctrls/tbcontrl.cxx | 105 ++++++---- svx/util/svxcore.component | 4 sw/source/uibase/app/swmodule.cxx | 1 9 files changed, 86 insertions(+), 120 deletions(-)
New commits: commit 970a66f8c919ea0524f216f40d21b3e2a8c88ccc Author: Maxim Monastirsky <momonas...@gmail.com> Date: Sun Oct 16 01:27:10 2016 +0300 Use UNO registration for font name toolbox control Should help to eventually get rid of the wrapper in reportdesign. Change-Id: I9fc94f2ed650561eb47f2f91939b3aa37f031c3b Reviewed-on: https://gerrit.libreoffice.org/29910 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx index 21f07f2..dfa129a 100644 --- a/include/svx/tbcontrl.hxx +++ b/include/svx/tbcontrl.hxx @@ -203,17 +203,6 @@ friend class SfxStyleControllerItem_Impl; SVX_DLLPRIVATE SfxStyleFamily GetActFamily(); }; -class SVX_DLLPUBLIC SvxFontNameToolBoxControl : public SfxToolBoxControl -{ -public: - SFX_DECL_TOOLBOX_CONTROL(); - SvxFontNameToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); - - virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, - const SfxPoolItem* pState) override; - virtual VclPtr<vcl::Window> CreateItemWindow(vcl::Window* pParent) override; -}; - class BorderColorStatus { Color maColor; diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index 73f9d17..c91e8e1 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -1137,15 +1137,15 @@ <value>com.sun.star.report.ReportToolboxController</value> </prop> </node> - <node oor:name="c14" oor:op="replace" install:module="reportbuilder"> + <node oor:name="FontNameToolBox" oor:op="replace"> <prop oor:name="Command"> <value>.uno:CharFontName</value> </prop> <prop oor:name="Module"> - <value>com.sun.star.report.ReportDefinition</value> + <value/> </prop> <prop oor:name="Controller"> - <value>com.sun.star.report.ReportToolboxController</value> + <value>com.sun.star.comp.svx.FontNameToolBoxControl</value> </prop> </node> <node oor:name="OpenToolbarController" oor:op="replace"> diff --git a/reportdesign/source/ui/inc/toolboxcontroller.hxx b/reportdesign/source/ui/inc/toolboxcontroller.hxx index 2b7e910..66d1bb1b 100644 --- a/reportdesign/source/ui/inc/toolboxcontroller.hxx +++ b/reportdesign/source/ui/inc/toolboxcontroller.hxx @@ -44,7 +44,6 @@ namespace rptui TCommandState m_aStates; TToolbarHelper m_pToolbarController; sal_uInt16 m_nToolBoxId; - sal_uInt16 m_nSlotId; OToolboxController(const OToolboxController&) = delete; void operator =(const OToolboxController&) = delete; public: @@ -78,7 +77,6 @@ namespace rptui virtual OUString SAL_CALL getSubToolbarName( ) throw (css::uno::RuntimeException, std::exception) override; virtual void SAL_CALL functionSelected( const OUString& aCommand ) throw (css::uno::RuntimeException, std::exception) override; virtual void SAL_CALL updateImage( ) throw (css::uno::RuntimeException, std::exception) override; - virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw (css::uno::RuntimeException, std::exception) override; }; } // rptui diff --git a/reportdesign/source/ui/misc/toolboxcontroller.cxx b/reportdesign/source/ui/misc/toolboxcontroller.cxx index 5e05843..c7f5b6a 100644 --- a/reportdesign/source/ui/misc/toolboxcontroller.cxx +++ b/reportdesign/source/ui/misc/toolboxcontroller.cxx @@ -34,9 +34,6 @@ #include <svtools/menuoptions.hxx> #include <osl/mutex.hxx> #include <svx/svxids.hrc> -#define ITEMID_FONT 3 -#include <editeng/fontitem.hxx> -#include <editeng/fhgtitem.hxx> #include <svx/tbcontrl.hxx> #include <cppuhelper/supportsservice.hxx> @@ -87,7 +84,6 @@ Reference< XInterface > OToolboxController::create(Reference< XComponentContext OToolboxController::OToolboxController(const Reference< XComponentContext >& _rxORB) : m_pToolbarController(nullptr) ,m_nToolBoxId(1) - ,m_nSlotId(0) { osl_atomic_increment(&m_refCount); m_xContext = _rxORB; @@ -137,21 +133,16 @@ void SAL_CALL OToolboxController::initialize( const Sequence< Any >& _rArguments break; } } - if ( m_aCommandURL == ".uno:CharFontName" ) - { - m_aStates.insert(TCommandState::value_type(OUString(".uno:CharFontName"),true)); - m_pToolbarController = new SvxFontNameToolBoxControl/*SvxStyleToolBoxControl*/(m_nSlotId = SID_ATTR_CHAR_FONT,m_nToolBoxId,*pToolBox); - } - else if ( m_aCommandURL == ".uno:FontColor" || m_aCommandURL == ".uno:Color" ) + if ( m_aCommandURL == ".uno:FontColor" || m_aCommandURL == ".uno:Color" ) { m_aStates.insert(TCommandState::value_type(OUString(".uno:FontColor"),true)); m_aStates.insert(TCommandState::value_type(OUString(".uno:Color"),true)); - m_pToolbarController = new SvxColorToolBoxControl(m_nSlotId = SID_ATTR_CHAR_COLOR2,m_nToolBoxId,*pToolBox); + m_pToolbarController = new SvxColorToolBoxControl(SID_ATTR_CHAR_COLOR2,m_nToolBoxId,*pToolBox); } else { m_aStates.insert(TCommandState::value_type(OUString(".uno:BackgroundColor"),true)); - m_pToolbarController = new SvxColorToolBoxControl(m_nSlotId = SID_BACKGROUND_COLOR,m_nToolBoxId,*pToolBox); + m_pToolbarController = new SvxColorToolBoxControl(SID_BACKGROUND_COLOR,m_nToolBoxId,*pToolBox); } TCommandState::const_iterator aIter = m_aStates.begin(); @@ -169,43 +160,8 @@ void SAL_CALL OToolboxController::statusChanged( const FeatureStateEvent& Event { ::osl::MutexGuard aGuard(m_aMutex); TCommandState::iterator aFind = m_aStates.find( Event.FeatureURL.Complete ); - if ( aFind != m_aStates.end() ) - { - aFind->second = Event.IsEnabled; - if ( m_pToolbarController.is() ) - { - // All other status events will be processed here - ToolBox& rTb = m_pToolbarController->GetToolBox(); - for ( sal_uInt16 i = 0; i < rTb.GetItemCount(); i++ ) - { - sal_uInt16 nId = rTb.GetItemId( i ); - if ( nId == 0 ) - continue; - - OUString aCmd = rTb.GetItemCommand( nId ); - if ( aCmd == Event.FeatureURL.Complete ) - { - // Enable/disable item - rTb.EnableItem( nId, Event.IsEnabled ); - } - } - - switch(m_nSlotId) - { - case SID_ATTR_CHAR_COLOR2: - case SID_BACKGROUND_COLOR: - m_pToolbarController->statusChanged( Event ); - break; - case SID_ATTR_CHAR_FONT: - { - SvxFontItem aItem(ITEMID_FONT); - aItem.PutValue(Event.State, 0); - static_cast<SvxFontNameToolBoxControl*>(m_pToolbarController.get())->StateChanged(m_nSlotId,Event.IsEnabled ? SfxItemState::DEFAULT : SfxItemState::DISABLED,&aItem); - } - break; - } - } - } + if ( aFind != m_aStates.end() && m_pToolbarController.is() ) + m_pToolbarController->statusChanged( Event ); } Reference< awt::XWindow > SAL_CALL OToolboxController::createPopupWindow() throw (RuntimeException, std::exception) @@ -229,7 +185,7 @@ void SAL_CALL OToolboxController::execute( sal_Int16 KeyModifier ) throw (uno::R sal_Bool SAL_CALL OToolboxController::opensSubToolbar() throw (uno::RuntimeException, std::exception) { - return ( m_nSlotId != SID_ATTR_CHAR_FONT ); + return true; } OUString SAL_CALL OToolboxController::getSubToolbarName() throw (uno::RuntimeException, std::exception) @@ -249,25 +205,6 @@ void SAL_CALL OToolboxController::updateImage( ) throw (uno::RuntimeException, m_pToolbarController->updateImage(); } -uno::Reference< awt::XWindow > SAL_CALL OToolboxController::createItemWindow( const uno::Reference< awt::XWindow >& _xParent) -throw (uno::RuntimeException, std::exception) -{ - uno::Reference< awt::XWindow > xWindow; - if ( m_pToolbarController.is() ) - { - switch(m_nSlotId) - { - case SID_ATTR_CHAR_FONT: - xWindow = VCLUnoHelper::GetInterface(static_cast<SvxFontNameToolBoxControl*>(m_pToolbarController.get())->CreateItemWindow(VCLUnoHelper::GetWindow(_xParent))); - break; - default: - ; - } - } - return xWindow; -} - - } // rptui diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx index 4e249d3..f001bcc 100644 --- a/sc/source/ui/app/scdll.cxx +++ b/sc/source/ui/app/scdll.cxx @@ -163,7 +163,6 @@ void ScDLL::Init() SvxColorToolBoxControl ::RegisterControl(SID_ATTR_FILL_COLOR, pMod); SvxLineEndToolBoxControl ::RegisterControl(SID_ATTR_LINEEND_STYLE, pMod); SvxStyleToolBoxControl ::RegisterControl(SID_STYLE_APPLY, pMod); - SvxFontNameToolBoxControl ::RegisterControl(SID_ATTR_CHAR_FONT, pMod); SvxColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_COLOR, pMod); SvxColorToolBoxControl ::RegisterControl(SID_BACKGROUND_COLOR, pMod); SvxColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_BACK_COLOR, pMod); diff --git a/sd/source/ui/app/sddll.cxx b/sd/source/ui/app/sddll.cxx index 41fed94..97a4e08d 100644 --- a/sd/source/ui/app/sddll.cxx +++ b/sd/source/ui/app/sddll.cxx @@ -189,7 +189,6 @@ void SdDLL::RegisterControllers(SdModule* pMod) SvxLineEndToolBoxControl::RegisterControl( SID_ATTR_LINEEND_STYLE, pMod ); SvxStyleToolBoxControl::RegisterControl(0, pMod); - SvxFontNameToolBoxControl::RegisterControl(0, pMod); SvxColorToolBoxControl::RegisterControl( SID_ATTR_CHAR_COLOR, pMod ); SvxColorToolBoxControl::RegisterControl( SID_ATTR_CHAR_BACK_COLOR, pMod ); diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index e6309dd..a081a58 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -46,6 +46,7 @@ #include <svl/isethint.hxx> #include <sfx2/querystatus.hxx> #include <sfx2/sfxstatuslistener.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <tools/urlobj.hxx> #include <sfx2/childwin.hxx> #include <sfx2/viewfrm.hxx> @@ -116,7 +117,6 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem ); -SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem ); SFX_IMPL_TOOLBOX_CONTROL( SvxCurrencyToolBoxControl, SfxBoolItem ); @@ -216,7 +216,7 @@ public: virtual void dispose() override; void FillList(); - void Update( const SvxFontItem* pFontItem ); + void Update( const css::awt::FontDescriptor* pFontDesc ); sal_uInt16 GetListCount() { return nFtCount; } void Clear() { FontNameBox::Clear(); nFtCount = 0; } void Fill( const FontList* pList ) @@ -1021,15 +1021,15 @@ IMPL_LINK( SvxFontNameBox_Impl, CheckAndMarkUnknownFont, VclWindowEvent&, event, } } -void SvxFontNameBox_Impl::Update( const SvxFontItem* pFontItem ) +void SvxFontNameBox_Impl::Update( const css::awt::FontDescriptor* pFontDesc ) { - if ( pFontItem ) + if ( pFontDesc ) { - aCurFont.SetFamilyName ( pFontItem->GetFamilyName() ); - aCurFont.SetFamily ( pFontItem->GetFamily() ); - aCurFont.SetStyleName ( pFontItem->GetStyleName() ); - aCurFont.SetPitch ( pFontItem->GetPitch() ); - aCurFont.SetCharSet ( pFontItem->GetCharSet() ); + aCurFont.SetFamilyName ( pFontDesc->Name ); + aCurFont.SetFamily ( FontFamily( pFontDesc->Family ) ); + aCurFont.SetStyleName ( pFontDesc->StyleName ); + aCurFont.SetPitch ( FontPitch( pFontDesc->Pitch ) ); + aCurFont.SetCharSet ( rtl_TextEncoding( pFontDesc->CharSet ) ); } OUString aCurName = aCurFont.GetFamilyName(); if ( GetText() != aCurName ) @@ -2554,24 +2554,42 @@ VclPtr<vcl::Window> SvxStyleToolBoxControl::CreateItemWindow( vcl::Window *pPare return pBox.get(); } -SvxFontNameToolBoxControl::SvxFontNameToolBoxControl( - sal_uInt16 nSlotId, - sal_uInt16 nId, - ToolBox& rTbx ) - : SfxToolBoxControl( nSlotId, nId, rTbx ) +class SvxFontNameToolBoxControl : public cppu::ImplInheritanceHelper< svt::ToolboxController, + css::lang::XServiceInfo > +{ +public: + SvxFontNameToolBoxControl(); + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException, std::exception ) override; + + // XToolbarController + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& rParent ) throw ( css::uno::RuntimeException, std::exception ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() throw ( css::uno::RuntimeException, std::exception ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw ( css::uno::RuntimeException, std::exception ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw ( css::uno::RuntimeException, std::exception ) override; +}; + +SvxFontNameToolBoxControl::SvxFontNameToolBoxControl() { } -void SvxFontNameToolBoxControl::StateChanged( - sal_uInt16 , SfxItemState eState, const SfxPoolItem* pState ) +void SvxFontNameToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent ) + throw ( css::uno::RuntimeException, std::exception ) { - sal_uInt16 nId = GetId(); - ToolBox& rTbx = GetToolBox(); - SvxFontNameBox_Impl* pBox = static_cast<SvxFontNameBox_Impl*>(rTbx.GetItemWindow( nId )); + SolarMutexGuard aGuard; + ToolBox* pToolBox = nullptr; + sal_uInt16 nId = 0; + if ( !getToolboxId( nId, &pToolBox ) ) + return; + + SvxFontNameBox_Impl* pBox = static_cast<SvxFontNameBox_Impl*>(pToolBox->GetItemWindow( nId )); DBG_ASSERT( pBox, "Control not found!" ); - if ( SfxItemState::DISABLED == eState ) + if ( !rEvent.IsEnabled ) { pBox->Disable(); pBox->Update( nullptr ); @@ -2580,28 +2598,51 @@ void SvxFontNameToolBoxControl::StateChanged( { pBox->Enable(); - if ( SfxItemState::DEFAULT == eState ) - { - const SvxFontItem* pFontItem = dynamic_cast< const SvxFontItem* >( pState ); - - DBG_ASSERT( pFontItem, "svx::SvxFontNameToolBoxControl::StateChanged(), wrong item type!" ); - if( pFontItem ) - pBox->Update( pFontItem ); - } + css::awt::FontDescriptor aFontDesc; + if ( rEvent.State >>= aFontDesc ) + pBox->Update( &aFontDesc ); else pBox->SetText( "" ); pBox->SaveValue(); } - rTbx.EnableItem( nId, SfxItemState::DISABLED != eState ); + pToolBox->EnableItem( nId, rEvent.IsEnabled ); } -VclPtr<vcl::Window> SvxFontNameToolBoxControl::CreateItemWindow( vcl::Window *pParent ) +css::uno::Reference< css::awt::XWindow > SvxFontNameToolBoxControl::createItemWindow( const css::uno::Reference< css::awt::XWindow >& rParent ) + throw ( css::uno::RuntimeException, std::exception ) { - VclPtrInstance<SvxFontNameBox_Impl> pBox( pParent, + SolarMutexGuard aGuard; + VclPtrInstance<SvxFontNameBox_Impl> pBox( VCLUnoHelper::GetWindow( rParent ), Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ), m_xFrame,0); - return pBox.get(); + return VCLUnoHelper::GetInterface( pBox ); +} + +OUString SvxFontNameToolBoxControl::getImplementationName() + throw ( css::uno::RuntimeException, std::exception ) +{ + return OUString( "com.sun.star.comp.svx.FontNameToolBoxControl" ); +} + +sal_Bool SvxFontNameToolBoxControl::supportsService( const OUString& rServiceName ) + throw ( css::uno::RuntimeException, std::exception ) +{ + return cppu::supportsService( this, rServiceName ); +} + +css::uno::Sequence< OUString > SvxFontNameToolBoxControl::getSupportedServiceNames() + throw ( css::uno::RuntimeException, std::exception ) +{ + return { "com.sun.star.frame.ToolbarController" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_svx_FontNameToolBoxControl_get_implementation( + css::uno::XComponentContext*, + css::uno::Sequence<css::uno::Any> const & ) +{ + return cppu::acquire( new SvxFontNameToolBoxControl() ); } SvxColorToolBoxControl::SvxColorToolBoxControl( diff --git a/svx/util/svxcore.component b/svx/util/svxcore.component index 8c8d42d..c51f3a6 100644 --- a/svx/util/svxcore.component +++ b/svx/util/svxcore.component @@ -44,6 +44,10 @@ constructor="com_sun_star_comp_svx_FrameToolBoxControl_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> + <implementation name="com.sun.star.comp.svx.FontNameToolBoxControl" + constructor="com_sun_star_comp_svx_FontNameToolBoxControl_get_implementation"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> <implementation name="com.sun.star.comp.Svx.GraphicExportHelper" constructor="com_sun_star_comp_Svx_GraphicExportHelper_get_implementation"> <service name="com.sun.star.document.BinaryStreamResolver"/> diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 6269338..9d2818b 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -314,7 +314,6 @@ void SwDLL::RegisterControls() SvxColorToolBoxControl::RegisterControl(SID_ATTR_FILL_COLOR, pMod); SvxColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_BACK_COLOR, pMod); - SvxFontNameToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONT, pMod ); SvxColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR, pMod ); SvxColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR2, pMod ); SvxColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND, pMod ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits