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 //*****************************************************************************************************************
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 
127 UIConfigElementWrapperBase::~UIConfigElementWrapperBase()
128 {
129 }
130 
131 // XComponent
132 void SAL_CALL UIConfigElementWrapperBase::dispose() throw (::com::sun::star::uno::RuntimeException)
133 {
134     // must be implemented by derived class
135     ResetableGuard aLock( m_aLock );
136     m_bDisposed = sal_True;
137 }
138 
139 void SAL_CALL UIConfigElementWrapperBase::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
140 {
141     m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), xListener );
142 }
143 
144 void SAL_CALL UIConfigElementWrapperBase::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException)
145 {
146     m_aListenerContainer.removeInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >* ) NULL ), aListener );
147 }
148 
149 // XEventListener
150 void SAL_CALL UIConfigElementWrapperBase::disposing( const EventObject& )
151 throw( RuntimeException )
152 {
153     ResetableGuard aLock( m_aLock );
154     m_xConfigSource.clear();
155 }
156 
157 void SAL_CALL UIConfigElementWrapperBase::initialize( const Sequence< Any >& aArguments )
158 throw ( Exception, RuntimeException )
159 {
160     ResetableGuard aLock( m_aLock );
161 
162     if ( !m_bInitialized )
163     {
164         for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ )
165         {
166             PropertyValue aPropValue;
167             if ( aArguments[n] >>= aPropValue )
168             {
169                 if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_CONFIGSOURCE ))
170                     setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_CONFIGSOURCE, aPropValue.Value );
171                 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_FRAME ))
172                     setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_FRAME, aPropValue.Value );
173                 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_PERSISTENT ))
174                     setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_PERSISTENT, aPropValue.Value );
175                 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_RESOURCEURL ))
176                     setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_RESOURCEURL, aPropValue.Value );
177                 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_TYPE ))
178                     setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_TYPE, aPropValue.Value );
179                 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_CONFIGLISTENER ))
180                     setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_CONFIGLISTENER, aPropValue.Value );
181                 else if ( aPropValue.Name.equals( UIELEMENT_PROPNAME_NOCLOSE ))
182                     setFastPropertyValue_NoBroadcast( UIELEMENT_PROPHANDLE_NOCLOSE, aPropValue.Value );
183             }
184         }
185 
186         m_bInitialized = sal_True;
187     }
188 }
189 
190 // XUpdatable
191 void SAL_CALL UIConfigElementWrapperBase::update() throw (::com::sun::star::uno::RuntimeException)
192 {
193     // can be implemented by derived class
194 }
195 
196 void SAL_CALL UIConfigElementWrapperBase::elementInserted( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException)
197 {
198     // can be implemented by derived class
199 }
200 
201 void SAL_CALL UIConfigElementWrapperBase::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException)
202 {
203     // can be implemented by derived class
204 }
205 
206 void SAL_CALL UIConfigElementWrapperBase::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& ) throw (::com::sun::star::uno::RuntimeException)
207 {
208     // can be implemented by derived class
209 }
210 
211 // XPropertySet helper
212 sal_Bool SAL_CALL UIConfigElementWrapperBase::convertFastPropertyValue( Any&       aConvertedValue ,
213                                                                         Any&       aOldValue       ,
214                                                                         sal_Int32  nHandle         ,
215                                                                         const Any& aValue             ) throw( com::sun::star::lang::IllegalArgumentException )
216 {
217 	//	Initialize state with sal_False !!!
218 	//	(Handle can be invalid)
219 	sal_Bool bReturn = sal_False;
220 
221     switch( nHandle )
222 	{
223         case UIELEMENT_PROPHANDLE_CONFIGLISTENER:
224             bReturn = PropHelper::willPropertyBeChanged(
225                         com::sun::star::uno::makeAny(m_bConfigListener),
226                         aValue,
227                         aOldValue,
228                         aConvertedValue);
229             break;
230 
231         case UIELEMENT_PROPHANDLE_CONFIGSOURCE:
232             bReturn = PropHelper::willPropertyBeChanged(
233                         com::sun::star::uno::makeAny(m_xConfigSource),
234                         aValue,
235                         aOldValue,
236                         aConvertedValue);
237             break;
238 
239         case UIELEMENT_PROPHANDLE_FRAME:
240         {
241             Reference< XFrame > xFrame( m_xWeakFrame );
242             bReturn = PropHelper::willPropertyBeChanged(
243                         com::sun::star::uno::makeAny(xFrame),
244                         aValue,
245                         aOldValue,
246                         aConvertedValue);
247         }
248         break;
249 
250         case UIELEMENT_PROPHANDLE_PERSISTENT:
251             bReturn = PropHelper::willPropertyBeChanged(
252                         com::sun::star::uno::makeAny(m_bPersistent),
253                         aValue,
254                         aOldValue,
255                         aConvertedValue);
256             break;
257 
258         case UIELEMENT_PROPHANDLE_RESOURCEURL:
259             bReturn = PropHelper::willPropertyBeChanged(
260                         com::sun::star::uno::makeAny(m_aResourceURL),
261                         aValue,
262                         aOldValue,
263                         aConvertedValue);
264             break;
265 
266         case UIELEMENT_PROPHANDLE_TYPE :
267             bReturn = PropHelper::willPropertyBeChanged(
268                         com::sun::star::uno::makeAny(m_nType),
269                         aValue,
270                         aOldValue,
271                         aConvertedValue);
272                 break;
273 
274         case UIELEMENT_PROPHANDLE_XMENUBAR :
275             bReturn = PropHelper::willPropertyBeChanged(
276                         com::sun::star::uno::makeAny(m_xMenuBar),
277                         aValue,
278                         aOldValue,
279                         aConvertedValue);
280                 break;
281 
282         case UIELEMENT_PROPHANDLE_NOCLOSE:
283             bReturn = PropHelper::willPropertyBeChanged(
284                         com::sun::star::uno::makeAny(m_bNoClose),
285                         aValue,
286                         aOldValue,
287                         aConvertedValue);
288                 break;
289 	}
290 
291 	// Return state of operation.
292 	return bReturn ;
293 }
294 
295 void SAL_CALL UIConfigElementWrapperBase::setFastPropertyValue_NoBroadcast(   sal_Int32               nHandle ,
296                                                                         const com::sun::star::uno::Any&    aValue  ) throw( com::sun::star::uno::Exception )
297 {
298     switch( nHandle )
299 	{
300         case UIELEMENT_PROPHANDLE_CONFIGLISTENER:
301         {
302             bool bBool( m_bConfigListener );
303             aValue >>= bBool;
304             if ( m_bConfigListener != bBool )
305             {
306                 if ( m_bConfigListening )
307                 {
308                     if ( m_xConfigSource.is() && !bBool )
309                     {
310                         try
311                         {
312                             Reference< XUIConfiguration > xUIConfig( m_xConfigSource, UNO_QUERY );
313                             if ( xUIConfig.is() )
314                             {
315                                 xUIConfig->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
316                                 m_bConfigListening = sal_False;
317                             }
318                         }
319                         catch ( Exception& )
320                         {
321                         }
322                     }
323                 }
324                 else
325                 {
326                     if ( m_xConfigSource.is() && bBool )
327                     {
328                         try
329                         {
330                             Reference< XUIConfiguration > xUIConfig( m_xConfigSource, UNO_QUERY );
331                             if ( xUIConfig.is() )
332                             {
333                                 xUIConfig->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
334                                 m_bConfigListening = sal_True;
335                             }
336                         }
337                         catch ( Exception& )
338                         {
339                         }
340                     }
341                 }
342 
343                 m_bConfigListener = bBool;
344             }
345         }
346         break;
347         case UIELEMENT_PROPHANDLE_CONFIGSOURCE:
348             aValue >>= m_xConfigSource;
349             break;
350         case UIELEMENT_PROPHANDLE_FRAME:
351         {
352             Reference< XFrame > xFrame;
353 
354             aValue >>= xFrame;
355             m_xWeakFrame = xFrame;
356             break;
357         }
358         case UIELEMENT_PROPHANDLE_PERSISTENT:
359         {
360             sal_Bool bBool( m_bPersistent );
361             aValue >>= bBool;
362             m_bPersistent = bBool;
363             break;
364         }
365         case UIELEMENT_PROPHANDLE_RESOURCEURL:
366             aValue >>= m_aResourceURL;
367             break;
368         case UIELEMENT_PROPHANDLE_TYPE:
369             aValue >>= m_nType;
370             break;
371         case UIELEMENT_PROPHANDLE_XMENUBAR:
372             aValue >>= m_xMenuBar;
373             break;
374         case UIELEMENT_PROPHANDLE_NOCLOSE:
375         {
376             sal_Bool bBool( m_bNoClose );
377             aValue >>= bBool;
378             m_bNoClose = bBool;
379             break;
380         }
381 	}
382 }
383 
384 void SAL_CALL UIConfigElementWrapperBase::getFastPropertyValue( com::sun::star::uno::Any& aValue  ,
385                                                                 sal_Int32                 nHandle   ) const
386 {
387     switch( nHandle )
388 	{
389         case UIELEMENT_PROPHANDLE_CONFIGLISTENER:
390             aValue <<= m_bConfigListener;
391             break;
392         case UIELEMENT_PROPHANDLE_CONFIGSOURCE:
393             aValue <<= m_xConfigSource;
394             break;
395         case UIELEMENT_PROPHANDLE_FRAME:
396         {
397             Reference< XFrame > xFrame( m_xWeakFrame );
398             aValue <<= xFrame;
399             break;
400         }
401         case UIELEMENT_PROPHANDLE_PERSISTENT:
402             aValue <<= m_bPersistent;
403             break;
404         case UIELEMENT_PROPHANDLE_RESOURCEURL:
405             aValue <<= m_aResourceURL;
406             break;
407         case UIELEMENT_PROPHANDLE_TYPE:
408             aValue <<= m_nType;
409             break;
410         case UIELEMENT_PROPHANDLE_XMENUBAR:
411             aValue <<= m_xMenuBar;
412             break;
413         case UIELEMENT_PROPHANDLE_NOCLOSE:
414             aValue <<= m_bNoClose;
415             break;
416 	}
417 }
418 
419 ::cppu::IPropertyArrayHelper& SAL_CALL UIConfigElementWrapperBase::getInfoHelper()
420 {
421 	// Optimize this method !
422 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
423 	// For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
424     static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;
425 
426     if( pInfoHelper == NULL )
427 	{
428 		// Ready for multithreading
429         osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
430 
431 		// Control this pointer again, another instance can be faster then these!
432         if( pInfoHelper == NULL )
433 		{
434 			// Define static member to give structure of properties to baseclass "OPropertySetHelper".
435 			// "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
436 			// "sal_True" say: Table is sorted by name.
437             static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
438 			pInfoHelper = &aInfoHelper;
439 		}
440 	}
441 
442     return(*pInfoHelper);
443 }
444 
445 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL UIConfigElementWrapperBase::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException)
446 {
447 	// Optimize this method !
448 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
449 	// For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
450     static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >* pInfo = NULL;
451 
452     if( pInfo == NULL )
453 	{
454 		// Ready for multithreading
455 		osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
456 		// Control this pointer again, another instance can be faster then these!
457         if( pInfo == NULL )
458 		{
459 			// Create structure of propertysetinfo for baseclass "OPropertySetHelper".
460 			// (Use method "getInfoHelper()".)
461             static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
462 			pInfo = &xInfo;
463 		}
464 	}
465 
466 	return (*pInfo);
467 }
468 
469 const com::sun::star::uno::Sequence< com::sun::star::beans::Property > UIConfigElementWrapperBase::impl_getStaticPropertyDescriptor()
470 {
471 	// Create a new static property array to initialize sequence!
472 	// Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
473 	// Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
474 	// It's necessary for methods of OPropertySetHelper.
475 	// ATTENTION:
476     //      YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
477 
478     static const com::sun::star::beans::Property pProperties[] =
479 	{
480         com::sun::star::beans::Property( UIELEMENT_PROPNAME_CONFIGLISTENER, UIELEMENT_PROPHANDLE_CONFIGLISTENER , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT  ),
481         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  ),
482         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 ),
483         com::sun::star::beans::Property( UIELEMENT_PROPNAME_NOCLOSE       , UIELEMENT_PROPHANDLE_NOCLOSE        , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ),
484         com::sun::star::beans::Property( UIELEMENT_PROPNAME_PERSISTENT    , UIELEMENT_PROPHANDLE_PERSISTENT     , ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT  ),
485         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 ),
486         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 ),
487         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 )
488 	};
489 	// Use it to initialize sequence!
490     static const com::sun::star::uno::Sequence< com::sun::star::beans::Property > lPropertyDescriptor( pProperties, UIELEMENT_PROPCOUNT );
491 	// Return static "PropertyDescriptor"
492     return lPropertyDescriptor;
493 }
494 void SAL_CALL UIConfigElementWrapperBase::setSettings( const Reference< XIndexAccess >& xSettings ) throw ( RuntimeException )
495 {
496     ResetableGuard aLock( m_aLock );
497 
498     //if ( m_bDisposed )
499     //    throw DisposedException();
500 
501     if ( xSettings.is() )
502     {
503         // Create a copy of the data if the container is not const
504         Reference< XIndexReplace > xReplace( xSettings, UNO_QUERY );
505         if ( xReplace.is() )
506             m_xConfigData = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xSettings ) ), UNO_QUERY );
507         else
508             m_xConfigData = xSettings;
509 
510         if ( m_xConfigSource.is() && m_bPersistent )
511         {
512             ::rtl::OUString aResourceURL( m_aResourceURL );
513             Reference< XUIConfigurationManager > xUICfgMgr( m_xConfigSource );
514 
515             aLock.unlock();
516 
517             try
518             {
519                 xUICfgMgr->replaceSettings( aResourceURL, m_xConfigData );
520             }
521             catch( NoSuchElementException& )
522             {
523             }
524         }
525         else if ( !m_bPersistent )
526         {
527             // Transient menubar => Fill menubar with new data
528             impl_fillNewData();
529         }
530     }
531 }
532 void UIConfigElementWrapperBase::impl_fillNewData()
533 {
534 }
535 Reference< XIndexAccess > SAL_CALL UIConfigElementWrapperBase::getSettings( sal_Bool bWriteable ) throw ( RuntimeException )
536 {
537     ResetableGuard aLock( m_aLock );
538 
539     //if ( m_bDisposed )
540     //    throw DisposedException();
541 
542     if ( bWriteable )
543         return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( m_xConfigData ) ), UNO_QUERY );
544 
545     return m_xConfigData;
546 }
547 
548 Reference< XFrame > SAL_CALL UIConfigElementWrapperBase::getFrame() throw (RuntimeException)
549 {
550     ResetableGuard aLock( m_aLock );
551     Reference< XFrame > xFrame( m_xWeakFrame );
552     return xFrame;
553 }
554 
555 ::rtl::OUString SAL_CALL UIConfigElementWrapperBase::getResourceURL() throw (RuntimeException)
556 {
557     ResetableGuard aLock( m_aLock );
558     return m_aResourceURL;
559 }
560 
561 ::sal_Int16 SAL_CALL UIConfigElementWrapperBase::getType() throw (RuntimeException)
562 {
563     ResetableGuard aLock( m_aLock );
564     return m_nType;
565 }
566 
567 }
568