27#include <com/sun/star/beans/PropertyAttribute.hpp>
39 using namespace ::com::sun::star::form::binding;
46 :OBoundControlModel( _rxFactory, _rUnoControlModelTypeName, _rDefault, false, true, true )
52 OReferenceValueComponent::OReferenceValueComponent(
const OReferenceValueComponent* _pOriginal,
const Reference< XComponentContext>& _rxFactory )
53 :OBoundControlModel( _pOriginal, _rxFactory )
55 m_sReferenceValue = _pOriginal->m_sReferenceValue;
56 m_sNoCheckReferenceValue = _pOriginal->m_sNoCheckReferenceValue;
57 m_eDefaultChecked = _pOriginal->m_eDefaultChecked;
59 calculateExternalValueType();
63 OReferenceValueComponent::~OReferenceValueComponent()
68 void OReferenceValueComponent::setReferenceValue(
const OUString& _rRefValue )
70 m_sReferenceValue = _rRefValue;
71 calculateExternalValueType();
75 void SAL_CALL OReferenceValueComponent::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle )
const
83 _rValue <<= m_sNoCheckReferenceValue;
87 OBoundControlModel::getFastPropertyValue( _rValue, _nHandle );
92 void SAL_CALL OReferenceValueComponent::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle,
const Any& _rValue )
97 OSL_VERIFY( _rValue >>= m_sReferenceValue );
98 calculateExternalValueType();
102 OSL_VERIFY( _rValue >>= m_sNoCheckReferenceValue );
107 sal_Int16 nDefaultChecked;
108 if (!(_rValue >>= nDefaultChecked) || nDefaultChecked < 0
109 || nDefaultChecked > 2)
111 throw css::lang::IllegalArgumentException(
112 (
"DefaultState property value must be a SHORT in the range"
114 css::uno::Reference<css::uno::XInterface>(), -1);
116 m_eDefaultChecked =
static_cast<ToggleState>(nDefaultChecked);
122 OBoundControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
127 sal_Bool SAL_CALL OReferenceValueComponent::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle,
const Any& _rValue )
129 bool bModified =
false;
133 bModified =
tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_sReferenceValue );
137 bModified =
tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_sNoCheckReferenceValue );
141 bModified =
tryPropertyValue( _rConvertedValue, _rOldValue, _rValue,
static_cast<sal_Int16
>(m_eDefaultChecked) );
145 bModified = OBoundControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
152 Any OReferenceValueComponent::getDefaultForReset()
const
154 return Any(
static_cast<sal_Int16
>(m_eDefaultChecked) );
158 void OReferenceValueComponent::describeFixedProperties( Sequence< Property >& _rProps )
const
160 OBoundControlModel::describeFixedProperties( _rProps );
161 sal_Int32 nOldCount = _rProps.getLength();
162 _rProps.realloc( nOldCount + 3);
163 css::beans::Property* pProperties = _rProps.getArray() + nOldCount;
167 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(),
"<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
171 Sequence< Type > OReferenceValueComponent::getSupportedBindingTypes()
173 ::std::vector< Type >
aTypes;
175 if ( !m_sReferenceValue.isEmpty() )
184 Any OReferenceValueComponent::translateExternalValueToControlValue(
const Any& _rExternalValue )
const
188 bool bExternalState =
false;
189 OUString sExternalValue;
190 if ( _rExternalValue >>= bExternalState )
194 else if ( _rExternalValue >>= sExternalValue )
196 if ( sExternalValue == m_sReferenceValue )
200 if ( sExternalValue == m_sNoCheckReferenceValue )
206 else if ( !_rExternalValue.hasValue() )
212 OSL_FAIL(
"OReferenceValueComponent::translateExternalValueToControlValue: unexpected value type!" );
219 Any OReferenceValueComponent::translateControlValueToExternalValue( )
const
229 bool bBooleanExchange = getExternalValueType().getTypeClass() == TypeClass_BOOLEAN;
230 bool bStringExchange = getExternalValueType().getTypeClass() == TypeClass_STRING;
231 OSL_ENSURE( bBooleanExchange || bStringExchange,
232 "OReferenceValueComponent::translateControlValueToExternalValue: unexpected value exchange type!" );
237 if ( bBooleanExchange )
239 aExternalValue <<=
true;
241 else if ( bStringExchange )
243 aExternalValue <<= m_sReferenceValue;
248 if ( bBooleanExchange )
250 aExternalValue <<=
false;
252 else if ( bStringExchange )
254 aExternalValue <<= m_sNoCheckReferenceValue;
261 TOOLS_WARN_EXCEPTION(
"forms.component",
"OReferenceValueComponent::translateControlValueToExternalValue" );
264 return aExternalValue;
268 Any OReferenceValueComponent::translateControlValueToValidatableValue( )
const
270 if ( !m_xAggregateSet.is() )
277 Any aValidatableValue;
281 aValidatableValue <<=
true;
284 aValidatableValue <<=
false;
287 return aValidatableValue;
OReferenceValueComponent(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory, const OUString &_rUnoControlModelTypeName, const OUString &_rDefault)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr OUStringLiteral PROPERTY_REFVALUE
constexpr OUStringLiteral PROPERTY_STATE
constexpr OUStringLiteral PROPERTY_DEFAULT_STATE
constexpr OUStringLiteral PROPERTY_UNCHECKED_REFVALUE
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool tryPropertyValue(Any &_rConvertedValue, Any &_rOldValue, const Any &_rValueToSet, const Any &_rCurrentValue, const Type &_rExpectedType)
ListBox is a bit confusing / different from other form components, so here are a few notes:
#define PROPERTY_ID_DEFAULT_STATE
#define PROPERTY_ID_UNCHECKED_REFVALUE
#define PROPERTY_ID_REFVALUE