INTEGRATION: CWS geordi2q10 (1.10.80); FILE MERGED

2003/11/28 11:15:29 rt 1.10.80.1: #111934#: join CWS dba01pp1
This commit is contained in:
Rüdiger Timm 2003-12-01 09:15:40 +00:00
parent e17bde3792
commit 232ed9fdfa

View file

@ -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 <com/sun/star/beans/XFastPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
#include <com/sun/star/form/FormComponentType.hpp>
#endif
#ifndef _COMPHELPER_PROPERTY_HXX_
#include <comphelper/property.hxx>
@ -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,10 +500,27 @@ void OGroupManager::InsertElement( const Reference<XPropertySet>& 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 )
{
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 );
}