26#include <rtl/math.hxx>
28#include <com/sun/star/beans/PropertyAttribute.hpp>
29#include <com/sun/star/form/FormComponentType.hpp>
41 using namespace ::com::sun::star::form::binding;
47 const Any& _rExternalValue,
const Reference< XPropertySet >& _rxProperties,
48 const OUString& _rMinValueName,
const OUString& _rMaxValueName )
50 OSL_ENSURE( _rxProperties.is(),
"translateExternalDoubleToControlIntValue: no aggregate!?" );
53 double nExternalValue = 0;
54 if ( _rExternalValue >>= nExternalValue )
56 if ( std::isinf( nExternalValue ) )
59 OUString sLimitPropertyName = std::signbit( nExternalValue )
60 ? _rMinValueName : _rMaxValueName;
61 if ( _rxProperties.is() )
62 _rxProperties->getPropertyValue( sLimitPropertyName ) >>=
nControlValue;
66 nControlValue =
static_cast<sal_Int32
>(::rtl::math::round( nExternalValue ));
71 if ( _rxProperties.is() )
72 _rxProperties->getPropertyValue( _rMinValueName ) >>=
nControlValue;
81 Any aExternalDoubleValue;
82 sal_Int32 nScrollValue = 0;
83 if ( _rControlIntValue >>= nScrollValue )
84 aExternalDoubleValue <<= static_cast<double>(nScrollValue);
87 OSL_FAIL(
"translateControlIntToExternalDoubleValue: no integer scroll value!" );
91 return aExternalDoubleValue;
96 ,m_nDefaultScrollValue( 0 )
99 m_nClassId = FormComponentType::SCROLLBAR;
104 OScrollBarModel::OScrollBarModel(
const OScrollBarModel* _pOriginal,
const Reference< XComponentContext >& _rxFactory )
105 :OBoundControlModel( _pOriginal, _rxFactory )
107 m_nDefaultScrollValue = _pOriginal->m_nDefaultScrollValue;
111 OScrollBarModel::~OScrollBarModel( )
115 OUString SAL_CALL OScrollBarModel::getImplementationName()
117 return "com.sun.star.comp.forms.OScrollBarModel";
124 Sequence< OUString > SAL_CALL OScrollBarModel::getSupportedServiceNames()
128 return ::comphelper::combineSequences(
129 getAggregateServiceNames(),
130 ::comphelper::concatSequences(
131 OControlModel::getSupportedServiceNames_Static(),
136 css::uno::Reference< css::util::XCloneable > SAL_CALL OScrollBarModel::createClone()
139 pClone->clonedFrom(
this);
144 void OScrollBarModel::describeFixedProperties( Sequence< Property >& _rProps )
const
146 OControlModel::describeFixedProperties( _rProps );
147 sal_Int32 nOldCount = _rProps.getLength();
148 _rProps.realloc( nOldCount + 3);
149 css::beans::Property* pProperties = _rProps.getArray() + nOldCount;
153 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(),
"<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
157 void OScrollBarModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle )
const
162 _rValue <<= m_nDefaultScrollValue;
166 OBoundControlModel::getFastPropertyValue( _rValue, _nHandle );
171 void OScrollBarModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle,
const Any& _rValue )
176 OSL_VERIFY( _rValue >>= m_nDefaultScrollValue );
181 OBoundControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
186 sal_Bool OScrollBarModel::convertFastPropertyValue(
187 Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle,
const Any& _rValue )
189 bool bModified(
false );
193 bModified =
tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_nDefaultScrollValue );
197 bModified = OBoundControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
204 Any OScrollBarModel::getPropertyDefaultByHandle( sal_Int32 _nHandle )
const
211 aReturn <<= sal_Int32(0);
215 aReturn = OBoundControlModel::getPropertyDefaultByHandle( _nHandle );
223 Any OScrollBarModel::translateDbColumnToControlValue( )
225 OSL_FAIL(
"OScrollBarModel::commitControlValueToDbColumn: never to be called (we're not bound)!" );
230 bool OScrollBarModel::commitControlValueToDbColumn(
bool )
232 OSL_FAIL(
"OScrollBarModel::commitControlValueToDbColumn: never to be called (we're not bound)!" );
237 Any OScrollBarModel::getDefaultForReset()
const
239 return Any( m_nDefaultScrollValue );
243 OUString SAL_CALL OScrollBarModel::getServiceName()
249 void SAL_CALL OScrollBarModel::write(
const Reference< XObjectOutputStream >& _rxOutStream )
251 OBoundControlModel::write( _rxOutStream );
252 ::osl::MutexGuard aGuard(
m_aMutex );
254 OStreamSection aSection( _rxOutStream );
257 _rxOutStream->writeShort( 0x0001 );
260 _rxOutStream << m_nDefaultScrollValue;
261 writeHelpTextCompatibly( _rxOutStream );
265 void SAL_CALL OScrollBarModel::read(
const Reference< XObjectInputStream>& _rxInStream )
267 OBoundControlModel::read( _rxInStream );
268 ::osl::MutexGuard aGuard(
m_aMutex );
272 OStreamSection aSection( _rxInStream );
274 sal_uInt16
nVersion = _rxInStream->readShort();
277 _rxInStream >> m_nDefaultScrollValue;
278 readHelpTextCompatibly( _rxInStream );
281 defaultCommonProperties();
288 Any OScrollBarModel::translateExternalValueToControlValue(
const Any& _rExternalValue )
const
296 Any OScrollBarModel::translateControlValueToExternalValue( )
const
303 Sequence< Type > OScrollBarModel::getSupportedBindingTypes()
310extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
312 css::uno::Sequence<css::uno::Any>
const &)
#define DBG_ASSERT(sCon, aError)
constexpr OUStringLiteral PROPERTY_TABINDEX
constexpr OUStringLiteral PROPERTY_SCROLL_VALUE
constexpr OUStringLiteral PROPERTY_DEFAULT_SCROLL_VALUE
constexpr OUStringLiteral PROPERTY_CONTROLSOURCEPROPERTY
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:
Any translateControlIntToExternalDoubleValue(const Any &_rControlIntValue)
Any translateExternalDoubleToControlIntValue(const Any &_rExternalValue, const Reference< XPropertySet > &_rxProperties, const OUString &_rMinValueName, const OUString &_rMaxValueName)
#define PROPERTY_ID_CONTROLSOURCEPROPERTY
#define PROPERTY_ID_DEFAULT_SCROLL_VALUE
#define PROPERTY_ID_SCROLL_VALUE
#define PROPERTY_ID_TABINDEX
constexpr OUStringLiteral FRM_SUN_COMPONENT_SCROLLBAR
constexpr OUStringLiteral VCL_CONTROLMODEL_SCROLLBAR
constexpr OUStringLiteral VCL_CONTROL_SCROLLBAR
constexpr OUStringLiteral BINDABLE_INTEGER_VALUE_RANGE