1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_framework.hxx"
26
27 //_________________________________________________________________________________________________________________
28 // my own includes
29 //_________________________________________________________________________________________________________________
30 #include <helper/uiconfigelementwrapperbase.hxx>
31 #include <general.h>
32 #include <properties.h>
33 #include <threadhelp/resetableguard.hxx>
34 #include <uielement/constitemcontainer.hxx>
35 #include <uielement/rootitemcontainer.hxx>
36
37 //_________________________________________________________________________________________________________________
38 // interface includes
39 //_________________________________________________________________________________________________________________
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
41 #include <com/sun/star/beans/PropertyValue.hpp>
42 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <com/sun/star/ui/XUIConfiguration.hpp>
44
45 //_________________________________________________________________________________________________________________
46 // includes of other projects
47 //_________________________________________________________________________________________________________________
48 #include <vcl/svapp.hxx>
49 #include <rtl/logfile.hxx>
50
51 const int UIELEMENT_PROPHANDLE_CONFIGSOURCE = 1;
52 const int UIELEMENT_PROPHANDLE_FRAME = 2;
53 const int UIELEMENT_PROPHANDLE_PERSISTENT = 3;
54 const int UIELEMENT_PROPHANDLE_RESOURCEURL = 4;
55 const int UIELEMENT_PROPHANDLE_TYPE = 5;
56 const int UIELEMENT_PROPHANDLE_XMENUBAR = 6;
57 const int UIELEMENT_PROPHANDLE_CONFIGLISTENER = 7;
58 const int UIELEMENT_PROPHANDLE_NOCLOSE = 8;
59 const int UIELEMENT_PROPCOUNT = 8;
60 const rtl::OUString UIELEMENT_PROPNAME_CONFIGLISTENER( RTL_CONSTASCII_USTRINGPARAM( "ConfigListener" ));
61 const rtl::OUString UIELEMENT_PROPNAME_CONFIGSOURCE( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
62 const rtl::OUString UIELEMENT_PROPNAME_FRAME( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
63 const rtl::OUString UIELEMENT_PROPNAME_PERSISTENT( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ));
64 const rtl::OUString UIELEMENT_PROPNAME_RESOURCEURL( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" ));
65 const rtl::OUString UIELEMENT_PROPNAME_TYPE( RTL_CONSTASCII_USTRINGPARAM( "Type" ));
66 const rtl::OUString UIELEMENT_PROPNAME_XMENUBAR( RTL_CONSTASCII_USTRINGPARAM( "XMenuBar" ));
67 const rtl::OUString UIELEMENT_PROPNAME_NOCLOSE( RTL_CONSTASCII_USTRINGPARAM( "NoClose" ));
68
69 //using namespace rtl;
70 using namespace com::sun::star::beans;
71 using namespace com::sun::star::uno;
72 using namespace com::sun::star::frame;
73 using namespace com::sun::star::lang;
74 using namespace com::sun::star::container;
75 using namespace ::com::sun::star::ui;
76
77 namespace framework
78 {
79
80 //*****************************************************************************************************************
81 // XInterface, XTypeProvider
82 //*****************************************************************************************************************
DEFINE_XINTERFACE_10(UIConfigElementWrapperBase,OWeakObject,DIRECT_INTERFACE (::com::sun::star::lang::XTypeProvider),DIRECT_INTERFACE (::com::sun::star::ui::XUIElement),DIRECT_INTERFACE (::com::sun::star::ui::XUIElementSettings),DIRECT_INTERFACE (::com::sun::star::beans::XMultiPropertySet),DIRECT_INTERFACE (::com::sun::star::beans::XFastPropertySet),DIRECT_INTERFACE (::com::sun::star::beans::XPropertySet),DIRECT_INTERFACE (::com::sun::star::lang::XInitialization),DIRECT_INTERFACE (::com::sun::star::lang::XComponent),DIRECT_INTERFACE (::com::sun::star::util::XUpdatable),DIRECT_INTERFACE (::com::sun::star::ui::XUIConfigurationListener))83 DEFINE_XINTERFACE_10 ( UIConfigElementWrapperBase ,
84 OWeakObject ,
85 DIRECT_INTERFACE( ::com::sun::star::lang::XTypeProvider ),
86 DIRECT_INTERFACE( ::com::sun::star::ui::XUIElement ),
87 DIRECT_INTERFACE( ::com::sun::star::ui::XUIElementSettings ),
88 DIRECT_INTERFACE( ::com::sun::star::beans::XMultiPropertySet ),
89 DIRECT_INTERFACE( ::com::sun::star::beans::XFastPropertySet ),
90 DIRECT_INTERFACE( ::com::sun::star::beans::XPropertySet ),
91 DIRECT_INTERFACE( ::com::sun::star::lang::XInitialization ),
92 DIRECT_INTERFACE( ::com::sun::star::lang::XComponent ),
93 DIRECT_INTERFACE( ::com::sun::star::util::XUpdatable ),
94 DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationListener )
95 )
96
97 DEFINE_XTYPEPROVIDER_10 ( UIConfigElementWrapperBase ,
98 ::com::sun::star::lang::XTypeProvider ,
99 ::com::sun::star::ui::XUIElement ,
100 ::com::sun::star::ui::XUIElementSettings ,
101 ::com::sun::star::beans::XMultiPropertySet ,
102 ::com::sun::star::beans::XFastPropertySet ,
103 ::com::sun::star::beans::XPropertySet ,
104 ::com::sun::star::lang::XInitialization ,
105 ::com::sun::star::lang::XComponent ,
106 ::com::sun::star::util::XUpdatable ,
107 ::com::sun::star::ui::XUIConfigurationListener
108 )
109
110 UIConfigElementWrapperBase::UIConfigElementWrapperBase( sal_Int16 nType,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory )
111 : ThreadHelpBase ( &Application::GetSolarMutex() )
112 , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() )
113 , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
114 , ::cppu::OWeakObject ( )
115 , m_nType ( nType )
116 , m_bPersistent ( sal_True )
117 , m_bInitialized ( sal_False )
118 , m_bConfigListener ( sal_False )
119 , m_bConfigListening ( sal_False )
120 , m_bDisposed ( sal_False )
121 , m_bNoClose ( sal_False )
122 , m_xServiceFactory ( _xServiceFactory )
123 , m_aListenerContainer ( m_aLock.getShareableOslMutex() )
124 {
125 }
126
~UIConfigElementWrapperBase()127 UIConfigElementWrapperBase::~UIConfigElementWrapperBase()
128 {
129 }
130
131 // XComponent
dispose()132 void SAL_CALL UIConfigElementWrapperBase::dispose()
133 {
134 // must be implemented by derived class
135 ResetableGuard aLock( m_aLock );
136 m_bDisposed = sal_True;
137 }
138
addEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & xListener)139 void SAL_CALL UIConfigElementWrapperBase::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )
140 {
141 m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), xListener );
142 }
143
removeEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & aListener)144 void SAL_CALL UIConfigElementWrapperBase::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener )
145 {
146 m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), aListener );
147 }
148
149 // XEventListener
disposing(const EventObject &)150 void SAL_CALL UIConfigElementWrapperBase::disposing( const EventObject& )
151 {
152 ResetableGuard aLock( m_aLock );
153 m_xConfigSource.clear();
154 }
155
initialize(const Sequence<Any> & aArguments)156 void SAL_CALL UIConfigElementWrapperBase::initialize( const Sequence< Any >& aArguments )
157 {
158 ResetableGuard aLock( m_aLock );
159
160 if ( !m_bInitialized )
161 {
162 for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ )
163 {
164 PropertyValue aPropValue;
165 if ( aArguments[n] >>= aPropValue )
166 {
167 if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_CONFIGSOURCE ))
168 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_CONFIGSOURCE, aPropValue.Value );
169 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_FRAME ))
170 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_FRAME, aPropValue.Value );
171 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_PERSISTENT ))
172 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_PERSISTENT, aPropValue.Value );
173 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_RESOURCEURL ))
174 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_RESOURCEURL, aPropValue.Value );
175 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_TYPE ))
176 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_TYPE, aPropValue.Value );
177 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_CONFIGLISTENER ))
178 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_CONFIGLISTENER, aPropValue.Value );
179 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_NOCLOSE ))
180 setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_NOCLOSE, aPropValue.Value );
181 }
182 }
183
184 m_bInitialized = sal_True;
185 }
186 }
187
188 // XUpdatable
update()189 void SAL_CALL UIConfigElementWrapperBase::update()
190 {
191 // can be implemented by derived class
192 }
193
elementInserted(const::com::sun::star::ui::ConfigurationEvent &)194 void SAL_CALL UIConfigElementWrapperBase::elementInserted( const ::com::sun::star::ui::ConfigurationEvent& )
195 {
196 // can be implemented by derived class
197 }
198
elementRemoved(const::com::sun::star::ui::ConfigurationEvent &)199 void SAL_CALL UIConfigElementWrapperBase::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& )
200 {
201 // can be implemented by derived class
202 }
203
elementReplaced(const::com::sun::star::ui::ConfigurationEvent &)204 void SAL_CALL UIConfigElementWrapperBase::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& )
205 {
206 // can be implemented by derived class
207 }
208
209 // XPropertySet helper
convertFastPropertyValue(Any & aConvertedValue,Any & aOldValue,sal_Int32 nHandle,const Any & aValue)210 sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any& aConvertedValue ,
211 Any& aOldValue ,
212 sal_Int32 nHandle ,
213 const Any& aValue )
214 {
215 // Initialize state with sal_False !!!
216 // (Handle can be invalid)
217 sal_Bool bReturn = sal_False;
218
219 switch( nHandle )
220 {
221 case UIELEMENT_PROPHANDLE_CONFIGLISTENER:
222 bReturn = PropHelper::willPropertyBeChanged(
223 com::sun::star::uno::makeAny(m_bConfigListener),
224 aValue,
225 aOldValue,
226 aConvertedValue);
227 break;
228
229 case UIELEMENT_PROPHANDLE_CONFIGSOURCE:
230 bReturn = PropHelper::willPropertyBeChanged(
231 com::sun::star::uno::makeAny(m_xConfigSource),
232 aValue,
233 aOldValue,
234 aConvertedValue);
235 break;
236
237 case UIELEMENT_PROPHANDLE_FRAME:
238 {
239 Reference< XFrame > xFrame( m_xWeakFrame );
240 bReturn = PropHelper::willPropertyBeChanged(
241 com::sun::star::uno::makeAny(xFrame),
242 aValue,
243 aOldValue,
244 aConvertedValue);
245 }
246 break;
247
248 case UIELEMENT_PROPHANDLE_PERSISTENT:
249 bReturn = PropHelper::willPropertyBeChanged(
250 com::sun::star::uno::makeAny(m_bPersistent),
251 aValue,
252 aOldValue,
253 aConvertedValue);
254 break;
255
256 case UIELEMENT_PROPHANDLE_RESOURCEURL:
257 bReturn = PropHelper::willPropertyBeChanged(
258 com::sun::star::uno::makeAny(m_aResourceURL),
259 aValue,
260 aOldValue,
261 aConvertedValue);
262 break;
263
264 case UIELEMENT_PROPHANDLE_TYPE :
265 bReturn = PropHelper::willPropertyBeChanged(
266 com::sun::star::uno::makeAny(m_nType),
267 aValue,
268 aOldValue,
269 aConvertedValue);
270 break;
271
272 case UIELEMENT_PROPHANDLE_XMENUBAR :
273 bReturn = PropHelper::willPropertyBeChanged(
274 com::sun::star::uno::makeAny(m_xMenuBar),
275 aValue,
276 aOldValue,
277 aConvertedValue);
278 break;
279
280 case UIELEMENT_PROPHANDLE_NOCLOSE:
281 bReturn = PropHelper::willPropertyBeChanged(
282 com::sun::star::uno::makeAny(m_bNoClose),
283 aValue,
284 aOldValue,
285 aConvertedValue);
286 break;
287 }
288
289 // Return state of operation.
290 return bReturn ;
291 }
292
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const com::sun::star::uno::Any & aValue)293 void SAL_CALL UIConfigElementWrapperBase::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
294 const com::sun::star::uno::Any& aValue )
295 {
296 switch( nHandle )
297 {
298 case UIELEMENT_PROPHANDLE_CONFIGLISTENER:
299 {
300 bool bBool( m_bConfigListener );
301 aValue >>= bBool;
302 if ( m_bConfigListener != bBool )
303 {
304 if ( m_bConfigListening )
305 {
306 if ( m_xConfigSource.is() && !bBool )
307 {
308 try
309 {
310 Reference< XUIConfiguration > xUIConfig( m_xConfigSource, UNO_QUERY );
311 if ( xUIConfig.is() )
312 {
313 xUIConfig->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
314 m_bConfigListening = sal_False;
315 }
316 }
317 catch ( Exception& )
318 {
319 }
320 }
321 }
322 else
323 {
324 if ( m_xConfigSource.is() && bBool )
325 {
326 try
327 {
328 Reference< XUIConfiguration > xUIConfig( m_xConfigSource, UNO_QUERY );
329 if ( xUIConfig.is() )
330 {
331 xUIConfig->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
332 m_bConfigListening = sal_True;
333 }
334 }
335 catch ( Exception& )
336 {
337 }
338 }
339 }
340
341 m_bConfigListener = bBool;
342 }
343 }
344 break;
345 case UIELEMENT_PROPHANDLE_CONFIGSOURCE:
346 aValue >>= m_xConfigSource;
347 break;
348 case UIELEMENT_PROPHANDLE_FRAME:
349 {
350 Reference< XFrame > xFrame;
351
352 aValue >>= xFrame;
353 m_xWeakFrame = xFrame;
354 break;
355 }
356 case UIELEMENT_PROPHANDLE_PERSISTENT:
357 {
358 sal_Bool bBool( m_bPersistent );
359 aValue >>= bBool;
360 m_bPersistent = bBool;
361 break;
362 }
363 case UIELEMENT_PROPHANDLE_RESOURCEURL:
364 aValue >>= m_aResourceURL;
365 break;
366 case UIELEMENT_PROPHANDLE_TYPE:
367 aValue >>= m_nType;
368 break;
369 case UIELEMENT_PROPHANDLE_XMENUBAR:
370 aValue >>= m_xMenuBar;
371 break;
372 case UIELEMENT_PROPHANDLE_NOCLOSE:
373 {
374 sal_Bool bBool( m_bNoClose );
375 aValue >>= bBool;
376 m_bNoClose = bBool;
377 break;
378 }
379 }
380 }
381
getFastPropertyValue(com::sun::star::uno::Any & aValue,sal_Int32 nHandle) const382 void SAL_CALL UIConfigElementWrapperBase::getFastPropertyValue( com::sun::star::uno::Any& aValue ,
383 sal_Int32 nHandle ) const
384 {
385 switch( nHandle )
386 {
387 case UIELEMENT_PROPHANDLE_CONFIGLISTENER:
388 aValue <<= m_bConfigListener;
389 break;
390 case UIELEMENT_PROPHANDLE_CONFIGSOURCE:
391 aValue <<= m_xConfigSource;
392 break;
393 case UIELEMENT_PROPHANDLE_FRAME:
394 {
395 Reference< XFrame > xFrame( m_xWeakFrame );
396 aValue <<= xFrame;
397 break;
398 }
399 case UIELEMENT_PROPHANDLE_PERSISTENT:
400 aValue <<= m_bPersistent;
401 break;
402 case UIELEMENT_PROPHANDLE_RESOURCEURL:
403 aValue <<= m_aResourceURL;
404 break;
405 case UIELEMENT_PROPHANDLE_TYPE:
406 aValue <<= m_nType;
407 break;
408 case UIELEMENT_PROPHANDLE_XMENUBAR:
409 aValue <<= m_xMenuBar;
410 break;
411 case UIELEMENT_PROPHANDLE_NOCLOSE:
412 aValue <<= m_bNoClose;
413 break;
414 }
415 }
416
getInfoHelper()417 ::cppu::IPropertyArrayHelper& SAL_CALL UIConfigElementWrapperBase::getInfoHelper()
418 {
419 // Optimize this method !
420 // We initialize a static variable only one time. And we don't must use a mutex at every call!
421 // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
422 static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;
423
424 if( pInfoHelper == NULL )
425 {
426 // Ready for multithreading
427 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
428
429 // Control this pointer again, another instance can be faster then these!
430 if( pInfoHelper == NULL )
431 {
432 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
433 // "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable.
434 // "sal_True" say: Table is sorted by name.
435 static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
436 pInfoHelper = &aInfoHelper;
437 }
438 }
439
440 return(*pInfoHelper);
441 }
442
getPropertySetInfo()443 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL UIConfigElementWrapperBase::getPropertySetInfo()
444 {
445 // Optimize this method !
446 // We initialize a static variable only one time. And we don't must use a mutex at every call!
447 // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
448 static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >* pInfo = NULL;
449
450 if( pInfo == NULL )
451 {
452 // Ready for multithreading
453 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
454 // Control this pointer again, another instance can be faster then these!
455 if( pInfo == NULL )
456 {
457 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
458 // (Use method "getInfoHelper()".)
459 static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
460 pInfo = &xInfo;
461 }
462 }
463
464 return (*pInfo);
465 }
466
impl_getStaticPropertyDescriptor()467 const com::sun::star::uno::Sequence< com::sun::star::beans::Property > UIConfigElementWrapperBase::impl_getStaticPropertyDescriptor()
468 {
469 // Create a new static property array to initialize sequence!
470 // Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
471 // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
472 // It's necessary for methods of OPropertySetHelper.
473 // ATTENTION:
474 // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
475
476 static const com::sun::star::beans::Property pProperties[] =
477 {
478 com::sun::star::beans::Property( UIELEMENT_PROPNAME_CONFIGLISTENER, UIELEMENT_PROPHANDLE_CONFIGLISTENER , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ),
479 com::sun::star::beans::Property( UIELEMENT_PROPNAME_CONFIGSOURCE , UIELEMENT_PROPHANDLE_CONFIGSOURCE , ::getCppuType((const Reference< ::com::sun::star::ui::XUIConfigurationManager >*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ),
480 com::sun::star::beans::Property( UIELEMENT_PROPNAME_FRAME , UIELEMENT_PROPHANDLE_FRAME , ::getCppuType((const Reference< com::sun::star::frame::XFrame >*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY ),
481 com::sun::star::beans::Property( UIELEMENT_PROPNAME_NOCLOSE , UIELEMENT_PROPHANDLE_NOCLOSE , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ),
482 com::sun::star::beans::Property( UIELEMENT_PROPNAME_PERSISTENT , UIELEMENT_PROPHANDLE_PERSISTENT , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ),
483 com::sun::star::beans::Property( UIELEMENT_PROPNAME_RESOURCEURL , UIELEMENT_PROPHANDLE_RESOURCEURL , ::getCppuType((const ::rtl::OUString*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY ),
484 com::sun::star::beans::Property( UIELEMENT_PROPNAME_TYPE , UIELEMENT_PROPHANDLE_TYPE , ::getCppuType((const ::rtl::OUString*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY ),
485 com::sun::star::beans::Property( UIELEMENT_PROPNAME_XMENUBAR , UIELEMENT_PROPHANDLE_XMENUBAR , ::getCppuType((const Reference< com::sun::star::awt::XMenuBar >*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT | com::sun::star::beans::PropertyAttribute::READONLY )
486 };
487 // Use it to initialize sequence!
488 static const com::sun::star::uno::Sequence< com::sun::star::beans::Property > lPropertyDescriptor( pProperties, UIELEMENT_PROPCOUNT );
489 // Return static "PropertyDescriptor"
490 return lPropertyDescriptor;
491 }
setSettings(const Reference<XIndexAccess> & xSettings)492 void SAL_CALL UIConfigElementWrapperBase::setSettings( const Reference< XIndexAccess >& xSettings )
493 {
494 ResetableGuard aLock( m_aLock );
495
496 //if ( m_bDisposed )
497 // throw DisposedException();
498
499 if ( xSettings.is() )
500 {
501 // Create a copy of the data if the container is not const
502 Reference< XIndexReplace > xReplace( xSettings, UNO_QUERY );
503 if ( xReplace.is() )
504 m_xConfigData = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xSettings ) ), UNO_QUERY );
505 else
506 m_xConfigData = xSettings;
507
508 if ( m_xConfigSource.is() && m_bPersistent )
509 {
510 ::rtl::OUString aResourceURL( m_aResourceURL );
511 Reference< XUIConfigurationManager > xUICfgMgr( m_xConfigSource );
512
513 aLock.unlock();
514
515 try
516 {
517 xUICfgMgr->replaceSettings( aResourceURL, m_xConfigData );
518 }
519 catch( NoSuchElementException& )
520 {
521 }
522 }
523 else if ( !m_bPersistent )
524 {
525 // Transient menubar => Fill menubar with new data
526 impl_fillNewData();
527 }
528 }
529 }
impl_fillNewData()530 void UIConfigElementWrapperBase::impl_fillNewData()
531 {
532 }
getSettings(sal_Bool bWriteable)533 Reference< XIndexAccess > SAL_CALL UIConfigElementWrapperBase::getSettings( sal_Bool bWriteable )
534 {
535 ResetableGuard aLock( m_aLock );
536
537 //if ( m_bDisposed )
538 // throw DisposedException();
539
540 if ( bWriteable )
541 return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( m_xConfigData ) ), UNO_QUERY );
542
543 return m_xConfigData;
544 }
545
getFrame()546 Reference< XFrame > SAL_CALL UIConfigElementWrapperBase::getFrame()
547 {
548 ResetableGuard aLock( m_aLock );
549 Reference< XFrame > xFrame( m_xWeakFrame );
550 return xFrame;
551 }
552
getResourceURL()553 ::rtl::OUString SAL_CALL UIConfigElementWrapperBase::getResourceURL()
554 {
555 ResetableGuard aLock( m_aLock );
556 return m_aResourceURL;
557 }
558
getType()559 ::sal_Int16 SAL_CALL UIConfigElementWrapperBase::getType()
560 {
561 ResetableGuard aLock( m_aLock );
562 return m_nType;
563 }
564
565 }
566