Bump for 3.6-28
[LibreOffice.git] / extensions / source / propctrlr / pcrcomponentcontext.cxx
blob319f35cd4d3c858728a545fb862145a26d193fec
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #include "pcrcomponentcontext.hxx"
31 /** === begin UNO includes === **/
32 #include <com/sun/star/lang/NullPointerException.hpp>
33 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 /** === end UNO includes === **/
37 //........................................................................
38 namespace pcr
40 //........................................................................
42 /** === begin UNO using === **/
43 using ::com::sun::star::uno::Reference;
44 using ::com::sun::star::uno::XComponentContext;
45 using ::com::sun::star::lang::NullPointerException;
46 using ::com::sun::star::lang::ServiceNotRegisteredException;
47 using ::com::sun::star::uno::Exception;
48 using ::com::sun::star::uno::Any;
49 using ::com::sun::star::uno::XInterface;
50 using ::com::sun::star::uno::UNO_QUERY_THROW;
51 using ::com::sun::star::lang::XMultiServiceFactory;
52 using ::com::sun::star::beans::XPropertySet;
53 using ::com::sun::star::uno::UNO_QUERY;
54 using ::com::sun::star::uno::RuntimeException;
55 /** === end UNO using === **/
57 //====================================================================
58 //= ComponentContext
59 //====================================================================
60 //--------------------------------------------------------------------
61 ComponentContext::ComponentContext( const Reference< XComponentContext >& _rxContext )
62 :m_xContext( _rxContext )
64 if ( m_xContext.is() )
65 m_xORB = m_xContext->getServiceManager();
66 if ( !m_xORB.is() )
67 throw NullPointerException();
70 //------------------------------------------------------------------------
71 Any ComponentContext::getContextValueByName( const ::rtl::OUString& _rName ) const
73 Any aReturn;
74 try
76 aReturn = m_xContext->getValueByName( _rName );
78 catch( const Exception& )
80 OSL_FAIL( "PropertyHandler::getContextValueByName: caught an exception!" );
82 return aReturn;
85 //------------------------------------------------------------------------
86 Reference< XInterface > ComponentContext::createComponent( const ::rtl::OUString& _rServiceName ) const
88 Reference< XInterface > xComponent(
89 m_xORB->createInstanceWithContext( _rServiceName, m_xContext )
91 if ( !xComponent.is() )
92 throw ServiceNotRegisteredException( _rServiceName, NULL );
93 return xComponent;
96 //------------------------------------------------------------------------
97 Reference< XMultiServiceFactory > ComponentContext::getLegacyServiceFactory() const
99 return Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY_THROW );
102 //........................................................................
103 } // namespace pcr
104 //........................................................................
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */