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