LCOV - code coverage report
Current view: top level - framework/source/uiconfiguration - uiconfigurationmanager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 184 620 29.7 %
Date: 2012-08-25 Functions: 28 50 56.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 184 1264 14.6 %

           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/uiconfigurationmanager.hxx>
      30                 :            : #include <threadhelp/resetableguard.hxx>
      31                 :            : #include <services.h>
      32                 :            : #include <uielement/rootitemcontainer.hxx>
      33                 :            : #include <uielement/constitemcontainer.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/XInitialization.hpp>
      43                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      44                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      45                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      46                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      47                 :            : #include <com/sun/star/io/XStream.hpp>
      48                 :            : #include <com/sun/star/embed/XTransactedObject.hpp>
      49                 :            : 
      50                 :            : #include <vcl/svapp.hxx>
      51                 :            : #include <rtl/ustrbuf.hxx>
      52                 :            : 
      53                 :            : //_________________________________________________________________________________________________________________
      54                 :            : //  namespaces
      55                 :            : //_________________________________________________________________________________________________________________
      56                 :            : 
      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 [ +  + ][ +  - ]:     416231 : DEFINE_XINTERFACE_7                    (    UIConfigurationManager                                                          ,
      72                 :            :                                             OWeakObject                                                                     ,
      73                 :            :                                             DIRECT_INTERFACE( css::lang::XTypeProvider                                      ),
      74                 :            :                                             DIRECT_INTERFACE( css::lang::XServiceInfo                                       ),
      75                 :            :                                             DIRECT_INTERFACE( css::lang::XComponent                                         ),
      76                 :            :                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfiguration                  ),
      77                 :            :                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationManager           ),
      78                 :            :                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationPersistence       ),
      79                 :            :                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationStorage           )
      80                 :            :                                         )
      81                 :            : 
      82 [ +  - ][ +  - ]:          2 : DEFINE_XTYPEPROVIDER_7                  (   UIConfigurationManager                                  ,
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      83                 :            :                                             css::lang::XTypeProvider                                ,
      84                 :            :                                             css::lang::XServiceInfo                                 ,
      85                 :            :                                             css::lang::XComponent                                   ,
      86                 :            :                                             ::com::sun::star::ui::XUIConfiguration            ,
      87                 :            :                                             ::com::sun::star::ui::XUIConfigurationManager     ,
      88                 :            :                                             ::com::sun::star::ui::XUIConfigurationPersistence ,
      89                 :            :                                             ::com::sun::star::ui::XUIConfigurationStorage
      90                 :            :                                         )
      91                 :            : 
      92 [ +  - ][ +  - ]:       4495 : DEFINE_XSERVICEINFO_MULTISERVICE        (   UIConfigurationManager                      ,
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
      93                 :            :                                             ::cppu::OWeakObject                         ,
      94                 :            :                                             SERVICENAME_UICONFIGURATIONMANAGER          ,
      95                 :            :                                             IMPLEMENTATIONNAME_UICONFIGURATIONMANAGER
      96                 :            :                                         )
      97                 :            : 
      98                 :       2137 : DEFINE_INIT_SERVICE                     (   UIConfigurationManager, {} )
      99                 :            : 
     100                 :            : 
     101                 :            : // important: The order and position of the elements must match the constant
     102                 :            : // definition of "::com::sun::star::ui::UIElementType"
     103                 :            : static const char* UIELEMENTTYPENAMES[] =
     104                 :            : {
     105                 :            :     "",  // Dummy value for unknown!
     106                 :            :     UIELEMENTTYPE_MENUBAR_NAME,
     107                 :            :     UIELEMENTTYPE_POPUPMENU_NAME,
     108                 :            :     UIELEMENTTYPE_TOOLBAR_NAME,
     109                 :            :     UIELEMENTTYPE_STATUSBAR_NAME,
     110                 :            :     UIELEMENTTYPE_FLOATINGWINDOW_NAME,
     111                 :            :     UIELEMENTTYPE_PROGRESSBAR_NAME,
     112                 :            :     UIELEMENTTYPE_TOOLPANEL_NAME
     113                 :            : };
     114                 :            : 
     115                 :            : static const char       RESOURCEURL_PREFIX[] = "private:resource/";
     116                 :            : static const sal_Int32  RESOURCEURL_PREFIX_SIZE = 17;
     117                 :            : 
     118                 :       7019 : static sal_Int16 RetrieveTypeFromResourceURL( const rtl::OUString& aResourceURL )
     119                 :            : {
     120                 :            : 
     121   [ +  -  +  - ]:      14038 :     if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) &&
                 [ +  - ]
     122                 :       7019 :         ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
     123                 :            :     {
     124                 :       7019 :         rtl::OUString aTmpStr     = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE );
     125                 :       7019 :         sal_Int32     nIndex      = aTmpStr.indexOf( '/' );
     126 [ +  - ][ +  - ]:       7019 :         if (( nIndex > 0 ) &&  ( aTmpStr.getLength() > nIndex ))
                 [ +  - ]
     127                 :            :         {
     128                 :       7019 :             rtl::OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
     129         [ +  - ]:      26369 :             for ( int i = 0; i < UIElementType::COUNT; i++ )
     130                 :            :             {
     131         [ +  + ]:      26369 :                 if ( aTypeStr.equalsAscii( UIELEMENTTYPENAMES[i] ))
     132                 :       7019 :                     return sal_Int16( i );
     133         [ -  + ]:       7019 :             }
     134         [ -  + ]:       7019 :         }
     135                 :            :     }
     136                 :            : 
     137                 :       7019 :     return UIElementType::UNKNOWN;
     138                 :            : }
     139                 :            : 
     140                 :          0 : static rtl::OUString RetrieveNameFromResourceURL( const rtl::OUString& aResourceURL )
     141                 :            : {
     142   [ #  #  #  # ]:          0 :     if (( aResourceURL.indexOf( RESOURCEURL_PREFIX ) == 0 ) &&
                 [ #  # ]
     143                 :          0 :         ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
     144                 :            :     {
     145                 :          0 :         sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' );
     146 [ #  # ][ #  # ]:          0 :         if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength()))
                 [ #  # ]
     147                 :          0 :             return aResourceURL.copy( nIndex+1 );
     148                 :            :     }
     149                 :            : 
     150                 :          0 :     return rtl::OUString();
     151                 :            : }
     152                 :            : 
     153                 :       1733 : void UIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType )
     154                 :            : {
     155                 :            :     // preload list of element types on demand
     156         [ +  - ]:       1733 :     impl_preloadUIElementTypeList( nElementType );
     157                 :            : 
     158                 :       1733 :     UIElementDataHashMap& rUserElements = m_aUIElements[nElementType].aElementsHashMap;
     159         [ +  - ]:       1733 :     UIElementDataHashMap::const_iterator pUserIter = rUserElements.begin();
     160                 :            : 
     161 [ +  - ][ -  + ]:       1733 :     while ( pUserIter != rUserElements.end() )
     162                 :            :     {
     163 [ #  # ][ #  # ]:          0 :         UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType );
     164 [ #  # ][ #  # ]:          0 :         if ( pDataSettings && !pDataSettings->bDefault )
     165                 :            :         {
     166                 :            :             // Retrieve user interface name from XPropertySet interface
     167                 :          0 :             rtl::OUString aUIName;
     168         [ #  # ]:          0 :             Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY );
     169         [ #  # ]:          0 :             if ( xPropSet.is() )
     170                 :            :             {
     171 [ #  # ][ #  # ]:          0 :                 Any a = xPropSet->getPropertyValue( m_aPropUIName );
     172                 :          0 :                 a >>= aUIName;
     173                 :            :             }
     174                 :            : 
     175         [ #  # ]:          0 :             UIElementInfo aInfo( pUserIter->second.aResourceURL, aUIName );
     176 [ #  # ][ #  # ]:          0 :             aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo ));
     177                 :            :         }
     178                 :          0 :         ++pUserIter;
     179                 :            :     }
     180                 :       1733 : }
     181                 :            : 
     182                 :       8752 : void UIConfigurationManager::impl_preloadUIElementTypeList( sal_Int16 nElementType )
     183                 :            : {
     184                 :       8752 :     UIElementType& rElementTypeData = m_aUIElements[nElementType];
     185                 :            : 
     186         [ +  + ]:       8752 :     if ( !rElementTypeData.bLoaded )
     187                 :            :     {
     188                 :       5087 :         Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
     189         [ +  + ]:       5087 :         if ( xElementTypeStorage.is() )
     190                 :            :         {
     191                 :       4628 :             rtl::OUStringBuffer aBuf( RESOURCEURL_PREFIX_SIZE );
     192         [ +  - ]:       4628 :             aBuf.appendAscii( RESOURCEURL_PREFIX );
     193         [ +  - ]:       4628 :             aBuf.appendAscii( UIELEMENTTYPENAMES[ nElementType ] );
     194         [ +  - ]:       4628 :             aBuf.appendAscii( "/" );
     195         [ +  - ]:       4628 :             rtl::OUString aResURLPrefix( aBuf.makeStringAndClear() );
     196                 :            : 
     197                 :       4628 :             UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap;
     198         [ +  - ]:       4628 :             Reference< XNameAccess > xNameAccess( xElementTypeStorage, UNO_QUERY );
     199 [ +  - ][ +  - ]:       4628 :             Sequence< rtl::OUString > aUIElementNames = xNameAccess->getElementNames();
     200         [ -  + ]:       4628 :             for ( sal_Int32 n = 0; n < aUIElementNames.getLength(); n++ )
     201                 :            :             {
     202         [ #  # ]:          0 :                 UIElementData aUIElementData;
     203                 :            : 
     204                 :            :                 // Resource name must be without ".xml"
     205         [ #  # ]:          0 :                 sal_Int32 nIndex = aUIElementNames[n].lastIndexOf( '.' );
     206 [ #  # ][ #  # ]:          0 :                 if (( nIndex > 0 ) && ( nIndex < aUIElementNames[n].getLength() ))
         [ #  # ][ #  # ]
     207                 :            :                 {
     208         [ #  # ]:          0 :                     rtl::OUString aExtension( aUIElementNames[n].copy( nIndex+1 ));
     209         [ #  # ]:          0 :                     rtl::OUString aUIElementName( aUIElementNames[n].copy( 0, nIndex ));
     210                 :            : 
     211         [ #  # ]:          0 :                     if (!aUIElementName.isEmpty() &&
           [ #  #  #  # ]
     212                 :          0 :                         ( aExtension.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("xml"))))
     213                 :            :                     {
     214                 :          0 :                         aUIElementData.aResourceURL = aResURLPrefix + aUIElementName;
     215         [ #  # ]:          0 :                         aUIElementData.aName        = aUIElementNames[n];
     216                 :          0 :                         aUIElementData.bModified    = false;
     217                 :          0 :                         aUIElementData.bDefault     = false;
     218                 :            : 
     219                 :            :                         // Create boost::unordered_map entries for all user interface elements inside the storage. We don't load the
     220                 :            :                         // settings to speed up the process.
     221 [ #  # ][ #  # ]:          0 :                         rHashMap.insert( UIElementDataHashMap::value_type( aUIElementData.aResourceURL, aUIElementData ));
                 [ #  # ]
     222                 :          0 :                     }
     223                 :            :                 }
     224 [ #  # ][ +  - ]:       4628 :             }
     225                 :       5087 :         }
     226                 :            :     }
     227                 :            : 
     228                 :       8752 :     rElementTypeData.bLoaded = true;
     229                 :       8752 : }
     230                 :            : 
     231                 :          0 : void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, UIElementData& aUIElementData )
     232                 :            : {
     233                 :          0 :     UIElementType& rElementTypeData = m_aUIElements[nElementType];
     234                 :            : 
     235                 :          0 :     Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
     236 [ #  # ][ #  # ]:          0 :     if ( xElementTypeStorage.is() && !aUIElementData.aName.isEmpty() )
                 [ #  # ]
     237                 :            :     {
     238                 :            :         try
     239                 :            :         {
     240 [ #  # ][ #  # ]:          0 :             Reference< XStream > xStream = xElementTypeStorage->openStreamElement( aUIElementData.aName, ElementModes::READ );
     241 [ #  # ][ #  # ]:          0 :             Reference< XInputStream > xInputStream = xStream->getInputStream();
     242                 :            : 
     243         [ #  # ]:          0 :             if ( xInputStream.is() )
     244                 :            :             {
     245   [ #  #  #  #  :          0 :                 switch ( nElementType )
                #  #  # ]
     246                 :            :                 {
     247                 :            :                     case ::com::sun::star::ui::UIElementType::UNKNOWN:
     248                 :          0 :                     break;
     249                 :            : 
     250                 :            :                     case ::com::sun::star::ui::UIElementType::MENUBAR:
     251                 :            :                     {
     252                 :            :                         try
     253                 :            :                         {
     254         [ #  # ]:          0 :                             MenuConfiguration aMenuCfg( m_xServiceManager );
     255         [ #  # ]:          0 :                             Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
     256                 :          0 :                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xContainer );
     257         [ #  # ]:          0 :                             if ( pRootItemContainer )
     258 [ #  # ][ #  # ]:          0 :                                 aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     259                 :            :                             else
     260 [ #  # ][ #  # ]:          0 :                                 aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xContainer, sal_True ) ), UNO_QUERY );
         [ #  # ][ #  # ]
     261 [ #  # ][ #  # ]:          0 :                             return;
     262                 :            :                         }
     263         [ #  # ]:          0 :                         catch ( const ::com::sun::star::lang::WrappedTargetException& )
     264                 :            :                         {
     265                 :            :                         }
     266                 :            :                     }
     267                 :          0 :                     break;
     268                 :            : 
     269                 :            :                     case ::com::sun::star::ui::UIElementType::POPUPMENU:
     270                 :            :                     {
     271                 :          0 :                         break;
     272                 :            :                     }
     273                 :            : 
     274                 :            :                     case ::com::sun::star::ui::UIElementType::TOOLBAR:
     275                 :            :                     {
     276                 :            :                         try
     277                 :            :                         {
     278 [ #  # ][ #  # ]:          0 :                             Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
                 [ #  # ]
     279         [ #  # ]:          0 :                             ToolBoxConfiguration::LoadToolBox( m_xServiceManager, xInputStream, xIndexContainer );
     280                 :          0 :                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer );
     281 [ #  # ][ #  # ]:          0 :                             aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     282         [ #  # ]:          0 :                             return;
     283                 :            :                         }
     284         [ #  # ]:          0 :                         catch ( const ::com::sun::star::lang::WrappedTargetException& )
     285                 :            :                         {
     286                 :            :                         }
     287                 :            : 
     288                 :          0 :                         break;
     289                 :            :                     }
     290                 :            : 
     291                 :            :                     case ::com::sun::star::ui::UIElementType::STATUSBAR:
     292                 :            :                     {
     293                 :            :                         try
     294                 :            :                         {
     295 [ #  # ][ #  # ]:          0 :                             Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
                 [ #  # ]
     296         [ #  # ]:          0 :                             StatusBarConfiguration::LoadStatusBar( m_xServiceManager, xInputStream, xIndexContainer );
     297                 :          0 :                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer );
     298 [ #  # ][ #  # ]:          0 :                             aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     299         [ #  # ]:          0 :                             return;
     300                 :            :                         }
     301         [ #  # ]:          0 :                         catch ( const ::com::sun::star::lang::WrappedTargetException& )
     302                 :            :                         {
     303                 :            :                         }
     304                 :            : 
     305                 :          0 :                         break;
     306                 :            :                     }
     307                 :            : 
     308                 :            :                     case ::com::sun::star::ui::UIElementType::FLOATINGWINDOW:
     309                 :            :                     {
     310                 :          0 :                         break;
     311                 :            :                     }
     312                 :            :                 }
     313 [ #  # ][ #  # ]:          0 :             }
           [ #  #  #  #  
                      # ]
     314                 :            :         }
     315         [ #  # ]:          0 :         catch ( const ::com::sun::star::embed::InvalidStorageException& )
     316                 :            :         {
     317                 :            :         }
     318         [ #  # ]:          0 :         catch ( const ::com::sun::star::lang::IllegalArgumentException& )
     319                 :            :         {
     320                 :            :         }
     321         [ #  # ]:          0 :         catch ( const ::com::sun::star::io::IOException& )
     322                 :            :         {
     323                 :            :         }
     324         [ #  # ]:          0 :         catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
     325                 :            :         {
     326                 :            :         }
     327                 :            :     }
     328                 :            : 
     329                 :            :     // At least we provide an empty settings container!
     330 [ #  # ][ #  # ]:          0 :     aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer()), UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     331                 :            : }
     332                 :            : 
     333                 :       7019 : UIConfigurationManager::UIElementData* UIConfigurationManager::impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad )
     334                 :            : {
     335                 :            :     // preload list of element types on demand
     336         [ +  - ]:       7019 :     impl_preloadUIElementTypeList( nElementType );
     337                 :            : 
     338                 :            :     // try to look into our document vector/boost::unordered_map combination
     339                 :       7019 :     UIElementDataHashMap& rUserHashMap = m_aUIElements[nElementType].aElementsHashMap;
     340         [ +  - ]:       7019 :     UIElementDataHashMap::iterator pIter = rUserHashMap.find( aResourceURL );
     341 [ +  - ][ -  + ]:       7019 :     if ( pIter != rUserHashMap.end() )
     342                 :            :     {
     343                 :            :         // Default data settings data means removed!
     344 [ #  # ][ #  # ]:          0 :         if ( pIter->second.bDefault )
     345         [ #  # ]:          0 :             return &(pIter->second);
     346                 :            :         else
     347                 :            :         {
     348 [ #  # ][ #  # ]:          0 :             if ( !pIter->second.xSettings.is() && bLoad )
         [ #  # ][ #  # ]
     349 [ #  # ][ #  # ]:          0 :                 impl_requestUIElementData( nElementType, pIter->second );
     350         [ #  # ]:          0 :             return &(pIter->second);
     351                 :            :         }
     352                 :            :     }
     353                 :            : 
     354                 :            :     // Nothing has been found!
     355                 :       7019 :     return NULL;
     356                 :            : }
     357                 :            : 
     358                 :          0 : void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage >& xStorage, UIElementType& rElementType, bool bResetModifyState )
     359                 :            : {
     360                 :          0 :     UIElementDataHashMap& rHashMap          = rElementType.aElementsHashMap;
     361         [ #  # ]:          0 :     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
     362                 :            : 
     363 [ #  # ][ #  # ]:          0 :     while ( pIter != rHashMap.end() )
     364                 :            :     {
     365         [ #  # ]:          0 :         UIElementData& rElement = pIter->second;
     366         [ #  # ]:          0 :         if ( rElement.bModified )
     367                 :            :         {
     368         [ #  # ]:          0 :             if ( rElement.bDefault )
     369                 :            :             {
     370 [ #  # ][ #  # ]:          0 :                 xStorage->removeElement( rElement.aName );
     371                 :          0 :                 rElement.bModified = sal_False; // mark as not modified
     372                 :            :             }
     373                 :            :             else
     374                 :            :             {
     375 [ #  # ][ #  # ]:          0 :                 Reference< XStream > xStream( xStorage->openStreamElement( rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY );
                 [ #  # ]
     376 [ #  # ][ #  # ]:          0 :                 Reference< XOutputStream > xOutputStream( xStream->getOutputStream() );
     377                 :            : 
     378         [ #  # ]:          0 :                 if ( xOutputStream.is() )
     379                 :            :                 {
     380   [ #  #  #  # ]:          0 :                     switch( rElementType.nElementType )
     381                 :            :                     {
     382                 :            :                         case ::com::sun::star::ui::UIElementType::MENUBAR:
     383                 :            :                         {
     384                 :            :                             try
     385                 :            :                             {
     386         [ #  # ]:          0 :                                 MenuConfiguration aMenuCfg( m_xServiceManager );
     387 [ #  # ][ #  # ]:          0 :                                 aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream );
                 [ #  # ]
     388                 :            :                             }
     389   [ #  #  #  # ]:          0 :                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
     390                 :            :                             {
     391                 :            :                             }
     392                 :            :                         }
     393                 :          0 :                         break;
     394                 :            : 
     395                 :            :                         case ::com::sun::star::ui::UIElementType::TOOLBAR:
     396                 :            :                         {
     397                 :            :                             try
     398                 :            :                             {
     399         [ #  # ]:          0 :                                 ToolBoxConfiguration::StoreToolBox( m_xServiceManager, xOutputStream, rElement.xSettings );
     400                 :            :                             }
     401   [ #  #  #  # ]:          0 :                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
     402                 :            :                             {
     403                 :            :                             }
     404                 :            :                         }
     405                 :          0 :                         break;
     406                 :            : 
     407                 :            :                         case ::com::sun::star::ui::UIElementType::STATUSBAR:
     408                 :            :                         {
     409                 :            :                             try
     410                 :            :                             {
     411         [ #  # ]:          0 :                                 StatusBarConfiguration::StoreStatusBar( m_xServiceManager, xOutputStream, rElement.xSettings );
     412                 :            :                             }
     413         [ #  # ]:          0 :                             catch ( const ::com::sun::star::lang::WrappedTargetException& )
     414                 :            :                             {
     415                 :            :                             }
     416                 :            :                         }
     417                 :          0 :                         break;
     418                 :            : 
     419                 :            :                         default:
     420                 :          0 :                         break;
     421                 :            :                     }
     422                 :            :                 }
     423                 :            : 
     424                 :            :                 // mark as not modified if we store to our own storage
     425         [ #  # ]:          0 :                 if ( bResetModifyState )
     426                 :          0 :                     rElement.bModified = sal_False;
     427                 :            :             }
     428                 :            :         }
     429                 :            : 
     430                 :          0 :         ++pIter;
     431                 :            :     }
     432                 :            : 
     433                 :            :     // commit element type storage
     434         [ #  # ]:          0 :     Reference< XTransactedObject > xTransactedObject( xStorage, UNO_QUERY );
     435         [ #  # ]:          0 :     if ( xTransactedObject.is() )
     436 [ #  # ][ #  # ]:          0 :         xTransactedObject->commit();
     437                 :            : 
     438                 :            :     // mark UIElementType as not modified if we store to our own storage
     439         [ #  # ]:          0 :     if ( bResetModifyState )
     440                 :          0 :         rElementType.bModified = sal_False;
     441                 :          0 : }
     442                 :            : 
     443                 :          0 : void UIConfigurationManager::impl_resetElementTypeData(
     444                 :            :     UIElementType& rDocElementType,
     445                 :            :     ConfigEventNotifyContainer& rRemoveNotifyContainer )
     446                 :            : {
     447                 :          0 :     UIElementDataHashMap& rHashMap          = rDocElementType.aElementsHashMap;
     448         [ #  # ]:          0 :     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
     449                 :            : 
     450         [ #  # ]:          0 :     Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
     451         [ #  # ]:          0 :     Reference< XInterface > xIfac( xThis, UNO_QUERY );
     452                 :            : 
     453                 :            :     // Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling
     454                 :            :     // our listeners!
     455 [ #  # ][ #  # ]:          0 :     while ( pIter != rHashMap.end() )
     456                 :            :     {
     457         [ #  # ]:          0 :         UIElementData& rElement = pIter->second;
     458         [ #  # ]:          0 :         if ( !rElement.bDefault )
     459                 :            :         {
     460                 :            :             // Remove user-defined settings from document
     461         [ #  # ]:          0 :             ConfigurationEvent aEvent;
     462                 :          0 :             aEvent.ResourceURL = rElement.aResourceURL;
     463         [ #  # ]:          0 :             aEvent.Accessor <<= xThis;
     464         [ #  # ]:          0 :             aEvent.Source = xIfac;
     465         [ #  # ]:          0 :             aEvent.Element <<= rElement.xSettings;
     466                 :            : 
     467         [ #  # ]:          0 :             rRemoveNotifyContainer.push_back( aEvent );
     468                 :            : 
     469                 :            :             // Mark element as default.
     470                 :          0 :             rElement.bModified = false;
     471         [ #  # ]:          0 :             rElement.bDefault  = true;
     472                 :            :         }
     473                 :            :         else
     474                 :          0 :             rElement.bModified = false;
     475                 :            : 
     476                 :          0 :         ++pIter;
     477                 :            :     }
     478                 :            : 
     479                 :            :     // Remove all settings from our user interface elements
     480         [ #  # ]:          0 :     rHashMap.clear();
     481                 :          0 : }
     482                 :            : 
     483                 :          0 : void UIConfigurationManager::impl_reloadElementTypeData(
     484                 :            :     UIElementType&              rDocElementType,
     485                 :            :     ConfigEventNotifyContainer& rRemoveNotifyContainer,
     486                 :            :     ConfigEventNotifyContainer& rReplaceNotifyContainer )
     487                 :            : {
     488                 :          0 :     UIElementDataHashMap& rHashMap          = rDocElementType.aElementsHashMap;
     489         [ #  # ]:          0 :     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
     490                 :          0 :     Reference< XStorage > xElementStorage( rDocElementType.xStorage );
     491         [ #  # ]:          0 :     Reference< XNameAccess > xElementNameAccess( xElementStorage, UNO_QUERY );
     492                 :            : 
     493         [ #  # ]:          0 :     Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
     494         [ #  # ]:          0 :     Reference< XInterface > xIfac( xThis, UNO_QUERY );
     495                 :          0 :     sal_Int16 nType = rDocElementType.nElementType;
     496                 :            : 
     497 [ #  # ][ #  # ]:          0 :     while ( pIter != rHashMap.end() )
     498                 :            :     {
     499         [ #  # ]:          0 :         UIElementData& rElement = pIter->second;
     500         [ #  # ]:          0 :         if ( rElement.bModified )
     501                 :            :         {
     502 [ #  # ][ #  # ]:          0 :             if ( xElementNameAccess->hasByName( rElement.aName ))
                 [ #  # ]
     503                 :            :             {
     504                 :            :                 // Replace settings with data from user layer
     505                 :          0 :                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
     506                 :            : 
     507         [ #  # ]:          0 :                 impl_requestUIElementData( nType, rElement );
     508                 :            : 
     509         [ #  # ]:          0 :                 ConfigurationEvent aReplaceEvent;
     510                 :            : 
     511                 :          0 :                 aReplaceEvent.ResourceURL = rElement.aResourceURL;
     512         [ #  # ]:          0 :                 aReplaceEvent.Accessor <<= xThis;
     513         [ #  # ]:          0 :                 aReplaceEvent.Source = xIfac;
     514         [ #  # ]:          0 :                 aReplaceEvent.ReplacedElement <<= xOldSettings;
     515         [ #  # ]:          0 :                 aReplaceEvent.Element <<= rElement.xSettings;
     516         [ #  # ]:          0 :                 rReplaceNotifyContainer.push_back( aReplaceEvent );
     517                 :            : 
     518         [ #  # ]:          0 :                 rElement.bModified = false;
     519                 :            :             }
     520                 :            :             else
     521                 :            :             {
     522                 :            :                 // Element settings are not in any storage => remove
     523         [ #  # ]:          0 :                 ConfigurationEvent aRemoveEvent;
     524                 :            : 
     525                 :          0 :                 aRemoveEvent.ResourceURL = rElement.aResourceURL;
     526         [ #  # ]:          0 :                 aRemoveEvent.Accessor <<= xThis;
     527         [ #  # ]:          0 :                 aRemoveEvent.Source = xIfac;
     528         [ #  # ]:          0 :                 aRemoveEvent.Element <<= rElement.xSettings;
     529                 :            : 
     530         [ #  # ]:          0 :                 rRemoveNotifyContainer.push_back( aRemoveEvent );
     531                 :            : 
     532                 :            :                 // Mark element as default and not modified. That means "not active" in the document anymore
     533                 :          0 :                 rElement.bModified = false;
     534         [ #  # ]:          0 :                 rElement.bDefault  = true;
     535                 :            :             }
     536                 :            :         }
     537                 :          0 :         ++pIter;
     538                 :            :     }
     539                 :            : 
     540                 :          0 :     rDocElementType.bModified = sal_False;
     541                 :          0 : }
     542                 :            : 
     543                 :       3005 : void UIConfigurationManager::impl_Initialize()
     544                 :            : {
     545                 :            :     // Initialize the top-level structures with the storage data
     546         [ +  + ]:       3005 :     if ( m_xDocConfigStorage.is() )
     547                 :            :     {
     548         [ -  + ]:       2852 :         long nModes = m_bReadOnly ? ElementModes::READ : ElementModes::READWRITE;
     549                 :            : 
     550                 :            :         // Try to access our module sub folder
     551         [ +  + ]:      22816 :         for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT;
     552                 :            :               i++ )
     553                 :            :         {
     554                 :      19964 :             Reference< XStorage > xElementTypeStorage;
     555                 :            :             try
     556                 :            :             {
     557 [ +  - ][ +  - ]:      19964 :                 xElementTypeStorage = m_xDocConfigStorage->openStorageElement( rtl::OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), nModes );
           [ #  #  #  #  
           #  # ][ +  - ]
     558                 :            :             }
     559         [ #  # ]:          0 :             catch ( const com::sun::star::container::NoSuchElementException& )
     560                 :            :             {
     561                 :            :             }
     562         [ #  # ]:          0 :             catch ( const ::com::sun::star::embed::InvalidStorageException& )
     563                 :            :             {
     564                 :            :             }
     565         [ #  # ]:          0 :             catch ( const ::com::sun::star::lang::IllegalArgumentException& )
     566                 :            :             {
     567                 :            :             }
     568         [ #  # ]:          0 :             catch ( const ::com::sun::star::io::IOException& )
     569                 :            :             {
     570                 :            :             }
     571         [ #  # ]:          0 :             catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
     572                 :            :             {
     573                 :            :             }
     574                 :            : 
     575                 :      19964 :             m_aUIElements[i].nElementType = i;
     576                 :      19964 :             m_aUIElements[i].bModified = false;
     577         [ +  - ]:      19964 :             m_aUIElements[i].xStorage = xElementTypeStorage;
     578                 :      19964 :             m_aUIElements[i].bDefaultLayer = false;
     579                 :      19964 :         }
     580                 :            :     }
     581                 :            :     else
     582                 :            :     {
     583                 :            :         // We have no storage, just initialize ui element types with empty storage!
     584         [ +  + ]:       1224 :         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
     585                 :       1071 :             m_aUIElements[i].xStorage = m_xDocConfigStorage;
     586                 :            :     }
     587                 :       3005 : }
     588                 :            : 
     589                 :       2137 : UIConfigurationManager::UIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ) :
     590         [ +  - ]:       2137 :     ThreadHelpBase( &Application::GetSolarMutex() )
     591                 :            :     , m_xDocConfigStorage( 0 )
     592                 :            :     , m_bReadOnly( true )
     593                 :            :     , m_bModified( false )
     594                 :            :     , m_bConfigRead( false )
     595                 :            :     , m_bDisposed( false )
     596                 :            :     , m_aXMLPostfix( ".xml" )
     597                 :            :     , m_aPropUIName( "UIName" )
     598                 :            :     , m_aPropResourceURL( "ResourceURL" )
     599                 :            :     , m_xServiceManager( xServiceManager )
     600 [ +  - ][ +  - ]:       4274 :     , m_aListenerContainer( m_aLock.getShareableOslMutex() )
         [ +  - ][ +  - ]
                 [ +  - ]
     601                 :            : {
     602                 :            :     // Make sure we have a default initialized entry for every layer and user interface element type!
     603                 :            :     // The following code depends on this!
     604         [ +  - ]:       2137 :     m_aUIElements.resize( ::com::sun::star::ui::UIElementType::COUNT );
     605                 :       2137 : }
     606                 :            : 
     607 [ +  - ][ +  - ]:       1993 : UIConfigurationManager::~UIConfigurationManager()
                 [ +  - ]
     608                 :            : {
     609         [ -  + ]:       3986 : }
     610                 :            : 
     611                 :            : // XComponent
     612                 :          2 : void SAL_CALL UIConfigurationManager::dispose() throw (::com::sun::star::uno::RuntimeException)
     613                 :            : {
     614         [ +  - ]:          2 :     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
     615                 :            : 
     616         [ +  - ]:          2 :     css::lang::EventObject aEvent( xThis );
     617         [ +  - ]:          2 :     m_aListenerContainer.disposeAndClear( aEvent );
     618                 :            : 
     619                 :            :     {
     620         [ +  - ]:          2 :         ResetableGuard aGuard( m_aLock );
     621                 :            :         try
     622                 :            :         {
     623         [ -  + ]:          2 :             if ( m_xImageManager.is() )
     624 [ #  # ][ #  # ]:          0 :                 m_xImageManager->dispose();
     625                 :            :         }
     626         [ #  # ]:          0 :         catch ( const Exception& )
     627                 :            :         {
     628                 :            :         }
     629                 :            : 
     630                 :          2 :         m_xImageManager.clear();
     631                 :          2 :         m_aUIElements.clear();
     632                 :          2 :         m_xDocConfigStorage.clear();
     633                 :          2 :         m_bConfigRead = false;
     634                 :          2 :         m_bModified = false;
     635         [ +  - ]:          2 :         m_bDisposed = true;
     636         [ +  - ]:          2 :     }
     637         [ #  # ]:          2 : }
     638                 :            : 
     639                 :          4 : void SAL_CALL UIConfigurationManager::addEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     640                 :            : {
     641                 :            :     {
     642         [ +  - ]:          4 :         ResetableGuard aGuard( m_aLock );
     643                 :            : 
     644                 :            :         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     645         [ -  + ]:          4 :         if ( m_bDisposed )
     646 [ #  # ][ +  - ]:          4 :             throw DisposedException();
     647                 :            :     }
     648                 :            : 
     649                 :          4 :     m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
     650                 :          4 : }
     651                 :            : 
     652                 :          2 : void SAL_CALL UIConfigurationManager::removeEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     653                 :            : {
     654                 :            :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     655                 :          2 :     m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
     656                 :          2 : }
     657                 :            : 
     658                 :            : // XUIConfigurationManager
     659                 :       1731 : void SAL_CALL UIConfigurationManager::addConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     660                 :            : {
     661                 :            :     {
     662         [ +  - ]:       1731 :         ResetableGuard aGuard( m_aLock );
     663                 :            : 
     664                 :            :         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     665         [ -  + ]:       1731 :         if ( m_bDisposed )
     666 [ #  # ][ +  - ]:       1731 :             throw DisposedException();
     667                 :            :     }
     668                 :            : 
     669                 :       1731 :     m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener );
     670                 :       1731 : }
     671                 :            : 
     672                 :       1640 : void SAL_CALL UIConfigurationManager::removeConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     673                 :            : {
     674                 :            :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     675                 :       1640 :     m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener );
     676                 :       1640 : }
     677                 :            : 
     678                 :            : 
     679                 :          0 : void SAL_CALL UIConfigurationManager::reset() throw (::com::sun::star::uno::RuntimeException)
     680                 :            : {
     681         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
     682                 :            : 
     683                 :            :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     684         [ #  # ]:          0 :     if ( m_bDisposed )
     685         [ #  # ]:          0 :         throw DisposedException();
     686                 :            : 
     687 [ #  # ][ #  # ]:          0 :     if ( isReadOnly() )
     688                 :          0 :         return;
     689                 :            : 
     690         [ #  # ]:          0 :     if ( m_xDocConfigStorage.is() )
     691                 :            :     {
     692                 :            :         try
     693                 :            :         {
     694                 :            :             // Remove all elements from our user-defined storage!
     695                 :          0 :             bool bCommit( false );
     696         [ #  # ]:          0 :             for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
     697                 :            :             {
     698                 :          0 :                 UIElementType&        rElementType = m_aUIElements[i];
     699         [ #  # ]:          0 :                 Reference< XStorage > xSubStorage( rElementType.xStorage, UNO_QUERY );
     700                 :            : 
     701         [ #  # ]:          0 :                 if ( xSubStorage.is() )
     702                 :            :                 {
     703                 :          0 :                     bool bCommitSubStorage( false );
     704         [ #  # ]:          0 :                     Reference< XNameAccess > xSubStorageNameAccess( xSubStorage, UNO_QUERY );
     705 [ #  # ][ #  # ]:          0 :                     Sequence< rtl::OUString > aUIElementStreamNames = xSubStorageNameAccess->getElementNames();
     706         [ #  # ]:          0 :                     for ( sal_Int32 j = 0; j < aUIElementStreamNames.getLength(); j++ )
     707                 :            :                     {
     708 [ #  # ][ #  # ]:          0 :                         xSubStorage->removeElement( aUIElementStreamNames[j] );
                 [ #  # ]
     709                 :          0 :                         bCommitSubStorage = true;
     710                 :          0 :                         bCommit = true;
     711                 :            :                     }
     712                 :            : 
     713         [ #  # ]:          0 :                     if ( bCommitSubStorage )
     714                 :            :                     {
     715         [ #  # ]:          0 :                         Reference< XTransactedObject > xTransactedObject( xSubStorage, UNO_QUERY );
     716         [ #  # ]:          0 :                         if ( xTransactedObject.is() )
     717 [ #  # ][ #  # ]:          0 :                             xTransactedObject->commit();
     718         [ #  # ]:          0 :                     }
     719                 :            :                 }
     720                 :          0 :             }
     721                 :            : 
     722                 :            :             // Commit changes
     723         [ #  # ]:          0 :             if ( bCommit )
     724                 :            :             {
     725         [ #  # ]:          0 :                 Reference< XTransactedObject > xTransactedObject( m_xDocConfigStorage, UNO_QUERY );
     726         [ #  # ]:          0 :                 if ( xTransactedObject.is() )
     727 [ #  # ][ #  # ]:          0 :                     xTransactedObject->commit();
     728                 :            :             }
     729                 :            : 
     730                 :            :             // remove settings from user defined layer and notify listener about removed settings data!
     731                 :            :             // Try to access our module sub folder
     732         [ #  # ]:          0 :             ConfigEventNotifyContainer aRemoveEventNotifyContainer;
     733         [ #  # ]:          0 :             for ( sal_Int16 j = 1; j < ::com::sun::star::ui::UIElementType::COUNT; j++ )
     734                 :            :             {
     735                 :          0 :                 UIElementType& rDocElementType = m_aUIElements[j];
     736                 :            : 
     737         [ #  # ]:          0 :                 impl_resetElementTypeData( rDocElementType, aRemoveEventNotifyContainer );
     738                 :          0 :                 rDocElementType.bModified = sal_False;
     739                 :            :             }
     740                 :            : 
     741                 :          0 :             m_bModified = sal_False;
     742                 :            : 
     743                 :            :             // Unlock mutex before notify our listeners
     744         [ #  # ]:          0 :             aGuard.unlock();
     745                 :            : 
     746                 :            :             // Notify our listeners
     747         [ #  # ]:          0 :             for ( sal_uInt32 k = 0; k < aRemoveEventNotifyContainer.size(); k++ )
     748 [ #  # ][ #  #  :          0 :                 implts_notifyContainerListener( aRemoveEventNotifyContainer[k], NotifyOp_Remove );
                #  #  # ]
     749                 :            :         }
     750         [ #  # ]:          0 :         catch ( const ::com::sun::star::lang::IllegalArgumentException& )
     751                 :            :         {
     752                 :            :         }
     753         [ #  # ]:          0 :         catch ( const ::com::sun::star::container::NoSuchElementException& )
     754                 :            :         {
     755                 :            :         }
     756         [ #  # ]:          0 :         catch ( const ::com::sun::star::embed::InvalidStorageException& )
     757                 :            :         {
     758                 :            :         }
     759         [ #  # ]:          0 :         catch ( const ::com::sun::star::embed::StorageWrappedTargetException& )
     760                 :            :         {
     761                 :            :         }
     762 [ #  # ][ #  # ]:          0 :     }
     763                 :            : }
     764                 :            : 
     765                 :       1733 : Sequence< Sequence< PropertyValue > > SAL_CALL UIConfigurationManager::getUIElementsInfo( sal_Int16 ElementType )
     766                 :            : throw ( IllegalArgumentException, RuntimeException )
     767                 :            : {
     768 [ +  - ][ -  + ]:       1733 :     if (( ElementType < 0 ) || ( ElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
     769         [ #  # ]:          0 :         throw IllegalArgumentException();
     770                 :            : 
     771         [ +  - ]:       1733 :     ResetableGuard aGuard( m_aLock );
     772         [ -  + ]:       1733 :     if ( m_bDisposed )
     773         [ #  # ]:          0 :         throw DisposedException();
     774                 :            : 
     775         [ +  - ]:       1733 :     Sequence< Sequence< PropertyValue > > aElementInfoSeq;
     776         [ +  - ]:       1733 :     UIElementInfoHashMap aUIElementInfoCollection;
     777                 :            : 
     778         [ -  + ]:       1733 :     if ( ElementType == ::com::sun::star::ui::UIElementType::UNKNOWN )
     779                 :            :     {
     780         [ #  # ]:          0 :         for ( sal_Int16 i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
     781         [ #  # ]:          0 :             impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, sal_Int16( i ) );
     782                 :            :     }
     783                 :            :     else
     784         [ +  - ]:       1733 :         impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, ElementType );
     785                 :            : 
     786         [ +  - ]:       1733 :     Sequence< PropertyValue > aUIElementInfo( 2 );
     787         [ +  - ]:       1733 :     aUIElementInfo[0].Name = m_aPropResourceURL;
     788         [ +  - ]:       1733 :     aUIElementInfo[1].Name = m_aPropUIName;
     789                 :            : 
     790         [ +  - ]:       1733 :     aElementInfoSeq.realloc( aUIElementInfoCollection.size() );
     791         [ +  - ]:       1733 :     UIElementInfoHashMap::const_iterator pIter = aUIElementInfoCollection.begin();
     792                 :            : 
     793                 :       1733 :     sal_Int32 n = 0;
     794 [ +  - ][ -  + ]:       1733 :     while ( pIter != aUIElementInfoCollection.end() )
     795                 :            :     {
     796 [ #  # ][ #  # ]:          0 :         aUIElementInfo[0].Value <<= pIter->second.aResourceURL;
                 [ #  # ]
     797 [ #  # ][ #  # ]:          0 :         aUIElementInfo[1].Value <<= pIter->second.aUIName;
                 [ #  # ]
     798 [ #  # ][ #  # ]:          0 :         aElementInfoSeq[n++] = aUIElementInfo;
     799                 :          0 :         ++pIter;
     800                 :            :     }
     801                 :            : 
     802 [ +  - ][ +  - ]:       1733 :     return aElementInfoSeq;
                 [ +  - ]
     803                 :            : }
     804                 :            : 
     805                 :          0 : Reference< XIndexContainer > SAL_CALL UIConfigurationManager::createSettings() throw (::com::sun::star::uno::RuntimeException)
     806                 :            : {
     807         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
     808                 :            : 
     809         [ #  # ]:          0 :     if ( m_bDisposed )
     810         [ #  # ]:          0 :         throw DisposedException();
     811                 :            : 
     812                 :            :     // Creates an empty item container which can be filled from outside
     813 [ #  # ][ #  # ]:          0 :     return Reference< XIndexContainer >( static_cast< OWeakObject * >( new RootItemContainer()), UNO_QUERY );
         [ #  # ][ #  # ]
     814                 :            : }
     815                 :            : 
     816                 :       7019 : sal_Bool SAL_CALL UIConfigurationManager::hasSettings( const ::rtl::OUString& ResourceURL )
     817                 :            : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     818                 :            : {
     819                 :       7019 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
     820                 :            : 
     821 [ -  + ][ +  - ]:       7019 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
     822                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
     823         [ #  # ]:          0 :         throw IllegalArgumentException();
     824                 :            :     else
     825                 :            :     {
     826                 :       7019 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false );
     827 [ #  # ][ -  + ]:       7019 :         if ( pDataSettings && !pDataSettings->bDefault )
     828                 :          0 :             return sal_True;
     829                 :            :     }
     830                 :            : 
     831                 :       7019 :     return sal_False;
     832                 :            : }
     833                 :            : 
     834                 :          0 : Reference< XIndexAccess > SAL_CALL UIConfigurationManager::getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable )
     835                 :            : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     836                 :            : {
     837                 :          0 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
     838                 :            : 
     839 [ #  # ][ #  # ]:          0 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
     840                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
     841         [ #  # ]:          0 :         throw IllegalArgumentException();
     842                 :            :     else
     843                 :            :     {
     844         [ #  # ]:          0 :         ResetableGuard aGuard( m_aLock );
     845                 :            : 
     846         [ #  # ]:          0 :         if ( m_bDisposed )
     847         [ #  # ]:          0 :             throw DisposedException();
     848                 :            : 
     849         [ #  # ]:          0 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
     850 [ #  # ][ #  # ]:          0 :         if ( pDataSettings && !pDataSettings->bDefault )
     851                 :            :         {
     852                 :            :             // Create a copy of our data if someone wants to change the data.
     853         [ #  # ]:          0 :             if ( bWriteable )
     854 [ #  # ][ #  # ]:          0 :                 return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( pDataSettings->xSettings ) ), UNO_QUERY );
                 [ #  # ]
     855                 :            :             else
     856                 :          0 :                 return pDataSettings->xSettings;
     857 [ #  # ][ #  # ]:          0 :         }
     858                 :            :     }
     859                 :            : 
     860         [ #  # ]:          0 :     throw NoSuchElementException();
     861                 :            : }
     862                 :            : 
     863                 :          0 : void SAL_CALL UIConfigurationManager::replaceSettings( const ::rtl::OUString& ResourceURL, const Reference< ::com::sun::star::container::XIndexAccess >& aNewData )
     864                 :            : throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
     865                 :            : {
     866                 :          0 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
     867                 :            : 
     868 [ #  # ][ #  # ]:          0 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
     869                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
     870         [ #  # ]:          0 :         throw IllegalArgumentException();
     871         [ #  # ]:          0 :     else if ( m_bReadOnly )
     872         [ #  # ]:          0 :         throw IllegalAccessException();
     873                 :            :     else
     874                 :            :     {
     875         [ #  # ]:          0 :         ResetableGuard aGuard( m_aLock );
     876                 :            : 
     877         [ #  # ]:          0 :         if ( m_bDisposed )
     878         [ #  # ]:          0 :             throw DisposedException();
     879                 :            : 
     880         [ #  # ]:          0 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
     881 [ #  # ][ #  # ]:          0 :         if ( pDataSettings && !pDataSettings->bDefault )
     882                 :            :         {
     883                 :            :             // we have a settings entry in our user-defined layer - replace
     884                 :          0 :             Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings;
     885                 :            : 
     886                 :            :             // Create a copy of the data if the container is not const
     887         [ #  # ]:          0 :             Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
     888         [ #  # ]:          0 :             if ( xReplace.is() )
     889 [ #  # ][ #  # ]:          0 :                 pDataSettings->xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
         [ #  # ][ #  # ]
     890                 :            :             else
     891         [ #  # ]:          0 :                 pDataSettings->xSettings = aNewData;
     892                 :            : 
     893                 :          0 :             pDataSettings->bDefault  = false;
     894                 :          0 :             pDataSettings->bModified = true;
     895                 :          0 :             m_bModified = true;
     896                 :            : 
     897                 :            :             // Modify type container
     898                 :          0 :             UIElementType& rElementType = m_aUIElements[nElementType];
     899                 :          0 :             rElementType.bModified = true;
     900                 :            : 
     901         [ #  # ]:          0 :             Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
     902                 :            : 
     903                 :            :             // Create event to notify listener about replaced element settings
     904         [ #  # ]:          0 :             ConfigurationEvent aEvent;
     905         [ #  # ]:          0 :             Reference< XInterface > xIfac( xThis, UNO_QUERY );
     906                 :            : 
     907                 :          0 :             aEvent.ResourceURL = ResourceURL;
     908         [ #  # ]:          0 :             aEvent.Accessor <<= xThis;
     909         [ #  # ]:          0 :             aEvent.Source = xIfac;
     910         [ #  # ]:          0 :             aEvent.ReplacedElement <<= xOldSettings;
     911         [ #  # ]:          0 :             aEvent.Element <<= pDataSettings->xSettings;
     912                 :            : 
     913         [ #  # ]:          0 :             aGuard.unlock();
     914                 :            : 
     915 [ #  # ][ #  # ]:          0 :             implts_notifyContainerListener( aEvent, NotifyOp_Replace );
     916                 :            :         }
     917                 :            :         else
     918 [ #  # ][ #  # ]:          0 :             throw NoSuchElementException();
     919                 :            :     }
     920                 :          0 : }
     921                 :            : 
     922                 :          0 : void SAL_CALL UIConfigurationManager::removeSettings( const ::rtl::OUString& ResourceURL )
     923                 :            : throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException, RuntimeException)
     924                 :            : {
     925                 :          0 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
     926                 :            : 
     927 [ #  # ][ #  # ]:          0 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
     928                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
     929         [ #  # ]:          0 :         throw IllegalArgumentException();
     930         [ #  # ]:          0 :     else if ( m_bReadOnly )
     931         [ #  # ]:          0 :         throw IllegalAccessException();
     932                 :            :     else
     933                 :            :     {
     934         [ #  # ]:          0 :         ResetableGuard aGuard( m_aLock );
     935                 :            : 
     936         [ #  # ]:          0 :         if ( m_bDisposed )
     937         [ #  # ]:          0 :             throw DisposedException();
     938                 :            : 
     939         [ #  # ]:          0 :         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
     940         [ #  # ]:          0 :         if ( pDataSettings )
     941                 :            :         {
     942                 :            :             // If element settings are default, we don't need to change anything!
     943         [ #  # ]:          0 :             if ( pDataSettings->bDefault )
     944                 :          0 :                 return;
     945                 :            :             else
     946                 :            :             {
     947                 :          0 :                 Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings;
     948                 :          0 :                 pDataSettings->bDefault = true;
     949                 :            : 
     950                 :            :                 // check if this is a default layer node
     951                 :          0 :                 pDataSettings->bModified = true; // we have to remove this node from the user layer!
     952                 :          0 :                 pDataSettings->xSettings.clear();
     953                 :          0 :                 m_bModified = true; // user layer must be written
     954                 :            : 
     955                 :            :                 // Modify type container
     956                 :          0 :                 UIElementType& rElementType = m_aUIElements[nElementType];
     957                 :          0 :                 rElementType.bModified = true;
     958                 :            : 
     959         [ #  # ]:          0 :                 Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
     960         [ #  # ]:          0 :                 Reference< XInterface > xIfac( xThis, UNO_QUERY );
     961                 :            : 
     962                 :            :                 // Create event to notify listener about removed element settings
     963         [ #  # ]:          0 :                 ConfigurationEvent aEvent;
     964                 :            : 
     965                 :          0 :                 aEvent.ResourceURL = ResourceURL;
     966         [ #  # ]:          0 :                 aEvent.Accessor <<= xThis;
     967         [ #  # ]:          0 :                 aEvent.Source = xIfac;
     968         [ #  # ]:          0 :                 aEvent.Element <<= xRemovedSettings;
     969                 :            : 
     970         [ #  # ]:          0 :                 aGuard.unlock();
     971                 :            : 
     972 [ #  # ][ #  # ]:          0 :                 implts_notifyContainerListener( aEvent, NotifyOp_Remove );
     973                 :            :             }
     974                 :            :         }
     975                 :            :         else
     976 [ #  # ][ #  # ]:          0 :             throw NoSuchElementException();
                 [ #  # ]
     977                 :            :     }
     978                 :            : }
     979                 :            : 
     980                 :          0 : void SAL_CALL UIConfigurationManager::insertSettings( const ::rtl::OUString& NewResourceURL, const Reference< XIndexAccess >& aNewData )
     981                 :            : throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, RuntimeException )
     982                 :            : {
     983                 :          0 :     sal_Int16 nElementType = RetrieveTypeFromResourceURL( NewResourceURL );
     984                 :            : 
     985 [ #  # ][ #  # ]:          0 :     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
     986                 :            :         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
     987         [ #  # ]:          0 :         throw IllegalArgumentException();
     988         [ #  # ]:          0 :     else if ( m_bReadOnly )
     989         [ #  # ]:          0 :         throw IllegalAccessException();
     990                 :            :     else
     991                 :            :     {
     992         [ #  # ]:          0 :         ResetableGuard aGuard( m_aLock );
     993                 :            : 
     994         [ #  # ]:          0 :         if ( m_bDisposed )
     995         [ #  # ]:          0 :             throw DisposedException();
     996                 :            : 
     997                 :          0 :         bool           bInsertData( false );
     998         [ #  # ]:          0 :         UIElementData  aUIElementData;
     999         [ #  # ]:          0 :         UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType );
    1000                 :            : 
    1001 [ #  # ][ #  # ]:          0 :         if ( pDataSettings && !pDataSettings->bDefault )
    1002         [ #  # ]:          0 :             throw ElementExistException();
    1003                 :            : 
    1004         [ #  # ]:          0 :         if ( !pDataSettings )
    1005                 :            :         {
    1006                 :          0 :             pDataSettings = &aUIElementData;
    1007                 :          0 :             bInsertData   = true;
    1008                 :            :         }
    1009                 :            : 
    1010                 :            :         {
    1011                 :          0 :             pDataSettings->bDefault     = false;
    1012                 :          0 :             pDataSettings->bModified    = true;
    1013                 :            : 
    1014                 :            :             // Create a copy of the data if the container is not const
    1015         [ #  # ]:          0 :             Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
    1016         [ #  # ]:          0 :             if ( xReplace.is() )
    1017 [ #  # ][ #  # ]:          0 :                 pDataSettings->xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
         [ #  # ][ #  # ]
    1018                 :            :             else
    1019         [ #  # ]:          0 :                 pDataSettings->xSettings = aNewData;
    1020                 :            : 
    1021                 :          0 :             m_bModified = true;
    1022                 :            : 
    1023                 :          0 :             UIElementType& rElementType = m_aUIElements[nElementType];
    1024                 :          0 :             rElementType.bModified = true;
    1025                 :            : 
    1026         [ #  # ]:          0 :             if ( bInsertData )
    1027                 :            :             {
    1028         [ #  # ]:          0 :                 pDataSettings->aName        = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix;
    1029                 :          0 :                 pDataSettings->aResourceURL = NewResourceURL;
    1030                 :            : 
    1031                 :          0 :                 UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
    1032 [ #  # ][ #  # ]:          0 :                 rElements.insert( UIElementDataHashMap::value_type( NewResourceURL, *pDataSettings ));
                 [ #  # ]
    1033                 :            :             }
    1034                 :            : 
    1035                 :          0 :             Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
    1036         [ #  # ]:          0 :             Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
    1037         [ #  # ]:          0 :             Reference< XInterface > xIfac( xThis, UNO_QUERY );
    1038                 :            : 
    1039                 :            :             // Create event to notify listener about removed element settings
    1040         [ #  # ]:          0 :             ConfigurationEvent aEvent;
    1041                 :            : 
    1042                 :          0 :             aEvent.ResourceURL = NewResourceURL;
    1043         [ #  # ]:          0 :             aEvent.Accessor <<= xThis;
    1044         [ #  # ]:          0 :             aEvent.Source = xIfac;
    1045         [ #  # ]:          0 :             aEvent.Element <<= xInsertSettings;
    1046                 :            : 
    1047         [ #  # ]:          0 :             aGuard.unlock();
    1048                 :            : 
    1049 [ #  # ][ #  # ]:          0 :             implts_notifyContainerListener( aEvent, NotifyOp_Insert );
    1050 [ #  # ][ #  # ]:          0 :         }
    1051                 :            :     }
    1052                 :          0 : }
    1053                 :            : 
    1054                 :      61089 : Reference< XInterface > SAL_CALL UIConfigurationManager::getImageManager() throw (::com::sun::star::uno::RuntimeException)
    1055                 :            : {
    1056         [ -  + ]:      61089 :     if ( m_bDisposed )
    1057         [ #  # ]:          0 :         throw DisposedException();
    1058                 :            : 
    1059         [ +  + ]:      61089 :     if ( !m_xImageManager.is() )
    1060                 :            :     {
    1061         [ +  - ]:       1689 :         m_xImageManager = Reference< XComponent >( static_cast< cppu::OWeakObject *>( new ImageManager( m_xServiceManager )),
    1062 [ +  - ][ +  - ]:       3378 :                                                          UNO_QUERY );
    1063         [ +  - ]:       1689 :         Reference< XInitialization > xInit( m_xImageManager, UNO_QUERY );
    1064                 :            : 
    1065         [ +  - ]:       1689 :         Sequence< Any > aPropSeq( 2 );
    1066                 :       1689 :         PropertyValue aPropValue;
    1067                 :       1689 :         aPropValue.Name  = rtl::OUString( "UserConfigStorage" );
    1068         [ +  - ]:       1689 :         aPropValue.Value = makeAny( m_xDocConfigStorage );
    1069 [ +  - ][ +  - ]:       1689 :         aPropSeq[0] = makeAny( aPropValue );
    1070                 :       1689 :         aPropValue.Name  = rtl::OUString( "ModuleIdentifier" );
    1071         [ +  - ]:       1689 :         aPropValue.Value = makeAny( m_aModuleIdentifier );
    1072 [ +  - ][ +  - ]:       1689 :         aPropSeq[1] = makeAny( aPropValue );
    1073                 :            : 
    1074 [ +  - ][ +  - ]:       1689 :         xInit->initialize( aPropSeq );
                 [ +  - ]
    1075                 :            :     }
    1076                 :            : 
    1077                 :      61089 :     return Reference< XInterface >( m_xImageManager, UNO_QUERY );
    1078                 :            : }
    1079                 :            : 
    1080                 :       2454 : Reference< XInterface > SAL_CALL UIConfigurationManager::getShortCutManager() throw (::com::sun::star::uno::RuntimeException)
    1081                 :            : {
    1082                 :            :     // SAFE ->
    1083         [ +  - ]:       2454 :     ResetableGuard aGuard( m_aLock );
    1084                 :            : 
    1085         [ +  + ]:       2454 :     if (m_xAccConfig.is())
    1086                 :       1329 :         return m_xAccConfig;
    1087                 :            : 
    1088                 :       1125 :     Reference< XMultiServiceFactory > xSMGR         = m_xServiceManager;
    1089                 :       1125 :     Reference< XStorage >             xDocumentRoot = m_xDocConfigStorage;
    1090                 :            : 
    1091         [ +  - ]:       1125 :     aGuard.unlock();
    1092                 :            :     // <- SAFE
    1093                 :            : 
    1094 [ +  - ][ +  - ]:       1125 :     Reference< XInterface >      xAccConfig = xSMGR->createInstance(SERVICENAME_DOCUMENTACCELERATORCONFIGURATION);
                 [ +  - ]
    1095         [ +  - ]:       1125 :     Reference< XInitialization > xInit      (xAccConfig, UNO_QUERY_THROW);
    1096                 :            : 
    1097                 :       1125 :     PropertyValue aProp;
    1098                 :       1125 :     aProp.Name    = ::rtl::OUString("DocumentRoot");
    1099         [ +  - ]:       1125 :     aProp.Value <<= xDocumentRoot;
    1100                 :            : 
    1101         [ +  - ]:       1125 :     Sequence< Any > lArgs(1);
    1102 [ +  - ][ +  - ]:       1125 :     lArgs[0] <<= aProp;
    1103                 :            : 
    1104 [ +  - ][ +  - ]:       1125 :     xInit->initialize(lArgs);
    1105                 :            : 
    1106                 :            :     // SAFE ->
    1107         [ +  - ]:       1125 :     aGuard.lock();
    1108         [ +  - ]:       1125 :     m_xAccConfig = xAccConfig;
    1109         [ +  - ]:       1125 :     aGuard.unlock();
    1110                 :            :     // <- SAFE
    1111                 :            : 
    1112 [ +  - ][ +  - ]:       2454 :     return xAccConfig;
    1113                 :            : }
    1114                 :            : 
    1115                 :          0 : Reference< XInterface > SAL_CALL UIConfigurationManager::getEventsManager() throw (::com::sun::star::uno::RuntimeException)
    1116                 :            : {
    1117                 :          0 :     return Reference< XInterface >();
    1118                 :            : }
    1119                 :            : 
    1120                 :            : // XUIConfigurationStorage
    1121                 :       3005 : void SAL_CALL UIConfigurationManager::setStorage( const Reference< XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException)
    1122                 :            : {
    1123         [ +  - ]:       3005 :     ResetableGuard aGuard( m_aLock );
    1124                 :            : 
    1125         [ -  + ]:       3005 :     if ( m_bDisposed )
    1126         [ #  # ]:          0 :         throw DisposedException();
    1127                 :            : 
    1128         [ +  + ]:       3005 :     if ( m_xDocConfigStorage.is() )
    1129                 :            :     {
    1130                 :            :         try
    1131                 :            :         {
    1132                 :            :             // Dispose old storage to be sure that it will be closed
    1133         [ +  - ]:        868 :             Reference< XComponent > xComponent( m_xDocConfigStorage, UNO_QUERY );
    1134         [ +  - ]:        868 :             if ( xComponent.is() )
    1135 [ +  - ][ +  + ]:        868 :                 xComponent->dispose();
                 [ -  + ]
    1136                 :            :         }
    1137         [ +  - ]:        426 :         catch ( const Exception& )
    1138                 :            :         {
    1139                 :            :         }
    1140                 :            :     }
    1141                 :            : 
    1142                 :            :     // We store the new storage. Be careful it could be an empty reference!
    1143         [ +  - ]:       3005 :     m_xDocConfigStorage = Storage;
    1144                 :       3005 :     m_bReadOnly         = sal_True;
    1145                 :            : 
    1146         [ +  - ]:       3005 :     Reference< XUIConfigurationStorage > xAccUpdate(m_xAccConfig, UNO_QUERY);
    1147         [ +  + ]:       3005 :     if ( xAccUpdate.is() )
    1148 [ +  - ][ +  - ]:         16 :         xAccUpdate->setStorage( m_xDocConfigStorage );
    1149                 :            : 
    1150         [ +  + ]:       3005 :     if ( m_xImageManager.is() )
    1151                 :            :     {
    1152 [ +  - ][ +  - ]:         16 :         ImageManager* pImageManager = (ImageManager*)m_xImageManager.get();
    1153         [ +  - ]:         16 :         if ( pImageManager )
    1154         [ +  - ]:         16 :             pImageManager->setStorage( m_xDocConfigStorage );
    1155                 :            :     }
    1156                 :            : 
    1157         [ +  + ]:       3005 :     if ( m_xDocConfigStorage.is() )
    1158                 :            :     {
    1159         [ +  - ]:       2852 :         Reference< XPropertySet > xPropSet( m_xDocConfigStorage, UNO_QUERY );
    1160         [ +  - ]:       2852 :         if ( xPropSet.is() )
    1161                 :            :         {
    1162                 :            :             try
    1163                 :            :             {
    1164                 :       2852 :                 long nOpenMode = 0;
    1165 [ +  - ][ +  - ]:       2852 :                 Any a = xPropSet->getPropertyValue( rtl::OUString( "OpenMode" ));
              [ #  #  # ]
    1166         [ +  - ]:       2852 :                 if ( a >>= nOpenMode )
    1167                 :       2852 :                     m_bReadOnly = !( nOpenMode & ElementModes::WRITE );
    1168                 :            :             }
    1169         [ #  # ]:          0 :             catch ( const com::sun::star::beans::UnknownPropertyException& )
    1170                 :            :             {
    1171                 :            :             }
    1172         [ #  # ]:          0 :             catch ( const com::sun::star::lang::WrappedTargetException& )
    1173                 :            :             {
    1174                 :            :             }
    1175                 :       2852 :         }
    1176                 :            :     }
    1177                 :            : 
    1178 [ +  - ][ +  - ]:       3005 :     impl_Initialize();
    1179                 :       3005 : }
    1180                 :            : 
    1181                 :          0 : sal_Bool SAL_CALL UIConfigurationManager::hasStorage() throw (::com::sun::star::uno::RuntimeException)
    1182                 :            : {
    1183         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
    1184                 :            : 
    1185         [ #  # ]:          0 :     if ( m_bDisposed )
    1186         [ #  # ]:          0 :         throw DisposedException();
    1187                 :            : 
    1188         [ #  # ]:          0 :     return ( m_xDocConfigStorage.is() );
    1189                 :            : }
    1190                 :            : 
    1191                 :            : // XUIConfigurationPersistence
    1192                 :          0 : void SAL_CALL UIConfigurationManager::reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
    1193                 :            : {
    1194         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
    1195                 :            : 
    1196         [ #  # ]:          0 :     if ( m_bDisposed )
    1197         [ #  # ]:          0 :         throw DisposedException();
    1198                 :            : 
    1199 [ #  # ][ #  # ]:          0 :     if ( m_xDocConfigStorage.is() && m_bModified && !m_bReadOnly )
         [ #  # ][ #  # ]
    1200                 :            :     {
    1201                 :            :         // Try to access our module sub folder
    1202         [ #  # ]:          0 :         ConfigEventNotifyContainer aRemoveNotifyContainer;
    1203         [ #  # ]:          0 :         ConfigEventNotifyContainer aReplaceNotifyContainer;
    1204         [ #  # ]:          0 :         for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
    1205                 :            :         {
    1206                 :            :             try
    1207                 :            :             {
    1208                 :          0 :                 UIElementType& rDocElementType = m_aUIElements[i];
    1209         [ #  # ]:          0 :                 if ( rDocElementType.bModified )
    1210         [ #  # ]:          0 :                     impl_reloadElementTypeData( rDocElementType, aRemoveNotifyContainer, aReplaceNotifyContainer );
    1211                 :            :             }
    1212         [ #  # ]:          0 :             catch ( const Exception& )
    1213                 :            :             {
    1214         [ #  # ]:          0 :                 throw IOException();
    1215                 :            :             }
    1216                 :            :         }
    1217                 :            : 
    1218                 :          0 :         m_bModified = sal_False;
    1219                 :            : 
    1220                 :            :         // Unlock mutex before notify our listeners
    1221         [ #  # ]:          0 :         aGuard.unlock();
    1222                 :            : 
    1223                 :            :         // Notify our listeners
    1224         [ #  # ]:          0 :         for ( sal_uInt32 j = 0; j < aRemoveNotifyContainer.size(); j++ )
    1225         [ #  # ]:          0 :             implts_notifyContainerListener( aRemoveNotifyContainer[j], NotifyOp_Remove );
    1226         [ #  # ]:          0 :         for ( sal_uInt32 k = 0; k < aReplaceNotifyContainer.size(); k++ )
    1227         [ #  # ]:          0 :             implts_notifyContainerListener( aReplaceNotifyContainer[k], NotifyOp_Replace );
    1228         [ #  # ]:          0 :     }
    1229                 :          0 : }
    1230                 :            : 
    1231                 :          0 : void SAL_CALL UIConfigurationManager::store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
    1232                 :            : {
    1233         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
    1234                 :            : 
    1235         [ #  # ]:          0 :     if ( m_bDisposed )
    1236         [ #  # ]:          0 :         throw DisposedException();
    1237                 :            : 
    1238 [ #  # ][ #  # ]:          0 :     if ( m_xDocConfigStorage.is() && m_bModified && !m_bReadOnly )
         [ #  # ][ #  # ]
    1239                 :            :     {
    1240                 :            :         // Try to access our module sub folder
    1241         [ #  # ]:          0 :         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
    1242                 :            :         {
    1243                 :            :             try
    1244                 :            :             {
    1245                 :          0 :                 UIElementType& rElementType = m_aUIElements[i];
    1246         [ #  # ]:          0 :                 Reference< XStorage > xStorage( rElementType.xStorage, UNO_QUERY );
    1247                 :            : 
    1248 [ #  # ][ #  # ]:          0 :                 if ( rElementType.bModified && xStorage.is() )
                 [ #  # ]
    1249         [ #  # ]:          0 :                     impl_storeElementTypeData( xStorage, rElementType );
    1250                 :            :             }
    1251         [ #  # ]:          0 :             catch ( const Exception& )
    1252                 :            :             {
    1253         [ #  # ]:          0 :                 throw IOException();
    1254                 :            :             }
    1255                 :            :         }
    1256                 :            : 
    1257                 :          0 :         m_bModified = false;
    1258         [ #  # ]:          0 :         Reference< XTransactedObject > xTransactedObject( m_xDocConfigStorage, UNO_QUERY );
    1259         [ #  # ]:          0 :         if ( xTransactedObject.is() )
    1260 [ #  # ][ #  # ]:          0 :             xTransactedObject->commit();
    1261         [ #  # ]:          0 :     }
    1262                 :          0 : }
    1263                 :            : 
    1264                 :          0 : void SAL_CALL UIConfigurationManager::storeToStorage( const Reference< XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
    1265                 :            : {
    1266         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
    1267                 :            : 
    1268         [ #  # ]:          0 :     if ( m_bDisposed )
    1269         [ #  # ]:          0 :         throw DisposedException();
    1270                 :            : 
    1271 [ #  # ][ #  # ]:          0 :     if ( m_xDocConfigStorage.is() && m_bModified && !m_bReadOnly )
         [ #  # ][ #  # ]
    1272                 :            :     {
    1273                 :            :         // Try to access our module sub folder
    1274         [ #  # ]:          0 :         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
    1275                 :            :         {
    1276                 :            :             try
    1277                 :            :             {
    1278         [ #  # ]:          0 :                 Reference< XStorage > xElementTypeStorage( Storage->openStorageElement(
    1279         [ #  # ]:          0 :                                                            rtl::OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), ElementModes::READWRITE ));
    1280                 :          0 :                 UIElementType& rElementType = m_aUIElements[i];
    1281                 :            : 
    1282 [ #  # ][ #  # ]:          0 :                 if ( rElementType.bModified && xElementTypeStorage.is() )
                 [ #  # ]
    1283         [ #  # ]:          0 :                     impl_storeElementTypeData( xElementTypeStorage, rElementType, false ); // store data to storage, but don't reset modify flag!
    1284                 :            :             }
    1285         [ #  # ]:          0 :             catch ( const Exception& )
    1286                 :            :             {
    1287         [ #  # ]:          0 :                 throw IOException();
    1288                 :            :             }
    1289                 :            :         }
    1290                 :            : 
    1291         [ #  # ]:          0 :         Reference< XTransactedObject > xTransactedObject( Storage, UNO_QUERY );
    1292         [ #  # ]:          0 :         if ( xTransactedObject.is() )
    1293 [ #  # ][ #  # ]:          0 :             xTransactedObject->commit();
    1294         [ #  # ]:          0 :     }
    1295                 :          0 : }
    1296                 :            : 
    1297                 :          0 : sal_Bool SAL_CALL UIConfigurationManager::isModified() throw (::com::sun::star::uno::RuntimeException)
    1298                 :            : {
    1299         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
    1300                 :            : 
    1301         [ #  # ]:          0 :     return m_bModified;
    1302                 :            : }
    1303                 :            : 
    1304                 :          0 : sal_Bool SAL_CALL UIConfigurationManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
    1305                 :            : {
    1306         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
    1307                 :            : 
    1308         [ #  # ]:          0 :     return m_bReadOnly;
    1309                 :            : }
    1310                 :            : 
    1311                 :          0 : void UIConfigurationManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
    1312                 :            : {
    1313                 :          0 :     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >*) NULL ) );
    1314         [ #  # ]:          0 :     if ( pContainer != NULL )
    1315                 :            :     {
    1316         [ #  # ]:          0 :         ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
    1317         [ #  # ]:          0 :         while ( pIterator.hasMoreElements() )
    1318                 :            :         {
    1319                 :            :             try
    1320                 :            :             {
    1321   [ #  #  #  # ]:          0 :                 switch ( eOp )
    1322                 :            :                 {
    1323                 :            :                     case NotifyOp_Replace:
    1324 [ #  # ][ #  # ]:          0 :                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementReplaced( aEvent );
    1325                 :          0 :                         break;
    1326                 :            :                     case NotifyOp_Insert:
    1327 [ #  # ][ #  # ]:          0 :                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementInserted( aEvent );
    1328                 :          0 :                         break;
    1329                 :            :                     case NotifyOp_Remove:
    1330 [ #  # ][ #  # ]:          0 :                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementRemoved( aEvent );
    1331                 :          0 :                         break;
    1332                 :            :                 }
    1333                 :            :             }
    1334   [ #  #  #  # ]:          0 :             catch( const css::uno::RuntimeException& )
    1335                 :            :             {
    1336         [ #  # ]:          0 :                 pIterator.remove();
    1337                 :            :             }
    1338         [ #  # ]:          0 :         }
    1339                 :            :     }
    1340                 :          0 : }
    1341                 :            : 
    1342                 :            : } // namespace framework
    1343                 :            : 
    1344                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10