From 232ed9fdfa64d57b8c15524bb869847a61d66c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Timm?= Date: Mon, 1 Dec 2003 09:15:40 +0000 Subject: [PATCH] INTEGRATION: CWS geordi2q10 (1.10.80); FILE MERGED 2003/11/28 11:15:29 rt 1.10.80.1: #111934#: join CWS dba01pp1 --- forms/source/component/GroupManager.cxx | 60 ++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/forms/source/component/GroupManager.cxx b/forms/source/component/GroupManager.cxx index 5d35c9d048e4..6650755adad8 100644 --- a/forms/source/component/GroupManager.cxx +++ b/forms/source/component/GroupManager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: GroupManager.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: hr $ $Date: 2003-03-25 18:01:17 $ + * last change: $Author: rt $ $Date: 2003-12-01 10:15:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,9 @@ #ifndef _COM_SUN_STAR_BEANS_XFASTPROPERTYSET_HPP_ #include #endif +#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_ +#include +#endif #ifndef _COMPHELPER_PROPERTY_HXX_ #include @@ -102,6 +105,23 @@ using namespace ::com::sun::star::awt; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; +using namespace ::com::sun::star::form; + +namespace +{ + bool isRadioButton( const Reference< XPropertySet >& _rxComponent ) + { + bool bIs = false; + if ( hasProperty( PROPERTY_CLASSID, _rxComponent ) ) + { + sal_Int16 nClassId = FormComponentType::CONTROL; + _rxComponent->getPropertyValue( PROPERTY_CLASSID ) >>= nClassId; + if ( nClassId == FormComponentType::RADIOBUTTON ) + bIs = true; + } + return bIs; + } +} //======================================================================== // class OGroupCompAcc @@ -354,9 +374,18 @@ void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const // Wenn Anzahl der Gruppenelemente == 1 ist, Gruppe deaktivieren if ( aFind->second.Count() == 1 ) { - OActiveGroups::iterator aActiveFind = ::std::find(m_aActiveGroupMap.begin(),m_aActiveGroupMap.end(),aFind); + OActiveGroups::iterator aActiveFind = ::std::find( + m_aActiveGroupMap.begin(), + m_aActiveGroupMap.end(), + aFind + ); if ( aActiveFind != m_aActiveGroupMap.end() ) - m_aActiveGroupMap.erase(aActiveFind); + { + // the group is active. Deactivate it if the remaining component + // is *no* radio button + if ( !isRadioButton( aFind->second.GetObject( 0 ) ) ) + m_aActiveGroupMap.erase( aActiveFind ); + } } } @@ -471,11 +500,28 @@ void OGroupManager::InsertElement( const Reference& xSet ) aFind->second.InsertComponent( xSet ); + // if we have at least 2 elements in the group, then this is an "active group" + bool bActivateGroup = aFind->second.Count() == 2; - // Wenn Anzahl der Gruppenelemente == 2 ist, Gruppe aktivieren - if ( aFind->second.Count() == 2 ) + // Additionally, if the component is a radio button, then it's group becomes active, + // too. With this, we ensure that in a container with n radio buttons which all are + // in different groups the selection still works reliably (means that all radios can be + // clicked independently) + if ( aFind->second.Count() == 1 ) { - m_aActiveGroupMap.push_back( aFind ); + if ( isRadioButton( xSet ) ) + bActivateGroup = true; + } + + if ( bActivateGroup ) + { + OActiveGroups::iterator aAlreadyExistent = ::std::find( + m_aActiveGroupMap.begin(), + m_aActiveGroupMap.end(), + aFind + ); + if ( aAlreadyExistent == m_aActiveGroupMap.end() ) + m_aActiveGroupMap.push_back( aFind ); }