merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0305-cli_ure-source-bootstrap-managed_bootstrap-cs.diff
blob1b6e1d7d31e0197d2c6855c9038784f82e581a72
1 --- /dev/null
2 +++ cli_ure/source/bootstrap/managed_bootstrap.cs
3 @@ -0,0 +1,140 @@
4 +/*************************************************************************
5 + *
6 + * $RCSfile: $
7 + *
8 + * $Revision: $
9 + *
10 + * last change: $Author: $ $Date: $
11 + *
12 + * The Contents of this file are made available subject to the terms of
13 + * either of the following licenses
14 + *
15 + * - GNU Lesser General Public License Version 2.1
16 + * - Sun Industry Standards Source License Version 1.1
17 + *
18 + * Sun Microsystems Inc., October, 2000
19 + *
20 + * GNU Lesser General Public License Version 2.1
21 + * =============================================
22 + * Copyright 2000 by Sun Microsystems, Inc.
23 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
24 + *
25 + * This library is free software; you can redistribute it and/or
26 + * modify it under the terms of the GNU Lesser General Public
27 + * License version 2.1, as published by the Free Software Foundation.
28 + *
29 + * This library is distributed in the hope that it will be useful,
30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 + * Lesser General Public License for more details.
33 + *
34 + * You should have received a copy of the GNU Lesser General Public
35 + * License along with this library; if not, write to the Free Software
36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 + * MA 02111-1307 USA
38 + *
39 + *
40 + * Sun Industry Standards Source License Version 1.1
41 + * =================================================
42 + * The contents of this file are subject to the Sun Industry Standards
43 + * Source License Version 1.1 (the "License"); You may not use this file
44 + * except in compliance with the License. You may obtain a copy of the
45 + * License at http://www.openoffice.org/license.html.
46 + *
47 + * Software provided under this License is provided on an "AS IS" basis,
48 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
49 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
50 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
51 + * See the License for the specific provisions governing your rights and
52 + * obligations concerning the Software.
53 + *
54 + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
55 + *
56 + * Copyright: 2000 by Sun Microsystems, Inc.
57 + *
58 + * All Rights Reserved.
59 + *
60 + * Contributor(s): _______________________________________
61 + *
62 + *
63 + ************************************************************************/
65 +namespace uno.util
68 +using System;
69 +using System.Collections;
70 +using System.Runtime.InteropServices;
72 +public class Bootstrap
74 + private Bootstrap() {}
76 + public static unoidl.com.sun.star.uno.XComponentContext
77 + defaultBootstrap_InitialComponentContext()
78 + {
79 + return defaultBootstrap_InitialComponentContext(null, null);
80 + }
82 + public static unoidl.com.sun.star.uno.XComponentContext
83 + defaultBootstrap_InitialComponentContext(
84 + string iniFile,
85 + IDictionaryEnumerator bootstrapParameters)
86 + {
87 + if (bootstrapParameters != null)
88 + {
89 + bootstrapParameters.Reset();
90 + while (bootstrapParameters.MoveNext())
91 + {
92 + string key = (string)bootstrapParameters.Key;
93 + string value = (string)bootstrapParameters.Value;
95 + native_bootstrap_set(key, key.Length, value, value.Length);
96 + }
97 + }
99 + System.Console.WriteLine("Bootstrap with ini " + iniFile);
100 + // bootstrap native uno
101 + IntPtr context;
102 + if (iniFile == null)
104 + context = native_defaultBootstrap_InitialComponentContext();
106 + else
108 + context = native_defaultBootstrap_InitialComponentContext(iniFile, iniFile.Length);
111 + return (unoidl.com.sun.star.uno.XComponentContext)ExtractObject(context);
114 + public static unoidl.com.sun.star.uno.XComponentContext bootstrap()
116 + return (unoidl.com.sun.star.uno.XComponentContext)ExtractObject(native_bootstrap());
119 + static object ExtractObject(IntPtr managed)
121 + GCHandle handle = (GCHandle)managed;
122 + object ret = handle.Target;
123 + handle.Free();
124 + return ret;
127 + [DllImport("cli_uno_glue")]
128 + private static extern void native_bootstrap_set(
129 + [MarshalAs(UnmanagedType.LPWStr)] string key, int keyLength,
130 + [MarshalAs(UnmanagedType.LPWStr)] string value, int valueLength);
132 + [DllImport("cli_uno_glue", EntryPoint="native_defaultBootstrap_InitialComponentContext")]
133 + private static extern IntPtr native_defaultBootstrap_InitialComponentContext();
135 + [DllImport("cli_uno_glue", EntryPoint="native_defaultBootstrap_InitialComponentContext_iniFile")]
136 + private static extern IntPtr native_defaultBootstrap_InitialComponentContext(
137 + [MarshalAs(UnmanagedType.LPWStr)] string iniFile, int nameLength);
139 + [DllImport("cli_uno_glue")]
140 + private static extern IntPtr native_bootstrap();