1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testresource.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
34 #include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
35 #include <smart/com/sun/star/script/XInvocation.hxx>
37 #include <rtl/ustring.hxx>
38 #include <vos/dynload.hxx>
39 #include <vos/diagnose.hxx>
40 #include <usr/services.hxx>
41 #include <vcl/svapp.hxx>
47 class MyApp
: public Application
55 // -----------------------------------------------------------------------
59 XMultiServiceFactoryRef xSMgr
= createRegistryServiceManager();
60 registerUsrServices( xSMgr
);
61 setProcessServiceManager( xSMgr
);
63 XInterfaceRef x
= xSMgr
->createInstance( L
"com.sun.star.registry.ImplementationRegistration" );
64 XImplementationRegistrationRef
xReg( x
, USR_QUERY
);
66 ORealDynamicLoader::computeModuleName( "res", szBuf
, 1024 );
67 UString
aDllName( StringToOUString( szBuf
, CHARSET_SYSTEM
) );
68 xReg
->registerImplementation( L
"com.sun.star.loader.SharedLibrary", aDllName
, XSimpleRegistryRef() );
70 x
= xSMgr
->createInstance( L
"com.sun.star.resource.VclStringResourceLoader" );
71 XInvocationRef
xResLoader( x
, USR_QUERY
);
72 XIntrospectionAccessRef xIntrospection
= xResLoader
->getIntrospection();
73 UString
aFileName( L
"TestResource" );
75 aVal
.setString( aFileName
);
76 xResLoader
->setValue( L
"FileName", aVal
);
78 Sequence
< UsrAny
> Args( 1 );
79 Sequence
< INT16
> OutPos
;
80 Sequence
< UsrAny
> OutArgs
;
81 Args
.getArray()[0].setINT32( 1000 );
83 BOOL b
= xResLoader
->invoke( L
"hasString", Args
, OutPos
, OutArgs
).getBOOL();
84 VOS_ENSHURE( b
, "hasString" );
86 UString aStr
= xResLoader
->invoke( L
"getString", Args
, OutPos
, OutArgs
).getString();
87 VOS_ENSHURE( aStr
== L
"Hello", "getString" );
89 Args
.getArray()[0].setINT32( 1001 );
90 b
= xResLoader
->invoke( L
"hasString", Args
, OutPos
, OutArgs
).getBOOL();
91 VOS_ENSHURE( !b
, "!hasString" );
93 xReg
->revokeImplementation( aDllName
, XSimpleRegistryRef() );