LCOV - code coverage report
Current view: top level - framework/source/uiconfiguration - moduleuiconfigurationmanager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 518 773 67.0 %
Date: 2012-08-25 Functions: 43 51 84.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 547 1585 34.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <uiconfiguration/moduleuiconfigurationmanager.hxx>
      30                 :            : #include <threadhelp/resetableguard.hxx>
      31                 :            : #include <services.h>
      32                 :            : #include <uielement/constitemcontainer.hxx>
      33                 :            : #include <uielement/rootitemcontainer.hxx>
      34                 :            : #include <uielement/uielementtypenames.hxx>
      35                 :            : #include <framework/menuconfiguration.hxx>
      36                 :            : #include <framework/toolboxconfiguration.hxx>
      37                 :            : 
      38                 :            : #include <framework/statusbarconfiguration.hxx>
      39                 :            : 
      40                 :            : #include <com/sun/star/ui/UIElementType.hpp>
      41                 :            : #include <com/sun/star/ui/ConfigurationEvent.hpp>
      42                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      43                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      44                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      45                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      46                 :            : #include <com/sun/star/io/XStream.hpp>
      47                 :            : 
      48                 :            : #include <vcl/svapp.hxx>
      49                 :            : #include <rtl/ustrbuf.hxx>
      50                 :            : #include <comphelper/sequenceashashmap.hxx>
      51                 :            : 
      52                 :            : //_________________________________________________________________________________________________________________
      53                 :            : //  namespaces
      54                 :            : //_________________________________________________________________________________________________________________
      55                 :            : 
      56                 :            : using rtl::OUString;
      57                 :            : using namespace com::sun::star::uno;
      58                 :            : using namespace com::sun::star::io;
      59                 :            : using namespace com::sun::star::embed;
      60                 :            : using namespace com::sun::star::lang;
      61                 :            : using namespace com::sun::star::container;
      62                 :            : using namespace com::sun::star::beans;
      63                 :            : using namespace ::com::sun::star::ui;
      64                 :            : 
      65                 :            : namespace framework
      66                 :            : {
      67                 :            : 
      68                 :            : //*****************************************************************************************************************
      69                 :            : //  XInterface, XTypeProvider, XServiceInfo
      70                 :            : //*****************************************************************************************************************
      71 [ +  + ][ +  - ]:     243511 : DEFINE_XINTERFACE_8                    (    ModuleUIConfigurationManager                                                    ,
      72                 :            :                                             OWeakObject                                                                     ,
      73                 :            :                                             DIRECT_INTERFACE( css::lang::XTypeProvider                                      ),
      74                 :            :                                             DIRECT_INTERFACE( css::lang::XServiceInfo                                       ),
      75                 :            :                                             DIRECT_INTERFACE( css::lang::XComponent                                         ),
      76                 :            :                                             DIRECT_INTERFACE( css::lang::XInitialization                                    ),
      77                 :            :                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfiguration                  ),
      78                 :            :                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationManager           ),
      79                 :            :                                             DIRECT_INTERFACE( ::com::sun::star::ui::XModuleUIConfigurationManager     ),
      80                 :            :                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationPersistence       )
      81                 :            :                                         )
      82                 :            : 
      83 [ #  # ][ #  # ]:          0 : DEFINE_XTYPEPROVIDER_8                  (   ModuleUIConfigurationManager                                ,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      84                 :            :                                             css::lang::XTypeProvider                                    ,
      85                 :            :                                             css::lang::XServiceInfo                                     ,
      86                 :            :                                             css::lang::XComponent                                       ,
      87                 :            :                                             css::lang::XInitialization                                  ,
      88                 :            :                                             ::com::sun::star::ui::XUIConfiguration                ,
      89                 :            :                                             ::com::sun::star::ui::XUIConfigurationManager         ,
      90                 :            :                                             ::com::sun::star::ui::XModuleUIConfigurationManager   ,
      91                 :            :                                             ::com::sun::star::ui::XUIConfigurationPersistence
      92                 :            :                                         )
      93                 :            : 
      94 [ +  - ][ +  - ]:       2293 : DEFINE_XSERVICEINFO_MULTISERVICE        (   ModuleUIConfigurationManager                    ,
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
      95                 :            :                                             ::cppu::OWeakObject                             ,
      96                 :            :                                             SERVICENAME_MODULEUICONFIGURATIONMANAGER        ,
      97                 :            :                                             IMPLEMENTATIONNAME_MODULEUICONFIGURATIONMANAGER
      98                 :            :                                         )
      99                 :            : 
     100                 :        149 : DEFINE_INIT_SERVICE                     (   ModuleUIConfigurationManager, {} )
     101                 :            : 
     102                 :            : 
     103                 :            : // important: The order and position of the elements must match the constant
     104                 :            : // definition of "::com::sun::star::ui::UIElementType"
     105                 :            : static const char* UIELEMENTTYPENAMES[] =
     106                 :            : {
     107                 :            :     "",  // Dummy value for unknown!
     108                 :            :     UIELEMENTTYPE_MENUBAR_NAME,
     109                 :            :     UIELEMENTTYPE_POPUPMENU_NAME,
     110                 :            :     UIELEMENTTYPE_TOOLBAR_NAME,
     111                 :            :     UIELEMENTTYPE_STATUSBAR_NAME,
     112                 :            :     UIELEMENTTYPE_FLOATINGWINDOW_NAME,
     113                 :            :     UIELEMENTTYPE_PROGRESSBAR_NAME,
     114                 :            :     UIELEMENTTYPE_TOOLPANEL_NAME
     115                 :            : };
     116                 :            : 
     117                 :            : static const char       RESOURCEURL_PREFIX[] = "private:resource/";
     118                 :            : static const sal_Int32  RESOURCEURL_PREFIX_SIZE = 17;
     119                 :            : static const char       RESOURCEURL_CUSTOM_ELEMENT[] = "custom_";
     120                 :            : 
     121                 :      14358 : static sal_Int16 RetrieveTypeFromResourceURL( const rtl::OUString& aResourceURL )
     122                 :            : {
     123                 :            : 
     124   [ +  -  +  - ]:      28716 :     if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) &&
                 [ +  - ]
     125                 :      14358 :         ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
     126                 :            :     {
     127                 :      14358 :         OUString    aTmpStr     = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE );
     128                 :      14358 :         sal_Int32   nIndex      = aTmpStr.indexOf( '/' );
     129 [ +  - ][ +  - ]:      14358 :         if (( nIndex > 0 ) &&  ( aTmpStr.getLength() > nIndex ))
                 [ +  - ]
     130                 :            :         {
     131                 :      14358 :             OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
     132         [ +  - ]:      53998 :             for ( int i = 0; i < UIElementType::COUNT; i++ )
     133                 :            :             {
     134         [ +  + ]:      53998 :                 if ( aTypeStr.equalsAscii( UIELEMENTTYPENAMES[i] ))
     135                 :      14358 :                     return sal_Int16( i );
     136         [ -  + ]:      14358 :             }
     137         [ -  + ]:      14358 :         }
     138                 :            :     }
     139                 :            : 
     140                 :      14358 :     return UIElementType::UNKNOWN;
     141                 :            : }
     142                 :            : 
     143                 :          8 : static OUString RetrieveNameFromResourceURL( const rtl::OUString& aResourceURL )
     144                 :            : {
     145   [ +  -  +  - ]:         16 :     if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) &&
                 [ +  - ]
     146                 :          8 :         ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
     147                 :            :     {
     148                 :          8 :         sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' );
     149 [ +  - ][ +  - ]:          8 :         if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength()))
                 [ +  - ]
     150                 :          8 :             return aResourceURL.copy( nIndex+1 );
     151                 :            :     }
     152                 :            : 
     153                 :          8 :     return OUString();
     154                 :            : }
     155                 :            : 
     156                 :       1787 : void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType )
     157                 :            : {
     158                 :            :     // preload list of element types on demand
     159         [ +  - ]:       1787 :     impl_preloadUIElementTypeList( LAYER_USERDEFINED, nElementType );
     160         [ +  - ]:       1787 :     impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
     161                 :            : 
     162                 :       1787 :     UIElementDataHashMap& rUserElements = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap;
     163         [ +  - ]:       1787 :     UIElementDataHashMap::const_iterator pUserIter = rUserElements.begin();
     164                 :            : 
     165                 :       1787 :     OUString aCustomUrlPrefix( RESOURCEURL_CUSTOM_ELEMENT );
     166 [ +  - ][ -  + ]:       1787 :     while ( pUserIter != rUserElements.end() )
     167                 :            :     {
     168         [ #  # ]:          0 :         sal_Int32 nIndex = pUserIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
     169         [ #  # ]:          0 :         if ( nIndex > RESOURCEURL_PREFIX_SIZE )
     170                 :            :         {
     171                 :            :             // Performance: Retrieve user interface name only for custom user interface elements.
     172                 :            :             // It's only used by them!
     173 [ #  # ][ #  # ]:          0 :             UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType );
     174         [ #  # ]:          0 :             if ( pDataSettings )
     175                 :            :             {
     176                 :            :                 // Retrieve user interface name from XPropertySet interface
     177                 :          0 :                 rtl::OUString aUIName;
     178         [ #  # ]:          0 :                 Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY );
     179         [ #  # ]:          0 :                 if ( xPropSet.is() )
     180                 :            :                 {
     181 [ #  # ][ #  # ]:          0 :                     Any a = xPropSet->getPropertyValue( m_aPropUIName );
     182                 :          0 :                     a >>= aUIName;
     183                 :            :                 }
     184                 :            : 
     185         [ #  # ]:          0 :                 UIElementInfo aInfo( pUserIter->second.aResourceURL, aUIName );
     186 [ #  # ][ #  # ]:          0 :                 aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo ));
     187                 :            :             }
     188                 :            :         }
     189                 :            :         else
     190                 :            :         {
     191                 :            :             // The user interface name for standard user interface elements is stored in the WindowState.xcu file
     192         [ #  # ]:          0 :             UIElementInfo aInfo( pUserIter->second.aResourceURL, OUString() );
     193 [ #  # ][ #  # ]:          0 :             aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo ));
     194                 :            :         }
     195                 :          0 :         ++pUserIter;
     196                 :            :     }
     197                 :            : 
     198                 :       1787 :     UIElementDataHashMap& rDefaultElements = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
     199         [ +  - ]:       1787 :     UIElementDataHashMap::const_iterator pDefIter = rDefaultElements.begin();
     200                 :            : 
     201 [ +  - ][ +  + ]:      45133 :     while ( pDefIter != rDefaultElements.end() )
     202                 :            :     {
     203 [ +  - ][ +  - ]:      43346 :         UIElementInfoHashMap::const_iterator pIterInfo = aUIElementInfoCollection.find( pDefIter->second.aResourceURL );
     204 [ +  - ][ +  - ]:      43346 :         if ( pIterInfo == aUIElementInfoCollection.end() )
     205                 :            :         {
     206         [ +  - ]:      43346 :             sal_Int32 nIndex = pDefIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
     207         [ -  + ]:      43346 :             if ( nIndex > RESOURCEURL_PREFIX_SIZE )
     208                 :            :             {
     209                 :            :                 // Performance: Retrieve user interface name only for custom user interface elements.
     210                 :            :                 // It's only used by them!
     211 [ #  # ][ #  # ]:          0 :                 UIElementData* pDataSettings = impl_findUIElementData( pDefIter->second.aResourceURL, nElementType );
     212         [ #  # ]:          0 :                 if ( pDataSettings )
     213                 :            :                 {
     214                 :            :                     // Retrieve user interface name from XPropertySet interface
     215                 :          0 :                     rtl::OUString aUIName;
     216         [ #  # ]:          0 :                     Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY );
     217         [ #  # ]:          0 :                     if ( xPropSet.is() )
     218                 :            :                     {
     219 [ #  # ][ #  # ]:          0 :                         Any a = xPropSet->getPropertyValue( m_aPropUIName );
     220                 :          0 :                         a >>= aUIName;
     221                 :            :                     }
     222                 :            : 
     223         [ #  # ]:          0 :                     UIElementInfo aInfo( pDefIter->second.aResourceURL, aUIName );
     224 [ #  # ][ #  # ]:          0 :                     aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pDefIter->second.aResourceURL, aInfo ));
     225                 :            :                 }
     226                 :            :             }
     227                 :            :             else
     228                 :            :             {
     229                 :            :                 // The user interface name for standard user interface elements is stored in the WindowState.xcu file
     230         [ +  - ]:      43346 :                 UIElementInfo aInfo( pDefIter->second.aResourceURL, OUString() );
     231 [ +  - ][ +  - ]:      43346 :                 aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pDefIter->second.aResourceURL, aInfo ));
     232                 :            :             }
     233                 :            :         }
     234                 :            : 
     235                 :      43346 :         ++pDefIter;
     236                 :       1787 :     }
     237                 :       1787 : }
     238                 :            : 
     239                 :      32292 : void ModuleUIConfigurationManager::impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType )
     240                 :            : {
     241                 :      32292 :     UIElementType& rElementTypeData = m_aUIElements[eLayer][nElementType];
     242                 :            : 
     243         [ +  + ]:      32292 :     if ( !rElementTypeData.bLoaded )
     244                 :            :     {
     245                 :      21573 :         Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
     246         [ +  + ]:      21573 :         if ( xElementTypeStorage.is() )
     247                 :            :         {
     248                 :      21544 :             rtl::OUStringBuffer aBuf( RESOURCEURL_PREFIX_SIZE );
     249         [ +  - ]:      21544 :             aBuf.appendAscii( RESOURCEURL_PREFIX );
     250         [ +  - ]:      21544 :             aBuf.appendAscii( UIELEMENTTYPENAMES[ nElementType ] );
     251         [ +  - ]:      21544 :             aBuf.appendAscii( "/" );
     252         [ +  - ]:      21544 :             OUString aResURLPrefix( aBuf.makeStringAndClear() );
     253                 :            : 
     254                 :      21544 :             UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap;
     255         [ +  - ]:      21544 :             Reference< XNameAccess > xNameAccess( xElementTypeStorage, UNO_QUERY );
     256 [ +  - ][ +  - ]:      21544 :             Sequence< OUString > aUIElementNames = xNameAccess->getElementNames();
     257         [ +  + ]:      25052 :             for ( sal_Int32 n = 0; n < aUIElementNames.getLength(); n++ )
     258                 :            :             {
     259         [ +  - ]:       3508 :                 UIElementData aUIElementData;
     260                 :            : 
     261                 :            :                 // Resource name must be without ".xml"
     262         [ +  - ]:       3508 :                 sal_Int32 nIndex = aUIElementNames[n].lastIndexOf( '.' );
     263 [ +  - ][ +  - ]:       3508 :                 if (( nIndex > 0 ) && ( nIndex < aUIElementNames[n].getLength() ))
         [ +  - ][ +  - ]
     264                 :            :                 {
     265         [ +  - ]:       3508 :                     OUString aExtension( aUIElementNames[n].copy( nIndex+1 ));
     266         [ +  - ]:       3508 :                     OUString aUIElementName( aUIElementNames[n].copy( 0, nIndex ));
     267                 :            : 
     268         [ +  - ]:       7016 :                     if (!aUIElementName.isEmpty() &&
           [ +  -  +  - ]
     269                 :       3508 :                         ( aExtension.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("xml"))))
     270                 :            :                     {
     271                 :       3508 :                         aUIElementData.aResourceURL = aResURLPrefix + aUIElementName;
     272         [ +  - ]:       3508 :                         aUIElementData.aName        = aUIElementNames[n];
     273                 :            : 
     274         [ -  + ]:       3508 :                         if ( eLayer == LAYER_USERDEFINED )
     275                 :            :                         {
     276                 :          0 :                             aUIElementData.bModified    = false;
     277                 :          0 :                             aUIElementData.bDefault     = false;
     278                 :          0 :                             aUIElementData.bDefaultNode = false;
     279                 :            :                         }
     280                 :            : 
     281                 :            :                         // Create boost::unordered_map entries for all user interface elements inside the storage. We don't load the
     282                 :            :                         // settings to speed up the process.
     283 [ +  - ][ +  - ]:       3508 :                         rHashMap.insert( UIElementDataHashMap::value_type( aUIElementData.aResourceURL, aUIElementData ));
                 [ +  - ]
     284                 :       3508 :                     }
     285                 :            :                 }
     286                 :       3508 :                 rElementTypeData.bLoaded = true;
     287 [ +  - ][ +  - ]:      25052 :             }
     288                 :      21573 :         }
     289                 :            :     }
     290                 :            : 
     291                 :      32292 : }
     292                 :            : 
     293                 :        412 : void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData )
     294                 :            : {
     295                 :        412 :     UIElementType& rElementTypeData = m_aUIElements[eLayer][nElementType];
     296                 :            : 
     297                 :        412 :     Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
     298 [ +  - ][ +  - ]:        412 :     if ( xElementTypeStorage.is() && !aUIElementData.aName.isEmpty() )
                 [ +  - ]
     299                 :            :     {
     300                 :            :         try
     301                 :            :         {
     302 [ +  - ][ +  - ]:        412 :             Reference< XStream > xStream = xElementTypeStorage->openStreamElement( aUIElementData.aName, ElementModes::READ );
     303 [ +  - ][ +  - ]:        412 :             Reference< XInputStream > xInputStream = xStream->getInputStream();
     304                 :            : 
     305         [ +  - ]:        412 :             if ( xInputStream.is() )
     306                 :            :             {
     307   [ -  +  -  +  :        412 :                 switch ( nElementType )
                +  -  - ]
     308                 :            :                 {
     309                 :            :                     case ::com::sun::star::ui::UIElementType::UNKNOWN:
     310                 :          0 :                     break;
     311                 :            : 
     312                 :            :                     case ::com::sun::star::ui::UIElementType::MENUBAR:
     313                 :            :                     {
     314                 :            :                         try
     315                 :            :                         {
     316         [ +  - ]:         96 :                             MenuConfiguration aMenuCfg( m_xServiceManager );
     317         [ +  - ]:         96 :                             Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
     318                 :         96 :                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xContainer );
     319         [ +  - ]:         96 :                             if ( pRootItemContainer )
     320 [ +  - ][ +  - ]:         96 :                                 aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     321                 :            :                             else
     322 [ #  # ][ #  # ]:          0 :                                 aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xContainer, sal_True ) ), UNO_QUERY );
         [ #  # ][ #  # ]
     323 [ +  - ][ #  # ]:         96 :                             return;
     324                 :            :                         }
     325         [ #  # ]:          0 :                         catch ( const ::com::sun::star::lang::WrappedTargetException& )
     326                 :            :                         {
     327                 :            :                         }
     328                 :            :                     }
     329                 :          0 :                     break;
     330                 :            : 
     331                 :            :                     case ::com::sun::star::ui::UIElementType::POPUPMENU:
     332                 :            :                     {
     333                 :          0 :                         break;
     334                 :            :                     }
     335                 :            : 
     336                 :            :                     case ::com::sun::star::ui::UIElementType::TOOLBAR:
     337                 :            :                     {
     338                 :            :                         try
     339                 :            :                         {
     340 [ +  - ][ +  - ]:        226 :                             Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
                 [ +  - ]
     341         [ +  - ]:        226 :                             ToolBoxConfiguration::LoadToolBox( m_xServiceManager, xInputStream, xIndexContainer );
     342                 :        226 :                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer );
     343 [ +  - ][ +  - ]:        226 :                             aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     344         [ #  # ]:        226 :                             return;
     345                 :            :                         }
     346         [ #  # ]:          0 :                         catch ( const ::com::sun::star::lang::WrappedTargetException& )
     347                 :            :                         {
     348                 :            :                         }
     349                 :            : 
     350                 :          0 :                         break;
     351                 :            :                     }
     352                 :            : 
     353                 :            :                     case ::com::sun::star::ui::UIElementType::STATUSBAR:
     354                 :            :                     {
     355                 :            :                         try
     356                 :            :                         {
     357 [ +  - ][ +  - ]:         90 :                             Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
                 [ +  - ]
     358         [ +  - ]:         90 :                             StatusBarConfiguration::LoadStatusBar( m_xServiceManager, xInputStream, xIndexContainer );
     359                 :         90 :                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer );
     360 [ +  - ][ +  - ]:         90 :                             aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     361         [ #  # ]:         90 :                             return;
     362                 :            :                         }
     363         [ #  # ]:          0 :                         catch ( const ::com::sun::star::lang::WrappedTargetException& )
     364                 :            :                         {
     365                 :            :                         }
     366                 :            : 
     367                 :          0 :                         break;
     368                 :            :                     }
     369                 :            : 
     370                 :            :                     case ::com::sun::star::ui::UIElementType::FLOATINGWINDOW:
     371                 :            :                     {
     372                 :          0 :                         break;
     373                 :            :                     }
     374                 :            :                 }
     375 [ +  - ][ -  + ]:        412 :             }
           [ #  #  #  #  
                      # ]
     376                 :            :         }
     377         [ #  # ]:          0 :         catch ( const ::com::sun::star::embed::InvalidStorageException& )
     378                 :            :         {
     379                 :            :         }
     380         [ #  # ]:          0 :         catch ( const ::com::sun::star::lang::IllegalArgumentException& )
     381                 :            :         {
     382                 :            :         }
     383         [ #  # ]:          0 :         catch ( const ::com::sun::star::io::IOException& )
     384                 :            :         {
     385                 :            :         }
     386         [ #  # ]:          0 :         catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
     387                 :            :         {
     388                 :            :         }
     389                 :            :     }
     390                 :            : 
     391                 :            :     // At least we provide an empty settings container!
     392 [ #  # ][ #  # ]:        412 :     aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer() ), UNO_QUERY );
         [ #  # ][ #  # ]
                 [ -  + ]
     393                 :            : }
     394                 :            : 
     395                 :      14358 : ModuleUIConfigurationManager::UIElementData*  ModuleUIConfigurationManager::impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad )
     396                 :            : {
     397                 :            :     // preload list of element types on demand
     398         [ +  - ]:      14358 :     impl_preloadUIElementTypeList( LAYER_USERDEFINED, nElementType );
     399         [ +  - ]:      14358 :     impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
     400                 :            : 
     401                 :            :     // first try to look into our user-defined vector/boost::unordered_map combination
     402                 :      14358 :     UIElementDataHashMap& rUserHashMap = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap;
     403         [ +  - ]:      14358 :     UIElementDataHashMap::iterator pIter = rUserHashMap.find( aResourceURL );
     404 [ +  - ][ +  + ]:      14358 :     if ( pIter != rUserHashMap.end() )
     405                 :            :     {
     406                 :            :         // Default data settings data must be retrieved from the default layer!
     407 [ +  - ][ +  + ]:         12 :         if ( !pIter->second.bDefault )
     408                 :            :         {
     409 [ +  - ][ -  + ]:         10 :             if ( !pIter->second.xSettings.is() && bLoad )
         [ #  # ][ -  + ]
     410 [ #  # ][ #  # ]:          0 :                 impl_requestUIElementData( nElementType, LAYER_USERDEFINED, pIter->second );
     411         [ +  - ]:         10 :             return &(pIter->second);
     412                 :            :         }
     413                 :            :     }
     414                 :            : 
     415                 :            :     // Not successfull, we have to look into our default vector/boost::unordered_map combination
     416                 :      14348 :     UIElementDataHashMap& rDefaultHashMap = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
     417         [ +  - ]:      14348 :     pIter = rDefaultHashMap.find( aResourceURL );
     418 [ +  - ][ +  + ]:      14348 :     if ( pIter != rDefaultHashMap.end() )
     419                 :            :     {
     420 [ +  - ][ +  + ]:       9764 :         if ( !pIter->second.xSettings.is() && bLoad )
         [ +  + ][ +  + ]
     421 [ +  - ][ +  - ]:        406 :             impl_requestUIElementData( nElementType, LAYER_DEFAULT, pIter->second );
     422         [ +  - ]:       9764 :         return &(pIter->second);
     423                 :            :     }
     424                 :            : 
     425                 :            :     // Nothing has been found!
     426                 :      14358 :     return NULL;
     427                 :            : }
     428                 :            : 
     429                 :          0 : void ModuleUIConfigurationManager::impl_storeElementTypeData( Reference< XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState )
     430                 :            : {
     431                 :          0 :     UIElementDataHashMap& rHashMap          = rElementType.aElementsHashMap;
     432         [ #  # ]:          0 :     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
     433                 :            : 
     434 [ #  # ][ #  # ]:          0 :     while ( pIter != rHashMap.end() )
     435                 :            :     {
     436         [ #  # ]:          0 :         UIElementData& rElement = pIter->second;
     437         [ #  # ]:          0 :         if ( rElement.bModified )
     438                 :            :         {
     439         [ #  # ]:          0 :             if ( rElement.bDefault )
     440                 :            :             {
     441 [ #  # ][ #  # ]:          0 :                 xStorage->removeElement( rElement.aName );
     442                 :          0 :                 rElement.bModified = sal_False; // mark as not modified
     443                 :            :             }
     444                 :            :             else
     445                 :            :             {
     446 [ #  # ][ #  # ]:          0 :                 Reference< XStream > xStream( xStorage->openStreamElement( rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY );
                 [ #  # ]
     447 [ #  # ][ #  # ]:          0 :                 Reference< XOutputStream > xOutputStream( xStream->getOutputStream() );
     448                 :            : 
     449         [ #  # ]:          0 :                 if ( xOutputStream.is() )
     450                 :            :                 {
     451   [ #  #  #  # ]:          0 :                     switch( rElementType.nElementType )
     452                 :            :                     {
     453                 :            :                         case ::com::sun::star::ui::UIElementType::MENUBAR:
     454                 :            :                         {
     455                 :            :                             try
     456                 :            :                             {
     457         [ #  # ]:          0 :                                 MenuConfiguration aMenuCfg( m_xServiceManager );
     458 [ #  # ][ #  # ]:          0 :                                 aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream );
                 [ #  # ]
     459                 :            :                             }
     460   [ #  #  #  # ]:          0 :                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
     461                 :            :                             {
     462                 :            :                             }
     463                 :            :                         }
     464                 :          0 :                         break;
     465                 :            : 
     466                 :            :                         case ::com::sun::star::ui::UIElementType::TOOLBAR:
     467                 :            :                         {
     468                 :            :                             try
     469                 :            :                             {
     470         [ #  # ]:          0 :                                 ToolBoxConfiguration::StoreToolBox( m_xServiceManager, xOutputStream, rElement.xSettings );
     471                 :            :                             }
     472   [ #  #  #  # ]:          0 :                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
     473                 :            :                             {
     474                 :            :                             }
     475                 :            :                         }
     476                 :          0 :                         break;
     477                 :            : 
     478                 :            :                         case ::com::sun::star::ui::UIElementType::STATUSBAR:
     479                 :            :                         {
     480                 :            :                             try
     481                 :            :                             {
     482         [ #  # ]:          0 :                                 StatusBarConfiguration::StoreStatusBar( m_xServiceManager, xOutputStream, rElement.xSettings );
     483                 :            :                             }
     484         [ #  # ]:          0 :                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
     485                 :            :                             {
     486                 :            :                             }
     487                 :            :                         }
     488                 :          0 :                         break;
     489                 :            : 
     490                 :            :                         default:
     491                 :          0 :                         break;
     492                 :            :                     }
     493                 :            :                 }
     494                 :            : 
     495                 :            :                 // mark as not modified if we store to our own storage
     496         [ #  # ]:          0 :                 if ( bResetModifyState )
     497                 :          0 :                     rElement.bModified = sal_False;
     498                 :            :             }
     499                 :            :         }
     500                 :            : 
     501                 :          0 :         ++pIter;
     502                 :            :     }
     503                 :            : 
     504                 :            :     // commit element type storage
     505         [ #  # ]:          0 :     Reference< XTransactedObject > xTransactedObject( xStorage, UNO_QUERY );
     506         [ #  # ]:          0 :     if ( xTransactedObject.is() )
     507 [ #  # ][ #  # ]:          0 :         xTransactedObject->commit();
     508                 :            : 
     509                 :            :     // mark UIElementType as not modified if we store to our own storage
     510         [ #  # ]:          0 :     if ( bResetModifyState )
     511                 :          0 :         rElementType.bModified = sal_False;
     512                 :          0 : }
     513                 :            : 
     514                 :            : // This is only allowed to be called on the LAYER_USER_DEFINED!
     515                 :         42 : void ModuleUIConfigurationManager::impl_resetElementTypeData(
     516                 :            :     UIElementType& rUserElementType,
     517                 :            :     UIElementType& rDefaultElementType,
     518                 :            :     ConfigEventNotifyContainer& rRemoveNotifyContainer,
     519                 :            :     ConfigEventNotifyContainer& rReplaceNotifyContainer )
     520                 :            : {
     521                 :         42 :     UIElementDataHashMap& rHashMap          = rUserElementType.aElementsHashMap;
     522         [ +  - ]:         42 :     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
     523                 :            : 
     524         [ +  - ]:         42 :     Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
     525         [ +  - ]:         42 :     Reference< XInterface > xIfac( xThis, UNO_QUERY );
     526         [ +  - ]:         42 :     Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY );
     527                 :         42 :     sal_Int16 nType = rUserElementType.nElementType;
     528                 :            : 
     529                 :            :     // Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling
     530                 :            :     // our listeners!
     531 [ +  - ][ +  + ]:         50 :     while ( pIter != rHashMap.end() )
     532                 :            :     {
     533         [ +  - ]:          8 :         UIElementData& rElement = pIter->second;
     534         [ +  + ]:          8 :         if ( !rElement.bDefault )
     535                 :            :         {
     536 [ +  - ][ +  - ]:          6 :             if ( xDefaultNameAccess->hasByName( rElement.aName ))
                 [ +  - ]
     537                 :            :             {
     538                 :            :                 // Replace settings with data from default layer
     539                 :          6 :                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
     540         [ +  - ]:          6 :                 impl_requestUIElementData( nType, LAYER_DEFAULT, rElement );
     541                 :            : 
     542         [ +  - ]:          6 :                 ConfigurationEvent aReplaceEvent;
     543                 :          6 :                 aReplaceEvent.ResourceURL = rElement.aResourceURL;
     544         [ +  - ]:          6 :                 aReplaceEvent.Accessor <<= xThis;
     545         [ +  - ]:          6 :                 aReplaceEvent.Source = xIfac;
     546         [ +  - ]:          6 :                 aReplaceEvent.ReplacedElement <<= xOldSettings;
     547         [ +  - ]:          6 :                 aReplaceEvent.Element <<= rElement.xSettings;
     548                 :            : 
     549         [ +  - ]:          6 :                 rReplaceNotifyContainer.push_back( aReplaceEvent );
     550                 :            : 
     551                 :            :                 // Mark element as default and not modified. That means "not active"
     552                 :            :                 // in the user layer anymore.
     553                 :          6 :                 rElement.bModified = false;
     554         [ +  - ]:          6 :                 rElement.bDefault  = true;
     555                 :            :             }
     556                 :            :             else
     557                 :            :             {
     558                 :            :                 // Remove user-defined settings from user layer
     559         [ #  # ]:          0 :                 ConfigurationEvent aEvent;
     560                 :          0 :                 aEvent.ResourceURL = rElement.aResourceURL;
     561         [ #  # ]:          0 :                 aEvent.Accessor <<= xThis;
     562         [ #  # ]:          0 :                 aEvent.Source = xIfac;
     563         [ #  # ]:          0 :                 aEvent.Element <<= rElement.xSettings;
     564                 :            : 
     565         [ #  # ]:          0 :                 rRemoveNotifyContainer.push_back( aEvent );
     566                 :            : 
     567                 :            :                 // Mark element as default and not modified. That means "not active"
     568                 :            :                 // in the user layer anymore.
     569                 :          0 :                 rElement.bModified = false;
     570         [ #  # ]:          0 :                 rElement.bDefault  = true;
     571                 :            :             }
     572                 :            :         }
     573                 :            : 
     574                 :          8 :         ++pIter;
     575                 :            :     }
     576                 :            : 
     577                 :            :     // Remove all settings from our user interface elements
     578         [ +  - ]:         42 :     rHashMap.clear();
     579                 :         42 : }
     580                 :            : 
     581                 :          0 : void ModuleUIConfigurationManager::impl_reloadElementTypeData(
     582                 :            :     UIElementType&              rUserElementType,
     583                 :            :     UIElementType&              rDefaultElementType,
     584                 :            :     ConfigEventNotifyContainer& rRemoveNotifyContainer,
     585                 :            :     ConfigEventNotifyContainer& rReplaceNotifyContainer )
     586                 :            : {
     587                 :          0 :     UIElementDataHashMap& rHashMap          = rUserElementType.aElementsHashMap;
     588         [ #  # ]:          0 :     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
     589                 :          0 :     Reference< XStorage > xUserStorage( rUserElementType.xStorage );
     590                 :          0 :     Reference< XStorage > xDefaultStorage( rDefaultElementType.xStorage );
     591         [ #  # ]:          0 :     Reference< XNameAccess > xUserNameAccess( rUserElementType.xStorage, UNO_QUERY );
     592         [ #  # ]:          0 :     Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY );
     593                 :            : 
     594         [ #  # ]:          0 :     Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
     595         [ #  # ]:          0 :     Reference< XInterface > xIfac( xThis, UNO_QUERY );
     596                 :          0 :     sal_Int16 nType = rUserElementType.nElementType;
     597                 :            : 
     598 [ #  # ][ #  # ]:          0 :     while ( pIter != rHashMap.end() )
     599                 :            :     {
     600         [ #  # ]:          0 :         UIElementData& rElement = pIter->second;
     601         [ #  # ]:          0 :         if ( rElement.bModified )
     602                 :            :         {
     603 [ #  # ][ #  # ]:          0 :             if ( xUserNameAccess->hasByName( rElement.aName ))
                 [ #  # ]
     604                 :            :             {
     605                 :            :                 // Replace settings with data from user layer
     606                 :          0 :                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
     607                 :            : 
     608         [ #  # ]:          0 :                 impl_requestUIElementData( nType, LAYER_USERDEFINED, rElement );
     609                 :            : 
     610         [ #  # ]:          0 :                 ConfigurationEvent aReplaceEvent;
     611                 :            : 
     612                 :          0 :                 aReplaceEvent.ResourceURL = rElement.aResourceURL;
     613         [ #  # ]:          0 :                 aReplaceEvent.Accessor <<= xThis;
     614         [ #  # ]:          0 :                 aReplaceEvent.Source = xIfac;
     615         [ #  # ]:          0 :                 aReplaceEvent.ReplacedElement <<= xOldSettings;
     616         [ #  # ]:          0 :                 aReplaceEvent.Element <<= rElement.xSettings;
     617         [ #  # ]:          0 :                 rReplaceNotifyContainer.push_back( aReplaceEvent );
     618                 :            : 
     619         [ #  # ]:          0 :                 rElement.bModified = false;
     620                 :            :             }
     621 [ #  # ][ #  # ]:          0 :             else if ( xDefaultNameAccess->hasByName( rElement.aName ))
                 [ #  # ]
     622                 :            :             {
     623                 :            :                 // Replace settings with data from default layer
     624                 :          0 :                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
     625                 :            : 
     626         [ #  # ]:          0 :                 impl_requestUIElementData( nType, LAYER_DEFAULT, rElement );
     627                 :            : 
     628         [ #  # ]:          0 :                 ConfigurationEvent aReplaceEvent;
     629                 :            : 
     630                 :          0 :                 aReplaceEvent.ResourceURL = rElement.aResourceURL;
     631         [ #  # ]:          0 :                 aReplaceEvent.Accessor <<= xThis;
     632         [ #  # ]:          0 :                 aReplaceEvent.Source = xIfac;
     633         [ #  # ]:          0 :                 aReplaceEvent.ReplacedElement <<= xOldSettings;
     634         [ #  # ]:          0 :                 aReplaceEvent.Element <<= rElement.xSettings;
     635         [ #  # ]:          0 :                 rReplaceNotifyContainer.push_back( aReplaceEvent );
     636                 :            : 
     637                 :            :                 // Mark element as default and not modified. That means "not active"
     638                 :            :                 // in the user layer anymore.
     639                 :          0 :                 rElement.bModified = false;
     640         [ #  # ]:          0 :                 rElement.bDefault  = true;
     641                 :            :             }
     642                 :            :             else
     643                 :            :             {
     644                 :            :                 // Element settings are not in any storage => remove
     645         [ #  # ]:          0 :                 ConfigurationEvent aRemoveEvent;
     646                 :            : 
     647                 :          0 :                 aRemoveEvent.ResourceURL = rElement.aResourceURL;
     648         [ #  # ]:          0 :                 aRemoveEvent.Accessor <<= xThis;
     649         [ #  # ]:          0 :                 aRemoveEvent.Source = xIfac;
     650         [ #  # ]:          0 :                 aRemoveEvent.Element <<= rElement.xSettings;
     651                 :            : 
     652         [ #  # ]:          0 :                 rRemoveNotifyContainer.push_back( aRemoveEvent );
     653                 :            : 
     654                 :            :                 // Mark element as default and not modified. That means "not active"
     655                 :            :                 // in the user layer anymore.
     656                 :          0 :                 rElement.bModified = false;
     657         [ #  # ]:          0 :                 rElement.bDefault  = true;
     658                 :            :             }
     659                 :            :         }
     660                 :          0 :         ++pIter;
     661                 :            :     }
     662                 :            : 
     663                 :          0 :     rUserElementType.bModified = sal_False;
     664                 :          0 : }
     665                 :            : 
     666                 :        149 : void ModuleUIConfigurationManager::impl_Initialize()
     667                 :            : {
     668                 :            :     // Initialize the top-level structures with the storage data
     669         [ +  - ]:        149 :     if ( m_xUserConfigStorage.is() )
     670                 :            :     {
     671                 :            :         // Try to access our module sub folder
     672         [ +  + ]:       1192 :         for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT;
     673                 :            :               i++ )
     674                 :            :         {
     675                 :       1043 :             Reference< XStorage > xElementTypeStorage;
     676                 :            :             try
     677                 :            :             {
     678         [ +  + ]:       1043 :                 if ( m_pStorageHandler[i] )
     679 [ +  - ][ +  - ]:        447 :                     xElementTypeStorage = m_pStorageHandler[i]->getWorkingStorageUser();
           [ #  #  #  #  
                   #  # ]
     680                 :            :             }
     681         [ #  # ]:          0 :             catch ( const com::sun::star::container::NoSuchElementException& )
     682                 :            :             {
     683                 :            :             }
     684         [ #  # ]:          0 :             catch ( const ::com::sun::star::embed::InvalidStorageException& )
     685                 :            :             {
     686                 :            :             }
     687         [ #  # ]:          0 :             catch ( const ::com::sun::star::lang::IllegalArgumentException& )
     688                 :            :             {
     689                 :            :             }
     690         [ #  # ]:          0 :             catch ( const ::com::sun::star::io::IOException& )
     691                 :            :             {
     692                 :            :             }
     693         [ #  # ]:          0 :             catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
     694                 :            :             {
     695                 :            :             }
     696                 :            : 
     697                 :       1043 :             m_aUIElements[LAYER_USERDEFINED][i].nElementType = i;
     698                 :       1043 :             m_aUIElements[LAYER_USERDEFINED][i].bModified = false;
     699         [ +  - ]:       1043 :             m_aUIElements[LAYER_USERDEFINED][i].xStorage = xElementTypeStorage;
     700                 :       1043 :             m_aUIElements[LAYER_USERDEFINED][i].bDefaultLayer = false;
     701                 :       1043 :         }
     702                 :            :     }
     703                 :            : 
     704         [ +  + ]:        149 :     if ( m_xDefaultConfigStorage.is() )
     705                 :            :     {
     706         [ +  - ]:        148 :         Reference< XNameAccess > xNameAccess( m_xDefaultConfigStorage, UNO_QUERY_THROW );
     707                 :            : 
     708                 :            :         // Try to access our module sub folder
     709         [ +  + ]:       1184 :         for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT;
     710                 :            :               i++ )
     711                 :            :         {
     712                 :       1036 :             Reference< XStorage > xElementTypeStorage;
     713                 :            :             try
     714                 :            :             {
     715                 :       1036 :                 const OUString sName( OUString::createFromAscii( UIELEMENTTYPENAMES[i] ) );
     716 [ +  - ][ +  + ]:       1036 :                 if( xNameAccess->hasByName( sName ) )
                 [ +  - ]
     717 [ +  - ][ +  - ]:       1036 :                     xNameAccess->getByName( sName ) >>= xElementTypeStorage;
         [ +  - ][ #  # ]
     718                 :            :             }
     719         [ #  # ]:          0 :             catch ( const com::sun::star::container::NoSuchElementException& )
     720                 :            :             {
     721                 :            :             }
     722                 :            : 
     723                 :       1036 :             m_aUIElements[LAYER_DEFAULT][i].nElementType = i;
     724                 :       1036 :             m_aUIElements[LAYER_DEFAULT][i].bModified = false;
     725         [ +  - ]:       1036 :             m_aUIElements[LAYER_DEFAULT][i].xStorage = xElementTypeStorage;
     726                 :       1036 :             m_aUIElements[LAYER_DEFAULT][i].bDefaultLayer = true;
     727                 :       1184 :         }
     728                 :            :     }
     729                 :        149 : }
     730                 :            : 
     731                 :        149 : ModuleUIConfigurationManager::ModuleUIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ) :
     732         [ +  - ]:        149 :     ThreadHelpBase( &Application::GetSolarMutex() )
     733                 :            :     , m_xDefaultConfigStorage( 0 )
     734                 :            :     , m_xUserConfigStorage( 0 )
     735                 :            :     , m_bReadOnly( true )
     736                 :            :     , m_bInitialized( false )
     737                 :            :     , m_bModified( false )
     738                 :            :     , m_bConfigRead( false )
     739                 :            :     , m_bDisposed( false )
     740                 :            :     , m_aXMLPostfix( ".xml" )
     741                 :            :     , m_aPropUIName( "UIName" )
     742                 :            :     , m_aPropResourceURL( "ResourceURL" )
     743                 :            :     , m_xServiceManager( xServiceManager )
     744 [ +  - ][ +  - ]:        596 :     , m_aListenerContainer( m_aLock.getShareableOslMutex() )
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
           [ #  #  #  # ]
     745                 :            : {
     746         [ +  + ]:       1341 :     for ( int i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
     747                 :       1192 :         m_pStorageHandler[i] = 0;
     748                 :            : 
     749                 :            :     // Make sure we have a default initialized entry for every layer and user interface element type!
     750                 :            :     // The following code depends on this!
     751         [ +  - ]:        149 :     m_aUIElements[LAYER_DEFAULT].resize( ::com::sun::star::ui::UIElementType::COUNT );
     752         [ +  - ]:        149 :     m_aUIElements[LAYER_USERDEFINED].resize( ::com::sun::star::ui::UIElementType::COUNT );
     753   [ #  #  #  # ]:        149 : }
     754                 :            : 
     755 [ +  - ][ +  - ]:        556 : ModuleUIConfigurationManager::~ModuleUIConfigurationManager()
                 [ +  - ]
     756                 :            : {
     757         [ +  + ]:       1251 :     for ( int i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
     758 [ +  + ][ +  - ]:       1112 :         delete m_pStorageHandler[i];
     759         [ +  - ]:        695 : }
           [ +  +  -  + ]
           [ #  #  #  # ]
     760                 :            : 
     761                 :            : // XComponent
     762                 :        149 : void SAL_CALL ModuleUIConfigurationManager::dispose() throw (::com::sun::star::uno::RuntimeException)
     763                 :            : {
     764         [ +  - ]:        149 :     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
     765                 :            : 
     766         [ +  - ]:        149 :     css::lang::EventObject aEvent( xThis );
     767         [ +  - ]:        149 :     m_aListenerContainer.disposeAndClear( aEvent );
     768                 :            : 
     769                 :            :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     770         [ +  - ]:        149 :     ResetableGuard aGuard( m_aLock );
     771                 :        149 :     Reference< XComponent > xModuleImageManager( m_xModuleImageManager );
     772                 :        149 :     m_xModuleImageManager.clear();
     773                 :        149 :     m_xModuleAcceleratorManager.clear();
     774                 :        149 :     m_aUIElements[LAYER_USERDEFINED].clear();
     775                 :        149 :     m_aUIElements[LAYER_DEFAULT].clear();
     776                 :        149 :     m_xDefaultConfigStorage.clear();
     777                 :        149 :     m_xUserConfigStorage.clear();
     778                 :        149 :     m_xUserRootCommit.clear();
     779                 :        149 :     m_bConfigRead = false;
     780                 :        149 :     m_bModified = false;
     781                 :        149 :     m_bDisposed = true;
     782         [ +  - ]:        149 :     aGuard.unlock();
     783                 :            :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     784                 :            : 
     785                 :            :     try
     786                 :            :     {
     787         [ +  + ]:        149 :         if ( xModuleImageManager.is() )
     788 [ +  - ][ +  - ]:        145 :             xModuleImageManager->dispose();
     789                 :            :     }
     790         [ #  # ]:          0 :     catch ( const Exception& )
     791                 :            :     {
     792 [ +  - ][ +  - ]:        149 :     }
     793         [ #  # ]:        149 : }
     794                 :            : 
     795                 :          0 : void SAL_CALL ModuleUIConfigurationManager::addEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     796                 :            : {
     797                 :            :     {
     798         [ #  # ]:          0 :         ResetableGuard aGuard( m_aLock );
     799                 :            : 
     800                 :            :         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     801         [ #  # ]:          0 :         if ( m_bDisposed )
     802 [ #  # ][ #  # ]:          0 :             throw DisposedException();
     803                 :            :     }
     804                 :            : 
     805                 :          0 :     m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
     806                 :          0 : }
     807                 :            : 
     808                 :          0 : void SAL_CALL ModuleUIConfigurationManager::removeEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     809                 :            : {
     810                 :            :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     811                 :          0 :     m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
     812                 :          0 : }
     813                 :            : 
     814                 :            : // XInitialization
     815                 :        151 : void SAL_CALL ModuleUIConfigurationManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
     816                 :            : {
     817         [ +  - ]:        151 :     ResetableGuard aLock( m_aLock );
     818                 :            : 
     819         [ +  + ]:        151 :     if ( !m_bInitialized )
     820                 :            :     {
     821         [ +  - ]:        149 :         ::comphelper::SequenceAsHashMap lArgs(aArguments);
     822         [ +  - ]:        149 :         m_aModuleIdentifier = lArgs.getUnpackedValueOrDefault(::rtl::OUString("ModuleIdentifier"), ::rtl::OUString());
     823         [ +  - ]:        149 :         m_aModuleShortName  = lArgs.getUnpackedValueOrDefault(::rtl::OUString("ModuleShortName"), ::rtl::OUString());
     824                 :            : 
     825         [ +  + ]:       1192 :         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
     826                 :            :         {
     827                 :       1043 :             rtl::OUString aResourceType;
     828         [ +  + ]:       1043 :             if ( i == ::com::sun::star::ui::UIElementType::MENUBAR )
     829         [ +  - ]:        149 :                 aResourceType = PresetHandler::RESOURCETYPE_MENUBAR();
     830         [ +  + ]:        894 :             else if ( i == ::com::sun::star::ui::UIElementType::TOOLBAR )
     831         [ +  - ]:        149 :                 aResourceType = PresetHandler::RESOURCETYPE_TOOLBAR();
     832         [ +  + ]:        745 :             else if ( i == ::com::sun::star::ui::UIElementType::STATUSBAR )
     833         [ +  - ]:        149 :                 aResourceType = PresetHandler::RESOURCETYPE_STATUSBAR();
     834                 :            : 
     835         [ +  + ]:       1043 :             if ( !aResourceType.isEmpty() )
     836                 :            :             {
     837 [ +  - ][ +  - ]:        447 :                 m_pStorageHandler[i] = new PresetHandler( m_xServiceManager );
     838                 :        447 :                 m_pStorageHandler[i]->connectToResource( PresetHandler::E_MODULES,
     839                 :            :                                                          aResourceType, // this path wont be used later ... seee next lines!
     840                 :            :                                                          m_aModuleShortName,
     841 [ +  - ][ +  - ]:        447 :                                                          css::uno::Reference< css::embed::XStorage >()); // no document root used here!
                 [ +  - ]
     842                 :            :             }
     843                 :       1043 :         }
     844                 :            : 
     845                 :            :         // initialize root storages for all resource types
     846                 :            :         m_xUserRootCommit       = css::uno::Reference< css::embed::XTransactedObject >(
     847 [ +  - ][ +  - ]:        149 :                                     m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getOrCreateRootStorageUser(), css::uno::UNO_QUERY); // can be empty
                 [ +  - ]
     848                 :        149 :         m_xDefaultConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageShare(
     849 [ +  - ][ +  - ]:        149 :                                     m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageShare());
                 [ +  - ]
     850                 :        149 :         m_xUserConfigStorage    = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageUser(
     851 [ +  - ][ +  - ]:        149 :                                     m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageUser());
                 [ +  - ]
     852                 :            : 
     853         [ +  - ]:        149 :         if ( m_xUserConfigStorage.is() )
     854                 :            :         {
     855         [ +  - ]:        149 :             Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY );
     856         [ +  - ]:        149 :             if ( xPropSet.is() )
     857                 :            :             {
     858                 :        149 :                 long nOpenMode = 0;
     859 [ +  - ][ +  - ]:        149 :                 Any a = xPropSet->getPropertyValue( rtl::OUString( "OpenMode" ));
     860         [ +  - ]:        149 :                 if ( a >>= nOpenMode )
     861                 :        149 :                     m_bReadOnly = !( nOpenMode & ElementModes::WRITE );
     862                 :        149 :             }
     863                 :            :         }
     864                 :            : 
     865         [ +  - ]:        149 :         impl_Initialize();
     866                 :            : 
     867         [ +  - ]:        149 :         m_bInitialized = true;
     868         [ +  - ]:        151 :     }
     869                 :        151 : }
     870                 :            : 
     871                 :            : // XUIConfiguration
     872                 :       1767 : void SAL_CALL ModuleUIConfigurationManager::addConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     873                 :            : {
     874                 :            :     {
     875         [ +  - ]:       1767 :         ResetableGuard aGuard( m_aLock );
     876                 :            : 
     877                 :            :         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     878         [ -  + ]:       1767 :         if ( m_bDisposed )
     879 [ #  # ][ +  - ]:       1767 :             throw DisposedException();
     880                 :            :     }
     881                 :            : 
     882                 :       1767 :     m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener );
     883                 :       1767 : }
     884                 :            : 
     885                 :       1676 : void SAL_CALL ModuleUIConfigurationManager::removeConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     886                 :            : {
     887                 :            :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     888                 :       1676 :     m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener );
     889                 :       1676 : }
     890                 :            : 
     891                 :            : 
     892                 :            : // XUIConfigurationManager
     893                 :          6 : void SAL_CALL ModuleUIConfigurationManager::reset() throw (::com::sun::star::uno::RuntimeException)
     894                 :            : {
     895         [ +  - ]:          6 :     ResetableGuard aGuard( m_aLock );
     896                 :            : 
     897                 :            :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     898         [ -  + ]:          6 :     if ( m_bDisposed )
     899         [ #  # ]:          0 :         throw DisposedException();
     900                 :            : 
     901 [ +  - ][ +  - ]:          6 :     if ( !isReadOnly() )
     902                 :            :     {
     903                 :            :         // Remove all elements from our user-defined storage!
     904                 :            :         try
     905                 :            :         {
     906         [ +  + ]:         48 :             for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
     907                 :            :             {
     908                 :         42 :                 UIElementType&        rElementType = m_aUIElements[LAYER_USERDEFINED][i];
     909         [ +  - ]:         42 :                 Reference< XStorage > xSubStorage( rElementType.xStorage, UNO_QUERY );
     910                 :            : 
     911         [ +  + ]:         42 :                 if ( xSubStorage.is() )
     912                 :            :                 {
     913                 :         18 :                     bool bCommitSubStorage( false );
     914         [ +  - ]:         18 :                     Reference< XNameAccess > xSubStorageNameAccess( xSubStorage, UNO_QUERY );
     915 [ +  - ][ +  - ]:         18 :                     Sequence< OUString > aUIElementStreamNames = xSubStorageNameAccess->getElementNames();
     916         [ -  + ]:         18 :                     for ( sal_Int32 j = 0; j < aUIElementStreamNames.getLength(); j++ )
     917                 :            :                     {
     918 [ #  # ][ #  # ]:          0 :                         xSubStorage->removeElement( aUIElementStreamNames[j] );
                 [ #  # ]
     919                 :          0 :                         bCommitSubStorage = true;
     920                 :            :                     }
     921                 :            : 
     922         [ -  + ]:         18 :                     if ( bCommitSubStorage )
     923                 :            :                     {
     924         [ #  # ]:          0 :                         Reference< XTransactedObject > xTransactedObject( xSubStorage, UNO_QUERY );
     925         [ #  # ]:          0 :                         if ( xTransactedObject.is() )
     926 [ #  # ][ #  # ]:          0 :                             xTransactedObject->commit();
     927         [ #  # ]:          0 :                         m_pStorageHandler[i]->commitUserChanges();
     928         [ +  - ]:         18 :                     }
     929                 :            :                 }
     930                 :         42 :             }
     931                 :            : 
     932                 :            :             // remove settings from user defined layer and notify listener about removed settings data!
     933         [ +  - ]:          6 :             ConfigEventNotifyContainer aRemoveEventNotifyContainer;
     934         [ +  - ]:          6 :             ConfigEventNotifyContainer aReplaceEventNotifyContainer;
     935         [ +  + ]:         48 :             for ( sal_Int16 j = 1; j < ::com::sun::star::ui::UIElementType::COUNT; j++ )
     936                 :            :             {
     937                 :            :                 try
     938                 :            :                 {
     939                 :         42 :                     UIElementType& rUserElementType     = m_aUIElements[LAYER_USERDEFINED][j];
     940                 :         42 :                     UIElementType& rDefaultElementType  = m_aUIElements[LAYER_DEFAULT][j];
     941                 :            : 
     942         [ +  - ]:         42 :                     impl_resetElementTypeData( rUserElementType, rDefaultElementType, aRemoveEventNotifyContainer, aReplaceEventNotifyContainer );
     943                 :         42 :                     rUserElementType.bModified = sal_False;
     944                 :            :                 }
     945         [ #  # ]:          0 :                 catch ( const Exception& )
     946                 :            :                 {
     947         [ #  # ]:          0 :                     throw IOException();
     948                 :            :                 }
     949                 :            :             }
     950                 :            : 
     951                 :          6 :             m_bModified = sal_False;
     952                 :            : 
     953                 :            :             // Unlock mutex before notify our listeners
     954         [ +  - ]:          6 :             aGuard.unlock();
     955                 :            : 
     956                 :            :             // Notify our listeners
     957                 :          6 :             sal_uInt32 k = 0;
     958         [ -  + ]:          6 :             for ( k = 0; k < aRemoveEventNotifyContainer.size(); k++ )
     959         [ #  # ]:          0 :                 implts_notifyContainerListener( aRemoveEventNotifyContainer[k], NotifyOp_Remove );
     960         [ +  + ]:         12 :             for ( k = 0; k < aReplaceEventNotifyContainer.size(); k++ )
     961 [ +  - ][ #  #  :         12 :                 implts_notifyContainerListener( aReplaceEventNotifyContainer[k], NotifyOp_Replace );
                #  #  # ]
     962                 :            :         }
     963         [ #  # ]:          0 :         catch ( const ::com::sun::star::lang::IllegalArgumentException& )
     964                 :            :         {
     965                 :            :         }
     966         [ #  # ]:          0 :         catch ( const ::com::sun::star::container::NoSuchElementException& )
     967                 :            :         {
     968                 :            :         }
     969         [ #  # ]:          0 :         catch ( const ::com::sun::star::embed::InvalidStorageException& )
     970                 :            :         {
     971                 :            :         }
     972         [ #  # ]:          0 :         catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
     973                 :            :         {
     974                 :            :         }
     975         [ +  - ]:          6 :     }
     976                 :          6 : }
     977                 :            : 
     978                 :       1773 : Sequence< Sequence< PropertyValue > > SAL_CALL ModuleUIConfigurationManager::getUIElementsInfo( sal_Int16 ElementType )
     979                 :            : throw ( IllegalArgumentException, RuntimeException )
     980                 :            : {
     981 [ +  - ][ -  + ]:       1773 :     if (( ElementType < 0 ) || ( ElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
     982         [ #  # ]:          0 :         throw IllegalArgumentException();
     983                 :            : 
     984         [ +  - ]:       1773 :     ResetableGuard aGuard( m_aLock );
     985         [ -  + ]:       1773 :     if ( m_bDisposed )
     986         [ #  # ]:          0 :         throw DisposedException();
     987                 :            : 
     988         [ +  - ]:       1773 :     Sequence< Sequence< PropertyValue > > aElementInfoSeq;
     989         [ +  - ]:       1773 :     UIElementInfoHashMap aUIElementInfoCollection;
     990                 :            : 
     991         [ +  + ]:       1773 :     if ( ElementType == ::com::sun::star::ui::UIElementType::UNKNOWN )
     992                 :            :     {
     993         [ +  + ]:         18 :         for ( sal_Int16 i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
     994         [ +  - ]:         16 :             impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, sal_Int16( i ) );
     995                 :            :     }
     996                 :            :     else
     997         [ +  - ]:       1771 :         impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, ElementType );
     998                 :            : 
     999         [ +  - ]:       1773 :     Sequence< PropertyValue > aUIElementInfo( 2 );
    1000         [ +  - ]:       1773 :     aUIElementInfo[0].Name = m_aPropResourceURL;
    1001         [ +  - ]:       1773 :     aUIElementInfo[1].Name = m_aPropUIName;
    1002                 :            : 
    1003         [ +  - ]:       1773 :     aElementInfoSeq.realloc( aUIElementInfoCollection.size() );
    1004         [ +  - ]:       1773 :     UIElementInfoHashMap::const_iterator pIter = aUIElementInfoCollection.begin();
    1005                 :            : 
    1006                 :       1773 :     sal_Int32 n = 0;
    1007 [ +  - ][ +  + ]:      45119 :     while ( pIter != aUIElementInfoCollection.end() )
    1008                 :            :     {
    1009 [ +  - ][ +  - ]:      43346 :         aUIElementInfo[0].Value <<= pIter->second.aResourceURL;
                 [ +  - ]
    1010 [ +  - ][ +  - ]:      43346 :         aUIElementInfo[1].Value <<= pIter->second.aUIName;
                 [ +  - ]
    1011 [ +  - ][ +  - ]:      43346 :         aElementInfoSeq[n++] = aUIElementInfo;
    1012                 :      43346 :         ++pIter;
    1013                 :            :     }
    1014                 :            : 
    1015 [ +  - ][ +  - ]:       1773 :     return aElementInfoSeq;
                 [ +  - ]
    1016                 :            : }
    1017                 :            : 
    1018                 :          2 : Reference< XIndexContainer > SAL_CALL ModuleUIConfigurationManager::createSettings() throw (::com::sun::star::uno::RuntimeException)
    1019                 :            : {
    1020         [ +  - ]:          2 :     ResetableGuard aGuard( m_aLock );
    1021                 :            : 
    1022         [ -  + ]:          2 :     if ( m_bDisposed )
    1023         [ #  # ]:          0 :         throw DisposedException();
    1024                 :            : 
    1025                 :            :     // Creates an empty item container which can be filled from outside
    1026 [ +  - ][ +  - ]:          2 :     return Reference< XIndexContainer >( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
         [ +  - ][ +  - ]
    1027                 :            : }
    1028                 :            : 
    1029                 :       7161 : sal_Bool SAL_CALL ModuleUIConfigurationManager::hasSettings( const ::rtl::OUString& ResourceURL )
    1030                 :            : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
    1031                 :            : {
    1032                 :       7161 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
    1033                 :            : 
    1034 [ -  + ][ +  - ]:       7161 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
    1035                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
    1036         [ #  # ]:          0 :         throw IllegalArgumentException();
    1037                 :            :     else
    1038                 :            :     {
    1039         [ +  - ]:       7161 :         ResetableGuard aGuard( m_aLock );
    1040                 :            : 
    1041         [ -  + ]:       7161 :         if ( m_bDisposed )
    1042         [ #  # ]:          0 :             throw DisposedException();
    1043                 :            : 
    1044         [ +  - ]:       7161 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false );
    1045         [ +  + ]:       7161 :         if ( pDataSettings )
    1046 [ +  - ][ +  + ]:       7161 :             return sal_True;
    1047                 :            :     }
    1048                 :            : 
    1049                 :       7161 :     return sal_False;
    1050                 :            : }
    1051                 :            : 
    1052                 :       7181 : Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable )
    1053                 :            : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
    1054                 :            : {
    1055                 :       7181 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
    1056                 :            : 
    1057 [ -  + ][ +  - ]:       7181 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
    1058                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
    1059         [ #  # ]:          0 :         throw IllegalArgumentException();
    1060                 :            :     else
    1061                 :            :     {
    1062         [ +  - ]:       7181 :         ResetableGuard aGuard( m_aLock );
    1063                 :            : 
    1064         [ -  + ]:       7181 :         if ( m_bDisposed )
    1065         [ #  # ]:          0 :             throw DisposedException();
    1066                 :            : 
    1067         [ +  - ]:       7181 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
    1068         [ +  + ]:       7181 :         if ( pDataSettings )
    1069                 :            :         {
    1070                 :            :             // Create a copy of our data if someone wants to change the data.
    1071         [ +  + ]:       4892 :             if ( bWriteable )
    1072 [ +  - ][ +  - ]:          8 :                 return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( pDataSettings->xSettings ) ), UNO_QUERY );
                 [ +  - ]
    1073                 :            :             else
    1074                 :       7173 :                 return pDataSettings->xSettings;
    1075 [ +  - ][ +  + ]:       7181 :         }
    1076                 :            :     }
    1077                 :            : 
    1078         [ +  - ]:       7181 :     throw NoSuchElementException();
    1079                 :            : }
    1080                 :            : 
    1081                 :          6 : void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const ::rtl::OUString& ResourceURL, const Reference< ::com::sun::star::container::XIndexAccess >& aNewData )
    1082                 :            : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
    1083                 :            : {
    1084                 :          6 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
    1085                 :            : 
    1086 [ -  + ][ +  - ]:          6 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
    1087                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
    1088         [ #  # ]:          0 :         throw IllegalArgumentException();
    1089         [ -  + ]:          6 :     else if ( m_bReadOnly )
    1090         [ #  # ]:          0 :         throw IllegalAccessException();
    1091                 :            :     else
    1092                 :            :     {
    1093         [ +  - ]:          6 :         ResetableGuard aGuard( m_aLock );
    1094                 :            : 
    1095         [ -  + ]:          6 :         if ( m_bDisposed )
    1096         [ #  # ]:          0 :             throw DisposedException();
    1097                 :            : 
    1098         [ +  - ]:          6 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
    1099         [ +  - ]:          6 :         if ( pDataSettings )
    1100                 :            :         {
    1101         [ -  + ]:          6 :             if ( !pDataSettings->bDefaultNode )
    1102                 :            :             {
    1103                 :            :                 // we have a settings entry in our user-defined layer - replace
    1104                 :          0 :                 Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings;
    1105                 :            : 
    1106                 :            :                 // Create a copy of the data if the container is not const
    1107         [ #  # ]:          0 :                 Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
    1108         [ #  # ]:          0 :                 if ( xReplace.is() )
    1109 [ #  # ][ #  # ]:          0 :                     pDataSettings->xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
         [ #  # ][ #  # ]
    1110                 :            :                 else
    1111         [ #  # ]:          0 :                     pDataSettings->xSettings = aNewData;
    1112                 :          0 :                 pDataSettings->bDefault  = false;
    1113                 :          0 :                 pDataSettings->bModified = true;
    1114                 :          0 :                 m_bModified = true;
    1115                 :            : 
    1116                 :            :                 // Modify type container
    1117                 :          0 :                 UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
    1118                 :          0 :                 rElementType.bModified = true;
    1119                 :            : 
    1120         [ #  # ]:          0 :                 Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
    1121                 :            : 
    1122                 :            :                 // Create event to notify listener about replaced element settings
    1123         [ #  # ]:          0 :                 ConfigurationEvent aEvent;
    1124         [ #  # ]:          0 :                 Reference< XInterface > xIfac( xThis, UNO_QUERY );
    1125                 :            : 
    1126                 :          0 :                 aEvent.ResourceURL = ResourceURL;
    1127         [ #  # ]:          0 :                 aEvent.Accessor <<= xThis;
    1128         [ #  # ]:          0 :                 aEvent.Source = xIfac;
    1129         [ #  # ]:          0 :                 aEvent.ReplacedElement <<= xOldSettings;
    1130         [ #  # ]:          0 :                 aEvent.Element <<= pDataSettings->xSettings;
    1131                 :            : 
    1132         [ #  # ]:          0 :                 aGuard.unlock();
    1133                 :            : 
    1134 [ #  # ][ #  # ]:          0 :                 implts_notifyContainerListener( aEvent, NotifyOp_Replace );
    1135                 :            :             }
    1136                 :            :             else
    1137                 :            :             {
    1138                 :            :                 // we have no settings in our user-defined layer - insert
    1139         [ +  - ]:          6 :                 UIElementData aUIElementData;
    1140                 :            : 
    1141                 :          6 :                 aUIElementData.bDefault     = false;
    1142                 :          6 :                 aUIElementData.bDefaultNode = false;
    1143                 :          6 :                 aUIElementData.bModified    = true;
    1144                 :            : 
    1145                 :            :                 // Create a copy of the data if the container is not const
    1146         [ +  - ]:          6 :                 Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
    1147         [ +  - ]:          6 :                 if ( xReplace.is() )
    1148 [ +  - ][ +  - ]:          6 :                     aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
         [ +  - ][ +  - ]
    1149                 :            :                 else
    1150         [ #  # ]:          0 :                     aUIElementData.xSettings = aNewData;
    1151         [ +  - ]:          6 :                 aUIElementData.aName        = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix;
    1152                 :          6 :                 aUIElementData.aResourceURL = ResourceURL;
    1153                 :          6 :                 m_bModified = true;
    1154                 :            : 
    1155                 :            :                 // Modify type container
    1156                 :          6 :                 UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
    1157                 :          6 :                 rElementType.bModified = true;
    1158                 :            : 
    1159                 :          6 :                 UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
    1160                 :            : 
    1161                 :            :                 // Check our user element settings hash map as it can already contain settings that have been set to default!
    1162                 :            :                 // If no node can be found, we have to insert it.
    1163         [ +  - ]:          6 :                 UIElementDataHashMap::iterator pIter = rElements.find( ResourceURL );
    1164 [ +  - ][ -  + ]:          6 :                 if ( pIter != rElements.end() )
    1165 [ #  # ][ #  # ]:          0 :                     pIter->second = aUIElementData;
    1166                 :            :                 else
    1167 [ +  - ][ +  - ]:          6 :                     rElements.insert( UIElementDataHashMap::value_type( ResourceURL, aUIElementData ));
                 [ +  - ]
    1168                 :            : 
    1169         [ +  - ]:          6 :                 Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
    1170         [ +  - ]:          6 :                 Reference< XInterface > xIfac( xThis, UNO_QUERY );
    1171                 :            : 
    1172                 :            :                 // Create event to notify listener about replaced element settings
    1173         [ +  - ]:          6 :                 ConfigurationEvent aEvent;
    1174                 :            : 
    1175                 :          6 :                 aEvent.ResourceURL = ResourceURL;
    1176         [ +  - ]:          6 :                 aEvent.Accessor <<= xThis;
    1177         [ +  - ]:          6 :                 aEvent.Source = xIfac;
    1178         [ +  - ]:          6 :                 aEvent.ReplacedElement <<= pDataSettings->xSettings;
    1179         [ +  - ]:          6 :                 aEvent.Element <<= aUIElementData.xSettings;
    1180                 :            : 
    1181         [ +  - ]:          6 :                 aGuard.unlock();
    1182                 :            : 
    1183 [ +  - ][ +  - ]:          6 :                 implts_notifyContainerListener( aEvent, NotifyOp_Replace );
                 [ +  - ]
    1184                 :            :             }
    1185                 :            :         }
    1186                 :            :         else
    1187 [ #  # ][ +  - ]:          6 :             throw NoSuchElementException();
    1188                 :            :     }
    1189                 :          6 : }
    1190                 :            : 
    1191                 :          2 : void SAL_CALL ModuleUIConfigurationManager::removeSettings( const ::rtl::OUString& ResourceURL )
    1192                 :            : throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException, RuntimeException)
    1193                 :            : {
    1194                 :          2 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
    1195                 :            : 
    1196 [ -  + ][ +  - ]:          2 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
    1197                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
    1198         [ #  # ]:          0 :         throw IllegalArgumentException();
    1199         [ -  + ]:          2 :     else if ( m_bReadOnly )
    1200         [ #  # ]:          0 :         throw IllegalAccessException();
    1201                 :            :     else
    1202                 :            :     {
    1203         [ +  - ]:          2 :         ResetableGuard aGuard( m_aLock );
    1204                 :            : 
    1205         [ -  + ]:          2 :         if ( m_bDisposed )
    1206         [ #  # ]:          0 :             throw DisposedException();
    1207                 :            : 
    1208         [ +  - ]:          2 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
    1209         [ +  - ]:          2 :         if ( pDataSettings )
    1210                 :            :         {
    1211                 :            :             // If element settings are default, we don't need to change anything!
    1212         [ -  + ]:          2 :             if ( pDataSettings->bDefault )
    1213                 :          2 :                 return;
    1214                 :            :             else
    1215                 :            :             {
    1216                 :          2 :                 Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings;
    1217                 :          2 :                 pDataSettings->bDefault = true;
    1218                 :            : 
    1219                 :            :                 // check if this is a default layer node
    1220         [ +  - ]:          2 :                 if ( !pDataSettings->bDefaultNode )
    1221                 :          2 :                     pDataSettings->bModified = true; // we have to remove this node from the user layer!
    1222                 :          2 :                 pDataSettings->xSettings.clear();
    1223                 :          2 :                 m_bModified = true; // user layer must be written
    1224                 :            : 
    1225                 :            :                 // Modify type container
    1226                 :          2 :                 UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
    1227                 :          2 :                 rElementType.bModified = true;
    1228                 :            : 
    1229         [ +  - ]:          2 :                 Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
    1230         [ +  - ]:          2 :                 Reference< XInterface > xIfac( xThis, UNO_QUERY );
    1231                 :            : 
    1232                 :            :                 // Check if we have settings in the default layer which replaces the user-defined one!
    1233         [ +  - ]:          2 :                 UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType );
    1234         [ -  + ]:          2 :                 if ( pDefaultDataSettings )
    1235                 :            :                 {
    1236                 :            :                     // Create event to notify listener about replaced element settings
    1237         [ #  # ]:          0 :                     ConfigurationEvent aEvent;
    1238                 :            : 
    1239                 :          0 :                     aEvent.ResourceURL = ResourceURL;
    1240         [ #  # ]:          0 :                     aEvent.Accessor <<= xThis;
    1241         [ #  # ]:          0 :                     aEvent.Source = xIfac;
    1242         [ #  # ]:          0 :                     aEvent.Element <<= xRemovedSettings;
    1243         [ #  # ]:          0 :                     aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings;
    1244                 :            : 
    1245         [ #  # ]:          0 :                     aGuard.unlock();
    1246                 :            : 
    1247 [ #  # ][ #  # ]:          0 :                     implts_notifyContainerListener( aEvent, NotifyOp_Replace );
    1248                 :            :                 }
    1249                 :            :                 else
    1250                 :            :                 {
    1251                 :            :                     // Create event to notify listener about removed element settings
    1252         [ +  - ]:          2 :                     ConfigurationEvent aEvent;
    1253                 :            : 
    1254                 :          2 :                     aEvent.ResourceURL = ResourceURL;
    1255         [ +  - ]:          2 :                     aEvent.Accessor <<= xThis;
    1256         [ +  - ]:          2 :                     aEvent.Source = xIfac;
    1257         [ +  - ]:          2 :                     aEvent.Element <<= xRemovedSettings;
    1258                 :            : 
    1259         [ +  - ]:          2 :                     aGuard.unlock();
    1260                 :            : 
    1261 [ +  - ][ +  - ]:          2 :                     implts_notifyContainerListener( aEvent, NotifyOp_Remove );
    1262                 :          2 :                 }
    1263                 :            :             }
    1264                 :            :         }
    1265                 :            :         else
    1266 [ #  # ][ +  - ]:          2 :             throw NoSuchElementException();
                 [ +  - ]
    1267                 :            :     }
    1268                 :            : }
    1269                 :            : 
    1270                 :          2 : void SAL_CALL ModuleUIConfigurationManager::insertSettings( const ::rtl::OUString& NewResourceURL, const Reference< XIndexAccess >& aNewData )
    1271                 :            : throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, RuntimeException )
    1272                 :            : {
    1273                 :          2 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( NewResourceURL );
    1274                 :            : 
    1275 [ -  + ][ +  - ]:          2 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
    1276                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
    1277         [ #  # ]:          0 :         throw IllegalArgumentException();
    1278         [ -  + ]:          2 :     else if ( m_bReadOnly )
    1279         [ #  # ]:          0 :         throw IllegalAccessException();
    1280                 :            :     else
    1281                 :            :     {
    1282         [ +  - ]:          2 :         ResetableGuard aGuard( m_aLock );
    1283                 :            : 
    1284         [ -  + ]:          2 :         if ( m_bDisposed )
    1285         [ #  # ]:          0 :             throw DisposedException();
    1286                 :            : 
    1287         [ +  - ]:          2 :         UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType );
    1288         [ +  - ]:          2 :         if ( !pDataSettings )
    1289                 :            :         {
    1290         [ +  - ]:          2 :             UIElementData aUIElementData;
    1291                 :            : 
    1292                 :          2 :             aUIElementData.bDefault     = false;
    1293                 :          2 :             aUIElementData.bDefaultNode = false;
    1294                 :          2 :             aUIElementData.bModified    = true;
    1295                 :            : 
    1296                 :            :             // Create a copy of the data if the container is not const
    1297         [ +  - ]:          2 :             Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
    1298         [ +  - ]:          2 :             if ( xReplace.is() )
    1299 [ +  - ][ +  - ]:          2 :                 aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
         [ +  - ][ +  - ]
    1300                 :            :             else
    1301         [ #  # ]:          0 :                 aUIElementData.xSettings = aNewData;
    1302         [ +  - ]:          2 :             aUIElementData.aName        = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix;
    1303                 :          2 :             aUIElementData.aResourceURL = NewResourceURL;
    1304                 :          2 :             m_bModified = true;
    1305                 :            : 
    1306                 :          2 :             UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
    1307                 :          2 :             rElementType.bModified = true;
    1308                 :            : 
    1309                 :          2 :             UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
    1310 [ +  - ][ +  - ]:          2 :             rElements.insert( UIElementDataHashMap::value_type( NewResourceURL, aUIElementData ));
                 [ +  - ]
    1311                 :            : 
    1312                 :          2 :             Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
    1313         [ +  - ]:          2 :             Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
    1314         [ +  - ]:          2 :             Reference< XInterface > xIfac( xThis, UNO_QUERY );
    1315                 :            : 
    1316                 :            :             // Create event to notify listener about removed element settings
    1317         [ +  - ]:          2 :             ConfigurationEvent aEvent;
    1318                 :            : 
    1319                 :          2 :             aEvent.ResourceURL = NewResourceURL;
    1320         [ +  - ]:          2 :             aEvent.Accessor <<= xThis;
    1321         [ +  - ]:          2 :             aEvent.Source = xIfac;
    1322         [ +  - ]:          2 :             aEvent.Element <<= xInsertSettings;
    1323                 :            : 
    1324         [ +  - ]:          2 :             aGuard.unlock();
    1325                 :            : 
    1326 [ +  - ][ +  - ]:          2 :             implts_notifyContainerListener( aEvent, NotifyOp_Insert );
                 [ +  - ]
    1327                 :            :         }
    1328                 :            :         else
    1329 [ +  - ][ #  # ]:          2 :             throw ElementExistException();
    1330                 :            :     }
    1331                 :          2 : }
    1332                 :            : 
    1333                 :      46060 : Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getImageManager() throw (::com::sun::star::uno::RuntimeException)
    1334                 :            : {
    1335         [ +  - ]:      46060 :     ResetableGuard aGuard( m_aLock );
    1336                 :            : 
    1337         [ -  + ]:      46060 :     if ( m_bDisposed )
    1338         [ #  # ]:          0 :         throw DisposedException();
    1339                 :            : 
    1340         [ +  + ]:      46060 :     if ( !m_xModuleImageManager.is() )
    1341                 :            :     {
    1342         [ +  - ]:        145 :         m_xModuleImageManager = Reference< XComponent >( static_cast< cppu::OWeakObject *>( new ModuleImageManager( m_xServiceManager )),
    1343 [ +  - ][ +  - ]:        290 :                                                          UNO_QUERY );
    1344         [ +  - ]:        145 :         Reference< XInitialization > xInit( m_xModuleImageManager, UNO_QUERY );
    1345                 :            : 
    1346         [ +  - ]:        145 :         Sequence< Any > aPropSeq( 3 );
    1347                 :        145 :         PropertyValue aPropValue;
    1348                 :        145 :         aPropValue.Name  = rtl::OUString( "UserConfigStorage" );
    1349         [ +  - ]:        145 :         aPropValue.Value = makeAny( m_xUserConfigStorage );
    1350 [ +  - ][ +  - ]:        145 :         aPropSeq[0] = makeAny( aPropValue );
    1351                 :        145 :         aPropValue.Name  = rtl::OUString( "ModuleIdentifier" );
    1352         [ +  - ]:        145 :         aPropValue.Value = makeAny( m_aModuleIdentifier );
    1353 [ +  - ][ +  - ]:        145 :         aPropSeq[1] = makeAny( aPropValue );
    1354                 :        145 :         aPropValue.Name  = rtl::OUString( "UserRootCommit" );
    1355         [ +  - ]:        145 :         aPropValue.Value = makeAny( m_xUserRootCommit );
    1356 [ +  - ][ +  - ]:        145 :         aPropSeq[2] = makeAny( aPropValue );
    1357                 :            : 
    1358 [ +  - ][ +  - ]:        145 :         xInit->initialize( aPropSeq );
                 [ +  - ]
    1359                 :            :     }
    1360                 :            : 
    1361 [ +  - ][ +  - ]:      46060 :     return Reference< XInterface >( m_xModuleImageManager, UNO_QUERY );
    1362                 :            : }
    1363                 :            : 
    1364                 :       2562 : Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getShortCutManager() throw (::com::sun::star::uno::RuntimeException)
    1365                 :            : {
    1366         [ +  - ]:       2562 :     ResetableGuard aGuard( m_aLock );
    1367                 :            : 
    1368         [ -  + ]:       2562 :     if ( m_bDisposed )
    1369         [ #  # ]:          0 :         throw DisposedException();
    1370                 :            : 
    1371                 :       2562 :     Reference< XMultiServiceFactory > xSMGR   = m_xServiceManager;
    1372                 :       2562 :     ::rtl::OUString                   aModule = m_aModuleIdentifier;
    1373                 :            : 
    1374         [ +  + ]:       2562 :     if ( !m_xModuleAcceleratorManager.is() )
    1375                 :            :     {
    1376 [ +  - ][ +  - ]:         92 :         Reference< XInterface >      xManager = xSMGR->createInstance(SERVICENAME_MODULEACCELERATORCONFIGURATION);
                 [ +  - ]
    1377         [ +  - ]:         92 :         Reference< XInitialization > xInit    (xManager, UNO_QUERY_THROW);
    1378                 :            : 
    1379                 :         92 :         PropertyValue aProp;
    1380                 :         92 :         aProp.Name    = ::rtl::OUString("ModuleIdentifier");
    1381         [ +  - ]:         92 :         aProp.Value <<= aModule;
    1382                 :            : 
    1383         [ +  - ]:         92 :         Sequence< Any > lArgs(1);
    1384 [ +  - ][ +  - ]:         92 :         lArgs[0] <<= aProp;
    1385                 :            : 
    1386 [ +  - ][ +  - ]:         92 :         xInit->initialize(lArgs);
    1387 [ +  - ][ +  - ]:         92 :         m_xModuleAcceleratorManager = Reference< XInterface >( xManager, UNO_QUERY );
                 [ +  - ]
    1388                 :            :     }
    1389                 :            : 
    1390         [ +  - ]:       2562 :     return m_xModuleAcceleratorManager;
    1391                 :            : }
    1392                 :            : 
    1393                 :          2 : Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getEventsManager() throw (::com::sun::star::uno::RuntimeException)
    1394                 :            : {
    1395                 :          2 :     return Reference< XInterface >();
    1396                 :            : }
    1397                 :            : 
    1398                 :            : // XModuleUIConfigurationManager
    1399                 :          4 : sal_Bool SAL_CALL ModuleUIConfigurationManager::isDefaultSettings( const ::rtl::OUString& ResourceURL )
    1400                 :            : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
    1401                 :            : {
    1402                 :          4 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
    1403                 :            : 
    1404 [ -  + ][ +  - ]:          4 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
    1405                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
    1406         [ #  # ]:          0 :         throw IllegalArgumentException();
    1407                 :            :     else
    1408                 :            :     {
    1409         [ +  - ]:          4 :         ResetableGuard aGuard( m_aLock );
    1410                 :            : 
    1411         [ -  + ]:          4 :         if ( m_bDisposed )
    1412         [ #  # ]:          0 :             throw DisposedException();
    1413                 :            : 
    1414         [ +  - ]:          4 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false );
    1415 [ +  + ][ +  - ]:          4 :         if ( pDataSettings && pDataSettings->bDefaultNode )
    1416 [ +  - ][ +  + ]:          4 :             return sal_True;
    1417                 :            :     }
    1418                 :            : 
    1419                 :          4 :     return sal_False;
    1420                 :            : }
    1421                 :            : 
    1422                 :          2 : Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getDefaultSettings( const ::rtl::OUString& ResourceURL )
    1423                 :            : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
    1424                 :            : {
    1425                 :          2 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
    1426                 :            : 
    1427 [ -  + ][ +  - ]:          2 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
    1428                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
    1429         [ #  # ]:          0 :         throw IllegalArgumentException();
    1430                 :            :     else
    1431                 :            :     {
    1432         [ +  - ]:          2 :         ResetableGuard aGuard( m_aLock );
    1433                 :            : 
    1434         [ -  + ]:          2 :         if ( m_bDisposed )
    1435         [ #  # ]:          0 :             throw DisposedException();
    1436                 :            : 
    1437                 :            :         // preload list of element types on demand
    1438         [ +  - ]:          2 :         impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
    1439                 :            : 
    1440                 :            :         // Look into our default vector/boost::unordered_map combination
    1441                 :          2 :         UIElementDataHashMap& rDefaultHashMap = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
    1442         [ +  - ]:          2 :         UIElementDataHashMap::iterator pIter = rDefaultHashMap.find( ResourceURL );
    1443 [ +  - ][ +  - ]:          2 :         if ( pIter != rDefaultHashMap.end() )
    1444                 :            :         {
    1445 [ +  - ][ -  + ]:          2 :             if ( !pIter->second.xSettings.is() )
    1446 [ #  # ][ #  # ]:          0 :                 impl_requestUIElementData( nElementType, LAYER_DEFAULT, pIter->second );
    1447         [ +  - ]:          4 :             return pIter->second.xSettings;
    1448 [ +  - ][ -  + ]:          2 :         }
    1449                 :            :     }
    1450                 :            : 
    1451                 :            :     // Nothing has been found!
    1452         [ #  # ]:          2 :     throw NoSuchElementException();
    1453                 :            : }
    1454                 :            : 
    1455                 :            : // XUIConfigurationPersistence
    1456                 :          2 : void SAL_CALL ModuleUIConfigurationManager::reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
    1457                 :            : {
    1458         [ +  - ]:          2 :     ResetableGuard aGuard( m_aLock );
    1459                 :            : 
    1460         [ -  + ]:          2 :     if ( m_bDisposed )
    1461         [ #  # ]:          0 :         throw DisposedException();
    1462                 :            : 
    1463 [ +  - ][ -  + ]:          2 :     if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
         [ #  # ][ -  + ]
    1464                 :            :     {
    1465                 :            :         // Try to access our module sub folder
    1466         [ #  # ]:          0 :         ConfigEventNotifyContainer aRemoveNotifyContainer;
    1467         [ #  # ]:          0 :         ConfigEventNotifyContainer aReplaceNotifyContainer;
    1468         [ #  # ]:          0 :         for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
    1469                 :            :         {
    1470                 :            :             try
    1471                 :            :             {
    1472                 :          0 :                 UIElementType& rUserElementType    = m_aUIElements[LAYER_USERDEFINED][i];
    1473                 :          0 :                 UIElementType& rDefaultElementType = m_aUIElements[LAYER_DEFAULT][i];
    1474                 :            : 
    1475         [ #  # ]:          0 :                 if ( rUserElementType.bModified )
    1476         [ #  # ]:          0 :                     impl_reloadElementTypeData( rUserElementType, rDefaultElementType, aRemoveNotifyContainer, aReplaceNotifyContainer );
    1477                 :            :             }
    1478         [ #  # ]:          0 :             catch ( const Exception& )
    1479                 :            :             {
    1480         [ #  # ]:          0 :                 throw IOException();
    1481                 :            :             }
    1482                 :            :         }
    1483                 :            : 
    1484                 :          0 :         m_bModified = sal_False;
    1485                 :            : 
    1486                 :            :         // Unlock mutex before notify our listeners
    1487         [ #  # ]:          0 :         aGuard.unlock();
    1488                 :            : 
    1489                 :            :         // Notify our listeners
    1490         [ #  # ]:          0 :         for ( sal_uInt32 j = 0; j < aRemoveNotifyContainer.size(); j++ )
    1491         [ #  # ]:          0 :             implts_notifyContainerListener( aRemoveNotifyContainer[j], NotifyOp_Remove );
    1492         [ #  # ]:          0 :         for ( sal_uInt32 k = 0; k < aReplaceNotifyContainer.size(); k++ )
    1493         [ #  # ]:          0 :             implts_notifyContainerListener( aReplaceNotifyContainer[k], NotifyOp_Replace );
    1494         [ +  - ]:          2 :     }
    1495                 :          2 : }
    1496                 :            : 
    1497                 :          2 : void SAL_CALL ModuleUIConfigurationManager::store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
    1498                 :            : {
    1499         [ +  - ]:          2 :     ResetableGuard aGuard( m_aLock );
    1500                 :            : 
    1501         [ -  + ]:          2 :     if ( m_bDisposed )
    1502         [ #  # ]:          0 :         throw DisposedException();
    1503                 :            : 
    1504 [ +  - ][ -  + ]:          2 :     if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
         [ #  # ][ -  + ]
    1505                 :            :     {
    1506                 :            :         // Try to access our module sub folder
    1507         [ #  # ]:          0 :         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
    1508                 :            :         {
    1509                 :            :             try
    1510                 :            :             {
    1511                 :          0 :                 UIElementType&        rElementType = m_aUIElements[LAYER_USERDEFINED][i];
    1512         [ #  # ]:          0 :                 Reference< XStorage > xStorage( rElementType.xStorage, UNO_QUERY );
    1513                 :            : 
    1514 [ #  # ][ #  # ]:          0 :                 if ( rElementType.bModified && xStorage.is() )
                 [ #  # ]
    1515                 :            :                 {
    1516         [ #  # ]:          0 :                     impl_storeElementTypeData( xStorage, rElementType );
    1517         [ #  # ]:          0 :                     m_pStorageHandler[i]->commitUserChanges();
    1518                 :          0 :                 }
    1519                 :            :             }
    1520         [ #  # ]:          0 :             catch ( const Exception& )
    1521                 :            :             {
    1522         [ #  # ]:          0 :                 throw IOException();
    1523                 :            :             }
    1524                 :            :         }
    1525                 :            : 
    1526                 :          0 :         m_bModified = false;
    1527         [ +  - ]:          2 :     }
    1528                 :          2 : }
    1529                 :            : 
    1530                 :          2 : void SAL_CALL ModuleUIConfigurationManager::storeToStorage( const Reference< XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
    1531                 :            : {
    1532         [ +  - ]:          2 :     ResetableGuard aGuard( m_aLock );
    1533                 :            : 
    1534         [ -  + ]:          2 :     if ( m_bDisposed )
    1535         [ #  # ]:          0 :         throw DisposedException();
    1536                 :            : 
    1537 [ +  - ][ -  + ]:          2 :     if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
         [ #  # ][ -  + ]
    1538                 :            :     {
    1539                 :            :         // Try to access our module sub folder
    1540         [ #  # ]:          0 :         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
    1541                 :            :         {
    1542                 :            :             try
    1543                 :            :             {
    1544         [ #  # ]:          0 :                 Reference< XStorage > xElementTypeStorage( Storage->openStorageElement(
    1545         [ #  # ]:          0 :                                                             OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), ElementModes::READWRITE ));
    1546                 :          0 :                 UIElementType&        rElementType = m_aUIElements[LAYER_USERDEFINED][i];
    1547                 :            : 
    1548 [ #  # ][ #  # ]:          0 :                 if ( rElementType.bModified && xElementTypeStorage.is() )
                 [ #  # ]
    1549         [ #  # ]:          0 :                     impl_storeElementTypeData( xElementTypeStorage, rElementType, false ); // store data to storage, but don't reset modify flag!
    1550                 :            :             }
    1551         [ #  # ]:          0 :             catch ( const Exception& )
    1552                 :            :             {
    1553         [ #  # ]:          0 :                 throw IOException();
    1554                 :            :             }
    1555                 :            :         }
    1556                 :            : 
    1557         [ #  # ]:          0 :         Reference< XTransactedObject > xTransactedObject( Storage, UNO_QUERY );
    1558         [ #  # ]:          0 :         if ( xTransactedObject.is() )
    1559 [ #  # ][ #  # ]:          0 :             xTransactedObject->commit();
    1560         [ +  - ]:          2 :     }
    1561                 :          2 : }
    1562                 :            : 
    1563                 :          2 : sal_Bool SAL_CALL ModuleUIConfigurationManager::isModified() throw (::com::sun::star::uno::RuntimeException)
    1564                 :            : {
    1565         [ +  - ]:          2 :     ResetableGuard aGuard( m_aLock );
    1566                 :            : 
    1567         [ +  - ]:          2 :     return m_bModified;
    1568                 :            : }
    1569                 :            : 
    1570                 :          8 : sal_Bool SAL_CALL ModuleUIConfigurationManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
    1571                 :            : {
    1572         [ +  - ]:          8 :     ResetableGuard aGuard( m_aLock );
    1573                 :            : 
    1574         [ +  - ]:          8 :     return m_bReadOnly;
    1575                 :            : }
    1576                 :            : 
    1577                 :         16 : void ModuleUIConfigurationManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
    1578                 :            : {
    1579                 :         16 :     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >*) NULL ) );
    1580         [ +  - ]:         16 :     if ( pContainer != NULL )
    1581                 :            :     {
    1582         [ +  - ]:         16 :         ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
    1583         [ +  + ]:         36 :         while ( pIterator.hasMoreElements() )
    1584                 :            :         {
    1585                 :            :             try
    1586                 :            :             {
    1587   [ +  +  +  - ]:         20 :                 switch ( eOp )
    1588                 :            :                 {
    1589                 :            :                     case NotifyOp_Replace:
    1590 [ +  - ][ +  - ]:         16 :                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementReplaced( aEvent );
    1591                 :         16 :                         break;
    1592                 :            :                     case NotifyOp_Insert:
    1593 [ +  - ][ +  - ]:          2 :                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementInserted( aEvent );
    1594                 :          2 :                         break;
    1595                 :            :                     case NotifyOp_Remove:
    1596 [ +  - ][ +  - ]:          2 :                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementRemoved( aEvent );
    1597                 :          2 :                         break;
    1598                 :            :                 }
    1599                 :            :             }
    1600   [ #  #  #  # ]:          0 :             catch( const css::uno::RuntimeException& )
    1601                 :            :             {
    1602         [ #  # ]:          0 :                 pIterator.remove();
    1603                 :            :             }
    1604         [ +  - ]:         16 :         }
    1605                 :            :     }
    1606                 :         16 : }
    1607                 :            : 
    1608                 :            : } // namespace framework
    1609                 :            : 
    1610                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10