1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_forms.hxx" 30*cdf0e10cSrcweir #include "RadioButton.hxx" 31*cdf0e10cSrcweir #include "property.hxx" 32*cdf0e10cSrcweir #ifndef _FRM_PROPERTY_HRC_ 33*cdf0e10cSrcweir #include "property.hrc" 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir #include "services.hxx" 36*cdf0e10cSrcweir #include <tools/debug.hxx> 37*cdf0e10cSrcweir #include <comphelper/extract.hxx> 38*cdf0e10cSrcweir #include <comphelper/basicio.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/awt/XVclWindowPeer.hpp> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir //......................................................................... 43*cdf0e10cSrcweir namespace frm 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 46*cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 47*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 48*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 49*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 50*cdf0e10cSrcweir using namespace ::com::sun::star::container; 51*cdf0e10cSrcweir using namespace ::com::sun::star::form; 52*cdf0e10cSrcweir using namespace ::com::sun::star::awt; 53*cdf0e10cSrcweir using namespace ::com::sun::star::io; 54*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 55*cdf0e10cSrcweir using namespace ::com::sun::star::util; 56*cdf0e10cSrcweir using namespace ::com::sun::star::form::binding; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir //================================================================== 59*cdf0e10cSrcweir //------------------------------------------------------------------------------ 60*cdf0e10cSrcweir InterfaceRef SAL_CALL ORadioButtonControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException) 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir return *(new ORadioButtonControl(_rxFactory)); 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir //------------------------------------------------------------------------------ 66*cdf0e10cSrcweir StringSequence SAL_CALL ORadioButtonControl::getSupportedServiceNames() throw(RuntimeException) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir StringSequence aSupported = OBoundControl::getSupportedServiceNames(); 69*cdf0e10cSrcweir aSupported.realloc(aSupported.getLength() + 1); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir ::rtl::OUString* pArray = aSupported.getArray(); 72*cdf0e10cSrcweir pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_RADIOBUTTON; 73*cdf0e10cSrcweir return aSupported; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir //------------------------------------------------------------------ 78*cdf0e10cSrcweir ORadioButtonControl::ORadioButtonControl(const Reference<XMultiServiceFactory>& _rxFactory) 79*cdf0e10cSrcweir :OBoundControl(_rxFactory, VCL_CONTROL_RADIOBUTTON) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir //------------------------------------------------------------------ 84*cdf0e10cSrcweir void SAL_CALL ORadioButtonControl::createPeer(const Reference<starawt::XToolkit>& _rxToolkit, const Reference<starawt::XWindowPeer>& _rxParent) throw (RuntimeException) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir OBoundControl::createPeer(_rxToolkit, _rxParent); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // switch off the auto-toggle, we do this ourself .... 89*cdf0e10cSrcweir // (formerly this switch-off was done in the toolkit - but the correct place is here ...) 90*cdf0e10cSrcweir // Reference< XVclWindowPeer > xVclWindowPeer( getPeer(), UNO_QUERY ); 91*cdf0e10cSrcweir // if (xVclWindowPeer.is()) 92*cdf0e10cSrcweir // xVclWindowPeer->setProperty(::rtl::OUString::createFromAscii("AutoToggle"), ::cppu::bool2any(sal_False)); 93*cdf0e10cSrcweir // new order: do _not_ switch off the auto toggle because: 94*cdf0e10cSrcweir // * today, it is not necessary anymore to handle the toggling ourself (everything works fine without it) 95*cdf0e10cSrcweir // * without auto toggle, the AccessibleEvents as fired by the radio buttons are 96*cdf0e10cSrcweir // a. newly checked button: "unchecked"->"checked" 97*cdf0e10cSrcweir // b. previously checked button: "checked"->"unchecked" 98*cdf0e10cSrcweir // This is deadly for AT-tools, which then get the "unchecked" event _immediately_ after the "checked" event, 99*cdf0e10cSrcweir // and only read the latter. This makes radio buttons pretty unusable in form documents. 100*cdf0e10cSrcweir // So we switched AutoToggle _on_, again, because then VCL can handle the notifications, and will send 101*cdf0e10cSrcweir // them in the proper order. 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir //================================================================== 105*cdf0e10cSrcweir InterfaceRef SAL_CALL ORadioButtonModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) throw (RuntimeException) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir return *(new ORadioButtonModel(_rxFactory)); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir //------------------------------------------------------------------ 111*cdf0e10cSrcweir DBG_NAME( ORadioButtonModel ) 112*cdf0e10cSrcweir //------------------------------------------------------------------ 113*cdf0e10cSrcweir ORadioButtonModel::ORadioButtonModel(const Reference<XMultiServiceFactory>& _rxFactory) 114*cdf0e10cSrcweir :OReferenceValueComponent( _rxFactory, VCL_CONTROLMODEL_RADIOBUTTON, FRM_SUN_CONTROL_RADIOBUTTON,sal_True ) 115*cdf0e10cSrcweir // use the old control name for compytibility reasons 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir DBG_CTOR( ORadioButtonModel, NULL ); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir m_nClassId = FormComponentType::RADIOBUTTON; 120*cdf0e10cSrcweir m_aLabelServiceName = FRM_SUN_COMPONENT_GROUPBOX; 121*cdf0e10cSrcweir initValueProperty( PROPERTY_STATE, PROPERTY_ID_STATE ); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir //------------------------------------------------------------------ 125*cdf0e10cSrcweir ORadioButtonModel::ORadioButtonModel( const ORadioButtonModel* _pOriginal, const Reference<XMultiServiceFactory>& _rxFactory ) 126*cdf0e10cSrcweir :OReferenceValueComponent( _pOriginal, _rxFactory ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir DBG_CTOR( ORadioButtonModel, NULL ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir //------------------------------------------------------------------------------ 132*cdf0e10cSrcweir ORadioButtonModel::~ORadioButtonModel() 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir DBG_DTOR( ORadioButtonModel, NULL ); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir // XCloneable 138*cdf0e10cSrcweir //------------------------------------------------------------------------------ 139*cdf0e10cSrcweir IMPLEMENT_DEFAULT_CLONING( ORadioButtonModel ) 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir // XServiceInfo 142*cdf0e10cSrcweir //------------------------------------------------------------------------------ 143*cdf0e10cSrcweir StringSequence SAL_CALL ORadioButtonModel::getSupportedServiceNames() throw(RuntimeException) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir StringSequence aSupported = OReferenceValueComponent::getSupportedServiceNames(); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir sal_Int32 nOldLen = aSupported.getLength(); 148*cdf0e10cSrcweir aSupported.realloc( nOldLen + 8 ); 149*cdf0e10cSrcweir ::rtl::OUString* pStoreTo = aSupported.getArray() + nOldLen; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir *pStoreTo++ = BINDABLE_CONTROL_MODEL; 152*cdf0e10cSrcweir *pStoreTo++ = DATA_AWARE_CONTROL_MODEL; 153*cdf0e10cSrcweir *pStoreTo++ = VALIDATABLE_CONTROL_MODEL; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir *pStoreTo++ = BINDABLE_DATA_AWARE_CONTROL_MODEL; 156*cdf0e10cSrcweir *pStoreTo++ = VALIDATABLE_BINDABLE_CONTROL_MODEL; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir *pStoreTo++ = FRM_SUN_COMPONENT_RADIOBUTTON; 159*cdf0e10cSrcweir *pStoreTo++ = FRM_SUN_COMPONENT_DATABASE_RADIOBUTTON; 160*cdf0e10cSrcweir *pStoreTo++ = BINDABLE_DATABASE_RADIO_BUTTON; 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir return aSupported; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir //------------------------------------------------------------------------------ 166*cdf0e10cSrcweir void ORadioButtonModel::SetSiblingPropsTo(const ::rtl::OUString& rPropName, const Any& rValue) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir // mein Name 169*cdf0e10cSrcweir ::rtl::OUString sMyName(m_aName); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir // meine Siblings durchiterieren 172*cdf0e10cSrcweir Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY); 173*cdf0e10cSrcweir if (xIndexAccess.is()) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir Reference<XPropertySet> xMyProps; 176*cdf0e10cSrcweir query_interface(static_cast<XWeak*>(this), xMyProps); 177*cdf0e10cSrcweir ::rtl::OUString sCurrentName; 178*cdf0e10cSrcweir for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir Reference<XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), UNO_QUERY); 181*cdf0e10cSrcweir if (!xSiblingProperties.is()) 182*cdf0e10cSrcweir continue; 183*cdf0e10cSrcweir if (xMyProps == xSiblingProperties) 184*cdf0e10cSrcweir continue; // mich selber nicht umsetzen 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir // nur wenn es ein Radio-Button ist 187*cdf0e10cSrcweir if (!hasProperty(PROPERTY_CLASSID, xSiblingProperties)) 188*cdf0e10cSrcweir continue; 189*cdf0e10cSrcweir sal_Int16 nType = 0; 190*cdf0e10cSrcweir xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType; 191*cdf0e10cSrcweir if (nType != FormComponentType::RADIOBUTTON) 192*cdf0e10cSrcweir continue; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir // das 'zur selben Gruppe gehoeren' wird am Namen festgemacht 195*cdf0e10cSrcweir xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sCurrentName; 196*cdf0e10cSrcweir if (sCurrentName == sMyName) 197*cdf0e10cSrcweir xSiblingProperties->setPropertyValue(rPropName, rValue); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //------------------------------------------------------------------------------ 203*cdf0e10cSrcweir void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) throw (Exception) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir OReferenceValueComponent::setFastPropertyValue_NoBroadcast( nHandle, rValue ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // if the label control changed ... 208*cdf0e10cSrcweir if (nHandle == PROPERTY_ID_CONTROLLABEL) 209*cdf0e10cSrcweir { // ... forward this to our siblings 210*cdf0e10cSrcweir SetSiblingPropsTo(PROPERTY_CONTROLLABEL, rValue); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir // wenn sich die ControlSource-Eigenschaft geaendert hat ... 214*cdf0e10cSrcweir if (nHandle == PROPERTY_ID_CONTROLSOURCE) 215*cdf0e10cSrcweir { // ... muss ich allen meinen Siblings, die in der selben RadioButton-Gruppe sind wie ich, auch die 216*cdf0e10cSrcweir // neue ControlSource mitgeben 217*cdf0e10cSrcweir SetSiblingPropsTo(PROPERTY_CONTROLSOURCE, rValue); 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // die andere Richtung : wenn sich mein Name aendert ... 221*cdf0e10cSrcweir if (nHandle == PROPERTY_ID_NAME) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir // ... muss ich testen, ob ich Siblings mit dem selben Namen habe, damit ich deren ControlSource uebernehmen kann 224*cdf0e10cSrcweir Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY); 225*cdf0e10cSrcweir if (xIndexAccess.is()) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir ::rtl::OUString sName; 228*cdf0e10cSrcweir ::rtl::OUString sControlSource; 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir Reference<XPropertySet> xMyProps; 231*cdf0e10cSrcweir query_interface(static_cast<XWeak*>(this), xMyProps); 232*cdf0e10cSrcweir for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir Reference<XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), UNO_QUERY); 235*cdf0e10cSrcweir if (!xSiblingProperties.is()) 236*cdf0e10cSrcweir continue; 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir if (xMyProps == xSiblingProperties) 239*cdf0e10cSrcweir // nur wenn ich nicht mich selber gefunden habe 240*cdf0e10cSrcweir continue; 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir sal_Int16 nType = 0; 243*cdf0e10cSrcweir xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType; 244*cdf0e10cSrcweir if (nType != FormComponentType::RADIOBUTTON) 245*cdf0e10cSrcweir // nur Radio-Buttons 246*cdf0e10cSrcweir continue; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sName; 249*cdf0e10cSrcweir // Control, das zur gleichen Gruppe gehoert ? 250*cdf0e10cSrcweir if (rValue == sName) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir setPropertyValue(PROPERTY_CONTROLSOURCE, xSiblingProperties->getPropertyValue(PROPERTY_CONTROLSOURCE)); 253*cdf0e10cSrcweir break; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir if (nHandle == PROPERTY_ID_DEFAULT_STATE) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir sal_Int16 nValue; 262*cdf0e10cSrcweir rValue >>= nValue; 263*cdf0e10cSrcweir if (1 == nValue) 264*cdf0e10cSrcweir { // bei allen Radios der selben Gruppe das 'default checked' ruecksetzen, denn wie schon der highlander wusste : 265*cdf0e10cSrcweir // es kann nur einen geben. 266*cdf0e10cSrcweir Any aZero; 267*cdf0e10cSrcweir nValue = 0; 268*cdf0e10cSrcweir aZero <<= nValue; 269*cdf0e10cSrcweir SetSiblingPropsTo(PROPERTY_DEFAULT_STATE, aZero); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir //------------------------------------------------------------------------------ 275*cdf0e10cSrcweir void ORadioButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir BEGIN_DESCRIBE_PROPERTIES( 1, OReferenceValueComponent ) 278*cdf0e10cSrcweir DECL_PROP1(TABINDEX, sal_Int16, BOUND); 279*cdf0e10cSrcweir END_DESCRIBE_PROPERTIES(); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir //------------------------------------------------------------------------------ 283*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ORadioButtonModel::getServiceName() throw(RuntimeException) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir return FRM_COMPONENT_RADIOBUTTON; // old (non-sun) name for compatibility ! 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir //------------------------------------------------------------------------------ 289*cdf0e10cSrcweir void SAL_CALL ORadioButtonModel::write(const Reference<XObjectOutputStream>& _rxOutStream) 290*cdf0e10cSrcweir throw(IOException, RuntimeException) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir OReferenceValueComponent::write(_rxOutStream); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir // Version 295*cdf0e10cSrcweir _rxOutStream->writeShort(0x0003); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir // Properties 298*cdf0e10cSrcweir _rxOutStream << getReferenceValue(); 299*cdf0e10cSrcweir _rxOutStream << (sal_Int16)getDefaultChecked(); 300*cdf0e10cSrcweir writeHelpTextCompatibly(_rxOutStream); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir // from version 0x0003 : common properties 303*cdf0e10cSrcweir writeCommonProperties(_rxOutStream); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir //------------------------------------------------------------------------------ 307*cdf0e10cSrcweir void SAL_CALL ORadioButtonModel::read(const Reference<XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir OReferenceValueComponent::read(_rxInStream); 310*cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir // Version 313*cdf0e10cSrcweir sal_uInt16 nVersion = _rxInStream->readShort(); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir ::rtl::OUString sReferenceValue; 316*cdf0e10cSrcweir sal_Int16 nDefaultChecked( 0 ); 317*cdf0e10cSrcweir switch (nVersion) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir case 0x0001 : 320*cdf0e10cSrcweir _rxInStream >> sReferenceValue; 321*cdf0e10cSrcweir _rxInStream >> nDefaultChecked; 322*cdf0e10cSrcweir break; 323*cdf0e10cSrcweir case 0x0002 : 324*cdf0e10cSrcweir _rxInStream >> sReferenceValue; 325*cdf0e10cSrcweir _rxInStream >> nDefaultChecked; 326*cdf0e10cSrcweir readHelpTextCompatibly(_rxInStream); 327*cdf0e10cSrcweir break; 328*cdf0e10cSrcweir case 0x0003 : 329*cdf0e10cSrcweir _rxInStream >> sReferenceValue; 330*cdf0e10cSrcweir _rxInStream >> nDefaultChecked; 331*cdf0e10cSrcweir readHelpTextCompatibly(_rxInStream); 332*cdf0e10cSrcweir readCommonProperties(_rxInStream); 333*cdf0e10cSrcweir break; 334*cdf0e10cSrcweir default : 335*cdf0e10cSrcweir DBG_ERROR("ORadioButtonModel::read : unknown version !"); 336*cdf0e10cSrcweir defaultCommonProperties(); 337*cdf0e10cSrcweir break; 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir setReferenceValue( sReferenceValue ); 341*cdf0e10cSrcweir setDefaultChecked( (ToggleState)nDefaultChecked ); 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir // Nach dem Lesen die Defaultwerte anzeigen 344*cdf0e10cSrcweir if ( getControlSource().getLength() ) 345*cdf0e10cSrcweir // (not if we don't have a control source - the "State" property acts like it is persistent, then 346*cdf0e10cSrcweir resetNoBroadcast(); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir //------------------------------------------------------------------------------ 350*cdf0e10cSrcweir void ORadioButtonModel::_propertyChanged(const PropertyChangeEvent& _rEvent) throw(RuntimeException) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir if ( _rEvent.PropertyName.equals( PROPERTY_STATE ) ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir if ( _rEvent.NewValue == (sal_Int16)1 ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir // wenn sich mein Status auf 'checked' geaendert hat, muss ich alle meine Siblings, die in der selben Gruppe 357*cdf0e10cSrcweir // sind wie ich, entsprechend zuruecksetzen 358*cdf0e10cSrcweir Any aZero; 359*cdf0e10cSrcweir aZero <<= (sal_Int16)0; 360*cdf0e10cSrcweir SetSiblingPropsTo( PROPERTY_STATE, aZero ); 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir OReferenceValueComponent::_propertyChanged( _rEvent ); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir //------------------------------------------------------------------------------ 368*cdf0e10cSrcweir Any ORadioButtonModel::translateDbColumnToControlValue() 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir return makeAny( (sal_Int16) 371*cdf0e10cSrcweir ( ( m_xColumn->getString() == getReferenceValue() ) ? STATE_CHECK : STATE_NOCHECK ) 372*cdf0e10cSrcweir ); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir //------------------------------------------------------------------------------ 376*cdf0e10cSrcweir Any ORadioButtonModel::translateExternalValueToControlValue( const Any& _rExternalValue ) const 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir Any aControlValue = OReferenceValueComponent::translateExternalValueToControlValue( _rExternalValue ); 379*cdf0e10cSrcweir sal_Int16 nState = STATE_NOCHECK; 380*cdf0e10cSrcweir if ( ( aControlValue >>= nState ) && ( nState == STATE_DONTKNOW ) ) 381*cdf0e10cSrcweir // radio buttons do not have the DONTKNOW state 382*cdf0e10cSrcweir aControlValue <<= (sal_Int16)STATE_NOCHECK; 383*cdf0e10cSrcweir return aControlValue; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir //----------------------------------------------------------------------------- 387*cdf0e10cSrcweir sal_Bool ORadioButtonModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir Reference< XPropertySet > xField( getField() ); 390*cdf0e10cSrcweir OSL_PRECOND( xField.is(), "ORadioButtonModel::commitControlValueToDbColumn: not bound!" ); 391*cdf0e10cSrcweir if ( xField.is() ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir try 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir sal_Int16 nValue = 0; 396*cdf0e10cSrcweir m_xAggregateSet->getPropertyValue( PROPERTY_STATE ) >>= nValue; 397*cdf0e10cSrcweir if ( nValue == 1 ) 398*cdf0e10cSrcweir xField->setPropertyValue( PROPERTY_VALUE, makeAny( getReferenceValue() ) ); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir catch(Exception&) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir DBG_ERROR("ORadioButtonModel::commitControlValueToDbColumn: could not commit !"); 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir return sal_True; 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir //......................................................................... 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir //......................................................................... 411*cdf0e10cSrcweir 412