1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 #ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_
28 #define _CPPUHELPER_COMPONENT_CONTEXT_HXX_
29 
30 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
32 
33 
34 namespace cppu
35 {
36 
37 /** Context entries init struct calling createComponentContext().
38 */
39 struct ContextEntry_Init
40 {
41     /** late init denotes a object that will be raised when first get() is calling for it
42 
43         The context implementation expects either a ::com::sun::star::lang::XSingleComponentFactory
44         object as value (to instanciate the object) or a string as value for raising
45         a service via the used service manager.
46     */
47     bool bLateInitService;
48     /** name of context value
49     */
50     ::rtl::OUString name;
51     /** context value
52     */
53     ::com::sun::star::uno::Any value;
54 
55     /** Default ctor.
56     */
57     inline ContextEntry_Init() SAL_THROW( () )
58         : bLateInitService( false )
59         {}
60     /** Ctor.
61 
62         @param name_
63                name of entry
64         @param value_
65                value of entry
66         @param bLateInitService_
67                whether this entry is a late-init named object entry
68                (value is object factory or service string)
69     */
70     inline ContextEntry_Init(
71         ::rtl::OUString const & name_,
72         ::com::sun::star::uno::Any const & value_,
73         bool bLateInitService_ = false ) SAL_THROW( () )
74             : bLateInitService( bLateInitService_ ),
75               name( name_ ),
76               value( value_ )
77         {}
78 };
79 
80 /** Creates a component context with the given entries.
81 
82     @param pEntries array of entries
83     @param nEntries number of entries
84     @param xDelegate delegation to further context, if value was not found
85     @return new context object
86 */
87 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
88 SAL_CALL createComponentContext(
89     ContextEntry_Init const * pEntries, sal_Int32 nEntries,
90     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xDelegate =
91     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
92     SAL_THROW( () );
93 
94 }
95 
96 #endif
97