diff options
author | Noel Grandin <noel@peralex.com> | 2013-01-18 10:06:54 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-02-11 08:02:12 +0200 |
commit | b5cd8f9186c023124b25706f65e7608b68c426bd (patch) | |
tree | 16ea52a226311052fc76ad97a4b3163bf8569e08 /forms | |
parent | fdo#46808, Use service constructor for awt::DialogProvider (diff) | |
download | core-b5cd8f9186c023124b25706f65e7608b68c426bd.tar.gz core-b5cd8f9186c023124b25706f65e7608b68c426bd.zip |
fdo#46808, Adapt form::control::FilterControl UNO service to new style
The service already existed, it just did not have an IDL file
Change-Id: I1ca7ab09491057c1e9c91b5bb6763b84be10b47b
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/component/Filter.cxx | 114 | ||||
-rw-r--r-- | forms/source/component/Filter.hxx | 1 |
2 files changed, 66 insertions, 49 deletions
diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 8a64e8bd1903..9afc606ecfeb 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -763,8 +763,16 @@ namespace frm NamedValue aValue; const ::rtl::OUString* pName = NULL; const Any* pValue = NULL; + Reference< XPropertySet > xControlModel; - for ( ; pArguments != pArgumentsEnd; ++pArguments ) + if (aArguments.getLength() == 3 + && (aArguments[0] >>= m_xMessageParent) + && (aArguments[1] >>= m_xFormatter) + && (aArguments[2] >>= xControlModel)) + { + initControlModel(xControlModel); + } + else for ( ; pArguments != pArgumentsEnd; ++pArguments ) { // we recognize PropertyValues and NamedValues if ( *pArguments >>= aProp ) @@ -798,63 +806,71 @@ namespace frm else if ( 0 == pName->compareToAscii( "ControlModel" ) ) { // the control model for which we act as filter control - Reference< XPropertySet > xControlModel; - if ( !(*pValue >>= xControlModel ) || !xControlModel.is() ) + if ( !(*pValue >>= xControlModel ) ) { OSL_FAIL( "OFilterControl::initialize: invalid control model argument!" ); continue; } + initControlModel(xControlModel); + } + } + } - // some properties which are "derived" from the control model we're working for - // ................................................... - // the field - m_xField.clear(); - OSL_ENSURE( ::comphelper::hasProperty( PROPERTY_BOUNDFIELD, xControlModel ), "OFilterControl::initialize: control model needs a bound field property!" ); - xControlModel->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= m_xField; - - // ................................................... - // filter list and control class - m_bFilterList = ::comphelper::hasProperty( PROPERTY_FILTERPROPOSAL, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_FILTERPROPOSAL ) ); - if ( m_bFilterList ) - m_nControlClass = FormComponentType::COMBOBOX; - else - { - sal_Int16 nClassId = ::comphelper::getINT16( xControlModel->getPropertyValue( PROPERTY_CLASSID ) ); - switch (nClassId) + void OFilterControl::initControlModel(Reference< XPropertySet >& xControlModel) + { + if ( !xControlModel.is() ) + { + OSL_FAIL( "OFilterControl::initialize: invalid control model argument!" ); + return; + } + // some properties which are "derived" from the control model we're working for + // ................................................... + // the field + m_xField.clear(); + OSL_ENSURE( ::comphelper::hasProperty( PROPERTY_BOUNDFIELD, xControlModel ), "OFilterControl::initialize: control model needs a bound field property!" ); + xControlModel->getPropertyValue( PROPERTY_BOUNDFIELD ) >>= m_xField; + + // ................................................... + // filter list and control class + m_bFilterList = ::comphelper::hasProperty( PROPERTY_FILTERPROPOSAL, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_FILTERPROPOSAL ) ); + if ( m_bFilterList ) + m_nControlClass = FormComponentType::COMBOBOX; + else + { + sal_Int16 nClassId = ::comphelper::getINT16( xControlModel->getPropertyValue( PROPERTY_CLASSID ) ); + switch (nClassId) + { + case FormComponentType::CHECKBOX: + case FormComponentType::RADIOBUTTON: + case FormComponentType::LISTBOX: + case FormComponentType::COMBOBOX: + m_nControlClass = nClassId; + if ( FormComponentType::LISTBOX == nClassId ) { - case FormComponentType::CHECKBOX: - case FormComponentType::RADIOBUTTON: - case FormComponentType::LISTBOX: - case FormComponentType::COMBOBOX: - m_nControlClass = nClassId; - if ( FormComponentType::LISTBOX == nClassId ) - { - Sequence< ::rtl::OUString > aDisplayItems; - OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aDisplayItems ); - Sequence< ::rtl::OUString > aValueItems; - OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_VALUE_SEQ ) >>= aValueItems ); - OSL_ENSURE( aDisplayItems.getLength() == aValueItems.getLength(), "OFilterControl::initialize: inconsistent item lists!" ); - for ( sal_Int32 i=0; i < ::std::min( aDisplayItems.getLength(), aValueItems.getLength() ); ++i ) - m_aDisplayItemToValueItem[ aDisplayItems[i] ] = aValueItems[i]; - } - break; - default: - m_bMultiLine = ::comphelper::hasProperty( PROPERTY_MULTILINE, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_MULTILINE ) ); - m_nControlClass = FormComponentType::TEXTFIELD; - break; + Sequence< ::rtl::OUString > aDisplayItems; + OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aDisplayItems ); + Sequence< ::rtl::OUString > aValueItems; + OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_VALUE_SEQ ) >>= aValueItems ); + OSL_ENSURE( aDisplayItems.getLength() == aValueItems.getLength(), "OFilterControl::initialize: inconsistent item lists!" ); + for ( sal_Int32 i=0; i < ::std::min( aDisplayItems.getLength(), aValueItems.getLength() ); ++i ) + m_aDisplayItemToValueItem[ aDisplayItems[i] ] = aValueItems[i]; } - } - - // ................................................... - // the connection meta data for the form which we're working for - Reference< XChild > xModel( xControlModel, UNO_QUERY ); - Reference< XRowSet > xForm; - if ( xModel.is() ) - xForm = xForm.query( xModel->getParent() ); - m_xConnection = ::dbtools::getConnection( xForm ); - OSL_ENSURE( m_xConnection.is(), "OFilterControl::initialize: unable to determine the form's connection!" ); + break; + default: + m_bMultiLine = ::comphelper::hasProperty( PROPERTY_MULTILINE, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_MULTILINE ) ); + m_nControlClass = FormComponentType::TEXTFIELD; + break; } } + + // ................................................... + // the connection meta data for the form which we're working for + Reference< XChild > xModel( xControlModel, UNO_QUERY ); + Reference< XRowSet > xForm; + if ( xModel.is() ) + xForm = xForm.query( xModel->getParent() ); + m_xConnection = ::dbtools::getConnection( xForm ); + OSL_ENSURE( m_xConnection.is(), "OFilterControl::initialize: unable to determine the form's connection!" ); } //--------------------------------------------------------------------- diff --git a/forms/source/component/Filter.hxx b/forms/source/component/Filter.hxx index 438776445a3c..cd530478be0d 100644 --- a/forms/source/component/Filter.hxx +++ b/forms/source/component/Filter.hxx @@ -79,6 +79,7 @@ namespace frm private: void implInitFilterList(); + void initControlModel(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xControlModel); public: OFilterControl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB ); |