merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0306-cli_ure-source-bootstrap-native_glue-cxx.diff
blob6353db70c16b7621ce5adda40a0c09a30e82ea52
1 --- /dev/null
2 +++ cli_ure/source/bootstrap/native_glue.cxx
3 @@ -0,0 +1,148 @@
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 +#ifndef _RTL_USTRING_HXX_
66 +#include "rtl/ustring.hxx"
67 +#endif
68 +#ifndef _RTL_BOOTSTRAP_HXX_
69 +#include "rtl/bootstrap.hxx"
70 +#endif
71 +#ifndef _CPPUHELPER_BOOTSTRAP_HXX_
72 +#include "cppuhelper/bootstrap.hxx"
73 +#endif
74 +#ifndef _UNO_MAPPING_HXX_
75 +#include "uno/mapping.hxx"
76 +#endif
77 +extern "C" {
78 +#include "mono/metadata/object.h"
81 +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
83 +using namespace com::sun::star::uno;
85 +static void * to_cli( Reference< XInterface > const & context )
87 + Mapping mapping( OUSTR( CPPU_CURRENT_LANGUAGE_BINDING_NAME ), OUSTR( UNO_LB_CLI ) );
88 + OSL_ASSERT( mapping.is() );
89 + if (! mapping.is() )
90 + {
91 + // FIXME do something
92 + return 0;
93 + }
95 + return (void *)mono_gchandle_new( (MonoObject *)mapping.mapInterface( context.get(), ::getCppuType( &context ) ), sal_False );
98 +extern "C" {
100 +void SAL_CALL native_bootstrap_set( const sal_Unicode* pName, sal_Int32 nNameLength,
101 + const sal_Unicode* pValue, sal_Int32 nValueLength )
102 + SAL_THROW_EXTERN_C()
104 + ::rtl::OUString const name( pName, nNameLength );
105 + ::rtl::OUString const value( pValue, nValueLength );
107 + ::rtl::Bootstrap::set( name, value );
110 +void * SAL_CALL native_defaultBootstrap_InitialComponentContext()
111 + SAL_THROW_EXTERN_C()
113 + try {
114 + Reference< XComponentContext > xContext = ::cppu::defaultBootstrap_InitialComponentContext();
116 + return to_cli( xContext );
117 + } catch (const Exception &ex) {
118 + fprintf( stderr, "Exception bootstrapping '%s'\n",
119 + (const sal_Char *) rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_UTF8 ) );
120 + return NULL;
124 +void * SAL_CALL native_defaultBootstrap_InitialComponentContext_iniFile( const sal_Unicode *pIniFile, sal_Int32 nNameLength )
125 + SAL_THROW_EXTERN_C()
127 + ::rtl::OUString sFileName( pIniFile, nNameLength );
129 + try {
130 + Reference< XComponentContext > xContext = ::cppu::defaultBootstrap_InitialComponentContext( sFileName );
131 + if (!xContext.is())
132 + fprintf( stderr, "Bootstrap context is in fact NULL\n" );
134 + return to_cli( xContext );
135 + } catch (const Exception &ex) {
136 + rtl::OString aIni = rtl::OUStringToOString( sFileName, RTL_TEXTENCODING_UTF8 );
137 + fprintf( stderr, "Exception bootstrapping from ini '%s' (%d) '%s'\n", (const sal_Char *) aIni, nNameLength,
138 + (const sal_Char *) rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_UTF8 ) );
139 + return NULL;
143 +void * SAL_CALL native_bootstrap()
144 + SAL_THROW_EXTERN_C()
146 + Reference< XComponentContext > xContext = ::cppu::bootstrap();
148 + return to_cli( xContext );
151 +} // extern "C"