diff options
Diffstat (limited to 'forms/source/component/ListBox.cxx')
-rw-r--r-- | forms/source/component/ListBox.cxx | 82 |
1 files changed, 46 insertions, 36 deletions
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 2f95f6331f01..33d31180315c 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -28,6 +28,7 @@ #include "BaseListBox.hxx" #include <componenttools.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/sdbc/XRow.hpp> @@ -44,7 +45,7 @@ #include <o3tl/any.hxx> #include <o3tl/safeint.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <unotools/sharedunocomponent.hxx> @@ -98,7 +99,7 @@ namespace frm void operator()( const ORowSetValue& _append ) { - m_string += _append; + m_string += _append.getString(); } private: @@ -193,7 +194,12 @@ namespace frm // XCloneable - IMPLEMENT_DEFAULT_CLONING( OListBoxModel ) + css::uno::Reference< css::util::XCloneable > SAL_CALL OListBoxModel::createClone() +{ + rtl::Reference<OListBoxModel> pClone = new OListBoxModel(this, getContext()); + pClone->clonedFrom(this); + return pClone; +} // XServiceInfo @@ -467,6 +473,10 @@ namespace frm ); if ( ( pSelectedItemsPos != _rPropertyNames.end() ) && aStringItemListExists ) { + if (_rPropertyNames.getLength() != _rValues.getLength()) + throw css::lang::IllegalArgumentException("lengths do not match", + static_cast<cppu::OWeakObject*>(this), -1); + // both properties are present // -> remember the value for the select sequence pSelectSequenceValue = _rValues.getConstArray() + ( pSelectedItemsPos - _rPropertyNames.begin() ); @@ -487,18 +497,21 @@ namespace frm void OListBoxModel::describeFixedProperties( Sequence< Property >& _rProps ) const { - BEGIN_DESCRIBE_PROPERTIES( 10, OBoundControlModel ) - DECL_PROP1(TABINDEX, sal_Int16, BOUND); - DECL_PROP2(BOUNDCOLUMN, sal_Int16, BOUND, MAYBEVOID); - DECL_PROP1(LISTSOURCETYPE, ListSourceType, BOUND); - DECL_PROP1(LISTSOURCE, css::uno::Sequence<OUString>, BOUND); - DECL_PROP3(VALUE_SEQ, css::uno::Sequence<OUString>, BOUND, READONLY, TRANSIENT); - DECL_PROP2(SELECT_VALUE_SEQ, Sequence< Any >, BOUND, TRANSIENT); - DECL_PROP2(SELECT_VALUE, Any, BOUND, TRANSIENT); - DECL_PROP1(DEFAULT_SELECT_SEQ, Sequence<sal_Int16>, BOUND); - DECL_PROP1(STRINGITEMLIST, Sequence< OUString >, BOUND); - DECL_PROP1(TYPEDITEMLIST, Sequence< Any >, OPTIONAL); - END_DESCRIBE_PROPERTIES(); + OBoundControlModel::describeFixedProperties( _rProps ); + sal_Int32 nOldCount = _rProps.getLength(); + _rProps.realloc( nOldCount + 10); + css::beans::Property* pProperties = _rProps.getArray() + nOldCount; + *pProperties++ = css::beans::Property(PROPERTY_TABINDEX, PROPERTY_ID_TABINDEX, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_BOUNDCOLUMN, PROPERTY_ID_BOUNDCOLUMN, cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::MAYBEVOID); + *pProperties++ = css::beans::Property(PROPERTY_LISTSOURCETYPE, PROPERTY_ID_LISTSOURCETYPE, cppu::UnoType<ListSourceType>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_LISTSOURCE, PROPERTY_ID_LISTSOURCE, cppu::UnoType<css::uno::Sequence<OUString>>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_VALUE_SEQ, PROPERTY_ID_VALUE_SEQ, cppu::UnoType<css::uno::Sequence<OUString>>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_SELECT_VALUE_SEQ, PROPERTY_ID_SELECT_VALUE_SEQ, cppu::UnoType<Sequence< Any >>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_SELECT_VALUE, PROPERTY_ID_SELECT_VALUE, cppu::UnoType<Any>::get(), css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::TRANSIENT); + *pProperties++ = css::beans::Property(PROPERTY_DEFAULT_SELECT_SEQ, PROPERTY_ID_DEFAULT_SELECT_SEQ, cppu::UnoType<Sequence<sal_Int16>>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_STRINGITEMLIST, PROPERTY_ID_STRINGITEMLIST, cppu::UnoType<Sequence< OUString >>::get(), css::beans::PropertyAttribute::BOUND); + *pProperties++ = css::beans::Property(PROPERTY_TYPEDITEMLIST, PROPERTY_ID_TYPEDITEMLIST, cppu::UnoType<Sequence< Any >>::get(), css::beans::PropertyAttribute::OPTIONAL); + DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(), "<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?"); } @@ -681,8 +694,8 @@ namespace frm && !hasExternalListSource() ) { - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( css::uno::Sequence<OUString>() ) ); - setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( css::uno::Sequence<OUString>() ) ); + setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, Any( css::uno::Sequence<css::uno::Any>() ) ); } if (nVersion > 3) @@ -851,7 +864,7 @@ namespace frm } catch(const SQLException& eSQL) { - onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST)); + onError(eSQL, ResourceManager::loadString(RID_BASELISTBOX_ERROR_FILLLIST)); return; } catch(const Exception&) @@ -980,7 +993,7 @@ namespace frm } catch(const SQLException& eSQL) { - onError(eSQL, FRM_RES_STRING(RID_BASELISTBOX_ERROR_FILLLIST)); + onError(eSQL, ResourceManager::loadString(RID_BASELISTBOX_ERROR_FILLLIST)); return; } catch( const Exception& ) @@ -1002,8 +1015,8 @@ namespace frm setBoundValues(std::move(aValueList)); - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( lcl_convertToStringSequence( aDisplayList ) ) ); - setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence<css::uno::Any>() ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( lcl_convertToStringSequence( aDisplayList ) ) ); + setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, Any( css::uno::Sequence<css::uno::Any>() ) ); } @@ -1030,7 +1043,7 @@ namespace frm if ( m_eListSourceType != ListSourceType_VALUELIST ) { if ( !hasExternalListSource() ) - setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( css::uno::Sequence<OUString>() ) ); + setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, Any( css::uno::Sequence<OUString>() ) ); m_aListRowSet.dispose(); } @@ -1178,8 +1191,7 @@ namespace frm { if ( m_nNULLPos != -1 ) { - aSelectionIndicies.realloc(1); - aSelectionIndicies[0] = m_nNULLPos; + aSelectionIndicies = { m_nNULLPos }; } } else @@ -1191,8 +1203,7 @@ namespace frm ValueList::const_iterator curValuePos = ::std::find( aValues.begin(), aValues.end(), v ); if ( curValuePos != aValues.end() ) { - aSelectionIndicies.realloc( 1 ); - aSelectionIndicies[0] = curValuePos - aValues.begin(); + aSelectionIndicies = { o3tl::narrowing<sal_Int16>(curValuePos - aValues.begin()) }; } } @@ -1255,7 +1266,7 @@ namespace frm m_aSaveValue = aCurrentValue; - return makeAny( translateDbValueToControlValue(aCurrentValue) ); + return Any( translateDbValueToControlValue(aCurrentValue) ); #else return Any(); #endif @@ -1389,10 +1400,9 @@ namespace frm { sal_Int32 nSelectIndex = -1; OSL_VERIFY( _rExternalValue >>= nSelectIndex ); - if ( ( nSelectIndex >= 0 ) && ( nSelectIndex < static_cast<sal_Int32>(getStringItemList().size()) ) ) + if ( ( nSelectIndex >= 0 ) && ( o3tl::make_unsigned(nSelectIndex) < getStringItemList().size() ) ) { - aSelectIndexes.realloc( 1 ); - aSelectIndexes[ 0 ] = static_cast< sal_Int16 >( nSelectIndex ); + aSelectIndexes = { o3tl::narrowing<sal_Int16>(nSelectIndex) }; } } break; @@ -1406,7 +1416,7 @@ namespace frm ::std::set< sal_Int16 > aSelectionSet; // find the selection entries in our item list - for ( OUString const & selectEntry : std::as_const(aSelectEntries) ) + for (OUString const& selectEntry : aSelectEntries) { int idx = 0; for(const OUString& s : getStringItemList()) @@ -1440,7 +1450,7 @@ namespace frm break; } - return makeAny( aSelectIndexes ); + return Any( aSelectIndexes ); } @@ -1514,7 +1524,7 @@ namespace frm aSelectedEntriesTexts.getArray(), ExtractStringFromSequence_Safe( _rStringList ) ); - return makeAny( aSelectedEntriesTexts ); + return Any( aSelectedEntriesTexts ); } @@ -1725,8 +1735,8 @@ namespace frm suspendValueListening(); try { - m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, makeAny( comphelper::containerToSequence(getStringItemList()) ) ); - m_xAggregateSet->setPropertyValue( PROPERTY_TYPEDITEMLIST, makeAny( getTypedItemList() ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_STRINGITEMLIST, Any( comphelper::containerToSequence(getStringItemList()) ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_TYPEDITEMLIST, Any( getTypedItemList() ) ); } catch( const Exception& ) { @@ -1746,7 +1756,7 @@ namespace frm else { if ( m_aDefaultSelectSeq.hasElements() ) - setControlValue( makeAny( m_aDefaultSelectSeq ), eOther ); + setControlValue( Any( m_aDefaultSelectSeq ), eOther ); } } } |