Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "GroupManager.hxx"
30 : : #include <com/sun/star/beans/XFastPropertySet.hpp>
31 : : #include <com/sun/star/form/FormComponentType.hpp>
32 : : #include <comphelper/property.hxx>
33 : : #include <comphelper/uno3.hxx>
34 : : #include <tools/solar.h>
35 : : #include <tools/debug.hxx>
36 : :
37 : : #include "property.hrc"
38 : :
39 : : #include <algorithm>
40 : :
41 : : //.........................................................................
42 : : namespace frm
43 : : {
44 : : //.........................................................................
45 : :
46 : : using namespace ::com::sun::star::uno;
47 : : using namespace ::com::sun::star::sdbc;
48 : : using namespace ::com::sun::star::beans;
49 : : using namespace ::com::sun::star::container;
50 : : using namespace ::com::sun::star::form;
51 : : using namespace ::com::sun::star::awt;
52 : : using namespace ::com::sun::star::lang;
53 : : using namespace ::com::sun::star::form;
54 : :
55 : : namespace
56 : : {
57 : 1314 : bool isRadioButton( const Reference< XPropertySet >& _rxComponent )
58 : : {
59 : 1314 : bool bIs = false;
60 [ + - ][ + - ]: 1314 : if ( hasProperty( PROPERTY_CLASSID, _rxComponent ) )
61 : : {
62 : 1314 : sal_Int16 nClassId = FormComponentType::CONTROL;
63 [ + - ][ + - ]: 1314 : _rxComponent->getPropertyValue( PROPERTY_CLASSID ) >>= nClassId;
[ + - ]
64 [ + + ]: 1314 : if ( nClassId == FormComponentType::RADIOBUTTON )
65 : 1314 : bIs = true;
66 : : }
67 : 1314 : return bIs;
68 : : }
69 : : }
70 : :
71 : : //========================================================================
72 : : // class OGroupCompAcc
73 : : //========================================================================
74 : : //------------------------------------------------------------------
75 : 5128 : OGroupCompAcc::OGroupCompAcc(const Reference<XPropertySet>& rxElement, const OGroupComp& _rGroupComp )
76 : : :m_xComponent( rxElement )
77 [ + - ]: 5128 : ,m_aGroupComp( _rGroupComp )
78 : : {
79 : 5128 : }
80 : :
81 : : //------------------------------------------------------------------
82 : 2468 : sal_Bool OGroupCompAcc::operator==( const OGroupCompAcc& rCompAcc ) const
83 : : {
84 : 2468 : return (m_xComponent == rCompAcc.GetComponent());
85 : : }
86 : :
87 : : //------------------------------------------------------------------
88 : : class OGroupCompAccLess : public ::std::binary_function<OGroupCompAcc, OGroupCompAcc, sal_Bool>
89 : : {
90 : : public:
91 : 4411 : sal_Bool operator() (const OGroupCompAcc& lhs, const OGroupCompAcc& rhs) const
92 : : {
93 : : return
94 : 4411 : reinterpret_cast<sal_Int64>(lhs.m_xComponent.get())
95 : 4411 : < reinterpret_cast<sal_Int64>(rhs.m_xComponent.get());
96 : : }
97 : : };
98 : :
99 : : //========================================================================
100 : : // class OGroupComp
101 : : //========================================================================
102 : :
103 : : //------------------------------------------------------------------
104 : 2468 : OGroupComp::OGroupComp()
105 : : :m_nPos( -1 )
106 : 2468 : ,m_nTabIndex( 0 )
107 : : {
108 : 2468 : }
109 : :
110 : : //------------------------------------------------------------------
111 : 13222 : OGroupComp::OGroupComp(const OGroupComp& _rSource)
112 : : :m_aName( _rSource.m_aName )
113 : : ,m_xComponent( _rSource.m_xComponent )
114 : : ,m_xControlModel(_rSource.m_xControlModel)
115 : : ,m_nPos( _rSource.m_nPos )
116 : 13222 : ,m_nTabIndex( _rSource.m_nTabIndex )
117 : : {
118 : 13222 : }
119 : :
120 : : //------------------------------------------------------------------
121 : 2660 : OGroupComp::OGroupComp(const Reference<XPropertySet>& rxSet, sal_Int32 nInsertPos )
122 : : : m_aName( OGroupManager::GetGroupName( rxSet ) )
123 : : , m_xComponent( rxSet )
124 : : , m_xControlModel(rxSet,UNO_QUERY)
125 : : , m_nPos( nInsertPos )
126 [ + - ][ + - ]: 2660 : , m_nTabIndex(0)
127 : : {
128 [ + - ]: 2660 : if (m_xComponent.is())
129 : : {
130 [ + - ][ + - ]: 2660 : if (hasProperty( PROPERTY_TABINDEX, m_xComponent ) )
[ + + ]
131 : : // Indices kleiner 0 werden wie 0 behandelt
132 [ + - ][ + - ]: 2274 : m_nTabIndex = Max(getINT16(m_xComponent->getPropertyValue( PROPERTY_TABINDEX )) , sal_Int16(0));
[ + - ][ + - ]
133 : : }
134 : 2660 : }
135 : :
136 : : //------------------------------------------------------------------
137 : 2468 : sal_Bool OGroupComp::operator==( const OGroupComp& rComp ) const
138 : : {
139 [ + - ][ + - ]: 2468 : return m_nTabIndex == rComp.GetTabIndex() && m_nPos == rComp.GetPos();
140 : : }
141 : :
142 : : //------------------------------------------------------------------
143 : : class OGroupCompLess : public ::std::binary_function<OGroupComp, OGroupComp, sal_Bool>
144 : : {
145 : : public:
146 : 4401 : sal_Bool operator() (const OGroupComp& lhs, const OGroupComp& rhs) const
147 : : {
148 : : sal_Bool bResult;
149 : : // TabIndex von 0 wird hinten einsortiert
150 [ + + ]: 4401 : if (lhs.m_nTabIndex == rhs.GetTabIndex())
151 : 3361 : bResult = lhs.m_nPos < rhs.GetPos();
152 [ + + ][ - + ]: 1040 : else if (lhs.m_nTabIndex && rhs.GetTabIndex())
[ - + ]
153 : 0 : bResult = lhs.m_nTabIndex < rhs.GetTabIndex();
154 : : else
155 : 1040 : bResult = lhs.m_nTabIndex != 0;
156 : 4401 : return bResult;
157 : : }
158 : : };
159 : :
160 : : //========================================================================
161 : : // class OGroup
162 : : //========================================================================
163 : :
164 : : DBG_NAME(OGroup)
165 : : //------------------------------------------------------------------
166 : 1204 : OGroup::OGroup( const ::rtl::OUString& rGroupName )
167 : : :m_aGroupName( rGroupName )
168 [ + - ]: 1204 : ,m_nInsertPos(0)
169 : : {
170 : : DBG_CTOR(OGroup,NULL);
171 : 1204 : }
172 : :
173 : : #ifdef DBG_UTIL
174 : : //------------------------------------------------------------------
175 : : OGroup::OGroup( const OGroup& _rSource )
176 : : :m_aCompArray(_rSource.m_aCompArray)
177 : : ,m_aCompAccArray(_rSource.m_aCompAccArray)
178 : : ,m_aGroupName(_rSource.m_aGroupName)
179 : : ,m_nInsertPos(_rSource.m_nInsertPos)
180 : : {
181 : : DBG_CTOR(OGroup,NULL);
182 : : }
183 : : #endif
184 : :
185 : : //------------------------------------------------------------------
186 : 3049 : OGroup::~OGroup()
187 : : {
188 : : DBG_DTOR(OGroup,NULL);
189 [ - + ]: 3323 : }
190 : :
191 : : //------------------------------------------------------------------
192 : 2660 : void OGroup::InsertComponent( const Reference<XPropertySet>& xSet )
193 : : {
194 [ + - ]: 2660 : OGroupComp aNewGroupComp( xSet, m_nInsertPos );
195 [ + - ]: 2660 : sal_Int32 nPosInserted = insert_sorted(m_aCompArray, aNewGroupComp, OGroupCompLess());
196 : :
197 [ + - ]: 2660 : OGroupCompAcc aNewGroupCompAcc( xSet, m_aCompArray[nPosInserted] );
198 [ + - ]: 2660 : insert_sorted(m_aCompAccArray, aNewGroupCompAcc, OGroupCompAccLess());
199 [ + - ][ + - ]: 2660 : m_nInsertPos++;
200 : 2660 : }
201 : :
202 : : //------------------------------------------------------------------
203 : 2468 : void OGroup::RemoveComponent( const Reference<XPropertySet>& rxElement )
204 : : {
205 : : sal_Int32 nGroupCompAccPos;
206 [ + - ][ + - ]: 2468 : OGroupCompAcc aSearchCompAcc( rxElement, OGroupComp() );
[ + - ]
207 [ + - ][ + - ]: 2468 : if ( seek_entry(m_aCompAccArray, aSearchCompAcc, nGroupCompAccPos, OGroupCompAccLess()) )
208 : : {
209 : 2468 : OGroupCompAcc& aGroupCompAcc = m_aCompAccArray[nGroupCompAccPos];
210 : 2468 : const OGroupComp& aGroupComp = aGroupCompAcc.GetGroupComponent();
211 : :
212 : : sal_Int32 nGroupCompPos;
213 [ + - ][ + - ]: 2468 : if ( seek_entry(m_aCompArray, aGroupComp, nGroupCompPos, OGroupCompLess()) )
214 : : {
215 [ + - ][ + - ]: 2468 : m_aCompAccArray.erase( m_aCompAccArray.begin() + nGroupCompAccPos );
216 [ + - ][ + - ]: 2468 : m_aCompArray.erase( m_aCompArray.begin() + nGroupCompPos );
217 : :
218 : : /*============================================================
219 : : Durch das Entfernen der GroupComp ist die Einfuegeposition
220 : : ungueltig geworden. Sie braucht hier aber nicht angepasst werden,
221 : : da sie fortlaufend vergeben wird und damit immer
222 : : aufsteigend eindeutig ist.
223 : : ============================================================*/
224 : : }
225 : : else
226 : : {
227 : : OSL_FAIL( "OGroup::RemoveComponent: Component nicht in Gruppe" );
228 : : }
229 : : }
230 : : else
231 : : {
232 : : OSL_FAIL( "OGroup::RemoveComponent: Component nicht in Gruppe" );
233 [ + - ]: 2468 : }
234 : 2468 : }
235 : :
236 : : //------------------------------------------------------------------
237 : 0 : sal_Bool OGroup::operator==( const OGroup& rGroup ) const
238 : : {
239 : 0 : return m_aGroupName.equals(rGroup.GetGroupName());
240 : : }
241 : :
242 : : //------------------------------------------------------------------
243 : : class OGroupLess : public ::std::binary_function<OGroup, OGroup, sal_Bool>
244 : : {
245 : : public:
246 : : sal_Bool operator() (const OGroup& lhs, const OGroup& rhs) const
247 : : {
248 : : return lhs.m_aGroupName < rhs.m_aGroupName;
249 : : }
250 : : };
251 : :
252 : : //------------------------------------------------------------------
253 : 87 : Sequence< Reference<XControlModel> > OGroup::GetControlModels() const
254 : : {
255 : 87 : sal_Int32 nLen = m_aCompArray.size();
256 [ + - ]: 87 : Sequence<Reference<XControlModel> > aControlModelSeq( nLen );
257 [ + - ]: 87 : Reference<XControlModel>* pModels = aControlModelSeq.getArray();
258 : :
259 : 87 : ConstOGroupCompArrIterator aGroupComps = m_aCompArray.begin();
260 [ + + ]: 246 : for (sal_Int32 i = 0; i < nLen; ++i, ++pModels, ++aGroupComps)
261 : : {
262 [ + - ]: 159 : *pModels = aGroupComps->GetControlModel();
263 : : }
264 : 87 : return aControlModelSeq;
265 : : }
266 : :
267 : : DBG_NAME(OGroupManager);
268 : : //------------------------------------------------------------------
269 : 278 : OGroupManager::OGroupManager(const Reference< XContainer >& _rxContainer)
270 [ + - ]: 278 : :m_pCompGroup( new OGroup( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllComponentGroup") ) ) )
271 [ + - ][ + - ]: 556 : ,m_xContainer(_rxContainer)
[ + - ][ + - ]
272 : : {
273 : : DBG_CTOR(OGroupManager,NULL);
274 : :
275 [ + - ]: 278 : increment(m_refCount);
276 : : {
277 [ + - ][ + - ]: 278 : _rxContainer->addContainerListener(this);
[ + - ]
278 : : }
279 [ + - ]: 278 : decrement(m_refCount);
280 : 278 : }
281 : :
282 : : //------------------------------------------------------------------
283 : 271 : OGroupManager::~OGroupManager()
284 : : {
285 : : DBG_DTOR(OGroupManager,NULL);
286 : : // Alle Components und CompGroup loeschen
287 [ - + ][ # # ]: 271 : delete m_pCompGroup;
288 [ - + ]: 542 : }
289 : :
290 : : // XPropertyChangeListener
291 : : //------------------------------------------------------------------
292 : 472 : void OGroupManager::disposing(const EventObject& evt) throw( RuntimeException )
293 : : {
294 [ + - ]: 472 : Reference<XContainer> xContainer(evt.Source, UNO_QUERY);
295 [ + - ][ + - ]: 472 : if (xContainer.get() == m_xContainer.get())
[ + + ]
296 : : {
297 [ + - ][ + - ]: 274 : DELETEZ(m_pCompGroup);
298 : :
299 : : ////////////////////////////////////////////////////////////////
300 : : // Gruppen loeschen
301 : 274 : m_aGroupArr.clear();
302 : 274 : m_xContainer.clear();
303 : 472 : }
304 : 472 : }
305 : : // -----------------------------------------------------------------------------
306 : 1234 : void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const Reference<XPropertySet>& _xSet)
307 : : {
308 : : // Component aus CompGroup entfernen
309 [ + - ]: 1234 : m_pCompGroup->RemoveComponent( _xSet );
310 : :
311 [ + - ]: 1234 : OGroupArr::iterator aFind = m_aGroupArr.find(_sGroupName);
312 : :
313 [ + - ]: 1234 : if ( aFind != m_aGroupArr.end() )
314 : : {
315 : : // Gruppe vorhanden
316 [ + - ]: 1234 : aFind->second.RemoveComponent( _xSet );
317 : :
318 : : // Wenn Anzahl der Gruppenelemente == 1 ist, Gruppe deaktivieren
319 [ + - ]: 1234 : sal_Int32 nCount = aFind->second.Count();
320 [ + + ][ + + ]: 1234 : if ( nCount == 1 || nCount == 0 )
321 : : {
322 : : OActiveGroups::iterator aActiveFind = ::std::find(
323 : : m_aActiveGroupMap.begin(),
324 : : m_aActiveGroupMap.end(),
325 : : aFind
326 [ + - ]: 1230 : );
327 [ + - ][ + + ]: 1230 : if ( aActiveFind != m_aActiveGroupMap.end() )
328 : : {
329 : : // the group is active. Deactivate it if the remaining component
330 : : // is *no* radio button
331 [ + + ][ + - ]: 66 : if ( nCount == 0 || !isRadioButton( aFind->second.GetObject( 0 ) ) )
[ + - ][ + - ]
[ + - ]
332 [ + - ]: 1230 : m_aActiveGroupMap.erase( aActiveFind );
333 : : }
334 : : }
335 : : }
336 : :
337 : :
338 : : // Bei Component als PropertyChangeListener abmelden
339 [ + - ][ + - ]: 1234 : _xSet->removePropertyChangeListener( PROPERTY_NAME, this );
[ + - ][ + - ]
340 [ + - ][ + + ]: 1234 : if (hasProperty(PROPERTY_GROUP_NAME, _xSet))
[ + - ]
341 [ + - ][ + - ]: 64 : _xSet->removePropertyChangeListener( PROPERTY_GROUP_NAME, this );
[ + - ][ + - ]
342 [ + - ][ + - ]: 1234 : if (hasProperty(PROPERTY_TABINDEX, _xSet))
[ + + ]
343 [ + - ][ + - ]: 1048 : _xSet->removePropertyChangeListener( PROPERTY_TABINDEX, this );
[ + - ][ + - ]
344 : 1234 : }
345 : : //------------------------------------------------------------------
346 : 811 : void SAL_CALL OGroupManager::propertyChange(const PropertyChangeEvent& evt) throw ( ::com::sun::star::uno::RuntimeException)
347 : : {
348 [ + - ]: 811 : Reference<XPropertySet> xSet(evt.Source, UNO_QUERY);
349 : :
350 : : // Component aus Gruppe entfernen
351 : 811 : ::rtl::OUString sGroupName;
352 [ + - ][ + + ]: 811 : if (hasProperty( PROPERTY_GROUP_NAME, xSet ))
[ + - ]
353 [ + - ][ + - ]: 72 : xSet->getPropertyValue( PROPERTY_GROUP_NAME ) >>= sGroupName;
[ + - ]
354 [ + - ][ + + ]: 811 : if (evt.PropertyName == PROPERTY_NAME) {
355 [ + + ]: 449 : if (!sGroupName.isEmpty())
356 : 811 : return; // group hasn't changed; ignore this name change.
357 : : // no GroupName; use Name as GroupNme
358 : 429 : evt.OldValue >>= sGroupName;
359 : : }
360 [ + - ][ + + ]: 362 : else if (evt.PropertyName == PROPERTY_GROUP_NAME) {
361 : 20 : evt.OldValue >>= sGroupName;
362 [ + + ]: 20 : if (sGroupName.isEmpty()) {
363 : : // No prior GroupName; fallback to Nme
364 [ + - ][ + - ]: 6 : xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
[ + - ]
365 : : }
366 : : }
367 : : else
368 [ + - ]: 342 : sGroupName = GetGroupName( xSet );
369 : :
370 [ + - ]: 791 : removeFromGroupMap(sGroupName,xSet);
371 : :
372 : : // Component neu einordnen
373 [ + - ][ + + ]: 811 : InsertElement( xSet );
[ + + ]
374 : : }
375 : :
376 : : // XContainerListener
377 : : //------------------------------------------------------------------
378 : 543 : void SAL_CALL OGroupManager::elementInserted(const ContainerEvent& Event) throw ( ::com::sun::star::uno::RuntimeException)
379 : : {
380 : 543 : Reference< XPropertySet > xProps;
381 [ + - ]: 543 : Event.Element >>= xProps;
382 [ + - ]: 543 : if ( xProps.is() )
383 [ + - ]: 543 : InsertElement( xProps );
384 : 543 : }
385 : :
386 : : //------------------------------------------------------------------
387 : 443 : void SAL_CALL OGroupManager::elementRemoved(const ContainerEvent& Event) throw ( ::com::sun::star::uno::RuntimeException)
388 : : {
389 : 443 : Reference<XPropertySet> xProps;
390 [ + - ]: 443 : Event.Element >>= xProps;
391 [ + - ]: 443 : if ( xProps.is() )
392 [ + - ]: 443 : RemoveElement( xProps );
393 : 443 : }
394 : :
395 : : //------------------------------------------------------------------
396 : 0 : void SAL_CALL OGroupManager::elementReplaced(const ContainerEvent& Event) throw ( ::com::sun::star::uno::RuntimeException)
397 : : {
398 : 0 : Reference<XPropertySet> xProps;
399 [ # # ]: 0 : Event.ReplacedElement >>= xProps;
400 [ # # ]: 0 : if ( xProps.is() )
401 [ # # ]: 0 : RemoveElement( xProps );
402 : :
403 : 0 : xProps.clear();
404 [ # # ]: 0 : Event.Element >>= xProps;
405 [ # # ]: 0 : if ( xProps.is() )
406 [ # # ]: 0 : InsertElement( xProps );
407 : 0 : }
408 : :
409 : : // Other functions
410 : : //------------------------------------------------------------------
411 : 81 : Sequence<Reference<XControlModel> > OGroupManager::getControlModels()
412 : : {
413 : 81 : return m_pCompGroup->GetControlModels();
414 : : }
415 : :
416 : : //------------------------------------------------------------------
417 : 46 : sal_Int32 OGroupManager::getGroupCount()
418 : : {
419 : 46 : return m_aActiveGroupMap.size();
420 : : }
421 : :
422 : : //------------------------------------------------------------------
423 : 6 : void OGroupManager::getGroup(sal_Int32 nGroup, Sequence< Reference<XControlModel> >& _rGroup, ::rtl::OUString& _rName)
424 : : {
425 : : OSL_ENSURE(nGroup >= 0 && (size_t)nGroup < m_aActiveGroupMap.size(),"OGroupManager::getGroup: Invalid group index!");
426 : 6 : OGroupArr::iterator aGroupPos = m_aActiveGroupMap[nGroup];
427 : 6 : _rName = aGroupPos->second.GetGroupName();
428 [ + - ][ + - ]: 6 : _rGroup = aGroupPos->second.GetControlModels();
[ + - ]
429 : 6 : }
430 : :
431 : : //------------------------------------------------------------------
432 : 0 : void OGroupManager::getGroupByName(const ::rtl::OUString& _rName, Sequence< Reference<XControlModel> >& _rGroup)
433 : : {
434 [ # # ]: 0 : OGroupArr::iterator aFind = m_aGroupArr.find(_rName);
435 [ # # ]: 0 : if ( aFind != m_aGroupArr.end() )
436 [ # # ][ # # ]: 0 : _rGroup = aFind->second.GetControlModels();
[ # # ]
437 : 0 : }
438 : :
439 : : //------------------------------------------------------------------
440 : 1334 : void OGroupManager::InsertElement( const Reference<XPropertySet>& xSet )
441 : : {
442 : : // Nur ControlModels
443 [ + - ]: 1334 : Reference<XControlModel> xControl(xSet, UNO_QUERY);
444 [ + + ]: 1334 : if (!xControl.is() )
445 : 1334 : return;
446 : :
447 : : // Component in CompGroup aufnehmen
448 [ + - ]: 1330 : m_pCompGroup->InsertComponent( xSet );
449 : :
450 : : // Component in Gruppe aufnehmen
451 [ + - ]: 1330 : ::rtl::OUString sGroupName( GetGroupName( xSet ) );
452 : :
453 [ + - ]: 1330 : OGroupArr::iterator aFind = m_aGroupArr.find(sGroupName);
454 : :
455 [ + + ]: 1330 : if ( aFind == m_aGroupArr.end() )
456 : : {
457 [ + - ][ + - ]: 926 : aFind = m_aGroupArr.insert(OGroupArr::value_type(sGroupName,OGroup(sGroupName))).first;
[ + - ]
458 : : }
459 : :
460 [ + - ]: 1330 : aFind->second.InsertComponent( xSet );
461 : :
462 : : // if we have at least 2 elements in the group, then this is an "active group"
463 [ + - ]: 1330 : bool bActivateGroup = aFind->second.Count() == 2;
464 : :
465 : : // Additionally, if the component is a radio button, then it's group becomes active,
466 : : // too. With this, we ensure that in a container with n radio buttons which all are
467 : : // in different groups the selection still works reliably (means that all radios can be
468 : : // clicked independently)
469 [ + - ][ + + ]: 1330 : if ( aFind->second.Count() == 1 )
470 : : {
471 [ + - ][ + + ]: 1312 : if ( isRadioButton( xSet ) )
472 : 71 : bActivateGroup = true;
473 : : }
474 : :
475 [ + + ]: 1330 : if ( bActivateGroup )
476 : : {
477 : : OActiveGroups::iterator aAlreadyExistent = ::std::find(
478 : : m_aActiveGroupMap.begin(),
479 : : m_aActiveGroupMap.end(),
480 : : aFind
481 [ + - ]: 76 : );
482 [ + - ][ + - ]: 76 : if ( aAlreadyExistent == m_aActiveGroupMap.end() )
483 [ + - ]: 76 : m_aActiveGroupMap.push_back( aFind );
484 : : }
485 : :
486 : :
487 : : // Bei Component als PropertyChangeListener anmelden
488 [ + - ][ + - ]: 1330 : xSet->addPropertyChangeListener( PROPERTY_NAME, this );
[ + - ][ + - ]
489 [ + - ][ + + ]: 1330 : if (hasProperty(PROPERTY_GROUP_NAME, xSet))
[ + - ]
490 [ + - ][ + - ]: 83 : xSet->addPropertyChangeListener( PROPERTY_GROUP_NAME, this );
[ + - ][ + - ]
491 : :
492 : : // Tabindex muss nicht jeder unterstuetzen
493 [ + - ][ + - ]: 1330 : if (hasProperty(PROPERTY_TABINDEX, xSet))
[ + + ]
494 [ + - ][ + - ]: 1334 : xSet->addPropertyChangeListener( PROPERTY_TABINDEX, this );
[ + - ][ + - ]
[ + + ]
495 : :
496 : : }
497 : :
498 : : //------------------------------------------------------------------
499 : 443 : void OGroupManager::RemoveElement( const Reference<XPropertySet>& xSet )
500 : : {
501 : : // Nur ControlModels
502 [ + - ]: 443 : Reference<XControlModel> xControl(xSet, UNO_QUERY);
503 [ - + ]: 443 : if (!xControl.is() )
504 : 443 : return;
505 : :
506 : : // Component aus Gruppe entfernen
507 [ + - ]: 443 : ::rtl::OUString sGroupName( GetGroupName( xSet ) );
508 : :
509 [ + - ][ + - ]: 443 : removeFromGroupMap(sGroupName,xSet);
510 : : }
511 : :
512 : 4775 : ::rtl::OUString OGroupManager::GetGroupName( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xComponent )
513 : : {
514 [ - + ]: 4775 : if (!xComponent.is())
515 : 0 : return ::rtl::OUString();
516 : 4775 : ::rtl::OUString sGroupName;
517 [ + - ][ + + ]: 4775 : if (hasProperty( PROPERTY_GROUP_NAME, xComponent )) {
[ + - ]
518 [ + - ][ + - ]: 285 : xComponent->getPropertyValue( PROPERTY_GROUP_NAME ) >>= sGroupName;
[ + - ]
519 [ + + ]: 285 : if (sGroupName.isEmpty())
520 [ + - ][ + - ]: 139 : xComponent->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
[ + - ]
521 : : }
522 : : else
523 [ + - ][ + - ]: 4490 : xComponent->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
[ + - ]
524 : 4775 : return sGroupName;
525 : : }
526 : :
527 : : //.........................................................................
528 : : } // namespace frm
529 : : //.........................................................................
530 : :
531 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|