1 /*************************************************************************
7 * last change: $Author: $ $Date: $
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): _______________________________________
60 ************************************************************************/
66 using System
.Collections
;
67 using System
.Runtime
.InteropServices
;
69 public class Bootstrap
71 private Bootstrap() {}
73 public static unoidl
.com
.sun
.star
.uno
.XComponentContext
74 defaultBootstrap_InitialComponentContext()
76 return defaultBootstrap_InitialComponentContext(null, null);
79 public static unoidl
.com
.sun
.star
.uno
.XComponentContext
80 defaultBootstrap_InitialComponentContext(
82 IDictionaryEnumerator bootstrapParameters
)
84 if (bootstrapParameters
!= null)
86 bootstrapParameters
.Reset();
87 while (bootstrapParameters
.MoveNext())
89 string key
= (string)bootstrapParameters
.Key
;
90 string value = (string)bootstrapParameters
.Value
;
92 native_bootstrap_set(key
, key
.Length
, value, value.Length
);
96 System
.Console
.WriteLine("Bootstrap with ini " + iniFile
);
97 // bootstrap native uno
101 context
= native_defaultBootstrap_InitialComponentContext();
105 context
= native_defaultBootstrap_InitialComponentContext(iniFile
, iniFile
.Length
);
108 return (unoidl
.com
.sun
.star
.uno
.XComponentContext
)ExtractObject(context
);
111 public static unoidl
.com
.sun
.star
.uno
.XComponentContext
bootstrap()
113 return (unoidl
.com
.sun
.star
.uno
.XComponentContext
)ExtractObject(native_bootstrap());
116 static object ExtractObject(IntPtr managed
)
118 GCHandle handle
= (GCHandle
)managed
;
119 object ret
= handle
.Target
;
124 [DllImport("cli_uno_glue")]
125 private static extern void native_bootstrap_set(
126 [MarshalAs(UnmanagedType
.LPWStr
)] string key
, int keyLength
,
127 [MarshalAs(UnmanagedType
.LPWStr
)] string value, int valueLength
);
129 [DllImport("cli_uno_glue", EntryPoint
="native_defaultBootstrap_InitialComponentContext")]
130 private static extern IntPtr
native_defaultBootstrap_InitialComponentContext();
132 [DllImport("cli_uno_glue", EntryPoint
="native_defaultBootstrap_InitialComponentContext_iniFile")]
133 private static extern IntPtr
native_defaultBootstrap_InitialComponentContext(
134 [MarshalAs(UnmanagedType
.LPWStr
)] string iniFile
, int nameLength
);
136 [DllImport("cli_uno_glue")]
137 private static extern IntPtr
native_bootstrap();