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