1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "pcrcomponentcontext.hxx"
32 /** === begin UNO includes === **/
33 #include <com/sun/star/lang/NullPointerException.hpp>
34 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 /** === end UNO includes === **/
38 //........................................................................
41 //........................................................................
43 /** === begin UNO using === **/
44 using ::com::sun::star::uno::Reference
;
45 using ::com::sun::star::uno::XComponentContext
;
46 using ::com::sun::star::lang::NullPointerException
;
47 using ::com::sun::star::lang::ServiceNotRegisteredException
;
48 using ::com::sun::star::uno::Exception
;
49 using ::com::sun::star::uno::Any
;
50 using ::com::sun::star::uno::XInterface
;
51 using ::com::sun::star::uno::UNO_QUERY_THROW
;
52 using ::com::sun::star::lang::XMultiServiceFactory
;
53 using ::com::sun::star::beans::XPropertySet
;
54 using ::com::sun::star::uno::UNO_QUERY
;
55 using ::com::sun::star::uno::RuntimeException
;
56 /** === end UNO using === **/
58 //====================================================================
60 //====================================================================
61 //--------------------------------------------------------------------
62 ComponentContext::ComponentContext( const Reference
< XComponentContext
>& _rxContext
)
63 :m_xContext( _rxContext
)
65 if ( m_xContext
.is() )
66 m_xORB
= m_xContext
->getServiceManager();
68 throw NullPointerException();
71 //------------------------------------------------------------------------
72 Any
ComponentContext::getContextValueByName( const ::rtl::OUString
& _rName
) const
77 aReturn
= m_xContext
->getValueByName( _rName
);
79 catch( const Exception
& )
81 OSL_ENSURE( sal_False
, "PropertyHandler::getContextValueByName: caught an exception!" );
86 //------------------------------------------------------------------------
87 Reference
< XInterface
> ComponentContext::createComponent( const ::rtl::OUString
& _rServiceName
) const
89 Reference
< XInterface
> xComponent(
90 m_xORB
->createInstanceWithContext( _rServiceName
, m_xContext
)
92 if ( !xComponent
.is() )
93 throw ServiceNotRegisteredException( _rServiceName
, NULL
);
97 //------------------------------------------------------------------------
98 Reference
< XMultiServiceFactory
> ComponentContext::getLegacyServiceFactory() const
100 return Reference
< XMultiServiceFactory
>( m_xORB
, UNO_QUERY_THROW
);
103 //........................................................................
105 //........................................................................