LCOV - code coverage report
Current view: top level - libreoffice/framework/source/helper - uiconfigelementwrapperbase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 70 197 35.5 %
Date: 2012-12-27 Functions: 10 28 35.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10