2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-21 22:06:52 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-16 22:55:52 +00:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
#include "spinbutton.hxx"
|
2014-06-25 14:57:44 +02:00
|
|
|
#include "scrollbar.hxx"
|
2003-12-11 11:30:46 +00:00
|
|
|
#include <comphelper/streamsection.hxx>
|
2004-04-02 09:57:22 +00:00
|
|
|
#include <comphelper/basicio.hxx>
|
2003-12-11 11:30:46 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
namespace frm
|
|
|
|
{
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::form;
|
|
|
|
using namespace ::com::sun::star::awt;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::io;
|
2004-04-02 09:57:22 +00:00
|
|
|
using namespace ::com::sun::star::form::binding;
|
2003-12-11 11:30:46 +00:00
|
|
|
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
//= OSpinButtonModel
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2013-06-03 08:34:09 +02:00
|
|
|
OSpinButtonModel::OSpinButtonModel( const Reference<XComponentContext>& _rxFactory )
|
2014-05-06 12:37:38 +02:00
|
|
|
:OBoundControlModel( _rxFactory, VCL_CONTROLMODEL_SPINBUTTON, VCL_CONTROL_SPINBUTTON, true, true, false )
|
2003-12-11 11:30:46 +00:00
|
|
|
,m_nDefaultSpinValue( 0 )
|
|
|
|
{
|
|
|
|
|
|
|
|
m_nClassId = FormComponentType::SPINBUTTON;
|
|
|
|
initValueProperty( PROPERTY_SPIN_VALUE, PROPERTY_ID_SPIN_VALUE );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2013-06-03 08:34:09 +02:00
|
|
|
OSpinButtonModel::OSpinButtonModel( const OSpinButtonModel* _pOriginal, const Reference< XComponentContext >& _rxFactory )
|
2003-12-11 11:30:46 +00:00
|
|
|
:OBoundControlModel( _pOriginal, _rxFactory )
|
|
|
|
{
|
|
|
|
m_nDefaultSpinValue = _pOriginal->m_nDefaultSpinValue;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
OSpinButtonModel::~OSpinButtonModel( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-27 23:27:32 +01:00
|
|
|
OUString SAL_CALL OSpinButtonModel::getImplementationName() throw ( RuntimeException, std::exception )
|
|
|
|
{
|
|
|
|
return OUString( "com.sun.star.comp.forms.OSpinButtonModel" );
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
// note that we're passing OControlModel as "base class". This is because
|
|
|
|
// OBoundControlModel, our real base class, claims to support the DataAwareControlModel
|
|
|
|
// service, which isn't really true for us. We only derive from this class
|
|
|
|
// to benefit from the functionality for binding to spreadsheet cells
|
2015-03-27 23:27:32 +01:00
|
|
|
Sequence< OUString > SAL_CALL OSpinButtonModel::getSupportedServiceNames() throw (RuntimeException, std::exception)
|
|
|
|
{
|
|
|
|
Sequence< OUString > aOwnNames( 2 );
|
|
|
|
aOwnNames[ 0 ] = FRM_SUN_COMPONENT_SPINBUTTON;
|
|
|
|
aOwnNames[ 1 ] = BINDABLE_INTEGER_VALUE_RANGE;
|
|
|
|
|
|
|
|
return ::comphelper::combineSequences(
|
|
|
|
getAggregateServiceNames(),
|
|
|
|
::comphelper::concatSequences(
|
|
|
|
OControlModel::getSupportedServiceNames_Static(),
|
|
|
|
aOwnNames
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
IMPLEMENT_DEFAULT_CLONING( OSpinButtonModel )
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
void SAL_CALL OSpinButtonModel::disposing()
|
|
|
|
{
|
|
|
|
OBoundControlModel::disposing();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2007-03-09 12:34:57 +00:00
|
|
|
void OSpinButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
2004-04-02 09:57:22 +00:00
|
|
|
BEGIN_DESCRIBE_PROPERTIES( 3, OControlModel )
|
2003-12-11 11:30:46 +00:00
|
|
|
DECL_PROP1( DEFAULT_SPIN_VALUE, sal_Int32, BOUND );
|
|
|
|
DECL_PROP1( TABINDEX, sal_Int16, BOUND );
|
2013-04-07 12:06:47 +02:00
|
|
|
DECL_PROP2( CONTROLSOURCEPROPERTY,OUString, READONLY, TRANSIENT );
|
2004-04-02 09:57:22 +00:00
|
|
|
END_DESCRIBE_PROPERTIES();
|
2003-12-11 11:30:46 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
void OSpinButtonModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
|
|
|
|
{
|
|
|
|
switch ( _nHandle )
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_DEFAULT_SPIN_VALUE:
|
|
|
|
_rValue <<= m_nDefaultSpinValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
OBoundControlModel::getFastPropertyValue( _rValue, _nHandle );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void OSpinButtonModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception, std::exception )
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
|
|
|
switch ( _nHandle )
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_DEFAULT_SPIN_VALUE:
|
|
|
|
OSL_VERIFY( _rValue >>= m_nDefaultSpinValue );
|
|
|
|
resetNoBroadcast();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
OBoundControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
sal_Bool OSpinButtonModel::convertFastPropertyValue(
|
|
|
|
Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue )
|
|
|
|
throw ( IllegalArgumentException )
|
|
|
|
{
|
2014-05-06 12:37:38 +02:00
|
|
|
bool bModified( false );
|
2003-12-11 11:30:46 +00:00
|
|
|
switch ( _nHandle )
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_DEFAULT_SPIN_VALUE:
|
|
|
|
bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_nDefaultSpinValue );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bModified = OBoundControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return bModified;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
Any OSpinButtonModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const
|
|
|
|
{
|
|
|
|
Any aReturn;
|
|
|
|
|
|
|
|
switch ( _nHandle )
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_DEFAULT_SPIN_VALUE:
|
|
|
|
aReturn <<= (sal_Int32)0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
aReturn = OBoundControlModel::getPropertyDefaultByHandle( _nHandle );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
Any OSpinButtonModel::translateDbColumnToControlValue( )
|
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "OSpinButtonModel::commitControlValueToDbColumn: never to be called (we're not bound)!" );
|
2003-12-11 11:30:46 +00:00
|
|
|
return Any();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-05-06 12:37:38 +02:00
|
|
|
bool OSpinButtonModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
2011-03-19 14:06:18 +01:00
|
|
|
OSL_FAIL( "OSpinButtonModel::commitControlValueToDbColumn: never to be called (we're not bound)!" );
|
2014-05-06 12:37:38 +02:00
|
|
|
return true;
|
2003-12-11 11:30:46 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
Any OSpinButtonModel::getDefaultForReset() const
|
|
|
|
{
|
|
|
|
return makeAny( (sal_Int32)m_nDefaultSpinValue );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
OUString SAL_CALL OSpinButtonModel::getServiceName() throw( RuntimeException, std::exception )
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
2013-04-23 11:48:24 +02:00
|
|
|
return OUString(FRM_SUN_COMPONENT_SPINBUTTON);
|
2003-12-11 11:30:46 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2003-12-11 11:30:46 +00:00
|
|
|
void SAL_CALL OSpinButtonModel::write( const Reference< XObjectOutputStream >& _rxOutStream )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw( IOException, RuntimeException, std::exception )
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
|
|
|
OBoundControlModel::write( _rxOutStream );
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
2013-05-02 10:36:43 +02:00
|
|
|
OStreamSection aSection( _rxOutStream );
|
2003-12-11 11:30:46 +00:00
|
|
|
|
|
|
|
// version
|
|
|
|
_rxOutStream->writeShort( 0x0001 );
|
|
|
|
|
|
|
|
// properties
|
|
|
|
_rxOutStream << m_nDefaultSpinValue;
|
|
|
|
writeHelpTextCompatibly( _rxOutStream );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL OSpinButtonModel::read( const Reference< XObjectInputStream>& _rxInStream ) throw( IOException, RuntimeException, std::exception )
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
|
|
|
OBoundControlModel::read( _rxInStream );
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
|
|
|
// version
|
|
|
|
{
|
2013-05-02 10:36:43 +02:00
|
|
|
OStreamSection aSection( _rxInStream );
|
2003-12-11 11:30:46 +00:00
|
|
|
|
|
|
|
sal_uInt16 nVersion = _rxInStream->readShort();
|
|
|
|
if ( nVersion == 0x0001 )
|
|
|
|
{
|
|
|
|
_rxInStream >> m_nDefaultSpinValue;
|
|
|
|
readHelpTextCompatibly( _rxInStream );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
defaultCommonProperties();
|
|
|
|
|
|
|
|
// here, everything in the stream section which is left will be skipped
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2008-06-25 11:05:35 +00:00
|
|
|
Any OSpinButtonModel::translateExternalValueToControlValue( const Any& _rExternalValue ) const
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
2008-06-25 11:05:35 +00:00
|
|
|
return translateExternalDoubleToControlIntValue( _rExternalValue, m_xAggregateSet,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString( "SpinValueMin" ),
|
|
|
|
OUString( "SpinValueMax" ) );
|
2003-12-11 11:30:46 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2005-03-23 10:32:46 +00:00
|
|
|
Any OSpinButtonModel::translateControlValueToExternalValue( ) const
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
|
|
|
// by definition, the base class simply obtains the property value
|
|
|
|
return translateControlIntToExternalDoubleValue( OBoundControlModel::translateControlValueToExternalValue() );
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2008-06-25 11:05:35 +00:00
|
|
|
Sequence< Type > OSpinButtonModel::getSupportedBindingTypes()
|
2003-12-11 11:30:46 +00:00
|
|
|
{
|
2014-05-14 23:17:17 +02:00
|
|
|
return Sequence< Type >( &cppu::UnoType<double>::get(), 1 );
|
2003-12-11 11:30:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frm
|
2014-02-25 18:50:02 +01:00
|
|
|
|
2015-10-01 15:32:00 +02:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* SAL_CALL
|
|
|
|
com_sun_star_comp_forms_OSpinButtonModel_get_implementation(css::uno::XComponentContext* component,
|
|
|
|
css::uno::Sequence<css::uno::Any> const &)
|
2015-02-12 14:10:24 +11:00
|
|
|
{
|
|
|
|
return cppu::acquire(new frm::OSpinButtonModel(component));
|
|
|
|
}
|
2010-10-12 15:57:08 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|