21#include <com/sun/star/form/FormComponentType.hpp>
25#include <osl/diagnose.h>
44 bool isRadioButton(
const Reference< XPropertySet >& _rxComponent )
49 sal_Int16 nClassId = FormComponentType::CONTROL;
51 if ( nClassId == FormComponentType::RADIOBUTTON )
59 :m_xComponent( rxElement )
60 ,m_aGroupComp(
std::move( _aGroupComp ))
87 : m_xComponent( rxSet )
88 , m_xControlModel(rxSet,UNO_QUERY)
123 :m_aGroupName(
std::move( sGroupName ))
140 sal_Int32 nGroupCompAccPos;
147 sal_Int32 nGroupCompPos;
161 OSL_FAIL(
"OGroup::RemoveComponent: Component not in Group" );
166 OSL_FAIL(
"OGroup::RemoveComponent: Component not in Group" );
172 Sequence<Reference<XControlModel> > aControlModelSeq(
m_aCompArray.size() );
173 Reference<XControlModel>* pModels = aControlModelSeq.getArray();
177 *pModels++ = rGroupComp.GetControlModel();
179 return aControlModelSeq;
183 :m_pCompGroup( new
OGroup(
"AllComponentGroup" ) )
188 _rxContainer->addContainerListener(
this);
200 Reference<XContainer> xContainer(evt.Source, UNO_QUERY);
216 OGroupArr::iterator aFind =
m_aGroupArr.find(_sGroupName);
221 aFind->second.RemoveComponent( _xSet );
224 sal_Int32
nCount = aFind->second.Count();
227 OActiveGroups::iterator aActiveFind = ::std::find(
236 if (
nCount == 0 || !isRadioButton( aFind->second.GetObject( 0 ) ) )
253 Reference<XPropertySet> xSet(evt.Source, UNO_QUERY);
260 if (!sGroupName.isEmpty())
263 evt.OldValue >>= sGroupName;
266 evt.OldValue >>= sGroupName;
267 if (sGroupName.isEmpty()) {
284 Reference< XPropertySet > xProps;
285 Event.Element >>= xProps;
292 Reference<XPropertySet> xProps;
293 Event.Element >>= xProps;
300 Reference<XPropertySet> xProps;
301 Event.ReplacedElement >>= xProps;
306 Event.Element >>= xProps;
326 _rName = aGroupPos->second.GetGroupName();
327 _rGroup = aGroupPos->second.GetControlModels();
332 OGroupArr::iterator aFind =
m_aGroupArr.find(_rName);
334 _rGroup = aFind->second.GetControlModels();
340 Reference<XControlModel> xControl(xSet, UNO_QUERY);
350 OGroupArr::iterator aFind =
m_aGroupArr.find(sGroupName);
357 aFind->second.InsertComponent( xSet );
360 bool bActivateGroup = aFind->second.Count() == 2;
366 if ( aFind->second.Count() == 1 )
368 if ( isRadioButton( xSet ) )
369 bActivateGroup =
true;
372 if ( bActivateGroup )
374 OActiveGroups::iterator aAlreadyExistent = ::std::find(
396 Reference<XControlModel> xControl(xSet, UNO_QUERY);
408 if (!xComponent.is())
413 if (sGroupName.isEmpty())
414 xComponent->getPropertyValue(
PROPERTY_NAME ) >>= sGroupName;
417 xComponent->getPropertyValue(
PROPERTY_NAME ) >>= sGroupName;
bool operator()(const OGroupCompAcc &lhs, const OGroupCompAcc &rhs) const
const OGroupComp & GetGroupComponent() const
OGroupCompAcc(const css::uno::Reference< css::beans::XPropertySet > &rxElement, OGroupComp _aGroupComp)
bool operator==(const OGroupCompAcc &rCompAcc) const
css::uno::Reference< css::beans::XPropertySet > m_xComponent
bool operator()(const OGroupComp &lhs, const OGroupComp &rhs) const
bool operator==(const OGroupComp &rComp) const
css::uno::Reference< css::beans::XPropertySet > m_xComponent
sal_Int16 GetTabIndex() const
std::unique_ptr< OGroup > m_pCompGroup
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
OGroupManager(const css::uno::Reference< css::container::XContainer > &_rxContainer)
css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > > getControlModels() const
css::uno::Reference< css::container::XContainer > m_xContainer
static OUString GetGroupName(const css::uno::Reference< css::beans::XPropertySet > &xComponent)
void getGroupByName(const OUString &Name, css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > > &_rGroup)
virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent &_rEvent) override
void getGroup(sal_Int32 nGroup, css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > > &_rGroup, OUString &Name)
virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent &_rEvent) override
virtual ~OGroupManager() override
void InsertElement(const css::uno::Reference< css::beans::XPropertySet > &rxElement)
void RemoveElement(const css::uno::Reference< css::beans::XPropertySet > &rxElement)
virtual void SAL_CALL elementInserted(const css::container::ContainerEvent &_rEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &_rSource) override
void removeFromGroupMap(const OUString &_sGroupName, const css::uno::Reference< css::beans::XPropertySet > &_xSet)
sal_Int32 getGroupCount() const
OActiveGroups m_aActiveGroupMap
void RemoveComponent(const css::uno::Reference< css::beans::XPropertySet > &rxElement)
void InsertComponent(const css::uno::Reference< css::beans::XPropertySet > &rxElement)
std::vector< OGroupCompAcc > m_aCompAccArray
css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > > GetControlModels() const
std::vector< OGroupComp > m_aCompArray
OGroup(OUString sGroupName)
constexpr OUStringLiteral PROPERTY_TABINDEX
constexpr OUStringLiteral PROPERTY_NAME
constexpr OUStringLiteral PROPERTY_GROUP_NAME
constexpr OUStringLiteral PROPERTY_CLASSID
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
sal_Int16 getINT16(const Any &_rAny)
ListBox is a bit confusing / different from other form components, so here are a few notes:
sal_Int32 insert_sorted(::std::vector< ELEMENT > &_rArray, const ELEMENT &_rNewElement, const LESS_COMPARE &_rCompareOp)
bool seek_entry(const ::std::vector< ELEMENT > &_rArray, const ELEMENT &_rNewElement, sal_Int32 &nPos, const LESS_COMPARE &_rCompareOp)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
Reference< XNameAccess > m_xContainer