LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - pcrcomponentcontext.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 13 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           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                 :            : #ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
      30                 :            : #define EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/uno/XComponentContext.hpp>
      33                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      34                 :            : 
      35                 :            : //........................................................................
      36                 :            : namespace pcr
      37                 :            : {
      38                 :            : //........................................................................
      39                 :            : 
      40                 :            :     //====================================================================
      41                 :            :     //= ComponentContext
      42                 :            :     //====================================================================
      43                 :            :     /** a helper class for working with a component context
      44                 :            :     */
      45                 :          0 :     class ComponentContext
      46                 :            :     {
      47                 :            :     private:
      48                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >        m_xContext;
      49                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory >  m_xORB;
      50                 :            : 
      51                 :            :     public:
      52                 :            :         /** constructs an instance
      53                 :            :             @param _rxContext
      54                 :            :                 the component context to manage
      55                 :            :             @throws ::com::sun::star::lang::NullPointerException
      56                 :            :                 if the given context, or its component factory, are <NULL/>
      57                 :            :         */
      58                 :            :         ComponentContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
      59                 :            : 
      60                 :            :         /** returns the ->XComponentContext interface
      61                 :            :         */
      62                 :            :         inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
      63                 :          0 :             getUNOContext() const { return m_xContext; }
      64                 :            : 
      65                 :            :         /** determines whether the context is not <NULL/>
      66                 :            :         */
      67                 :            :         inline sal_Bool is() const
      68                 :            :         {
      69                 :            :             return m_xContext.is();
      70                 :            :         }
      71                 :            : 
      72                 :            :         /** creates a component using our component factory/context
      73                 :            :             @throws ::com::sun::star::uno::Exception
      74                 :            :             @return
      75                 :            :                 <TRUE/> if and only if the component could be successfully created
      76                 :            :         */
      77                 :            :         template < class INTERFACE >
      78                 :          0 :         bool createComponent( const ::rtl::OUString& _rServiceName, ::com::sun::star::uno::Reference< INTERFACE >& _out_rxComponent ) const
      79                 :            :         {
      80                 :          0 :             _out_rxComponent.clear();
      81                 :          0 :             _out_rxComponent = _out_rxComponent.query(
      82                 :            :                 m_xORB->createInstanceWithContext( _rServiceName, m_xContext )
      83                 :            :             );
      84                 :          0 :             return _out_rxComponent.is();
      85                 :            :         }
      86                 :            : 
      87                 :            :         /** creates a component using our component factory/context
      88                 :            :             @throws ::com::sun::star::uno::Exception
      89                 :            :             @return
      90                 :            :                 <TRUE/> if and only if the component could be successfully created
      91                 :            :         */
      92                 :            :         template < class INTERFACE >
      93                 :          0 :         bool createComponent( const sal_Char* _pAsciiServiceName, ::com::sun::star::uno::Reference< INTERFACE >& _out_rxComponent ) const
      94                 :            :         {
      95                 :          0 :             return createComponent( ::rtl::OUString::createFromAscii( _pAsciiServiceName ), _out_rxComponent );
      96                 :            :         }
      97                 :            : 
      98                 :            :         /** creates a component using our component factory/context
      99                 :            : 
     100                 :            :             @throws ::com::sun::star::lang::ServiceNotRegisteredException
     101                 :            :                 if the given service is not registered
     102                 :            :             @throws Exception
     103                 :            :                 if an exception occurred during creating the component
     104                 :            :             @return
     105                 :            :                 the newly created component. Is never <NULL/>.
     106                 :            :         */
     107                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createComponent( const ::rtl::OUString& _rServiceName ) const;
     108                 :            : 
     109                 :            :         /** creates a component using our component factory/context
     110                 :            : 
     111                 :            :             @throws ::com::sun::star::lang::ServiceNotRegisteredException
     112                 :            :                 if the given service is not registered
     113                 :            :             @throws Exception
     114                 :            :                 if an exception occurred during creating the component
     115                 :            :             @return
     116                 :            :                 the newly created component. Is never <NULL/>.
     117                 :            :         */
     118                 :          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createComponent( const sal_Char* _pAsciiServiceName ) const
     119                 :            :         {
     120                 :          0 :             return createComponent( ::rtl::OUString::createFromAscii( _pAsciiServiceName ) );
     121                 :            :         }
     122                 :            : 
     123                 :            :         /** returns the ->XMultiServiceFactory interface of ->m_xORB, for passing to
     124                 :            :             older code which does not yet support ->XMultiComponentFactory
     125                 :            :             @throws ::com::sun::star::uno::RuntimeException
     126                 :            :                 if our our component factory does not support this interface
     127                 :            :         */
     128                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
     129                 :            :             getLegacyServiceFactory() const;
     130                 :            : 
     131                 :            :         /** retrieves a value from our component context
     132                 :            :             @param _rName
     133                 :            :                 the name of the value to retrieve
     134                 :            :             @return
     135                 :            :                 the context value with the given name
     136                 :            :             @seealso XComponentContext::getValueByName
     137                 :            :             @seealso getContextValueByAsciiName
     138                 :            :         */
     139                 :            :         ::com::sun::star::uno::Any
     140                 :            :                 getContextValueByName( const ::rtl::OUString& _rName ) const;
     141                 :            : 
     142                 :            :         /** retrieves a value from our component context, specified by 8-bit ASCII string
     143                 :            :             @param _rName
     144                 :            :                 the name of the value to retrieve, as ASCII character string
     145                 :            :             @return
     146                 :            :                 the context value with the given name
     147                 :            :             @seealso XComponentContext::getValueByName
     148                 :            :             @seealso getContextValueByName
     149                 :            :         */
     150                 :            :         inline ::com::sun::star::uno::Any
     151                 :          0 :                 getContextValueByAsciiName( const sal_Char* _pAsciiName ) const
     152                 :            :         {
     153                 :          0 :             return getContextValueByName( ::rtl::OUString::createFromAscii( _pAsciiName ) );
     154                 :            :         }
     155                 :            : 
     156                 :            :         /** retrieve context to create interfaces by the ctors
     157                 :            :         */
     158                 :          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return        m_xContext;}
     159                 :            : 
     160                 :            :     };
     161                 :            : 
     162                 :            : //........................................................................
     163                 :            : } // namespace pcr
     164                 :            : //........................................................................
     165                 :            : 
     166                 :            : #endif // EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
     167                 :            : 
     168                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10