diff options
author | Noel Grandin <noel@peralex.com> | 2016-08-22 11:02:36 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-08-23 09:54:16 +0200 |
commit | ba263e124ce263c3c893542062d9c473f5aae589 (patch) | |
tree | 74b99db819c66eb333ab2188df0a65a0b7b8fc2e /basctl | |
parent | 962719df881a8aefdec7f564293d1e0cd42a5540 (diff) |
clean up the SdrObjFactory create callbacks
passing params by setting fields on yourself is just gross
Change-Id: Iee98a9e8e266b56fc886c76eab470ab1ff7ff8e4
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/dlged/dlgedfac.cxx | 123 | ||||
-rw-r--r-- | basctl/source/inc/dlgedfac.hxx | 2 |
2 files changed, 56 insertions, 69 deletions
diff --git a/basctl/source/dlged/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx index 496a34194699..d1df0c1f13bb 100644 --- a/basctl/source/dlged/dlgedfac.cxx +++ b/basctl/source/dlged/dlgedfac.cxx @@ -43,7 +43,7 @@ DlgEdFactory::~DlgEdFactory() } -IMPL_LINK_TYPED( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory, void ) +IMPL_LINK_TYPED( DlgEdFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject* ) { static bool bNeedsInit = true; static uno::Reference< lang::XMultiServiceFactory > xDialogSFact; @@ -60,57 +60,49 @@ IMPL_LINK_TYPED( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory, void ) bNeedsInit = false; } - if( (pObjFactory->nInventor == DlgInventor) && - (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) && - (pObjFactory->nIdentifier <= OBJ_DLG_FORMHSCROLL) ) + SdrObject* pNewObj = nullptr; + if( (aParams.nInventor == DlgInventor) && + (aParams.nObjIdentifier >= OBJ_DLG_PUSHBUTTON) && + (aParams.nObjIdentifier <= OBJ_DLG_FORMHSCROLL) ) { - switch( pObjFactory->nIdentifier ) + switch( aParams.nObjIdentifier ) { case OBJ_DLG_PUSHBUTTON: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlButtonModel", xDialogSFact ); - break; - case OBJ_DLG_FORMRADIO: + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlButtonModel", xDialogSFact ); + break; case OBJ_DLG_RADIOBUTTON: - if ( pObjFactory->nIdentifier == OBJ_DLG_RADIOBUTTON ) - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact ); - else - { - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.RadioButton", xDialogSFact ); - static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); - } + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact ); + break; + case OBJ_DLG_FORMRADIO: + pNewObj = new DlgEdObj( "com.sun.star.form.component.RadioButton", xDialogSFact ); + static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); break; - case OBJ_DLG_FORMCHECK: case OBJ_DLG_CHECKBOX: - if ( pObjFactory->nIdentifier == OBJ_DLG_CHECKBOX ) - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact ); - else - { - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.CheckBox", xDialogSFact ); - static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); - } + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact ); + break; + case OBJ_DLG_FORMCHECK: + pNewObj = new DlgEdObj( "com.sun.star.form.component.CheckBox", xDialogSFact ); + static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); break; - case OBJ_DLG_FORMLIST: case OBJ_DLG_LISTBOX: - if ( pObjFactory->nIdentifier == OBJ_DLG_LISTBOX ) - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact ); - else - { - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.ListBox", xDialogSFact ); - static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); - } + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact ); + break; + case OBJ_DLG_FORMLIST: + pNewObj = new DlgEdObj( "com.sun.star.form.component.ListBox", xDialogSFact ); + static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); break; case OBJ_DLG_FORMCOMBO: case OBJ_DLG_COMBOBOX: { DlgEdObj* pNew = nullptr; - if ( pObjFactory->nIdentifier == OBJ_DLG_COMBOBOX ) + if ( aParams.nObjIdentifier == OBJ_DLG_COMBOBOX ) pNew = new DlgEdObj( "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact ); else { pNew = new DlgEdObj( "com.sun.star.form.component.ComboBox", xDialogSFact ); pNew->MakeDataAware( mxModel ); } - pObjFactory->pNewObj = pNew; + pNewObj = pNew; try { uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY); @@ -122,44 +114,42 @@ IMPL_LINK_TYPED( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory, void ) catch(...) { } - } break; + } + break; case OBJ_DLG_GROUPBOX: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact ); break; case OBJ_DLG_EDIT: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlEditModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlEditModel", xDialogSFact ); break; case OBJ_DLG_FIXEDTEXT: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact ); break; case OBJ_DLG_IMAGECONTROL: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact ); break; case OBJ_DLG_PROGRESSBAR: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact ); break; - case OBJ_DLG_FORMHSCROLL: case OBJ_DLG_HSCROLLBAR: - if ( pObjFactory->nIdentifier == OBJ_DLG_HSCROLLBAR ) - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact ); - else - { - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact ); - static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); - } + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact ); + break; + case OBJ_DLG_FORMHSCROLL: + pNewObj = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact ); + static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); break; case OBJ_DLG_FORMVSCROLL: case OBJ_DLG_VSCROLLBAR: { DlgEdObj* pNew = nullptr; - if ( pObjFactory->nIdentifier == OBJ_DLG_VSCROLLBAR ) + if ( aParams.nObjIdentifier == OBJ_DLG_VSCROLLBAR ) pNew = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact ); else { pNew = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact ); pNew->MakeDataAware( mxModel ); } - pObjFactory->pNewObj = pNew; + pNewObj = pNew; // set vertical orientation try { @@ -174,12 +164,12 @@ IMPL_LINK_TYPED( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory, void ) } } break; case OBJ_DLG_HFIXEDLINE: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact ); break; case OBJ_DLG_VFIXEDLINE: { DlgEdObj* pNew = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact ); - pObjFactory->pNewObj = pNew; + pNewObj = pNew; // set vertical orientation try { @@ -194,42 +184,39 @@ IMPL_LINK_TYPED( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory, void ) } } break; case OBJ_DLG_DATEFIELD: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact ); break; case OBJ_DLG_TIMEFIELD: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact ); break; case OBJ_DLG_NUMERICFIELD: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact ); break; case OBJ_DLG_CURRENCYFIELD: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact ); break; case OBJ_DLG_FORMATTEDFIELD: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact ); break; case OBJ_DLG_PATTERNFIELD: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact ); break; case OBJ_DLG_FILECONTROL: - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact ); + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact ); break; - case OBJ_DLG_FORMSPIN: case OBJ_DLG_SPINBUTTON: - if ( pObjFactory->nIdentifier == OBJ_DLG_SPINBUTTON ) - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact ); - else - { - pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.SpinButton", xDialogSFact ); - static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel ); - } + pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact ); + break; + case OBJ_DLG_FORMSPIN: + pNewObj = new DlgEdObj( "com.sun.star.form.component.SpinButton", xDialogSFact ); + static_cast< DlgEdObj* >( pNewObj )->MakeDataAware( mxModel ); break; case OBJ_DLG_TREECONTROL: - DlgEdObj* pNew = new DlgEdObj( "com.sun.star.awt.tree.TreeControlModel", xDialogSFact ); - pObjFactory->pNewObj = pNew; + pNewObj = new DlgEdObj( "com.sun.star.awt.tree.TreeControlModel", xDialogSFact ); break; } } + return pNewObj; } } // namespace basctl diff --git a/basctl/source/inc/dlgedfac.hxx b/basctl/source/inc/dlgedfac.hxx index d9079d9911ca..a824921388f8 100644 --- a/basctl/source/inc/dlgedfac.hxx +++ b/basctl/source/inc/dlgedfac.hxx @@ -38,7 +38,7 @@ public: DlgEdFactory( const css::uno::Reference< css::frame::XModel >& xModel ); ~DlgEdFactory(); - DECL_LINK_TYPED( MakeObject, SdrObjFactory *, void ); + DECL_LINK_TYPED( MakeObject, SdrObjCreatorParams, SdrObject* ); }; } // namespace basctl |