1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
28cdf0e10cSrcweir #include <smart/com/sun/star/script/XInvocation.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <rtl/ustring.hxx>
31cdf0e10cSrcweir #include <vos/dynload.hxx>
32cdf0e10cSrcweir #include <vos/diagnose.hxx>
33cdf0e10cSrcweir #include <usr/services.hxx>
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using namespace rtl;
37cdf0e10cSrcweir using namespace vos;
38cdf0e10cSrcweir using namespace usr;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir class MyApp : public Application
41cdf0e10cSrcweir {
42cdf0e10cSrcweir public:
43cdf0e10cSrcweir 	void		Main();
44cdf0e10cSrcweir };
45cdf0e10cSrcweir 
46cdf0e10cSrcweir MyApp aMyApp;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // -----------------------------------------------------------------------
49cdf0e10cSrcweir 
Main()50cdf0e10cSrcweir void MyApp::Main()
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
53cdf0e10cSrcweir 	registerUsrServices( xSMgr );
54cdf0e10cSrcweir 	setProcessServiceManager( xSMgr );
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	XInterfaceRef x = xSMgr->createInstance( L"com.sun.star.registry.ImplementationRegistration" );
57cdf0e10cSrcweir 	XImplementationRegistrationRef xReg( x, USR_QUERY );
58cdf0e10cSrcweir 	sal_Char szBuf[1024];
59cdf0e10cSrcweir 	ORealDynamicLoader::computeModuleName( "res", szBuf, 1024 );
60cdf0e10cSrcweir 	UString aDllName( StringToOUString( szBuf, CHARSET_SYSTEM ) );
61cdf0e10cSrcweir 	xReg->registerImplementation( L"com.sun.star.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	x = xSMgr->createInstance( L"com.sun.star.resource.VclStringResourceLoader" );
64cdf0e10cSrcweir 	XInvocationRef xResLoader( x, USR_QUERY );
65cdf0e10cSrcweir 	XIntrospectionAccessRef xIntrospection = xResLoader->getIntrospection();
66cdf0e10cSrcweir 	UString aFileName( L"TestResource" );
67cdf0e10cSrcweir 	UsrAny aVal;
68cdf0e10cSrcweir 	aVal.setString( aFileName );
69cdf0e10cSrcweir 	xResLoader->setValue( L"FileName", aVal );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	Sequence< UsrAny > Args( 1 );
72cdf0e10cSrcweir 	Sequence< INT16 > OutPos;
73cdf0e10cSrcweir 	Sequence< UsrAny > OutArgs;
74cdf0e10cSrcweir 	Args.getArray()[0].setINT32( 1000 );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	BOOL b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL();
77cdf0e10cSrcweir 	VOS_ENSHURE( b, "hasString" );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	UString aStr = xResLoader->invoke( L"getString", Args, OutPos, OutArgs ).getString();
80cdf0e10cSrcweir 	VOS_ENSHURE( aStr == L"Hello", "getString" );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	Args.getArray()[0].setINT32( 1001 );
83cdf0e10cSrcweir 	b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL();
84cdf0e10cSrcweir 	VOS_ENSHURE( !b, "!hasString" );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	xReg->revokeImplementation( aDllName, XSimpleRegistryRef() );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89