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 : :
30 : : #include <toolkit/controls/roadmapcontrol.hxx>
31 : : #include <toolkit/helper/unopropertyarrayhelper.hxx>
32 : : #include <toolkit/helper/property.hxx>
33 : : #include <com/sun/star/awt/XVclWindowPeer.hpp>
34 : : #include <comphelper/processfactory.hxx>
35 : : #include <osl/diagnose.h>
36 : :
37 : : //........................................................................
38 : : namespace toolkit
39 : : {
40 : : //........................................................................
41 : :
42 : : using namespace ::com::sun::star::uno;
43 : : using namespace ::com::sun::star::awt;
44 : : using namespace ::com::sun::star::lang;
45 : : using namespace ::com::sun::star::beans;
46 : : using namespace ::com::sun::star::container;
47 : :
48 : : // ----------------------------------------------------
49 : : // helper
50 : : // ----------------------------------------------------
51 : :
52 : 0 : static void lcl_throwIllegalArgumentException( )
53 : : { // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this ....
54 [ # # ]: 0 : throw IllegalArgumentException();
55 : : }
56 : :
57 : 0 : static void lcl_throwIndexOutOfBoundsException( )
58 : : { // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this ....
59 [ # # ]: 0 : throw IndexOutOfBoundsException();
60 : : }
61 : :
62 : : // ===================================================================
63 : : // = UnoControlRoadmapModel
64 : : // ===================================================================
65 : : // -------------------------------------------------------------------
66 : 2 : UnoControlRoadmapModel::UnoControlRoadmapModel( const Reference< XMultiServiceFactory >& i_factory )
67 : : :UnoControlRoadmapModel_Base( i_factory )
68 [ + - ][ + - ]: 2 : ,maContainerListeners( *this )
69 : : {
70 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
71 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_BORDER );
72 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
73 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
74 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
75 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
76 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_HELPURL );
77 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_IMAGEURL );
78 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_GRAPHIC );
79 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
80 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_COMPLETE );
81 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_ACTIVATED );
82 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_CURRENTITEMID );
83 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_TABSTOP );
84 [ + - ]: 2 : ImplRegisterProperty( BASEPROPERTY_TEXT );
85 : 2 : }
86 : :
87 : : // -------------------------------------------------------------------
88 : 0 : ::rtl::OUString UnoControlRoadmapModel::getServiceName() throw(RuntimeException)
89 : : {
90 : 0 : return ::rtl::OUString::createFromAscii( szServiceName_UnoControlRoadmapModel );
91 : : }
92 : :
93 : :
94 : : // -------------------------------------------------------------------
95 : 38 : Any UnoControlRoadmapModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
96 : : {
97 : 38 : Any aReturn;
98 [ + + + + : 38 : switch (nPropId)
+ + + ]
99 : : {
100 : : case BASEPROPERTY_COMPLETE:
101 [ + - ]: 2 : aReturn <<= (sal_Bool) sal_True;
102 : 2 : break;
103 : : case BASEPROPERTY_ACTIVATED:
104 [ + - ]: 2 : aReturn <<= (sal_Bool) sal_True;
105 : 2 : break;
106 : : case BASEPROPERTY_CURRENTITEMID:
107 [ + - ]: 2 : aReturn <<= (sal_Int16) -1;
108 : 2 : break;
109 : : case BASEPROPERTY_TEXT:
110 : 2 : break;
111 : : case BASEPROPERTY_BORDER:
112 [ + - ]: 2 : aReturn <<= (sal_Int16) 2; // No Border
113 : 2 : break;
114 : : case BASEPROPERTY_DEFAULTCONTROL:
115 [ + - ]: 2 : aReturn <<= ::rtl::OUString( ::rtl::OUString::createFromAscii( szServiceName_UnoControlRoadmap ) );
116 : 2 : break;
117 [ + - ]: 26 : default : aReturn = UnoControlRoadmapModel_Base::ImplGetDefaultValue( nPropId ); break;
118 : : }
119 : :
120 : 38 : return aReturn;
121 : : }
122 : :
123 : :
124 : 0 : Reference< XInterface > SAL_CALL UnoControlRoadmapModel::createInstance( ) throw (Exception, ::com::sun::star::uno::RuntimeException)
125 : : {
126 [ # # ]: 0 : ORoadmapEntry* pRoadmapItem = new ORoadmapEntry();
127 : 0 : Reference< XInterface > xNewRoadmapItem = (::cppu::OWeakObject*)pRoadmapItem;
128 : 0 : return xNewRoadmapItem;
129 : : }
130 : :
131 : :
132 : 0 : Reference< XInterface > SAL_CALL UnoControlRoadmapModel::createInstanceWithArguments( const Sequence< Any >& /*aArguments*/ ) throw (Exception, RuntimeException)
133 : : {
134 : : // Todo: implementation of the arguments handling
135 [ # # ]: 0 : ORoadmapEntry* pRoadmapItem = new ORoadmapEntry();
136 : 0 : Reference< XInterface > xNewRoadmapItem = (::cppu::OWeakObject*)pRoadmapItem;
137 : 0 : return xNewRoadmapItem;
138 : : }
139 : :
140 : :
141 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoControlRoadmapModel, UnoControlRoadmapModel_Base, UnoControlRoadmapModel_IBase )
[ # # ]
142 : :
143 : :
144 : : // -------------------------------------------------------------------
145 : 14 : ::com::sun::star::uno::Any SAL_CALL UnoControlRoadmapModel::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
146 : : {
147 : 14 : Any aRet = UnoControlRoadmapModel_Base::queryAggregation( rType );
148 [ - + ]: 14 : if ( !aRet.hasValue() )
149 [ # # ]: 0 : aRet = UnoControlRoadmapModel_IBase::queryInterface( rType );
150 : 14 : return aRet;
151 : : }
152 : :
153 : :
154 : : // -------------------------------------------------------------------
155 : 0 : ::cppu::IPropertyArrayHelper& UnoControlRoadmapModel::getInfoHelper()
156 : : {
157 : : static UnoPropertyArrayHelper* pHelper = NULL;
158 [ # # ]: 0 : if ( !pHelper )
159 : : {
160 [ # # ]: 0 : Sequence<sal_Int32> aIDs = ImplGetPropertyIds();
161 [ # # ][ # # ]: 0 : pHelper = new UnoPropertyArrayHelper( aIDs );
162 : : }
163 : 0 : return *pHelper;
164 : : }
165 : :
166 : :
167 : : // beans::XMultiPropertySet
168 : : // -------------------------------------------------------------------
169 : 0 : Reference< XPropertySetInfo > UnoControlRoadmapModel::getPropertySetInfo( ) throw(RuntimeException)
170 : : {
171 [ # # ][ # # ]: 0 : static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
[ # # ][ # # ]
[ # # ]
172 : 0 : return xInfo;
173 : : }
174 : :
175 : :
176 : 0 : sal_Int32 SAL_CALL UnoControlRoadmapModel::getCount() throw(RuntimeException)
177 : : {
178 : 0 : return maRoadmapItems.size();
179 : : }
180 : :
181 : 0 : Any SAL_CALL UnoControlRoadmapModel::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
182 : : {
183 [ # # ][ # # ]: 0 : if (( Index >= (sal_Int32)maRoadmapItems.size()) || (Index < 0))
[ # # ]
184 : 0 : lcl_throwIndexOutOfBoundsException( );
185 : 0 : Any aAny;
186 [ # # ][ # # ]: 0 : aAny = makeAny( maRoadmapItems.at( Index ));
187 : 0 : return aAny;
188 : : }
189 : :
190 : :
191 : :
192 : 0 : void UnoControlRoadmapModel::MakeRMItemValidation( sal_Int32 Index, Reference< XInterface > xRoadmapItem )
193 : : {
194 [ # # ][ # # ]: 0 : if ((Index > (sal_Int32)maRoadmapItems.size()) || ( Index < 0 ) )
[ # # ]
195 [ # # ]: 0 : lcl_throwIndexOutOfBoundsException( );
196 [ # # ]: 0 : if ( !xRoadmapItem.is() )
197 [ # # ]: 0 : lcl_throwIllegalArgumentException();
198 [ # # ]: 0 : Reference< XServiceInfo > xServiceInfo( xRoadmapItem, UNO_QUERY );
199 [ # # ][ # # ]: 0 : sal_Bool bIsRoadmapItem = xServiceInfo->supportsService( ::rtl::OUString("com.sun.star.awt.RoadmapItem") );
200 [ # # ]: 0 : if ( !bIsRoadmapItem )
201 [ # # ]: 0 : lcl_throwIllegalArgumentException();
202 : 0 : }
203 : :
204 : :
205 : 0 : void UnoControlRoadmapModel::SetRMItemDefaultProperties( const sal_Int32 , Reference< XInterface > xRoadmapItem)
206 : : {
207 : 0 : Any aAny;
208 [ # # ]: 0 : Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY );
209 [ # # ]: 0 : Reference< XPropertySet > xProps( xRoadmapItem, UNO_QUERY );
210 [ # # ]: 0 : if ( xProps.is() )
211 : : {
212 : 0 : sal_Int32 LocID = 0;
213 [ # # ][ # # ]: 0 : Any aValue = xPropertySet->getPropertyValue( ::rtl::OUString("ID") );
214 : 0 : aValue >>= LocID;
215 [ # # ]: 0 : if (LocID < 0) // index may not be smaller than zero
216 : : {
217 [ # # ][ # # ]: 0 : aAny <<= GetUniqueID();
218 [ # # ][ # # ]: 0 : xPropertySet->setPropertyValue( ::rtl::OUString("ID"), aAny );
219 : 0 : }
220 : 0 : }
221 : 0 : }
222 : :
223 : :
224 : : // The performance of this method could certainly be improved.
225 : : // As long as only vectors with up to 10 elements are
226 : : // involved it should be sufficient
227 : 0 : sal_Int32 UnoControlRoadmapModel::GetUniqueID()
228 : : {
229 : 0 : Any aAny;
230 : 0 : sal_Bool bIncrement = sal_True;
231 : 0 : sal_Int32 CurID = 0;
232 : 0 : sal_Int32 n_CurItemID = 0;
233 : 0 : Reference< XInterface > CurRoadmapItem;
234 [ # # ]: 0 : while ( bIncrement )
235 : : {
236 : 0 : bIncrement = sal_False;
237 [ # # ][ # # ]: 0 : for ( RoadmapItemHolderList::iterator i = maRoadmapItems.begin(); i < maRoadmapItems.end(); ++i )
238 : : {
239 [ # # ]: 0 : CurRoadmapItem = *i;
240 [ # # ]: 0 : Reference< XPropertySet > xPropertySet( CurRoadmapItem, UNO_QUERY );
241 [ # # ][ # # ]: 0 : aAny = xPropertySet->getPropertyValue( ::rtl::OUString("ID") );
242 : 0 : aAny >>= n_CurItemID;
243 [ # # ]: 0 : if (n_CurItemID == CurID)
244 : : {
245 : 0 : bIncrement = sal_True;
246 : 0 : CurID++;
247 : : break;
248 : : }
249 [ # # ]: 0 : }
250 : : }
251 : 0 : return CurID;
252 : : }
253 : :
254 : :
255 : 0 : ContainerEvent UnoControlRoadmapModel::GetContainerEvent(sal_Int32 Index, Reference< XInterface > xRoadmapItem)
256 : : {
257 : 0 : ContainerEvent aEvent;
258 [ # # ][ # # ]: 0 : aEvent.Source = *this;
259 [ # # ]: 0 : aEvent.Element <<= xRoadmapItem;
260 [ # # ]: 0 : aEvent.Accessor = makeAny(Index);
261 : 0 : return aEvent;
262 : : }
263 : :
264 : :
265 : 0 : sal_Int16 UnoControlRoadmapModel::GetCurrentItemID( Reference< XPropertySet > xPropertySet )
266 : : {
267 [ # # ][ # # ]: 0 : Any aAny = xPropertySet->getPropertyValue( GetPropertyName( BASEPROPERTY_CURRENTITEMID ) );
[ # # ]
268 : 0 : sal_Int16 n_CurrentItemID = 0;
269 : 0 : aAny >>= n_CurrentItemID;
270 : 0 : return n_CurrentItemID;
271 : : }
272 : :
273 : :
274 : 0 : void SAL_CALL UnoControlRoadmapModel::insertByIndex( const sal_Int32 Index, const Any& _Element)
275 : : throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
276 : : {
277 [ # # ][ # # ]: 0 : if ( ( Index >= ( (sal_Int32)maRoadmapItems.size() + 1 ) ) || (Index < 0))
[ # # ]
278 [ # # ]: 0 : lcl_throwIndexOutOfBoundsException( );
279 : 0 : Reference< XInterface > xRoadmapItem;
280 [ # # ]: 0 : _Element >>= xRoadmapItem;
281 [ # # ]: 0 : MakeRMItemValidation( Index, xRoadmapItem);
282 [ # # ]: 0 : SetRMItemDefaultProperties( Index, xRoadmapItem );
283 [ # # ][ # # ]: 0 : maRoadmapItems.insert( maRoadmapItems.begin() + Index, xRoadmapItem);
284 [ # # ]: 0 : ContainerEvent aEvent = GetContainerEvent(Index, xRoadmapItem);
285 [ # # ]: 0 : maContainerListeners.elementInserted( aEvent );
286 [ # # ]: 0 : Reference< XPropertySet > xPropertySet( (XAggregation*) (::cppu::OWeakAggObject*)this, UNO_QUERY );
287 [ # # ]: 0 : sal_Int16 n_CurrentItemID = GetCurrentItemID( xPropertySet );
288 [ # # ]: 0 : if ( Index <= n_CurrentItemID )
289 : : {
290 : 0 : Any aAny;
291 [ # # ]: 0 : aAny <<= ( sal_Int16 ) ( n_CurrentItemID + 1 );
292 [ # # ][ # # ]: 0 : xPropertySet->setPropertyValue( GetPropertyName( BASEPROPERTY_CURRENTITEMID ), aAny );
[ # # ]
293 [ # # ]: 0 : }
294 : 0 : }
295 : :
296 : :
297 : :
298 : 0 : void SAL_CALL UnoControlRoadmapModel::removeByIndex( sal_Int32 Index)
299 : : throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
300 : : {
301 [ # # ][ # # ]: 0 : if (( Index > (sal_Int32)maRoadmapItems.size()) || (Index < 0))
[ # # ]
302 [ # # ]: 0 : lcl_throwIndexOutOfBoundsException( );
303 : 0 : Reference< XInterface > xRoadmapItem;
304 [ # # ][ # # ]: 0 : maRoadmapItems.erase( maRoadmapItems.begin() + Index );
305 [ # # ]: 0 : ContainerEvent aEvent = GetContainerEvent(Index, xRoadmapItem);
306 [ # # ]: 0 : maContainerListeners.elementRemoved( aEvent );
307 [ # # ]: 0 : Reference< XPropertySet > xPropertySet( (XAggregation*) (::cppu::OWeakAggObject*)this, UNO_QUERY );
308 [ # # ]: 0 : sal_Int16 n_CurrentItemID = GetCurrentItemID( xPropertySet );
309 : 0 : Any aAny;
310 [ # # ]: 0 : if ( Index <= n_CurrentItemID )
311 : : {
312 [ # # ]: 0 : if ( n_CurrentItemID >= (sal_Int32)maRoadmapItems.size() )
313 : : {
314 : : n_CurrentItemID = sal::static_int_cast< sal_Int16 >(
315 : 0 : maRoadmapItems.size()-1);
316 [ # # ]: 0 : if ( n_CurrentItemID < 0 )
317 : 0 : return;
318 [ # # ]: 0 : aAny <<= n_CurrentItemID;
319 : : }
320 [ # # ]: 0 : else if (Index == n_CurrentItemID)
321 [ # # ]: 0 : aAny <<= ( sal_Int16 ) -1;
322 [ # # ]: 0 : else if( Index < n_CurrentItemID)
323 [ # # ]: 0 : aAny <<= ( sal_Int16 ) ( n_CurrentItemID - 1 );
324 [ # # ][ # # ]: 0 : xPropertySet->setPropertyValue( GetPropertyName( BASEPROPERTY_CURRENTITEMID ), aAny );
[ # # ]
325 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ]
326 : : }
327 : :
328 : :
329 : 0 : void SAL_CALL UnoControlRoadmapModel::replaceByIndex( const sal_Int32 Index, const Any& _Element)
330 : : throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
331 : : {
332 : 0 : Reference< XInterface > xRoadmapItem;
333 [ # # ]: 0 : _Element >>= xRoadmapItem;
334 [ # # ]: 0 : MakeRMItemValidation( Index, xRoadmapItem);
335 [ # # ]: 0 : SetRMItemDefaultProperties( Index, xRoadmapItem );
336 [ # # ][ # # ]: 0 : maRoadmapItems.erase( maRoadmapItems.begin() + Index );
337 [ # # ][ # # ]: 0 : maRoadmapItems.insert( maRoadmapItems.begin() + Index, xRoadmapItem); //push_back( xRoadmapItem );
338 [ # # ]: 0 : ContainerEvent aEvent = GetContainerEvent(Index, xRoadmapItem);
339 [ # # ][ # # ]: 0 : maContainerListeners.elementReplaced( aEvent );
340 : 0 : }
341 : :
342 : :
343 : 0 : Type SAL_CALL UnoControlRoadmapModel::getElementType() throw(RuntimeException)
344 : : {
345 : 0 : Type aType = getCppuType( ( Reference< XPropertySet>* ) NULL );
346 : 0 : return aType;
347 : : }
348 : :
349 : :
350 : 0 : sal_Bool SAL_CALL UnoControlRoadmapModel::hasElements() throw(RuntimeException)
351 : : {
352 : 0 : return !maRoadmapItems.empty();
353 : : }
354 : :
355 : :
356 : 0 : void SAL_CALL UnoControlRoadmapModel::addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
357 : : {
358 : 0 : maContainerListeners.addInterface( xListener );
359 : 0 : }
360 : :
361 : 0 : void SAL_CALL UnoControlRoadmapModel::removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
362 : : {
363 : 0 : maContainerListeners.removeInterface( xListener );
364 : 0 : }
365 : :
366 : : // ===================================================================
367 : : // = UnoRoadmapControl
368 : : // ===================================================================
369 : : // -------------------------------------------------------------------
370 : 0 : UnoRoadmapControl::UnoRoadmapControl( const Reference< XMultiServiceFactory >& i_factory )
371 : : :UnoControlRoadmap_Base( i_factory )
372 [ # # ]: 0 : ,maItemListeners( *this )
373 : : {
374 : 0 : }
375 : :
376 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoRoadmapControl, UnoControlRoadmap_Base, UnoControlRoadmap_IBase )
[ # # ]
377 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XINTERFACE2( UnoRoadmapControl, UnoControlRoadmap_Base, UnoControlRoadmap_IBase )
378 : :
379 : :
380 : 0 : sal_Bool SAL_CALL UnoRoadmapControl::setModel(const Reference< XControlModel >& _rModel) throw ( RuntimeException )
381 : : {
382 : :
383 : :
384 [ # # ][ # # ]: 0 : Reference< XContainer > xC( getModel(), UNO_QUERY );
385 [ # # ]: 0 : if ( xC.is() )
386 [ # # ][ # # ]: 0 : xC->removeContainerListener( this );
[ # # ]
387 : :
388 [ # # ]: 0 : sal_Bool bReturn = UnoControlBase::setModel( _rModel );
389 : :
390 [ # # ][ # # ]: 0 : xC = xC.query( getModel());
[ # # ]
391 [ # # ]: 0 : if ( xC.is() )
392 [ # # ][ # # ]: 0 : xC->addContainerListener( this );
[ # # ]
393 : :
394 : 0 : return bReturn;
395 : : }
396 : :
397 : :
398 : : // -------------------------------------------------------------------
399 : 0 : ::rtl::OUString UnoRoadmapControl::GetComponentServiceName()
400 : : {
401 : 0 : return ::rtl::OUString("Roadmap");
402 : : }
403 : :
404 : :
405 : :
406 : 0 : void UnoRoadmapControl::dispose() throw(RuntimeException)
407 : : {
408 [ # # ]: 0 : EventObject aEvt;
409 [ # # ]: 0 : aEvt.Source = (::cppu::OWeakObject*)this;
410 [ # # ]: 0 : maItemListeners.disposeAndClear( aEvt );
411 [ # # ][ # # ]: 0 : UnoControl::dispose();
412 : 0 : }
413 : :
414 : :
415 : :
416 : 0 : void UnoRoadmapControl::elementInserted( const ContainerEvent& rEvent )throw(RuntimeException)
417 : : {
418 : 0 : Reference< XInterface > xRoadmapItem;
419 [ # # ]: 0 : rEvent.Element >>= xRoadmapItem;
420 [ # # ]: 0 : Reference< XPropertySet > xRoadmapPropertySet( xRoadmapItem, UNO_QUERY );
421 [ # # ]: 0 : if ( xRoadmapPropertySet.is() )
422 [ # # ][ # # ]: 0 : xRoadmapPropertySet->addPropertyChangeListener( rtl::OUString(), this );
[ # # ]
423 : :
424 [ # # ][ # # ]: 0 : Reference< XContainerListener > xPeer(getPeer(), UNO_QUERY);
425 [ # # ]: 0 : if ( xPeer.is() )
426 : : {
427 [ # # ][ # # ]: 0 : xPeer->elementInserted( rEvent );
428 [ # # ]: 0 : Reference < XPropertySet > xPropertySet( xPeer, UNO_QUERY );
429 [ # # ]: 0 : if ( xPropertySet.is() )
430 [ # # ][ # # ]: 0 : xPropertySet->addPropertyChangeListener( rtl::OUString(), this );
[ # # ]
431 : 0 : }
432 : 0 : }
433 : :
434 : :
435 : 0 : void UnoRoadmapControl::elementRemoved( const ContainerEvent& rEvent )throw(RuntimeException)
436 : : {
437 [ # # ][ # # ]: 0 : Reference< XContainerListener > xPeer(getPeer(), UNO_QUERY);
438 [ # # ]: 0 : if ( xPeer.is() )
439 [ # # ][ # # ]: 0 : xPeer->elementRemoved( rEvent );
440 : 0 : Reference< XInterface > xRoadmapItem;
441 [ # # ]: 0 : rEvent.Element >>= xRoadmapItem;
442 [ # # ]: 0 : Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY );
443 [ # # ]: 0 : if ( xPropertySet.is() )
444 [ # # ][ # # ]: 0 : xPropertySet->removePropertyChangeListener( rtl::OUString(), this );
[ # # ]
445 : 0 : }
446 : :
447 : :
448 : 0 : void UnoRoadmapControl::elementReplaced( const ContainerEvent& rEvent )throw(RuntimeException)
449 : : {
450 [ # # ][ # # ]: 0 : Reference< XContainerListener > xPeer(getPeer(), UNO_QUERY);
451 [ # # ]: 0 : if ( xPeer.is() )
452 [ # # ][ # # ]: 0 : xPeer->elementReplaced( rEvent );
453 : 0 : }
454 : :
455 : :
456 : 0 : void SAL_CALL UnoRoadmapControl::itemStateChanged( const ItemEvent& rEvent ) throw (RuntimeException)
457 : : {
458 : 0 : sal_Int16 CurItemIndex = sal::static_int_cast< sal_Int16 >(rEvent.ItemId);
459 : 0 : Any aAny;
460 [ # # ]: 0 : aAny <<= CurItemIndex;
461 [ # # ][ # # ]: 0 : Reference< XControlModel > xModel( getModel( ), UNO_QUERY );
462 [ # # ]: 0 : Reference< XPropertySet > xPropertySet( xModel, UNO_QUERY );
463 [ # # ][ # # ]: 0 : xPropertySet->setPropertyValue( GetPropertyName( BASEPROPERTY_CURRENTITEMID ), aAny );
[ # # ]
464 [ # # ][ # # ]: 0 : if ( maItemListeners.getLength() )
465 [ # # ]: 0 : maItemListeners.itemStateChanged( rEvent );
466 : 0 : }
467 : :
468 : :
469 : 0 : void SAL_CALL UnoRoadmapControl::addItemListener( const Reference< XItemListener >& l ) throw (RuntimeException)
470 : : {
471 : 0 : maItemListeners.addInterface( l );
472 [ # # ][ # # ]: 0 : if( getPeer().is() && maItemListeners.getLength() == 1 )
[ # # ][ # # ]
[ # # # # ]
[ # # ]
473 : : {
474 [ # # ][ # # ]: 0 : Reference < XItemEventBroadcaster > xRoadmap( getPeer(), UNO_QUERY );
475 [ # # ][ # # ]: 0 : xRoadmap->addItemListener( this );
[ # # ]
476 : : }
477 : 0 : }
478 : :
479 : :
480 : 0 : void SAL_CALL UnoRoadmapControl::removeItemListener( const Reference< XItemListener >& l ) throw (RuntimeException)
481 : : {
482 [ # # ][ # # ]: 0 : if( getPeer().is() && maItemListeners.getLength() == 1 )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
483 : : {
484 [ # # ][ # # ]: 0 : Reference < XItemEventBroadcaster > xRoadmap( getPeer(), UNO_QUERY );
485 [ # # ][ # # ]: 0 : xRoadmap->removeItemListener( this );
[ # # ]
486 : : }
487 : :
488 : 0 : maItemListeners.removeInterface( l );
489 : 0 : }
490 : :
491 : :
492 : 0 : void SAL_CALL UnoRoadmapControl::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
493 : : {
494 [ # # ][ # # ]: 0 : Reference< XPropertyChangeListener > xPeer(getPeer(), UNO_QUERY);
495 [ # # ]: 0 : if ( xPeer.is() )
496 [ # # ][ # # ]: 0 : xPeer->propertyChange( evt );
497 : 0 : }
498 : :
499 : : }
500 : :
501 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|