1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_extensions.hxx" 30 31 #include <smart/com/sun/star/registry/XImplementationRegistration.hxx> 32 #include <smart/com/sun/star/script/XInvocation.hxx> 33 34 #include <rtl/ustring.hxx> 35 #include <vos/dynload.hxx> 36 #include <vos/diagnose.hxx> 37 #include <usr/services.hxx> 38 #include <vcl/svapp.hxx> 39 40 using namespace rtl; 41 using namespace vos; 42 using namespace usr; 43 44 class MyApp : public Application 45 { 46 public: 47 void Main(); 48 }; 49 50 MyApp aMyApp; 51 52 // ----------------------------------------------------------------------- 53 54 void MyApp::Main() 55 { 56 XMultiServiceFactoryRef xSMgr = createRegistryServiceManager(); 57 registerUsrServices( xSMgr ); 58 setProcessServiceManager( xSMgr ); 59 60 XInterfaceRef x = xSMgr->createInstance( L"com.sun.star.registry.ImplementationRegistration" ); 61 XImplementationRegistrationRef xReg( x, USR_QUERY ); 62 sal_Char szBuf[1024]; 63 ORealDynamicLoader::computeModuleName( "res", szBuf, 1024 ); 64 UString aDllName( StringToOUString( szBuf, CHARSET_SYSTEM ) ); 65 xReg->registerImplementation( L"com.sun.star.loader.SharedLibrary", aDllName, XSimpleRegistryRef() ); 66 67 x = xSMgr->createInstance( L"com.sun.star.resource.VclStringResourceLoader" ); 68 XInvocationRef xResLoader( x, USR_QUERY ); 69 XIntrospectionAccessRef xIntrospection = xResLoader->getIntrospection(); 70 UString aFileName( L"TestResource" ); 71 UsrAny aVal; 72 aVal.setString( aFileName ); 73 xResLoader->setValue( L"FileName", aVal ); 74 75 Sequence< UsrAny > Args( 1 ); 76 Sequence< INT16 > OutPos; 77 Sequence< UsrAny > OutArgs; 78 Args.getArray()[0].setINT32( 1000 ); 79 80 BOOL b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL(); 81 VOS_ENSHURE( b, "hasString" ); 82 83 UString aStr = xResLoader->invoke( L"getString", Args, OutPos, OutArgs ).getString(); 84 VOS_ENSHURE( aStr == L"Hello", "getString" ); 85 86 Args.getArray()[0].setINT32( 1001 ); 87 b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL(); 88 VOS_ENSHURE( !b, "!hasString" ); 89 90 xReg->revokeImplementation( aDllName, XSimpleRegistryRef() ); 91 } 92 93