Base SvxLineWindow_Impl on ToolbarPopup

Change-Id: I93dbb180fc65bca77e0eb58f116d0a0a5266556a
This commit is contained in:
Maxim Monastirsky 2016-10-07 00:22:01 +03:00
parent 2796291bd8
commit 5e87eea81b
6 changed files with 25 additions and 61 deletions

View file

@ -254,17 +254,6 @@ public:
void setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction);
};
class SVX_DLLPUBLIC SvxFrameLineStyleToolBoxControl : public SfxToolBoxControl
{
public:
SFX_DECL_TOOLBOX_CONTROL();
SvxFrameLineStyleToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rToolBox);
virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override;
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState,
const SfxPoolItem* pState) override;
};
class SVX_DLLPUBLIC SvxSimpleUndoRedoController : public SfxToolBoxControl
{
private:

View file

@ -1082,7 +1082,7 @@
<value>com.sun.star.comp.sfx2.ClassificationCategoriesController</value>
</prop>
</node>
<node oor:name="com.sun.star.comp.svx.FrameToolBoxControl" oor:op="replace">
<node oor:name="BorderStyleToolBoxControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:SetBorderStyle</value>
</prop>
@ -1093,6 +1093,17 @@
<value>com.sun.star.comp.svx.FrameToolBoxControl</value>
</prop>
</node>
<node oor:name="BorderLineStyleToolBoxControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:LineStyle</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.svx.FrameToolBoxControl</value>
</prop>
</node>
<node oor:name="c4" oor:op="replace" install:module="reportbuilder">
<prop oor:name="Command">
<value>.uno:FontColor</value>

View file

@ -167,7 +167,6 @@ void ScDLL::Init()
SvxColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_COLOR, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_BACKGROUND_COLOR, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_BACK_COLOR, pMod);
SvxFrameLineStyleToolBoxControl ::RegisterControl(SID_FRAME_LINESTYLE, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_FRAME_LINECOLOR, pMod);
SvxClipBoardControl ::RegisterControl(SID_PASTE, pMod );
SvxUndoRedoControl ::RegisterControl(SID_UNDO, pMod );

View file

@ -235,7 +235,6 @@ void SdDLL::RegisterControllers(SdModule* pMod)
XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod );
SdTemplateControl::RegisterControl( SID_STATUS_LAYOUT, pMod );
SvxTableToolBoxControl::RegisterControl(SID_INSERT_TABLE, pMod );
SvxFrameLineStyleToolBoxControl::RegisterControl(SID_FRAME_LINESTYLE, pMod );
SvxColorToolBoxControl::RegisterControl(SID_FRAME_LINECOLOR, pMod );
SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );

View file

@ -115,7 +115,6 @@ using namespace ::com::sun::star::lang;
SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxCurrencyToolBoxControl, SfxBoolItem );
@ -270,10 +269,11 @@ public:
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
};
class SvxLineWindow_Impl : public SfxPopupWindow
class SvxLineWindow_Impl : public svtools::ToolbarPopup
{
private:
VclPtr<LineListBox> m_aLineStyleLb;
svt::ToolboxController& m_rController;
bool m_bIsWriter;
DECL_LINK( SelectHdl, ListBox&, void );
@ -282,9 +282,9 @@ protected:
virtual void Resize() override;
virtual void GetFocus() override;
public:
SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow );
SvxLineWindow_Impl( svt::ToolboxController& rController, vcl::Window* pParentWindow );
virtual ~SvxLineWindow_Impl() override { disposeOnce(); }
virtual void dispose() override { m_aLineStyleLb.disposeAndClear(); SfxPopupWindow::dispose(); }
virtual void dispose() override { m_aLineStyleLb.disposeAndClear(); ToolbarPopup::dispose(); }
};
class SvxCurrencyToolBoxControl;
@ -1928,14 +1928,14 @@ void SvxCurrencyList_Impl::dispose()
SfxPopupWindow::dispose();
}
SvxLineWindow_Impl::SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow ) :
SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION | WB_AUTOSIZE ) ),
m_aLineStyleLb( VclPtr<LineListBox>::Create(this) )
SvxLineWindow_Impl::SvxLineWindow_Impl( svt::ToolboxController& rController, vcl::Window* pParentWindow ) :
ToolbarPopup( rController.getFrameInterface(), pParentWindow, WB_STDPOPUP | WB_MOVEABLE | WB_CLOSEABLE ),
m_aLineStyleLb( VclPtr<LineListBox>::Create(this) ),
m_rController( rController )
{
try
{
Reference< lang::XServiceInfo > xServices( rFrame->getController()->getModel(), UNO_QUERY_THROW );
Reference< lang::XServiceInfo > xServices( rController.getFrameInterface()->getController()->getModel(), UNO_QUERY_THROW );
m_bIsWriter = xServices->supportsService("com.sun.star.text.TextDocument");
}
catch(const uno::Exception& )
@ -2026,9 +2026,7 @@ IMPL_LINK_NOARG(SvxLineWindow_Impl, SelectHdl, ListBox&, void)
aLineItem.QueryValue( a, m_bIsWriter ? CONVERT_TWIPS : 0 );
aArgs[0].Value = a;
SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
".uno:LineStyle",
aArgs );
m_rController.dispatchCommand( ".uno:LineStyle", aArgs );
}
void SvxLineWindow_Impl::Resize()
@ -2929,6 +2927,9 @@ void SvxFrameToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any
VclPtr<vcl::Window> SvxFrameToolBoxControl::createPopupWindow( vcl::Window* pParent )
{
if ( m_aCommandURL == ".uno:LineStyle" )
return VclPtr<SvxLineWindow_Impl>::Create( *this, pParent );
return VclPtr<SvxFrameWindow_Impl>::Create( *this, pParent );
}
@ -2952,40 +2953,6 @@ com_sun_star_comp_svx_FrameToolBoxControl_get_implementation(
return cppu::acquire( new SvxFrameToolBoxControl( rContext ) );
}
SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl(
sal_uInt16 nSlotId,
sal_uInt16 nId,
ToolBox& rTbx )
: SfxToolBoxControl( nSlotId, nId, rTbx )
{
rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits( nId ) );
}
VclPtr<SfxPopupWindow> SvxFrameLineStyleToolBoxControl::CreatePopupWindow()
{
VclPtr<SvxLineWindow_Impl> pLineWin = VclPtr<SvxLineWindow_Impl>::Create( GetSlotId(), m_xFrame, &GetToolBox() );
pLineWin->StartPopupMode( &GetToolBox(),
FloatWinPopupFlags::GrabFocus |
FloatWinPopupFlags::AllowTearOff |
FloatWinPopupFlags::NoAppFocusClose );
SetPopupWindow( pLineWin );
return pLineWin;
}
void SvxFrameLineStyleToolBoxControl::StateChanged(
sal_uInt16 , SfxItemState eState, const SfxPoolItem* )
{
sal_uInt16 nId = GetId();
ToolBox& rTbx = GetToolBox();
rTbx.EnableItem( nId, SfxItemState::DISABLED != eState );
rTbx.SetItemState( nId, (SfxItemState::DONTCARE == eState)
? TRISTATE_INDET
: TRISTATE_FALSE );
}
SvxSimpleUndoRedoController::SvxSimpleUndoRedoController( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
:SfxToolBoxControl( nSlotId, nId, rTbx )
{

View file

@ -320,7 +320,6 @@ void SwDLL::RegisterControls()
SvxColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND, pMod );
SvxStyleToolBoxControl::RegisterControl(SID_STYLE_APPLY, pMod );
SvxColorToolBoxControl::RegisterControl( SID_BACKGROUND_COLOR, pMod );
SvxFrameLineStyleToolBoxControl::RegisterControl(SID_FRAME_LINESTYLE, pMod );
SvxColorToolBoxControl::RegisterControl(SID_FRAME_LINECOLOR, pMod );
SvxColumnsToolBoxControl::RegisterControl(FN_INSERT_FRAME_INTERACT, pMod );