LCOV - code coverage report
Current view: top level - libreoffice/framework/inc/uifactory - uielementfactorymanager.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-12-27 Functions: 2 2 100.0 %
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             : #ifndef __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
      21             : #define __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
      22             : 
      23             : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
      24             :                with solaris headers ...
      25             : */
      26             : #include <vector>
      27             : #include <list>
      28             : 
      29             : #include <threadhelp/threadhelpbase.hxx>
      30             : #include <macros/generic.hxx>
      31             : #include <macros/xinterface.hxx>
      32             : #include <macros/xtypeprovider.hxx>
      33             : #include <macros/xserviceinfo.hxx>
      34             : #include <stdtypes.h>
      35             : 
      36             : #include <com/sun/star/lang/XServiceInfo.hpp>
      37             : #include <com/sun/star/ui/XUIElementFactoryManager.hpp>
      38             : #include <com/sun/star/container/XContainerListener.hpp>
      39             : #include <com/sun/star/container/XNameAccess.hpp>
      40             : #include "com/sun/star/frame/XModuleManager2.hpp"
      41             : 
      42             : #include <cppuhelper/implbase1.hxx>
      43             : #include <cppuhelper/implbase2.hxx>
      44             : #include <rtl/ustring.hxx>
      45             : 
      46             : namespace framework
      47             : {
      48             : 
      49             :     class ConfigurationAccess_FactoryManager : // interfaces
      50             :                                                     // baseclasses
      51             :                                                     // Order is neccessary for right initialization!
      52             :                                                     private ThreadHelpBase                           ,
      53             :                                                     public  ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
      54             : {
      55             :     public:
      56             :                       ConfigurationAccess_FactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, const ::rtl::OUString& _sRoot );
      57             :         virtual       ~ConfigurationAccess_FactoryManager();
      58             : 
      59             :         void          readConfigurationData();
      60             : 
      61             :         rtl::OUString                           getFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule ) const;
      62             :         void                                    addFactorySpecifierToTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule, const rtl::OUString& aServiceSpecifier );
      63             :         void                                    removeFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule );
      64             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >   getFactoriesDescription() const;
      65             : 
      66             :         // container.XContainerListener
      67             :     virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
      68             :     virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
      69             :     virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
      70             : 
      71             :     // lang.XEventListener
      72             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
      73             : 
      74             :     private:
      75          10 :         class FactoryManagerMap : public boost::unordered_map< rtl::OUString,
      76             :                                                      rtl::OUString,
      77             :                                                      OUStringHashCode,
      78             :                                                      ::std::equal_to< ::rtl::OUString > >
      79             :         {
      80             :             inline void free()
      81             :             {
      82             :                 FactoryManagerMap().swap( *this );
      83             :             }
      84             :         };
      85             : 
      86             :         sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, rtl::OUString& rType, rtl::OUString& rName, rtl::OUString& rModule, rtl::OUString& rServiceSpecifier ) const;
      87             : 
      88             :         rtl::OUString                     m_aPropType;
      89             :         rtl::OUString                     m_aPropName;
      90             :         rtl::OUString                     m_aPropModule;
      91             :         rtl::OUString                     m_aPropFactory;
      92             :         ::rtl::OUString                   m_sRoot;
      93             :         FactoryManagerMap                 m_aFactoryManagerMap;
      94             :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
      95             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >     m_xConfigAccess;
      96             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xConfigListener;
      97             :         sal_Bool                          m_bConfigAccessInitialized;
      98             : };
      99             : 
     100             : 
     101             : class UIElementFactoryManager :  private ThreadHelpBase                                             ,   // Struct for right initalization of mutex member! Must be first of baseclasses.
     102             :                                  public ::cppu::WeakImplHelper2< ::com::sun::star::lang::XServiceInfo,
     103             :                                                                  ::com::sun::star::ui::XUIElementFactoryManager>
     104             : {
     105             :     public:
     106             :         UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
     107             :         virtual ~UIElementFactoryManager();
     108             : 
     109             :         //  XInterface, XTypeProvider, XServiceInfo
     110             :         DECLARE_XSERVICEINFO
     111             : 
     112             :         // XUIElementFactory
     113             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const ::rtl::OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     114             : 
     115             :         // XUIElementFactoryRegistration
     116             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getRegisteredFactories(  ) throw (::com::sun::star::uno::RuntimeException);
     117             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElementFactory > SAL_CALL getFactory( const ::rtl::OUString& ResourceURL, const ::rtl::OUString& ModuleIdentifier ) throw (::com::sun::star::uno::RuntimeException);
     118             :         virtual void SAL_CALL registerFactory( const ::rtl::OUString& aType, const ::rtl::OUString& aName, const ::rtl::OUString& aModuleIdentifier, const ::rtl::OUString& aFactoryImplementationName ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
     119             :         virtual void SAL_CALL deregisterFactory( const ::rtl::OUString& aType, const ::rtl::OUString& aName, const ::rtl::OUString& aModuleIdentifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
     120             : 
     121             :     private:
     122             : 
     123             :         sal_Bool                                                                            m_bConfigRead;
     124             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >        m_xContext;
     125             :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >        m_xModuleManager;
     126             :         ConfigurationAccess_FactoryManager*                                        m_pConfigAccess;
     127             : };
     128             : 
     129             : } // namespace framework
     130             : 
     131             : #endif // __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10