1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _RTL_USTRING_HXX_
29 #include "rtl/ustring.hxx"
31 #ifndef _RTL_BOOTSTRAP_HXX_
32 #include "rtl/bootstrap.hxx"
34 #ifndef _CPPUHELPER_BOOTSTRAP_HXX_
35 #include "cppuhelper/bootstrap.hxx"
37 #ifndef _UNO_MAPPING_HXX_
38 #include "uno/mapping.hxx"
41 #include "mono/metadata/object.h"
44 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
46 using namespace com::sun::star::uno
;
48 static void * to_cli( Reference
< XInterface
> const & context
)
50 Mapping
mapping( OUSTR( CPPU_CURRENT_LANGUAGE_BINDING_NAME
), OUSTR( UNO_LB_CLI
) );
51 OSL_ASSERT( mapping
.is() );
58 return (void *)mono_gchandle_new( (MonoObject
*)mapping
.mapInterface( context
.get(), ::getCppuType( &context
) ), sal_False
);
63 void SAL_CALL
native_bootstrap_set( const sal_Unicode
* pName
, sal_Int32 nNameLength
,
64 const sal_Unicode
* pValue
, sal_Int32 nValueLength
)
67 ::rtl::OUString
const name( pName
, nNameLength
);
68 ::rtl::OUString
const value( pValue
, nValueLength
);
70 ::rtl::Bootstrap::set( name
, value
);
73 void * SAL_CALL
native_defaultBootstrap_InitialComponentContext()
77 Reference
< XComponentContext
> xContext
= ::cppu::defaultBootstrap_InitialComponentContext();
79 return to_cli( xContext
);
80 } catch (const Exception
&ex
) {
81 fprintf( stderr
, "Exception bootstrapping '%s'\n",
82 (const sal_Char
*) rtl::OUStringToOString( ex
.Message
, RTL_TEXTENCODING_UTF8
).getStr() );
87 void * SAL_CALL
native_defaultBootstrap_InitialComponentContext_iniFile( const sal_Unicode
*pIniFile
, sal_Int32 nNameLength
)
90 ::rtl::OUString
sFileName( pIniFile
, nNameLength
);
93 Reference
< XComponentContext
> xContext
= ::cppu::defaultBootstrap_InitialComponentContext( sFileName
);
95 fprintf( stderr
, "Bootstrap context is in fact NULL\n" );
97 return to_cli( xContext
);
98 } catch (const Exception
&ex
) {
99 rtl::OString aIni
= rtl::OUStringToOString( sFileName
, RTL_TEXTENCODING_UTF8
);
100 fprintf( stderr
, "Exception bootstrapping from ini '%s' (%d) '%s'\n", (const sal_Char
*) aIni
.getStr(), nNameLength
,
101 (const sal_Char
*) rtl::OUStringToOString( ex
.Message
, RTL_TEXTENCODING_UTF8
).getStr() );
106 void * SAL_CALL
native_bootstrap()
109 Reference
< XComponentContext
> xContext
= ::cppu::bootstrap();
111 return to_cli( xContext
);