File: | cppuhelper/source/servicefactory.cxx |
Location: | line 334, column 9 |
Description: | Called C++ object pointer is null |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /************************************************************************* | |||
3 | * | |||
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |||
5 | * | |||
6 | * Copyright 2000, 2010 Oracle and/or its affiliates. | |||
7 | * | |||
8 | * OpenOffice.org - a multi-platform office productivity suite | |||
9 | * | |||
10 | * This file is part of OpenOffice.org. | |||
11 | * | |||
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. | |||
15 | * | |||
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). | |||
21 | * | |||
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. | |||
26 | * | |||
27 | ************************************************************************/ | |||
28 | ||||
29 | ||||
30 | #include <vector> | |||
31 | ||||
32 | #include "rtl/string.hxx" | |||
33 | #include "rtl/bootstrap.hxx" | |||
34 | #include "rtl/strbuf.hxx" | |||
35 | #include "osl/diagnose.h" | |||
36 | #include "osl/file.h" | |||
37 | #include "osl/module.h" | |||
38 | #include "osl/process.h" | |||
39 | #include "cppuhelper/shlib.hxx" | |||
40 | #include "cppuhelper/factory.hxx" | |||
41 | #include "cppuhelper/component_context.hxx" | |||
42 | #include "cppuhelper/servicefactory.hxx" | |||
43 | #include "cppuhelper/bootstrap.hxx" | |||
44 | ||||
45 | #include "com/sun/star/uno/DeploymentException.hpp" | |||
46 | #include "com/sun/star/uno/XComponentContext.hpp" | |||
47 | #include "com/sun/star/lang/XInitialization.hpp" | |||
48 | #include <com/sun/star/lang/XServiceInfo.hpp> | |||
49 | #include "com/sun/star/lang/XSingleServiceFactory.hpp" | |||
50 | #include "com/sun/star/lang/XSingleComponentFactory.hpp" | |||
51 | #include "com/sun/star/beans/XPropertySet.hpp" | |||
52 | #include "com/sun/star/container/XSet.hpp" | |||
53 | #include "com/sun/star/container/XHierarchicalNameAccess.hpp" | |||
54 | #include "com/sun/star/registry/XSimpleRegistry.hpp" | |||
55 | #include "com/sun/star/registry/XImplementationRegistration.hpp" | |||
56 | #include "com/sun/star/security/XAccessController.hpp" | |||
57 | #if OSL_DEBUG_LEVEL1 > 1 | |||
58 | #include <stdio.h> | |||
59 | #endif | |||
60 | ||||
61 | #include "macro_expander.hxx" | |||
62 | #include "paths.hxx" | |||
63 | #include "servicefactory_detail.hxx" | |||
64 | ||||
65 | #define OUSTR(x)::rtl::OUString( (&(x)[0]), ((sal_Int32)((sizeof (x) / sizeof ((x)[0]))-1)), (((rtl_TextEncoding) 11)) ) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x)(&(x)[0]), ((sal_Int32)((sizeof (x) / sizeof ((x)[0]))-1) ), (((rtl_TextEncoding) 11)) ) | |||
66 | ||||
67 | ||||
68 | using namespace ::rtl; | |||
69 | using namespace ::osl; | |||
70 | using namespace ::com::sun::star; | |||
71 | using namespace ::com::sun::star::uno; | |||
72 | namespace css = com::sun::star; | |||
73 | ||||
74 | namespace cppu | |||
75 | { | |||
76 | ||||
77 | Reference< security::XAccessController > | |||
78 | createDefaultAccessController() SAL_THROW(()); | |||
79 | ||||
80 | static Reference< XInterface > SAL_CALL createInstance( | |||
81 | Reference< XInterface > const & xFactory, | |||
82 | Reference< XComponentContext > const & xContext = | |||
83 | Reference< XComponentContext >() ) | |||
84 | { | |||
85 | Reference< lang::XSingleComponentFactory > xFac( xFactory, UNO_QUERY ); | |||
86 | if (xFac.is()) | |||
87 | { | |||
88 | return xFac->createInstanceWithContext( xContext ); | |||
89 | } | |||
90 | else | |||
91 | { | |||
92 | Reference< lang::XSingleServiceFactory > xFac2( xFactory, UNO_QUERY ); | |||
93 | if (xFac2.is()) | |||
94 | { | |||
95 | OSL_ENSURE( !xContext.is(), "### ignoring context!" )do { if (true && (!(!xContext.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "95" ": "), "%s", "### ignoring context!"); } } while (false ); | |||
96 | return xFac2->createInstance(); | |||
97 | } | |||
98 | } | |||
99 | throw RuntimeException( | |||
100 | OUSTR("no factory object given!")::rtl::OUString( (&("no factory object given!")[0]), ((sal_Int32 )((sizeof ("no factory object given!") / sizeof (("no factory object given!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
101 | Reference< XInterface >() ); | |||
102 | } | |||
103 | ||||
104 | Reference< registry::XSimpleRegistry > SAL_CALL createSimpleRegistry( | |||
105 | OUString const & rBootstrapPath ) | |||
106 | SAL_THROW(()) | |||
107 | { | |||
108 | try | |||
109 | { | |||
110 | return Reference< registry::XSimpleRegistry >( | |||
111 | createInstance( | |||
112 | loadSharedLibComponentFactory( | |||
113 | OUSTR("bootstrap.uno" SAL_DLLEXTENSION)::rtl::OUString( (&("bootstrap.uno" ".so")[0]), ((sal_Int32 )((sizeof ("bootstrap.uno" ".so") / sizeof (("bootstrap.uno" ".so" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
114 | rBootstrapPath.isEmpty() | |||
115 | ? get_this_libpath() : rBootstrapPath, | |||
116 | OUSTR("com.sun.star.comp.stoc.SimpleRegistry")::rtl::OUString( (&("com.sun.star.comp.stoc.SimpleRegistry" )[0]), ((sal_Int32)((sizeof ("com.sun.star.comp.stoc.SimpleRegistry" ) / sizeof (("com.sun.star.comp.stoc.SimpleRegistry")[0]))-1) ), (((rtl_TextEncoding) 11)) ), | |||
117 | Reference< lang::XMultiServiceFactory >(), | |||
118 | Reference< registry::XRegistryKey >() ) ), | |||
119 | UNO_QUERY ); | |||
120 | } | |||
121 | catch (Exception & exc) | |||
122 | { | |||
123 | #if OSL_DEBUG_LEVEL1 > 0 | |||
124 | OString cstr_msg( | |||
125 | OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ) ); | |||
126 | OSL_ENSURE( !"### exception occurred:", cstr_msg.getStr() )do { if (true && (!(!"### exception occurred:"))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "126" ": "), "%s", cstr_msg.getStr()); } } while (false); | |||
127 | #else | |||
128 | (void) exc; // avoid warning about unused variable | |||
129 | #endif | |||
130 | } | |||
131 | ||||
132 | return Reference< registry::XSimpleRegistry >(); | |||
133 | } | |||
134 | ||||
135 | Reference< registry::XSimpleRegistry > SAL_CALL createNestedRegistry( | |||
136 | OUString const & rBootstrapPath ) | |||
137 | SAL_THROW(()) | |||
138 | { | |||
139 | try | |||
140 | { | |||
141 | return Reference< registry::XSimpleRegistry >( | |||
142 | createInstance( | |||
143 | loadSharedLibComponentFactory( | |||
144 | OUSTR("bootstrap.uno" SAL_DLLEXTENSION)::rtl::OUString( (&("bootstrap.uno" ".so")[0]), ((sal_Int32 )((sizeof ("bootstrap.uno" ".so") / sizeof (("bootstrap.uno" ".so" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
145 | rBootstrapPath.isEmpty() | |||
146 | ? get_this_libpath() : rBootstrapPath, | |||
147 | OUSTR("com.sun.star.comp.stoc.NestedRegistry")::rtl::OUString( (&("com.sun.star.comp.stoc.NestedRegistry" )[0]), ((sal_Int32)((sizeof ("com.sun.star.comp.stoc.NestedRegistry" ) / sizeof (("com.sun.star.comp.stoc.NestedRegistry")[0]))-1) ), (((rtl_TextEncoding) 11)) ), | |||
148 | Reference< lang::XMultiServiceFactory >(), | |||
149 | Reference< registry::XRegistryKey >() ) ), | |||
150 | UNO_QUERY ); | |||
151 | } | |||
152 | catch (Exception & exc) | |||
153 | { | |||
154 | #if OSL_DEBUG_LEVEL1 > 0 | |||
155 | OString cstr_msg( | |||
156 | OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ) ); | |||
157 | OSL_ENSURE( !"### exception occurred:", cstr_msg.getStr() )do { if (true && (!(!"### exception occurred:"))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "157" ": "), "%s", cstr_msg.getStr()); } } while (false); | |||
158 | #else | |||
159 | (void) exc; // avoid warning about unused variable | |||
160 | #endif | |||
161 | } | |||
162 | ||||
163 | return Reference< registry::XSimpleRegistry >(); | |||
164 | } | |||
165 | ||||
166 | ||||
167 | /** bootstrap variables: | |||
168 | ||||
169 | UNO_AC=<mode> [mandatory] | |||
170 | -- mode := { on, off, dynamic-only, single-user, single-default-user } | |||
171 | UNO_AC_SERVICE=<service_name> [optional] | |||
172 | -- override ac singleton service name | |||
173 | UNO_AC_SINGLEUSER=<user-id|nothing> [optional] | |||
174 | -- run with this user id or with default user policy (<nothing>) | |||
175 | set UNO_AC=single-[default-]user | |||
176 | UNO_AC_USERCACHE_SIZE=<cache_size> | |||
177 | -- number of user permission sets to be cached | |||
178 | ||||
179 | UNO_AC_POLICYSERVICE=<service_name> [optional] | |||
180 | -- override policy singleton service name | |||
181 | UNO_AC_POLICYFILE=<file_url> [optional] | |||
182 | -- read policy out of simple text file | |||
183 | */ | |||
184 | void add_access_control_entries( | |||
185 | ::std::vector< ContextEntry_Init > * values, | |||
186 | Bootstrap const & bootstrap ) | |||
187 | SAL_THROW( (Exception) ) | |||
188 | { | |||
189 | ContextEntry_Init entry; | |||
190 | ::std::vector< ContextEntry_Init > & context_values = *values; | |||
191 | ||||
192 | OUString ac_policy; | |||
193 | if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYSERVICE")::rtl::OUString( (&("UNO_AC_POLICYSERVICE")[0]), ((sal_Int32 )((sizeof ("UNO_AC_POLICYSERVICE") / sizeof (("UNO_AC_POLICYSERVICE" )[0]))-1)), (((rtl_TextEncoding) 11)) ), ac_policy )) | |||
194 | { | |||
195 | // overridden service name | |||
196 | // - policy singleton | |||
197 | entry.bLateInitService = true; | |||
198 | entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy")::rtl::OUString( (&("/singletons/com.sun.star.security.thePolicy" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.security.thePolicy" ) / sizeof (("/singletons/com.sun.star.security.thePolicy")[0 ]))-1)), (((rtl_TextEncoding) 11)) ); | |||
199 | entry.value <<= ac_policy; | |||
200 | context_values.push_back( entry ); | |||
201 | } | |||
202 | else if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYFILE")::rtl::OUString( (&("UNO_AC_POLICYFILE")[0]), ((sal_Int32 )((sizeof ("UNO_AC_POLICYFILE") / sizeof (("UNO_AC_POLICYFILE" )[0]))-1)), (((rtl_TextEncoding) 11)) ), ac_policy )) | |||
203 | { | |||
204 | // check for file policy | |||
205 | // - file policy prop: file-name | |||
206 | if (0 != ac_policy.compareToAscii( | |||
207 | RTL_CONSTASCII_STRINGPARAM("file:///")(&("file:///")[0]), ((sal_Int32)(sizeof ("file:///") / sizeof (("file:///")[0]))-1) )) | |||
208 | { | |||
209 | // no file url | |||
210 | OUString baseDir; | |||
211 | if ( ::osl_getProcessWorkingDir( &baseDir.pData ) | |||
212 | != osl_Process_E_None ) | |||
213 | { | |||
214 | OSL_ASSERT( false )do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "214" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); | |||
215 | } | |||
216 | OUString fileURL; | |||
217 | if ( ::osl_getAbsoluteFileURL( | |||
218 | baseDir.pData, ac_policy.pData, &fileURL.pData ) | |||
219 | != osl_File_E_None ) | |||
220 | { | |||
221 | OSL_ASSERT( false )do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "221" ": "), "OSL_ASSERT: %s", "false"); } } while (false ); | |||
222 | } | |||
223 | ac_policy = fileURL; | |||
224 | } | |||
225 | ||||
226 | entry.bLateInitService = false; | |||
227 | entry.name = | |||
228 | OUSTR("/implementations/com.sun.star.security.comp.stoc.FilePolicy/"::rtl::OUString( (&("/implementations/com.sun.star.security.comp.stoc.FilePolicy/" "file-name")[0]), ((sal_Int32)((sizeof ("/implementations/com.sun.star.security.comp.stoc.FilePolicy/" "file-name") / sizeof (("/implementations/com.sun.star.security.comp.stoc.FilePolicy/" "file-name")[0]))-1)), (((rtl_TextEncoding) 11)) ) | |||
229 | "file-name")::rtl::OUString( (&("/implementations/com.sun.star.security.comp.stoc.FilePolicy/" "file-name")[0]), ((sal_Int32)((sizeof ("/implementations/com.sun.star.security.comp.stoc.FilePolicy/" "file-name") / sizeof (("/implementations/com.sun.star.security.comp.stoc.FilePolicy/" "file-name")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
230 | entry.value <<= ac_policy; | |||
231 | context_values.push_back( entry ); | |||
232 | // - policy singleton | |||
233 | entry.bLateInitService = true; | |||
234 | entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy")::rtl::OUString( (&("/singletons/com.sun.star.security.thePolicy" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.security.thePolicy" ) / sizeof (("/singletons/com.sun.star.security.thePolicy")[0 ]))-1)), (((rtl_TextEncoding) 11)) ); | |||
235 | entry.value <<= OUSTR("com.sun.star.security.comp.stoc.FilePolicy")::rtl::OUString( (&("com.sun.star.security.comp.stoc.FilePolicy" )[0]), ((sal_Int32)((sizeof ("com.sun.star.security.comp.stoc.FilePolicy" ) / sizeof (("com.sun.star.security.comp.stoc.FilePolicy")[0] ))-1)), (((rtl_TextEncoding) 11)) ); | |||
236 | context_values.push_back( entry ); | |||
237 | } // else policy singleton comes from storage | |||
238 | ||||
239 | OUString ac_mode; | |||
240 | if (! bootstrap.getFrom( OUSTR("UNO_AC")::rtl::OUString( (&("UNO_AC")[0]), ((sal_Int32)((sizeof ( "UNO_AC") / sizeof (("UNO_AC")[0]))-1)), (((rtl_TextEncoding) 11)) ), ac_mode )) | |||
241 | { | |||
242 | ac_mode = OUSTR("off")::rtl::OUString( (&("off")[0]), ((sal_Int32)((sizeof ("off" ) / sizeof (("off")[0]))-1)), (((rtl_TextEncoding) 11)) ); // default | |||
243 | } | |||
244 | OUString ac_user; | |||
245 | if (bootstrap.getFrom( OUSTR("UNO_AC_SINGLEUSER")::rtl::OUString( (&("UNO_AC_SINGLEUSER")[0]), ((sal_Int32 )((sizeof ("UNO_AC_SINGLEUSER") / sizeof (("UNO_AC_SINGLEUSER" )[0]))-1)), (((rtl_TextEncoding) 11)) ), ac_user )) | |||
246 | { | |||
247 | // ac in single-user mode | |||
248 | if (!ac_user.isEmpty()) | |||
249 | { | |||
250 | // - ac prop: single-user-id | |||
251 | entry.bLateInitService = false; | |||
252 | entry.name = | |||
253 | OUSTR("/services/com.sun.star.security.AccessController/"::rtl::OUString( (&("/services/com.sun.star.security.AccessController/" "single-user-id")[0]), ((sal_Int32)((sizeof ("/services/com.sun.star.security.AccessController/" "single-user-id") / sizeof (("/services/com.sun.star.security.AccessController/" "single-user-id")[0]))-1)), (((rtl_TextEncoding) 11)) ) | |||
254 | "single-user-id")::rtl::OUString( (&("/services/com.sun.star.security.AccessController/" "single-user-id")[0]), ((sal_Int32)((sizeof ("/services/com.sun.star.security.AccessController/" "single-user-id") / sizeof (("/services/com.sun.star.security.AccessController/" "single-user-id")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
255 | entry.value <<= ac_user; | |||
256 | context_values.push_back( entry ); | |||
257 | if ( ac_mode != "single-user" ) | |||
258 | { | |||
259 | throw SecurityException( | |||
260 | OUSTR("set UNO_AC=single-user "::rtl::OUString( (&("set UNO_AC=single-user " "if you set UNO_AC_SINGLEUSER=<user-id>!" )[0]), ((sal_Int32)((sizeof ("set UNO_AC=single-user " "if you set UNO_AC_SINGLEUSER=<user-id>!" ) / sizeof (("set UNO_AC=single-user " "if you set UNO_AC_SINGLEUSER=<user-id>!" )[0]))-1)), (((rtl_TextEncoding) 11)) ) | |||
261 | "if you set UNO_AC_SINGLEUSER=<user-id>!")::rtl::OUString( (&("set UNO_AC=single-user " "if you set UNO_AC_SINGLEUSER=<user-id>!" )[0]), ((sal_Int32)((sizeof ("set UNO_AC=single-user " "if you set UNO_AC_SINGLEUSER=<user-id>!" ) / sizeof (("set UNO_AC=single-user " "if you set UNO_AC_SINGLEUSER=<user-id>!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
262 | Reference< XInterface >() ); | |||
263 | } | |||
264 | } | |||
265 | else | |||
266 | { | |||
267 | if ( ac_mode != "single-default-user" ) | |||
268 | { | |||
269 | throw SecurityException( | |||
270 | OUSTR("set UNO_AC=single-default-user "::rtl::OUString( (&("set UNO_AC=single-default-user " "if you set UNO_AC_SINGLEUSER=<nothing>!" )[0]), ((sal_Int32)((sizeof ("set UNO_AC=single-default-user " "if you set UNO_AC_SINGLEUSER=<nothing>!") / sizeof (( "set UNO_AC=single-default-user " "if you set UNO_AC_SINGLEUSER=<nothing>!" )[0]))-1)), (((rtl_TextEncoding) 11)) ) | |||
271 | "if you set UNO_AC_SINGLEUSER=<nothing>!")::rtl::OUString( (&("set UNO_AC=single-default-user " "if you set UNO_AC_SINGLEUSER=<nothing>!" )[0]), ((sal_Int32)((sizeof ("set UNO_AC=single-default-user " "if you set UNO_AC_SINGLEUSER=<nothing>!") / sizeof (( "set UNO_AC=single-default-user " "if you set UNO_AC_SINGLEUSER=<nothing>!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
272 | Reference< XInterface >() ); | |||
273 | } | |||
274 | } | |||
275 | } | |||
276 | ||||
277 | OUString ac_service; | |||
278 | if (! bootstrap.getFrom( OUSTR("UNO_AC_SERVICE")::rtl::OUString( (&("UNO_AC_SERVICE")[0]), ((sal_Int32)(( sizeof ("UNO_AC_SERVICE") / sizeof (("UNO_AC_SERVICE")[0]))-1 )), (((rtl_TextEncoding) 11)) ), ac_service )) | |||
279 | { | |||
280 | // override service name | |||
281 | ac_service = OUSTR("com.sun.star.security.AccessController")::rtl::OUString( (&("com.sun.star.security.AccessController" )[0]), ((sal_Int32)((sizeof ("com.sun.star.security.AccessController" ) / sizeof (("com.sun.star.security.AccessController")[0]))-1 )), (((rtl_TextEncoding) 11)) ); // default | |||
282 | // ac = OUSTR("com.sun.star.security.comp.stoc.AccessController"); | |||
283 | } | |||
284 | ||||
285 | // - ac prop: user-cache-size | |||
286 | OUString ac_cache; | |||
287 | if (bootstrap.getFrom( OUSTR("UNO_AC_USERCACHE_SIZE")::rtl::OUString( (&("UNO_AC_USERCACHE_SIZE")[0]), ((sal_Int32 )((sizeof ("UNO_AC_USERCACHE_SIZE") / sizeof (("UNO_AC_USERCACHE_SIZE" )[0]))-1)), (((rtl_TextEncoding) 11)) ), ac_cache )) | |||
288 | { | |||
289 | // ac cache size | |||
290 | sal_Int32 n = ac_cache.toInt32(); | |||
291 | if (0 < n) | |||
292 | { | |||
293 | entry.bLateInitService = false; | |||
294 | entry.name = | |||
295 | OUSTR("/services/com.sun.star.security.AccessController/"::rtl::OUString( (&("/services/com.sun.star.security.AccessController/" "user-cache-size")[0]), ((sal_Int32)((sizeof ("/services/com.sun.star.security.AccessController/" "user-cache-size") / sizeof (("/services/com.sun.star.security.AccessController/" "user-cache-size")[0]))-1)), (((rtl_TextEncoding) 11)) ) | |||
296 | "user-cache-size")::rtl::OUString( (&("/services/com.sun.star.security.AccessController/" "user-cache-size")[0]), ((sal_Int32)((sizeof ("/services/com.sun.star.security.AccessController/" "user-cache-size") / sizeof (("/services/com.sun.star.security.AccessController/" "user-cache-size")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
297 | entry.value <<= n; | |||
298 | context_values.push_back( entry ); | |||
299 | } | |||
300 | } | |||
301 | ||||
302 | // - ac prop: mode | |||
303 | // { "off", "on", "dynamic-only", "single-user", "single-default-user" } | |||
304 | entry.bLateInitService = false; | |||
305 | entry.name = OUSTR("/services/com.sun.star.security.AccessController/mode")::rtl::OUString( (&("/services/com.sun.star.security.AccessController/mode" )[0]), ((sal_Int32)((sizeof ("/services/com.sun.star.security.AccessController/mode" ) / sizeof (("/services/com.sun.star.security.AccessController/mode" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
306 | entry.value <<= ac_mode; | |||
307 | context_values.push_back( entry ); | |||
308 | // - ac singleton | |||
309 | entry.bLateInitService = true; | |||
310 | entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController")::rtl::OUString( (&("/singletons/com.sun.star.security.theAccessController" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.security.theAccessController" ) / sizeof (("/singletons/com.sun.star.security.theAccessController" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
311 | entry.value <<= ac_service; | |||
312 | context_values.push_back( entry ); | |||
313 | } | |||
314 | ||||
315 | namespace { | |||
316 | void addFactories( | |||
317 | char const * const * ppNames /* implname, ..., 0 */, | |||
318 | OUString const & bootstrapPath, | |||
319 | Reference< lang::XMultiComponentFactory > const & xMgr, | |||
320 | Reference< registry::XRegistryKey > const & xKey ) | |||
321 | SAL_THROW( (Exception) ) | |||
322 | { | |||
323 | Reference< container::XSet > xSet( xMgr, UNO_QUERY ); | |||
324 | OSL_ASSERT( xSet.is() )do { if (true && (!(xSet.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "324" ": "), "OSL_ASSERT: %s", "xSet.is()"); } } while ( false); | |||
325 | Reference< lang::XMultiServiceFactory > xSF( xMgr, UNO_QUERY ); | |||
326 | ||||
327 | while (*ppNames) | |||
328 | { | |||
329 | OUString implName( OUString::createFromAscii( *ppNames++ ) ); | |||
330 | ||||
331 | Any aFac( makeAny( loadSharedLibComponentFactory( | |||
332 | OUSTR("bootstrap.uno" SAL_DLLEXTENSION)::rtl::OUString( (&("bootstrap.uno" ".so")[0]), ((sal_Int32 )((sizeof ("bootstrap.uno" ".so") / sizeof (("bootstrap.uno" ".so" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
333 | bootstrapPath, implName, xSF, xKey ) ) ); | |||
334 | xSet->insert( aFac ); | |||
| ||||
335 | #if OSL_DEBUG_LEVEL1 > 1 | |||
336 | if (xSet->has( aFac )) | |||
337 | { | |||
338 | Reference< lang::XServiceInfo > xInfo; | |||
339 | if (aFac >>= xInfo) | |||
340 | { | |||
341 | ::fprintf( | |||
342 | stderr, "> implementation %s supports: ", ppNames[ -1 ] ); | |||
343 | Sequence< OUString > supported( | |||
344 | xInfo->getSupportedServiceNames() ); | |||
345 | for ( sal_Int32 nPos = supported.getLength(); nPos--; ) | |||
346 | { | |||
347 | OString str( OUStringToOString( | |||
348 | supported[ nPos ], RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ) ); | |||
349 | ::fprintf( stderr, nPos ? "%s, " : "%s\n", str.getStr() ); | |||
350 | } | |||
351 | } | |||
352 | else | |||
353 | { | |||
354 | ::fprintf( | |||
355 | stderr, | |||
356 | "> implementation %s provides NO lang::XServiceInfo!!!\n", | |||
357 | ppNames[ -1 ] ); | |||
358 | } | |||
359 | } | |||
360 | #endif | |||
361 | #if OSL_DEBUG_LEVEL1 > 0 | |||
362 | if (! xSet->has( aFac )) | |||
363 | { | |||
364 | OStringBuffer buf( 64 ); | |||
365 | buf.append( "### failed inserting shared lib \"" ); | |||
366 | buf.append( "bootstrap.uno" SAL_DLLEXTENSION".so" ); | |||
367 | buf.append( "\"!!!" ); | |||
368 | OString str( buf.makeStringAndClear() ); | |||
369 | OSL_FAIL( str.getStr() )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "369" ": "), "%s", str.getStr()); } } while (false); | |||
370 | } | |||
371 | #endif | |||
372 | } | |||
373 | } | |||
374 | ||||
375 | } // namespace | |||
376 | ||||
377 | Reference< lang::XMultiComponentFactory > bootstrapInitialSF( | |||
378 | OUString const & rBootstrapPath ) | |||
379 | SAL_THROW( (Exception) ) | |||
380 | { | |||
381 | OUString const & bootstrap_path = | |||
382 | rBootstrapPath.isEmpty() ? get_this_libpath() : rBootstrapPath; | |||
383 | ||||
384 | Reference< lang::XMultiComponentFactory > xMgr( | |||
385 | createInstance( | |||
386 | loadSharedLibComponentFactory( | |||
387 | OUSTR("bootstrap.uno" SAL_DLLEXTENSION)::rtl::OUString( (&("bootstrap.uno" ".so")[0]), ((sal_Int32 )((sizeof ("bootstrap.uno" ".so") / sizeof (("bootstrap.uno" ".so" )[0]))-1)), (((rtl_TextEncoding) 11)) ), bootstrap_path, | |||
388 | OUSTR("com.sun.star.comp.stoc.ORegistryServiceManager")::rtl::OUString( (&("com.sun.star.comp.stoc.ORegistryServiceManager" )[0]), ((sal_Int32)((sizeof ("com.sun.star.comp.stoc.ORegistryServiceManager" ) / sizeof (("com.sun.star.comp.stoc.ORegistryServiceManager" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
389 | Reference< lang::XMultiServiceFactory >(), | |||
390 | Reference< registry::XRegistryKey >() ) ), | |||
391 | UNO_QUERY ); | |||
392 | ||||
393 | // add initial bootstrap services | |||
394 | static char const * ar[] = { | |||
395 | "com.sun.star.comp.stoc.OServiceManagerWrapper", | |||
396 | "com.sun.star.comp.stoc.DLLComponentLoader", | |||
397 | "com.sun.star.comp.stoc.SimpleRegistry", | |||
398 | "com.sun.star.comp.stoc.NestedRegistry", | |||
399 | "com.sun.star.comp.stoc.TypeDescriptionManager", | |||
400 | "com.sun.star.comp.stoc.ImplementationRegistration", | |||
401 | "com.sun.star.security.comp.stoc.AccessController", | |||
402 | "com.sun.star.security.comp.stoc.FilePolicy", | |||
403 | 0 | |||
404 | }; | |||
405 | addFactories( | |||
406 | ar, bootstrap_path, | |||
407 | xMgr, Reference< registry::XRegistryKey >() ); | |||
408 | ||||
409 | return xMgr; | |||
410 | } | |||
411 | ||||
412 | // returns context with UNinitialized smgr | |||
413 | Reference< XComponentContext > bootstrapInitialContext( | |||
414 | Reference< lang::XMultiComponentFactory > const & xSF, | |||
415 | Reference< registry::XSimpleRegistry > const & types_xRegistry, | |||
416 | Reference< registry::XSimpleRegistry > const & services_xRegistry, | |||
417 | OUString const & rBootstrapPath, Bootstrap const & bootstrap ) | |||
418 | SAL_THROW( (Exception) ) | |||
419 | { | |||
420 | Reference< lang::XInitialization > xSFInit( xSF, UNO_QUERY ); | |||
421 | if (! xSFInit.is()) | |||
422 | { | |||
423 | throw RuntimeException( | |||
424 | OUSTR("servicemanager does not support XInitialization!")::rtl::OUString( (&("servicemanager does not support XInitialization!" )[0]), ((sal_Int32)((sizeof ("servicemanager does not support XInitialization!" ) / sizeof (("servicemanager does not support XInitialization!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
425 | Reference< XInterface >() ); | |||
426 | } | |||
427 | ||||
428 | // basic context values | |||
429 | ContextEntry_Init entry; | |||
430 | ::std::vector< ContextEntry_Init > context_values; | |||
431 | context_values.reserve( 14 ); | |||
432 | ||||
433 | // macro expander singleton for loader | |||
434 | entry.bLateInitService = true; | |||
435 | entry.name = OUSTR("/singletons/com.sun.star.util.theMacroExpander")::rtl::OUString( (&("/singletons/com.sun.star.util.theMacroExpander" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.util.theMacroExpander" ) / sizeof (("/singletons/com.sun.star.util.theMacroExpander" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
436 | entry.value | |||
437 | <<= cppuhelper::detail::create_bootstrap_macro_expander_factory(); | |||
438 | context_values.push_back( entry ); | |||
439 | ||||
440 | // tdmgr singleton | |||
441 | entry.bLateInitService = true; | |||
442 | entry.name = | |||
443 | OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager")::rtl::OUString( (&("/singletons/com.sun.star.reflection.theTypeDescriptionManager" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) / sizeof (("/singletons/com.sun.star.reflection.theTypeDescriptionManager" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
444 | entry.value <<= OUSTR("com.sun.star.comp.stoc.TypeDescriptionManager")::rtl::OUString( (&("com.sun.star.comp.stoc.TypeDescriptionManager" )[0]), ((sal_Int32)((sizeof ("com.sun.star.comp.stoc.TypeDescriptionManager" ) / sizeof (("com.sun.star.comp.stoc.TypeDescriptionManager") [0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
445 | context_values.push_back( entry ); | |||
446 | ||||
447 | // read out singleton infos from registry | |||
448 | if (services_xRegistry.is()) | |||
449 | { | |||
450 | Reference< registry::XRegistryKey > xKey( | |||
451 | services_xRegistry->getRootKey() ); | |||
452 | if (xKey.is()) | |||
453 | { | |||
454 | xKey = xKey->openKey( OUSTR("/SINGLETONS")::rtl::OUString( (&("/SINGLETONS")[0]), ((sal_Int32)((sizeof ("/SINGLETONS") / sizeof (("/SINGLETONS")[0]))-1)), (((rtl_TextEncoding ) 11)) ) ); | |||
455 | if (xKey.is()) | |||
456 | { | |||
457 | entry.bLateInitService = true; | |||
458 | ||||
459 | Sequence< Reference< registry::XRegistryKey > > keys( | |||
460 | xKey->openKeys() ); | |||
461 | Reference< registry::XRegistryKey > const * pKeys = | |||
462 | keys.getConstArray(); | |||
463 | for ( sal_Int32 nPos = keys.getLength(); nPos--; ) | |||
464 | { | |||
465 | css::uno::Sequence< rtl::OUString > impls( | |||
466 | css::uno::Reference< css::registry::XRegistryKey >( | |||
467 | pKeys[nPos]->openKey( | |||
468 | rtl::OUString( | |||
469 | RTL_CONSTASCII_USTRINGPARAM((&("REGISTERED_BY")[0]), ((sal_Int32)((sizeof ("REGISTERED_BY" ) / sizeof (("REGISTERED_BY")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
470 | "REGISTERED_BY")(&("REGISTERED_BY")[0]), ((sal_Int32)((sizeof ("REGISTERED_BY" ) / sizeof (("REGISTERED_BY")[0]))-1)), (((rtl_TextEncoding) 11 )))), | |||
471 | css::uno::UNO_SET_THROW)->getAsciiListValue()); | |||
472 | switch (impls.getLength()) { | |||
473 | case 0: | |||
474 | throw css::uno::DeploymentException( | |||
475 | (pKeys[nPos]->getKeyName() + | |||
476 | rtl::OUString( | |||
477 | RTL_CONSTASCII_USTRINGPARAM((&("/REGISTERED_BY is empty")[0]), ((sal_Int32)((sizeof ( "/REGISTERED_BY is empty") / sizeof (("/REGISTERED_BY is empty" )[0]))-1)), (((rtl_TextEncoding) 11)) | |||
478 | "/REGISTERED_BY is empty")(&("/REGISTERED_BY is empty")[0]), ((sal_Int32)((sizeof ( "/REGISTERED_BY is empty") / sizeof (("/REGISTERED_BY is empty" )[0]))-1)), (((rtl_TextEncoding) 11)))), | |||
479 | css::uno::Reference< css::uno::XInterface >()); | |||
480 | case 1: | |||
481 | break; | |||
482 | default: | |||
483 | OSL_TRACE(do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "490" ": "), ("arbitrarily chosing \"%s\" among multiple" " implementations for \"%s\""), rtl::OUStringToOString( impls [0], (((rtl_TextEncoding) 76))).getStr(), rtl::OUStringToOString ( pKeys[nPos]->getKeyName(), (((rtl_TextEncoding) 76))).getStr ()); } } while (false) | |||
484 | ("arbitrarily chosing \"%s\" among multiple"do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "490" ": "), ("arbitrarily chosing \"%s\" among multiple" " implementations for \"%s\""), rtl::OUStringToOString( impls [0], (((rtl_TextEncoding) 76))).getStr(), rtl::OUStringToOString ( pKeys[nPos]->getKeyName(), (((rtl_TextEncoding) 76))).getStr ()); } } while (false) | |||
485 | " implementations for \"%s\""),do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "490" ": "), ("arbitrarily chosing \"%s\" among multiple" " implementations for \"%s\""), rtl::OUStringToOString( impls [0], (((rtl_TextEncoding) 76))).getStr(), rtl::OUStringToOString ( pKeys[nPos]->getKeyName(), (((rtl_TextEncoding) 76))).getStr ()); } } while (false) | |||
486 | rtl::OUStringToOString(do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "490" ": "), ("arbitrarily chosing \"%s\" among multiple" " implementations for \"%s\""), rtl::OUStringToOString( impls [0], (((rtl_TextEncoding) 76))).getStr(), rtl::OUStringToOString ( pKeys[nPos]->getKeyName(), (((rtl_TextEncoding) 76))).getStr ()); } } while (false) | |||
487 | impls[0], RTL_TEXTENCODING_UTF8).getStr(),do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "490" ": "), ("arbitrarily chosing \"%s\" among multiple" " implementations for \"%s\""), rtl::OUStringToOString( impls [0], (((rtl_TextEncoding) 76))).getStr(), rtl::OUStringToOString ( pKeys[nPos]->getKeyName(), (((rtl_TextEncoding) 76))).getStr ()); } } while (false) | |||
488 | rtl::OUStringToOString(do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "490" ": "), ("arbitrarily chosing \"%s\" among multiple" " implementations for \"%s\""), rtl::OUStringToOString( impls [0], (((rtl_TextEncoding) 76))).getStr(), rtl::OUStringToOString ( pKeys[nPos]->getKeyName(), (((rtl_TextEncoding) 76))).getStr ()); } } while (false) | |||
489 | pKeys[nPos]->getKeyName(),do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "490" ": "), ("arbitrarily chosing \"%s\" among multiple" " implementations for \"%s\""), rtl::OUStringToOString( impls [0], (((rtl_TextEncoding) 76))).getStr(), rtl::OUStringToOString ( pKeys[nPos]->getKeyName(), (((rtl_TextEncoding) 76))).getStr ()); } } while (false) | |||
490 | RTL_TEXTENCODING_UTF8).getStr())do { if (true && (1 > 0)) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_INFO), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "490" ": "), ("arbitrarily chosing \"%s\" among multiple" " implementations for \"%s\""), rtl::OUStringToOString( impls [0], (((rtl_TextEncoding) 76))).getStr(), rtl::OUStringToOString ( pKeys[nPos]->getKeyName(), (((rtl_TextEncoding) 76))).getStr ()); } } while (false); | |||
491 | break; | |||
492 | } | |||
493 | context_values.push_back( | |||
494 | ContextEntry_Init( | |||
495 | (rtl::OUString( | |||
496 | RTL_CONSTASCII_USTRINGPARAM("/singletons/")(&("/singletons/")[0]), ((sal_Int32)((sizeof ("/singletons/" ) / sizeof (("/singletons/")[0]))-1)), (((rtl_TextEncoding) 11 ))) + | |||
497 | pKeys[nPos]->getKeyName().copy( | |||
498 | RTL_CONSTASCII_LENGTH("/SINGLETONS/")((sal_Int32)((sizeof ("/SINGLETONS/") / sizeof (("/SINGLETONS/" )[0]))-1)))), | |||
499 | css::uno::makeAny(impls[0]), | |||
500 | true)); | |||
501 | } | |||
502 | } | |||
503 | } | |||
504 | } | |||
505 | ||||
506 | // ac, policy: | |||
507 | add_access_control_entries( &context_values, bootstrap ); | |||
508 | ||||
509 | // smgr singleton | |||
510 | entry.bLateInitService = false; | |||
511 | entry.name = OUSTR("/singletons/com.sun.star.lang.theServiceManager")::rtl::OUString( (&("/singletons/com.sun.star.lang.theServiceManager" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.lang.theServiceManager" ) / sizeof (("/singletons/com.sun.star.lang.theServiceManager" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||
512 | entry.value <<= xSF; | |||
513 | context_values.push_back( entry ); | |||
514 | ||||
515 | Reference< XComponentContext > xContext( | |||
516 | createComponentContext( | |||
517 | &context_values[ 0 ], context_values.size(), | |||
518 | Reference< XComponentContext >() ) ); | |||
519 | // set default context | |||
520 | Reference< beans::XPropertySet > xProps( xSF, UNO_QUERY ); | |||
521 | OSL_ASSERT( xProps.is() )do { if (true && (!(xProps.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "521" ": "), "OSL_ASSERT: %s", "xProps.is()"); } } while (false); | |||
522 | if (xProps.is()) | |||
523 | { | |||
524 | xProps->setPropertyValue( | |||
525 | OUSTR("DefaultContext")::rtl::OUString( (&("DefaultContext")[0]), ((sal_Int32)(( sizeof ("DefaultContext") / sizeof (("DefaultContext")[0]))-1 )), (((rtl_TextEncoding) 11)) ), makeAny( xContext ) ); | |||
526 | } | |||
527 | ||||
528 | Reference< container::XHierarchicalNameAccess > xTDMgr; | |||
529 | ||||
530 | // get tdmgr singleton | |||
531 | if (xContext->getValueByName( | |||
532 | OUSTR("/singletons/"::rtl::OUString( (&("/singletons/" "com.sun.star.reflection.theTypeDescriptionManager" )[0]), ((sal_Int32)((sizeof ("/singletons/" "com.sun.star.reflection.theTypeDescriptionManager" ) / sizeof (("/singletons/" "com.sun.star.reflection.theTypeDescriptionManager" )[0]))-1)), (((rtl_TextEncoding) 11)) ) | |||
533 | "com.sun.star.reflection.theTypeDescriptionManager")::rtl::OUString( (&("/singletons/" "com.sun.star.reflection.theTypeDescriptionManager" )[0]), ((sal_Int32)((sizeof ("/singletons/" "com.sun.star.reflection.theTypeDescriptionManager" ) / sizeof (("/singletons/" "com.sun.star.reflection.theTypeDescriptionManager" )[0]))-1)), (((rtl_TextEncoding) 11)) ) ) | |||
534 | >>= xTDMgr) | |||
535 | { | |||
536 | if (types_xRegistry.is()) // insert rdb provider? | |||
537 | { | |||
538 | // add registry td provider factory to smgr and instance to tdmgr | |||
539 | Reference< lang::XSingleComponentFactory > xFac( | |||
540 | loadSharedLibComponentFactory( | |||
541 | OUSTR("bootstrap.uno" SAL_DLLEXTENSION)::rtl::OUString( (&("bootstrap.uno" ".so")[0]), ((sal_Int32 )((sizeof ("bootstrap.uno" ".so") / sizeof (("bootstrap.uno" ".so" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
542 | rBootstrapPath.isEmpty() | |||
543 | ? get_this_libpath() : rBootstrapPath, | |||
544 | OUSTR("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider")::rtl::OUString( (&("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider" )[0]), ((sal_Int32)((sizeof ("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider" ) / sizeof (("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
545 | Reference< lang::XMultiServiceFactory >( xSF, UNO_QUERY ), | |||
546 | Reference< registry::XRegistryKey >() ), UNO_QUERY ); | |||
547 | OSL_ASSERT( xFac.is() )do { if (true && (!(xFac.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "547" ": "), "OSL_ASSERT: %s", "xFac.is()"); } } while ( false); | |||
548 | ||||
549 | // smgr | |||
550 | Reference< container::XSet > xSet( xSF, UNO_QUERY ); | |||
551 | xSet->insert( makeAny( xFac ) ); | |||
552 | OSL_ENSURE(do { if (true && (!(xSet->has( makeAny( xFac ) ))) ) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "554" ": "), "%s", "### failed registering registry td provider at smgr!" ); } } while (false) | |||
553 | xSet->has( makeAny( xFac ) ),do { if (true && (!(xSet->has( makeAny( xFac ) ))) ) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "554" ": "), "%s", "### failed registering registry td provider at smgr!" ); } } while (false) | |||
554 | "### failed registering registry td provider at smgr!" )do { if (true && (!(xSet->has( makeAny( xFac ) ))) ) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "554" ": "), "%s", "### failed registering registry td provider at smgr!" ); } } while (false); | |||
555 | // tdmgr | |||
556 | xSet.set( xTDMgr, UNO_QUERY ); | |||
557 | OSL_ASSERT( xSet.is() )do { if (true && (!(xSet.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "557" ": "), "OSL_ASSERT: %s", "xSet.is()"); } } while ( false); | |||
558 | Any types_RDB( makeAny( types_xRegistry ) ); | |||
559 | Any rdbtdp( makeAny( xFac->createInstanceWithArgumentsAndContext( | |||
560 | Sequence< Any >( &types_RDB, 1 ), xContext ) ) ); | |||
561 | xSet->insert( rdbtdp ); | |||
562 | OSL_ENSURE(do { if (true && (!(xSet->has( rdbtdp )))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "564" ": "), "%s", "### failed inserting registry td provider to tdmgr!" ); } } while (false) | |||
563 | xSet->has( rdbtdp ),do { if (true && (!(xSet->has( rdbtdp )))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "564" ": "), "%s", "### failed inserting registry td provider to tdmgr!" ); } } while (false) | |||
564 | "### failed inserting registry td provider to tdmgr!" )do { if (true && (!(xSet->has( rdbtdp )))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "564" ": "), "%s", "### failed inserting registry td provider to tdmgr!" ); } } while (false); | |||
565 | } | |||
566 | // install callback | |||
567 | installTypeDescriptionManager( xTDMgr ); | |||
568 | } | |||
569 | ||||
570 | return xContext; | |||
571 | } | |||
572 | ||||
573 | static Reference< lang::XMultiComponentFactory > createImplServiceFactory( | |||
574 | const OUString & rWriteRegistry, | |||
575 | const OUString & rReadRegistry, | |||
576 | sal_Bool bReadOnly, | |||
577 | const OUString & rBootstrapPath ) | |||
578 | SAL_THROW( (Exception) ) | |||
579 | { | |||
580 | Reference< lang::XMultiComponentFactory > xSF( | |||
581 | bootstrapInitialSF( rBootstrapPath ) ); | |||
582 | ||||
583 | Reference< registry::XSimpleRegistry > xRegistry; | |||
584 | ||||
585 | // open a registry | |||
586 | sal_Bool bRegistryShouldBeValid = sal_False((sal_Bool)0); | |||
587 | if (!rWriteRegistry.isEmpty() && rReadRegistry.isEmpty()) | |||
588 | { | |||
589 | bRegistryShouldBeValid = sal_True((sal_Bool)1); | |||
590 | xRegistry.set( createSimpleRegistry( rBootstrapPath ) ); | |||
591 | if (xRegistry.is()) | |||
592 | { | |||
593 | if (bReadOnly) | |||
594 | { | |||
595 | xRegistry->open( rWriteRegistry, sal_True((sal_Bool)1), sal_False((sal_Bool)0) ); | |||
596 | } | |||
597 | else | |||
598 | { | |||
599 | xRegistry->open( rWriteRegistry, sal_False((sal_Bool)0), sal_True((sal_Bool)1) ); | |||
600 | } | |||
601 | } | |||
602 | } | |||
603 | else if (!rWriteRegistry.isEmpty() && !rReadRegistry.isEmpty()) | |||
604 | { | |||
605 | // default registry | |||
606 | bRegistryShouldBeValid = sal_True((sal_Bool)1); | |||
607 | xRegistry.set( createNestedRegistry( rBootstrapPath ) ); | |||
608 | ||||
609 | Reference< registry::XSimpleRegistry > xWriteReg( | |||
610 | createSimpleRegistry( rBootstrapPath ) ); | |||
611 | if (xWriteReg.is()) | |||
612 | { | |||
613 | if (bReadOnly) | |||
614 | { | |||
615 | try | |||
616 | { | |||
617 | xWriteReg->open( rWriteRegistry, sal_True((sal_Bool)1), sal_False((sal_Bool)0) ); | |||
618 | } | |||
619 | catch (registry::InvalidRegistryException &) | |||
620 | { | |||
621 | } | |||
622 | ||||
623 | if (! xWriteReg->isValid()) | |||
624 | { | |||
625 | throw RuntimeException( | |||
626 | OUSTR("specified first registry "::rtl::OUString( (&("specified first registry " "could not be open readonly!" )[0]), ((sal_Int32)((sizeof ("specified first registry " "could not be open readonly!" ) / sizeof (("specified first registry " "could not be open readonly!" )[0]))-1)), (((rtl_TextEncoding) 11)) ) | |||
627 | "could not be open readonly!")::rtl::OUString( (&("specified first registry " "could not be open readonly!" )[0]), ((sal_Int32)((sizeof ("specified first registry " "could not be open readonly!" ) / sizeof (("specified first registry " "could not be open readonly!" )[0]))-1)), (((rtl_TextEncoding) 11)) ), | |||
628 | Reference< XInterface >() ); | |||
629 | } | |||
630 | } | |||
631 | else | |||
632 | { | |||
633 | xWriteReg->open( rWriteRegistry, sal_False((sal_Bool)0), sal_True((sal_Bool)1) ); | |||
634 | } | |||
635 | } | |||
636 | ||||
637 | Reference< registry::XSimpleRegistry > xReadReg( | |||
638 | createSimpleRegistry( rBootstrapPath ) ); | |||
639 | if (xReadReg.is()) | |||
640 | { | |||
641 | xReadReg->open( rReadRegistry, sal_True((sal_Bool)1), sal_False((sal_Bool)0) ); | |||
642 | } | |||
643 | ||||
644 | Reference< lang::XInitialization > xInit( xRegistry, UNO_QUERY ); | |||
645 | Sequence< Any > aInitSeq( 2 ); | |||
646 | aInitSeq[ 0 ] <<= xWriteReg; | |||
647 | aInitSeq[ 1 ] <<= xReadReg; | |||
648 | xInit->initialize( aInitSeq ); | |||
649 | } | |||
650 | ||||
651 | if (bRegistryShouldBeValid && (!xRegistry.is() || !xRegistry->isValid())) | |||
652 | { | |||
653 | throw RuntimeException( | |||
654 | OUSTR("specified registry could not be initialized")::rtl::OUString( (&("specified registry could not be initialized" )[0]), ((sal_Int32)((sizeof ("specified registry could not be initialized" ) / sizeof (("specified registry could not be initialized")[0 ]))-1)), (((rtl_TextEncoding) 11)) ), | |||
655 | Reference< XInterface >() ); | |||
656 | } | |||
657 | ||||
658 | Bootstrap bootstrap; | |||
659 | Reference< XComponentContext > xContext( | |||
660 | bootstrapInitialContext( | |||
661 | xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) ); | |||
662 | ||||
663 | // initialize sf | |||
664 | Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); | |||
665 | OSL_ASSERT( xInit.is() )do { if (true && (!(xInit.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "665" ": "), "OSL_ASSERT: %s", "xInit.is()"); } } while ( false); | |||
666 | Sequence< Any > aSFInit( 1 ); | |||
667 | aSFInit[ 0 ] <<= xRegistry; | |||
668 | xInit->initialize( aSFInit ); | |||
669 | ||||
670 | return xSF; | |||
671 | } | |||
672 | ||||
673 | Reference< lang::XMultiServiceFactory > SAL_CALL createRegistryServiceFactory( | |||
674 | const OUString & rWriteRegistry, | |||
675 | const OUString & rReadRegistry, | |||
676 | sal_Bool bReadOnly, | |||
677 | const OUString & rBootstrapPath ) | |||
678 | SAL_THROW( (Exception) ) | |||
679 | { | |||
680 | return Reference< lang::XMultiServiceFactory >( createImplServiceFactory( | |||
681 | rWriteRegistry, rReadRegistry, bReadOnly, rBootstrapPath ), UNO_QUERY ); | |||
682 | } | |||
683 | ||||
684 | Reference< XComponentContext > SAL_CALL bootstrap_InitialComponentContext( | |||
685 | Reference< registry::XSimpleRegistry > const & xRegistry, | |||
686 | OUString const & rBootstrapPath ) | |||
687 | SAL_THROW( (Exception) ) | |||
688 | { | |||
689 | Bootstrap bootstrap; | |||
690 | ||||
691 | Reference< lang::XMultiComponentFactory > xSF( | |||
692 | bootstrapInitialSF( rBootstrapPath ) ); | |||
| ||||
693 | Reference< XComponentContext > xContext( | |||
694 | bootstrapInitialContext( | |||
695 | xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) ); | |||
696 | ||||
697 | // initialize sf | |||
698 | Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); | |||
699 | OSL_ASSERT( xInit.is() )do { if (true && (!(xInit.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/cppuhelper/source/servicefactory.cxx" ":" "699" ": "), "OSL_ASSERT: %s", "xInit.is()"); } } while ( false); | |||
700 | Sequence< Any > aSFInit( 2 ); | |||
701 | aSFInit[ 0 ] <<= xRegistry; | |||
702 | aSFInit[ 1 ] <<= xContext; // default context | |||
703 | xInit->initialize( aSFInit ); | |||
704 | ||||
705 | return xContext; | |||
706 | } | |||
707 | ||||
708 | } | |||
709 | ||||
710 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |