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 ************************************************************************/
62 #ifndef _RTL_USTRING_HXX_
63 #include "rtl/ustring.hxx"
65 #ifndef _RTL_BOOTSTRAP_HXX_
66 #include "rtl/bootstrap.hxx"
68 #ifndef _CPPUHELPER_BOOTSTRAP_HXX_
69 #include "cppuhelper/bootstrap.hxx"
71 #ifndef _UNO_MAPPING_HXX_
72 #include "uno/mapping.hxx"
75 #include "mono/metadata/object.h"
78 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
80 using namespace com::sun::star::uno
;
82 static void * to_cli( Reference
< XInterface
> const & context
)
84 Mapping
mapping( OUSTR( CPPU_CURRENT_LANGUAGE_BINDING_NAME
), OUSTR( UNO_LB_CLI
) );
85 OSL_ASSERT( mapping
.is() );
92 return (void *)mono_gchandle_new( (MonoObject
*)mapping
.mapInterface( context
.get(), ::getCppuType( &context
) ), sal_False
);
97 void SAL_CALL
native_bootstrap_set( const sal_Unicode
* pName
, sal_Int32 nNameLength
,
98 const sal_Unicode
* pValue
, sal_Int32 nValueLength
)
101 ::rtl::OUString
const name( pName
, nNameLength
);
102 ::rtl::OUString
const value( pValue
, nValueLength
);
104 ::rtl::Bootstrap::set( name
, value
);
107 void * SAL_CALL
native_defaultBootstrap_InitialComponentContext()
111 Reference
< XComponentContext
> xContext
= ::cppu::defaultBootstrap_InitialComponentContext();
113 return to_cli( xContext
);
114 } catch (const Exception
&ex
) {
115 fprintf( stderr
, "Exception bootstrapping '%s'\n",
116 (const sal_Char
*) rtl::OUStringToOString( ex
.Message
, RTL_TEXTENCODING_UTF8
) );
121 void * SAL_CALL
native_defaultBootstrap_InitialComponentContext_iniFile( const sal_Unicode
*pIniFile
, sal_Int32 nNameLength
)
124 ::rtl::OUString
sFileName( pIniFile
, nNameLength
);
127 Reference
< XComponentContext
> xContext
= ::cppu::defaultBootstrap_InitialComponentContext( sFileName
);
129 fprintf( stderr
, "Bootstrap context is in fact NULL\n" );
131 return to_cli( xContext
);
132 } catch (const Exception
&ex
) {
133 rtl::OString aIni
= rtl::OUStringToOString( sFileName
, RTL_TEXTENCODING_UTF8
);
134 fprintf( stderr
, "Exception bootstrapping from ini '%s' (%d) '%s'\n", (const sal_Char
*) aIni
, nNameLength
,
135 (const sal_Char
*) rtl::OUStringToOString( ex
.Message
, RTL_TEXTENCODING_UTF8
) );
140 void * SAL_CALL
native_bootstrap()
143 Reference
< XComponentContext
> xContext
= ::cppu::bootstrap();
145 return to_cli( xContext
);