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_BOOTSTRAP_HXX_
24 #define _CPPUHELPER_BOOTSTRAP_HXX_
25 
26 #include "sal/config.h"
27 #include "com/sun/star/uno/Exception.hpp"
28 #include "com/sun/star/uno/Reference.hxx"
29 #include "rtl/ustring.hxx"
30 #include "sal/types.h"
31 
32 namespace com { namespace sun { namespace star {
33     namespace container { class XHierarchicalNameAccess; }
34     namespace registry { class XSimpleRegistry; }
35     namespace uno { class XComponentContext; }
36 } } }
37 
38 namespace cppu
39 {
40 
41 /** Creates a simple registry service instance.
42 
43     @rBootstrapPath optional bootstrap path for initial components
44     @return simple registry service instance
45 */
46 ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry >
47 SAL_CALL createSimpleRegistry(
48 	const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() )
49     SAL_THROW( () );
50 
51 /** Creates a nested registry service instance.
52 
53     @rBootstrapPath optional bootstrap path for initial components
54     @return nested registry service instance
55 */
56 ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry >
57 SAL_CALL createNestedRegistry(
58 	const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() )
59     SAL_THROW( () );
60 
61 /** Installs type description manager instance, i.e. registers a callback at cppu core.
62 
63     @param xTDMgr manager instance
64     @return true, if successfully registered
65 */
66 sal_Bool SAL_CALL installTypeDescriptionManager(
67     ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess > const & xTDMgr )
68     SAL_THROW( () );
69 
70 /** Bootstraps an initial component context with service manager upon a given registry.
71     This includes insertion of initial services:
72       - (registry) service manager, shared lib loader,
73       - simple registry, nested registry,
74       - implementation registration
75       - registry typedescription provider, typedescription manager (also installs it into cppu core)
76 
77     @param xRegistry registry for service manager and singleton objects of context (may be null)
78     @param rBootstrapPath optional bootstrap path for initial components
79     @return component context
80 */
81 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
82 bootstrap_InitialComponentContext(
83     ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > const & xRegistry,
84     ::rtl::OUString const & rBootstrapPath = ::rtl::OUString() )
85 	SAL_THROW( (::com::sun::star::uno::Exception) );
86 
87 
88 /** Bootstraps an initial component context with service manager upon default types and
89     services registry.
90     This includes insertion of initial services:
91       - (registry) service manager, shared lib loader,
92       - simple registry, nested registry,
93       - implementation registration
94       - registry typedescription provider, typedescription manager (also installs it into cppu core)
95 
96     This function tries to find its parameters via these bootstrap variables:
97 
98       - UNO_TYPES         -- a space separated list of file urls of type rdbs
99       - UNO_SERVICES      -- a space separated list of file urls of service rdbs
100       - UNO_WRITERDB      -- a file url of a write rdb (e.g. user.rdb)
101 
102     Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html
103 	for further info.
104 
105     @return component context
106 */
107 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
108 defaultBootstrap_InitialComponentContext() SAL_THROW( (::com::sun::star::uno::Exception) );
109 
110 
111 /** Bootstraps an initial component context with service manager upon default types and
112     services registry.
113     This includes insertion of initial services:
114       - (registry) service manager, shared lib loader,
115       - simple registry, nested registry,
116       - implementation registration
117       - registry typedescription provider, typedescription manager (also installs it into cppu core)
118 
119     This function tries to find its parameters via these bootstrap variables:
120 
121       - UNO_TYPES         -- a space separated list of file urls of type rdbs
122       - UNO_SERVICES      -- a space separated list of file urls of service rdbs
123       - UNO_WRITERDB      -- a file url of a write rdb (e.g. user.rdb)
124 
125     Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html
126 	for further info.
127 
128     @param iniFile ini filename to get bootstrap variables
129     @return component context
130 */
131 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
132 defaultBootstrap_InitialComponentContext(const ::rtl::OUString & iniFile) SAL_THROW( (::com::sun::star::uno::Exception) );
133 
134 /**
135  * An exception indicating a bootstrap error.
136  *
137  * @since UDK 3.2.0
138  */
139 class BootstrapException
140 {
141 public:
142     /**
143      * Constructs a BootstrapException.
144      */
145     BootstrapException();
146 
147     /**
148      * Constructs a BootstrapException with the specified detail message.
149      *
150      * @param rMessage
151      * A message containing any details about the exception.
152      */
153     BootstrapException( const ::rtl::OUString & rMessage );
154 
155     /**
156      * Copy constructs a BootstrapException.
157      */
158     BootstrapException( const BootstrapException & e );
159 
160     /**
161      * Destructs a BootstrapException.
162      */
163     virtual ~BootstrapException();
164 
165     /**
166      * Assigns a BootstrapException.
167      */
168     BootstrapException & operator=( const BootstrapException & e );
169 
170     /** Gets the message.
171 
172         @return
173         A reference to the message. The reference is valid for the lifetime of
174         this BootstrapException.
175      */
176     const ::rtl::OUString & getMessage() const;
177 
178 private:
179     ::rtl::OUString m_aMessage;
180 };
181 
182 /**
183  * Bootstraps the component context from a UNO installation.
184  *
185  * @return a bootstrapped component context
186  * @exception BootstrapException
187  * Thrown in case bootstrap() signals an exception due to a
188  * bootstrap error.
189  *
190  * @since UDK 3.2.0
191  */
192 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
193 SAL_CALL bootstrap();
194 
195 /**
196  * Helper function to expand vnd.sun.star.expand URLs in contexts where no
197  * properly bootstrapped UNO is (yet) available.
198  *
199  * @internal
200  *
201  * @param uri
202  * Some URI (but not a URI reference).
203  *
204  * @return
205  * If uri is a vnd.sun.star.expand URL, then the expansion of that URL is
206  * returned; expansion may lead to a string that is not a legal URI. Otherwise,
207  * the uri is returned unchanged.
208  *
209  * @exception com::sun::star::lang::IllegalArgumentException
210  * If uri is a vnd.sun.star.expand URL that contains unknown macros.
211  *
212  * @since UDK 3.2.8
213  */
214 ::rtl::OUString
215 SAL_CALL bootstrap_expandUri(::rtl::OUString const & uri);
216 
217 } // end namespace cppu
218 
219 #endif
220