1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_
24 #define _CPPUHELPER_COMPONENT_CONTEXT_HXX_
25 
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
28 
29 #include "cppuhelper/cppuhelperdllapi.h"
30 
31 namespace cppu
32 {
33 
34 /** Context entries init struct calling createComponentContext().
35 */
36 struct ContextEntry_Init
37 {
38     /** late init denotes a object that will be raised when first get() is calling for it
39 
40         The context implementation expects either a ::com::sun::star::lang::XSingleComponentFactory
41         object as value (to instanciate the object) or a string as value for raising
42         a service via the used service manager.
43     */
44     bool bLateInitService;
45     /** name of context value
46     */
47     ::rtl::OUString name;
48     /** context value
49     */
50     ::com::sun::star::uno::Any value;
51 
52     /** Default ctor.
53     */
54     inline ContextEntry_Init() SAL_THROW( () )
55         : bLateInitService( false )
56         {}
57     /** Ctor.
58 
59         @param name_
60                name of entry
61         @param value_
62                value of entry
63         @param bLateInitService_
64                whether this entry is a late-init named object entry
65                (value is object factory or service string)
66     */
ContextEntry_Initcppu::ContextEntry_Init67     inline ContextEntry_Init(
68         ::rtl::OUString const & name_,
69         ::com::sun::star::uno::Any const & value_,
70         bool bLateInitService_ = false ) SAL_THROW( () )
71             : bLateInitService( bLateInitService_ ),
72               name( name_ ),
73               value( value_ )
74         {}
75 };
76 
77 /** Creates a component context with the given entries.
78 
79     @param pEntries array of entries
80     @param nEntries number of entries
81     @param xDelegate delegation to further context, if value was not found
82     @return new context object
83 */
84 CPPUHELPER_DLLPUBLIC
85 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
86 SAL_CALL createComponentContext(
87     ContextEntry_Init const * pEntries, sal_Int32 nEntries,
88     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xDelegate =
89     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() )
90     SAL_THROW( () );
91 
92 }
93 
94 #endif
95