LCOV - code coverage report
Current view: top level - libreoffice/framework/source/uifactory - uielementfactorymanager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 115 226 50.9 %
Date: 2012-12-27 Functions: 17 30 56.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <uifactory/uielementfactorymanager.hxx>
      21             : #include <uifactory/windowcontentfactorymanager.hxx>
      22             : #include <threadhelp/resetableguard.hxx>
      23             : #include "services.h"
      24             : 
      25             : #include "helper/mischelper.hxx"
      26             : 
      27             : #include <com/sun/star/beans/PropertyValue.hpp>
      28             : #include <com/sun/star/beans/XPropertySet.hpp>
      29             : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      30             : #include <com/sun/star/container/XNameAccess.hpp>
      31             : #include <com/sun/star/container/XNameContainer.hpp>
      32             : #include <com/sun/star/container/XContainer.hpp>
      33             : #include <com/sun/star/frame/ModuleManager.hpp>
      34             : #include <com/sun/star/frame/XFrame.hpp>
      35             : 
      36             : #include <rtl/ustrbuf.hxx>
      37             : #include <cppuhelper/weak.hxx>
      38             : #include <vcl/svapp.hxx>
      39             : #include <rtl/logfile.hxx>
      40             : 
      41             : //_________________________________________________________________________________________________________________
      42             : //  Defines
      43             : //_________________________________________________________________________________________________________________
      44             : 
      45             : using namespace com::sun::star::uno;
      46             : using namespace com::sun::star::lang;
      47             : using namespace com::sun::star::beans;
      48             : using namespace com::sun::star::frame;
      49             : using namespace com::sun::star::configuration;
      50             : using namespace com::sun::star::container;
      51             : using namespace ::com::sun::star::ui;
      52             : using namespace ::com::sun::star::frame;
      53             : 
      54             : //_________________________________________________________________________________________________________________
      55             : //  Namespace
      56             : //_________________________________________________________________________________________________________________
      57             : 
      58             : namespace framework
      59             : {
      60             : 
      61             : // global function needed by both implementations
      62        4357 : rtl::OUString getHashKeyFromStrings( const rtl::OUString& aType, const rtl::OUString& aName, const rtl::OUString& aModuleName )
      63             : {
      64        4357 :     rtl::OUStringBuffer aKey( aType );
      65        4357 :     aKey.appendAscii( "^" );
      66        4357 :     aKey.append( aName );
      67        4357 :     aKey.appendAscii( "^" );
      68        4357 :     aKey.append( aModuleName );
      69        4357 :     return aKey.makeStringAndClear();
      70             : }
      71             : 
      72             : 
      73             : //*****************************************************************************************************************
      74             : //  Configuration access class for UIElementFactoryManager implementation
      75             : //*****************************************************************************************************************
      76             : 
      77             : 
      78           9 : ConfigurationAccess_FactoryManager::ConfigurationAccess_FactoryManager( const Reference< XComponentContext >& rxContext, const ::rtl::OUString& _sRoot ) :
      79             :     ThreadHelpBase(),
      80             :     m_aPropType( RTL_CONSTASCII_USTRINGPARAM( "Type" )),
      81             :     m_aPropName( RTL_CONSTASCII_USTRINGPARAM( "Name" )),
      82             :     m_aPropModule( RTL_CONSTASCII_USTRINGPARAM( "Module" )),
      83             :     m_aPropFactory( RTL_CONSTASCII_USTRINGPARAM( "FactoryImplementation" )),
      84             :     m_sRoot(_sRoot),
      85           9 :     m_bConfigAccessInitialized( sal_False )
      86             : {
      87             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::ConfigurationAccess_FactoryManager" );
      88           9 :     m_xConfigProvider = theDefaultProvider::get( rxContext );
      89           9 : }
      90             : 
      91           3 : ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager()
      92             : {
      93             :     // SAFE
      94           1 :     ResetableGuard aLock( m_aLock );
      95             : 
      96           1 :     Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
      97           1 :     if ( xContainer.is() )
      98           1 :         xContainer->removeContainerListener(m_xConfigListener);
      99           2 : }
     100             : 
     101        1439 : rtl::OUString ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule ) const
     102             : {
     103             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::getFactorySpecifierFromTypeNameModule" );
     104             :     // SAFE
     105        1439 :     ResetableGuard aLock( m_aLock );
     106             : 
     107             :     FactoryManagerMap::const_iterator pIter =
     108        1439 :         m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, rName, rModule ));
     109        1439 :     if ( pIter != m_aFactoryManagerMap.end() )
     110           0 :         return pIter->second;
     111             :     else
     112             :     {
     113        1439 :         pIter = m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, rName, rtl::OUString() ));
     114        1439 :         if ( pIter != m_aFactoryManagerMap.end() )
     115           0 :             return pIter->second;
     116             :         else
     117             :         {
     118             :             // Support factories which uses a defined prefix before the ui name.
     119        1439 :             sal_Int32 nIndex = rName.indexOf( '_' );
     120        1439 :             if ( nIndex > 0 )
     121             :             {
     122         472 :                 rtl::OUString aName = rName.copy( 0, nIndex+1 );
     123         472 :                 pIter = m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, aName, rtl::OUString() ));
     124         472 :                 if ( pIter != m_aFactoryManagerMap.end() )
     125         472 :                     return pIter->second;
     126             :             }
     127             : 
     128         967 :             pIter = m_aFactoryManagerMap.find( getHashKeyFromStrings( rType, rtl::OUString(), rtl::OUString() ));
     129         967 :             if ( pIter != m_aFactoryManagerMap.end() )
     130         967 :                 return pIter->second;
     131             :         }
     132             :     }
     133             : 
     134           0 :     return rtl::OUString();
     135             : }
     136             : 
     137           0 : void ConfigurationAccess_FactoryManager::addFactorySpecifierToTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule, const rtl::OUString& rServiceSpecifier )
     138             : {
     139             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::addFactorySpecifierToTypeNameModule" );
     140             :     // SAFE
     141           0 :     ResetableGuard aLock( m_aLock );
     142             : 
     143           0 :     rtl::OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
     144             : 
     145           0 :     FactoryManagerMap::const_iterator pIter = m_aFactoryManagerMap.find( aHashKey );
     146             : 
     147           0 :     if ( pIter != m_aFactoryManagerMap.end() )
     148           0 :         throw ElementExistException();
     149             :     else
     150           0 :         m_aFactoryManagerMap.insert( FactoryManagerMap::value_type( aHashKey, rServiceSpecifier ));
     151           0 : }
     152             : 
     153             : 
     154           0 : void ConfigurationAccess_FactoryManager::removeFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule )
     155             : {
     156             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::removeFactorySpecifierFromTypeNameModule" );
     157             :     // SAFE
     158           0 :     ResetableGuard aLock( m_aLock );
     159             : 
     160           0 :     rtl::OUString aHashKey = getHashKeyFromStrings( rType, rName, rModule );
     161             : 
     162           0 :     FactoryManagerMap::const_iterator pIter = m_aFactoryManagerMap.find( aHashKey );
     163             : 
     164           0 :     if ( pIter == m_aFactoryManagerMap.end() )
     165           0 :         throw NoSuchElementException();
     166             :     else
     167           0 :         m_aFactoryManagerMap.erase( aHashKey );
     168           0 : }
     169             : 
     170           0 : Sequence< Sequence< PropertyValue > > ConfigurationAccess_FactoryManager::getFactoriesDescription() const
     171             : {
     172             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::getFactoriesDescription" );
     173             :     // SAFE
     174           0 :     ResetableGuard aLock( m_aLock );
     175             : 
     176           0 :     Sequence< Sequence< PropertyValue > > aSeqSeq;
     177             : 
     178           0 :     sal_Int32 nIndex( 0 );
     179           0 :     FactoryManagerMap::const_iterator pIter = m_aFactoryManagerMap.begin();
     180           0 :     while ( pIter != m_aFactoryManagerMap.end() )
     181             :     {
     182           0 :         rtl::OUString aFactory = pIter->first;
     183           0 :         if ( !aFactory.isEmpty() )
     184             :         {
     185           0 :             sal_Int32                 nToken = 0;
     186           0 :             Sequence< PropertyValue > aSeq( 1 );
     187             : 
     188           0 :             aSeqSeq.realloc( aSeqSeq.getLength() + 1 );
     189           0 :             aSeq[0].Name  = m_aPropType;
     190           0 :             aSeq[0].Value = makeAny( aFactory.getToken( 0, '^', nToken ));
     191           0 :             if ( nToken > 0 )
     192             :             {
     193           0 :                 aSeq.realloc( 2 );
     194           0 :                 aSeq[1].Name  = m_aPropName;
     195           0 :                 aSeq[1].Value = makeAny( aFactory.getToken( 0, '^', nToken ));
     196           0 :                 if ( nToken > 0 )
     197             :                 {
     198           0 :                     aSeq.realloc( 3 );
     199           0 :                     aSeq[2].Name  = m_aPropModule;
     200           0 :                     aSeq[2].Value = makeAny( aFactory.getToken( 0, '^', nToken ));
     201             :                 }
     202             :             }
     203             : 
     204           0 :             aSeqSeq[nIndex++] = aSeq;
     205             :         }
     206             : 
     207           0 :         ++pIter;
     208           0 :     }
     209             : 
     210           0 :     return aSeqSeq;
     211             : }
     212             : 
     213             : // container.XContainerListener
     214           0 : void SAL_CALL ConfigurationAccess_FactoryManager::elementInserted( const ContainerEvent& aEvent ) throw(RuntimeException)
     215             : {
     216             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::elementInserted" );
     217           0 :     rtl::OUString   aType;
     218           0 :     rtl::OUString   aName;
     219           0 :     rtl::OUString   aModule;
     220           0 :     rtl::OUString   aService;
     221             : 
     222             :     // SAFE
     223           0 :     ResetableGuard aLock( m_aLock );
     224             : 
     225           0 :     if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
     226             :     {
     227             :         // Create hash key from type, name and module as they are together a primary key to
     228             :         // the UNO service that implements a user interface factory.
     229           0 :         rtl::OUString aHashKey( getHashKeyFromStrings( aType, aName, aModule ));
     230           0 :         m_aFactoryManagerMap.insert( FactoryManagerMap::value_type( aHashKey, aService ));
     231           0 :     }
     232           0 : }
     233             : 
     234           0 : void SAL_CALL ConfigurationAccess_FactoryManager::elementRemoved ( const ContainerEvent& aEvent ) throw(RuntimeException)
     235             : {
     236             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::elementRemoved " );
     237           0 :     rtl::OUString   aType;
     238           0 :     rtl::OUString   aName;
     239           0 :     rtl::OUString   aModule;
     240           0 :     rtl::OUString   aService;
     241             : 
     242             :     // SAFE
     243           0 :     ResetableGuard aLock( m_aLock );
     244             : 
     245           0 :     if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
     246             :     {
     247             :         // Create hash key from command and model as they are together a primary key to
     248             :         // the UNO service that implements the popup menu controller.
     249           0 :         rtl::OUString aHashKey( getHashKeyFromStrings( aType, aName, aModule ));
     250           0 :         m_aFactoryManagerMap.erase( aHashKey );
     251           0 :     }
     252           0 : }
     253             : 
     254           0 : void SAL_CALL ConfigurationAccess_FactoryManager::elementReplaced( const ContainerEvent& aEvent ) throw(RuntimeException)
     255             : {
     256             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::elementReplaced" );
     257           0 :     rtl::OUString   aType;
     258           0 :     rtl::OUString   aName;
     259           0 :     rtl::OUString   aModule;
     260           0 :     rtl::OUString   aService;
     261             : 
     262             :     // SAFE
     263           0 :     ResetableGuard aLock( m_aLock );
     264             : 
     265           0 :     if ( impl_getElementProps( aEvent.Element, aType, aName, aModule, aService ))
     266             :     {
     267             :         // Create hash key from command and model as they are together a primary key to
     268             :         // the UNO service that implements the popup menu controller.
     269           0 :         rtl::OUString aHashKey( getHashKeyFromStrings( aType, aName, aModule ));
     270           0 :         m_aFactoryManagerMap.erase( aHashKey );
     271           0 :         m_aFactoryManagerMap.insert( FactoryManagerMap::value_type( aHashKey, aService ));
     272           0 :     }
     273           0 : }
     274             : 
     275             : // lang.XEventListener
     276           0 : void SAL_CALL ConfigurationAccess_FactoryManager::disposing( const EventObject& ) throw(RuntimeException)
     277             : {
     278             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::disposing" );
     279             :     // SAFE
     280             :     // remove our reference to the config access
     281           0 :     ResetableGuard aLock( m_aLock );
     282           0 :     m_xConfigAccess.clear();
     283           0 : }
     284             : 
     285           8 : void ConfigurationAccess_FactoryManager::readConfigurationData()
     286             : {
     287             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::readConfigurationData" );
     288             :     // SAFE
     289           8 :     ResetableGuard aLock( m_aLock );
     290             : 
     291           8 :     if ( !m_bConfigAccessInitialized )
     292             :     {
     293           8 :         Sequence< Any > aArgs( 1 );
     294           8 :         PropertyValue   aPropValue;
     295             : 
     296           8 :         aPropValue.Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
     297           8 :         aPropValue.Value <<= m_sRoot;
     298           8 :         aArgs[0] <<= aPropValue;
     299             : 
     300             :         try
     301             :         {
     302           8 :             m_xConfigAccess.set( m_xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS,aArgs ), UNO_QUERY );
     303             :         }
     304           0 :         catch ( const WrappedTargetException& )
     305             :         {
     306             :         }
     307             : 
     308           8 :         m_bConfigAccessInitialized = sal_True;
     309             :     }
     310             : 
     311           8 :     if ( m_xConfigAccess.is() )
     312             :     {
     313           8 :         Sequence< rtl::OUString >   aUIElementFactories = m_xConfigAccess->getElementNames();
     314             : 
     315           8 :         rtl::OUString             aType;
     316           8 :         rtl::OUString             aName;
     317           8 :         rtl::OUString             aModule;
     318           8 :         rtl::OUString             aService;
     319           8 :         rtl::OUString             aHashKey;
     320           8 :         Reference< XPropertySet > xPropertySet;
     321          48 :         for ( sal_Int32 i = 0; i < aUIElementFactories.getLength(); i++ )
     322             :         {
     323          40 :             if ( impl_getElementProps( m_xConfigAccess->getByName( aUIElementFactories[i] ), aType, aName, aModule, aService ))
     324             :             {
     325             :                 // Create hash key from type, name and module as they are together a primary key to
     326             :                 // the UNO service that implements the user interface element factory.
     327          40 :                 aHashKey = getHashKeyFromStrings( aType, aName, aModule );
     328          40 :                 m_aFactoryManagerMap.insert( FactoryManagerMap::value_type( aHashKey, aService ));
     329             :             }
     330             :         }
     331             : 
     332           8 :         Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
     333           8 :         aLock.unlock();
     334             :         // UNSAFE
     335           8 :         if ( xContainer.is() )
     336             :         {
     337           8 :             m_xConfigListener = new WeakContainerListener(this);
     338           8 :             xContainer->addContainerListener(m_xConfigListener);
     339           8 :         }
     340           8 :     }
     341           8 : }
     342             : 
     343          40 : sal_Bool ConfigurationAccess_FactoryManager::impl_getElementProps( const Any& aElement, rtl::OUString& rType, rtl::OUString& rName, rtl::OUString& rModule, rtl::OUString& rServiceSpecifier ) const
     344             : {
     345             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::impl_getElementProps" );
     346          40 :     Reference< XPropertySet > xPropertySet;
     347          40 :     aElement >>= xPropertySet;
     348             : 
     349          40 :     if ( xPropertySet.is() )
     350             :     {
     351             :         try
     352             :         {
     353          40 :             xPropertySet->getPropertyValue( m_aPropType ) >>= rType;
     354          40 :             xPropertySet->getPropertyValue( m_aPropName ) >>= rName;
     355          40 :             xPropertySet->getPropertyValue( m_aPropModule ) >>= rModule;
     356          40 :             xPropertySet->getPropertyValue( m_aPropFactory ) >>= rServiceSpecifier;
     357             :         }
     358           0 :         catch ( const com::sun::star::beans::UnknownPropertyException& )
     359             :         {
     360           0 :             return sal_False;
     361             :         }
     362           0 :         catch ( const com::sun::star::lang::WrappedTargetException& )
     363             :         {
     364           0 :             return sal_False;
     365             :         }
     366             :     }
     367             : 
     368          40 :     return sal_True;
     369             : }
     370             : 
     371             : //*****************************************************************************************************************
     372             : //  XInterface, XTypeProvider, XServiceInfo
     373             : //*****************************************************************************************************************
     374         210 : DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2  (   UIElementFactoryManager                         ,
     375             :                                             ::cppu::OWeakObject                             ,
     376             :                                             DECLARE_ASCII("com.sun.star.ui.UIElementFactoryManager"),
     377             :                                             IMPLEMENTATIONNAME_UIELEMENTFACTORYMANAGER
     378             :                                         )
     379             : 
     380           9 : DEFINE_INIT_SERVICE                     (   UIElementFactoryManager, {} )
     381             : 
     382           9 : UIElementFactoryManager::UIElementFactoryManager( const Reference< XComponentContext >& rxContext ) :
     383           9 :     ThreadHelpBase( &Application::GetSolarMutex() ),
     384             :     m_bConfigRead( sal_False ),
     385           9 :     m_xContext(rxContext)
     386             : {
     387             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::UIElementFactoryManager" );
     388           9 :     m_pConfigAccess = new ConfigurationAccess_FactoryManager( rxContext, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories" )) );
     389           9 :     m_pConfigAccess->acquire();
     390           9 :     m_xModuleManager = ModuleManager::create( rxContext );
     391           9 : }
     392             : 
     393           3 : UIElementFactoryManager::~UIElementFactoryManager()
     394             : {
     395           1 :     ResetableGuard aLock( m_aLock );
     396             : 
     397             :     // reduce reference count
     398           1 :     m_pConfigAccess->release();
     399           2 : }
     400             : 
     401             : // XUIElementFactory
     402        1439 : Reference< XUIElement > SAL_CALL UIElementFactoryManager::createUIElement(
     403             :     const ::rtl::OUString& ResourceURL,
     404             :     const Sequence< PropertyValue >& Args )
     405             : throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
     406             : {
     407             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::createUIElement" );
     408             :     // SAFE
     409        1439 :     ResetableGuard aLock( m_aLock );
     410             : 
     411        1439 :     if ( !m_bConfigRead )
     412             :     {
     413           8 :         m_bConfigRead = sal_True;
     414           8 :         m_pConfigAccess->readConfigurationData();
     415             :     }
     416             : 
     417        1439 :     const rtl::OUString aPropFrame( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
     418             : 
     419        1439 :     rtl::OUString   aModuleId;
     420        1439 :     PropertyValue   aPropValue;
     421        1439 :     Reference< XFrame > xFrame;
     422             : 
     423             :     // Retrieve the frame instance from the arguments to determine the module identifier. This must be provided
     424             :     // to the search function. An empty module identifier is provided if the frame is missing or the module id cannot
     425             :     // retrieve from it.
     426        4317 :     for ( int i = 0; i < Args.getLength(); i++ )
     427             :     {
     428        2878 :         if ( Args[i].Name.equals( aPropFrame ))
     429        1439 :             Args[i].Value >>= xFrame;
     430             :     }
     431             : 
     432        1439 :     Reference< XModuleManager2 > xManager( m_xModuleManager );
     433        1439 :     aLock.unlock();
     434             : 
     435             :     // Determine the module identifier
     436             :     try
     437             :     {
     438        1439 :         if ( xFrame.is() && xManager.is() )
     439        1203 :             aModuleId = xManager->identify( Reference< XInterface >( xFrame, UNO_QUERY ) );
     440             : 
     441        1439 :         Reference< XUIElementFactory > xUIElementFactory = getFactory( ResourceURL, aModuleId );
     442        1439 :         if ( xUIElementFactory.is() )
     443        2878 :             return xUIElementFactory->createUIElement( ResourceURL, Args );
     444             :     }
     445           0 :     catch ( const UnknownModuleException& )
     446             :     {
     447             :     }
     448             : 
     449        1439 :     throw NoSuchElementException();
     450             : }
     451             : 
     452             : // XUIElementFactoryRegistration
     453           0 : Sequence< Sequence< PropertyValue > > SAL_CALL UIElementFactoryManager::getRegisteredFactories()
     454             : throw ( RuntimeException )
     455             : {
     456             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::getRegisteredFactories" );
     457             :     // SAFE
     458           0 :     ResetableGuard aLock( m_aLock );
     459             : 
     460           0 :     if ( !m_bConfigRead )
     461             :     {
     462           0 :         m_bConfigRead = sal_True;
     463           0 :         m_pConfigAccess->readConfigurationData();
     464             :     }
     465             : 
     466           0 :     return m_pConfigAccess->getFactoriesDescription();
     467             : }
     468             : 
     469        1439 : Reference< XUIElementFactory > SAL_CALL UIElementFactoryManager::getFactory( const ::rtl::OUString& aResourceURL, const ::rtl::OUString& aModuleId )
     470             : throw ( RuntimeException )
     471             : {
     472             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::getFactory" );
     473        1439 :     ResetableGuard aLock( m_aLock );
     474             : 
     475        1439 :     if ( !m_bConfigRead )
     476             :     {
     477           0 :         m_bConfigRead = sal_True;
     478           0 :         m_pConfigAccess->readConfigurationData();
     479             :     }
     480             : 
     481        1439 :     rtl::OUString aType;
     482        1439 :     rtl::OUString aName;
     483             : 
     484        1439 :     WindowContentFactoryManager::RetrieveTypeNameFromResourceURL( aResourceURL, aType, aName );
     485             : 
     486        1439 :     Reference< XComponentContext > xContext( m_xContext );
     487             : 
     488        1439 :     rtl::OUString aServiceSpecifier = m_pConfigAccess->getFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
     489             : 
     490        1439 :     aLock.unlock();
     491        1439 :     if ( !aServiceSpecifier.isEmpty() )
     492        1439 :         return Reference< XUIElementFactory >( xContext->getServiceManager()->createInstanceWithContext(aServiceSpecifier, xContext), UNO_QUERY );
     493             :     else
     494           0 :         return Reference< XUIElementFactory >();
     495             : }
     496             : 
     497           0 : void SAL_CALL UIElementFactoryManager::registerFactory( const ::rtl::OUString& aType, const ::rtl::OUString& aName, const ::rtl::OUString& aModuleId, const ::rtl::OUString& aFactoryImplementationName )
     498             : throw ( ElementExistException, RuntimeException )
     499             : {
     500             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::registerFactory" );
     501             :     // SAFE
     502           0 :     ResetableGuard aLock( m_aLock );
     503             : 
     504           0 :     if ( !m_bConfigRead )
     505             :     {
     506           0 :         m_bConfigRead = sal_True;
     507           0 :         m_pConfigAccess->readConfigurationData();
     508             :     }
     509             : 
     510           0 :     m_pConfigAccess->addFactorySpecifierToTypeNameModule( aType, aName, aModuleId, aFactoryImplementationName );
     511             :     // SAFE
     512           0 : }
     513             : 
     514           0 : void SAL_CALL UIElementFactoryManager::deregisterFactory( const ::rtl::OUString& aType, const ::rtl::OUString& aName, const ::rtl::OUString& aModuleId )
     515             : throw ( NoSuchElementException, RuntimeException )
     516             : {
     517             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "UIElementFactoryManager::deregisterFactory" );
     518             :     // SAFE
     519           0 :     ResetableGuard aLock( m_aLock );
     520             : 
     521           0 :     if ( !m_bConfigRead )
     522             :     {
     523           0 :         m_bConfigRead = sal_True;
     524           0 :         m_pConfigAccess->readConfigurationData();
     525             :     }
     526             : 
     527           0 :     m_pConfigAccess->removeFactorySpecifierFromTypeNameModule( aType, aName, aModuleId );
     528             :     // SAFE
     529           0 : }
     530             : 
     531             : } // namespace framework
     532             : 
     533             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10