1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
22 #include <smart/com/sun/star/script/XInvocation.hxx>
24 #include <rtl/ustring.hxx>
25 #include <osl/diagnose.h>
26 #include <usr/services.hxx>
27 #include <vcl/svapp.hxx>
30 using ::rtl::StringToOUString
;
32 class MyApp
: public Application
44 XMultiServiceFactoryRef xSMgr
= createRegistryServiceManager();
45 registerUsrServices( xSMgr
);
46 setProcessServiceManager( xSMgr
);
48 XInterfaceRef x
= xSMgr
->createInstance( L
"com.sun.star.registry.ImplementationRegistration" );
49 XImplementationRegistrationRef
xReg( x
, USR_QUERY
);
51 ORealDynamicLoader::computeModuleName( "res", szBuf
, 1024 );
52 UString
aDllName( StringToOUString( szBuf
, CHARSET_SYSTEM
) );
53 xReg
->registerImplementation( L
"com.sun.star.loader.SharedLibrary", aDllName
, XSimpleRegistryRef() );
55 x
= xSMgr
->createInstance( L
"com.sun.star.resource.VclStringResourceLoader" );
56 XInvocationRef
xResLoader( x
, USR_QUERY
);
57 XIntrospectionAccessRef xIntrospection
= xResLoader
->getIntrospection();
58 UString
aFileName( L
"TestResource" );
60 aVal
.setString( aFileName
);
61 xResLoader
->setValue( L
"FileName", aVal
);
63 Sequence
< UsrAny
> Args( 1 );
64 Sequence
< INT16
> OutPos
;
65 Sequence
< UsrAny
> OutArgs
;
66 Args
.getArray()[0].setINT32( 1000 );
68 BOOL b
= xResLoader
->invoke( L
"hasString", Args
, OutPos
, OutArgs
).getBOOL();
69 OSL_ENSURE( b
, "hasString" );
71 UString aStr
= xResLoader
->invoke( L
"getString", Args
, OutPos
, OutArgs
).getString();
72 OSL_ENSURE( aStr
== L
"Hello", "getString" );
74 Args
.getArray()[0].setINT32( 1001 );
75 b
= xResLoader
->invoke( L
"hasString", Args
, OutPos
, OutArgs
).getBOOL();
76 OSL_ENSURE( !b
, "!hasString" );
78 xReg
->revokeImplementation( aDllName
, XSimpleRegistryRef() );
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */