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 10cdf0e10cSrcweir * 11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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 #include "res_services.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <vos/mutex.hxx> 29cdf0e10cSrcweir #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 30cdf0e10cSrcweir #include <cppuhelper/factory.hxx> // helper for factories 31cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> // helper for implementations 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 34cdf0e10cSrcweir #include <com/sun/star/script/XInvocation.hpp> 35cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp> 36cdf0e10cSrcweir #include <com/sun/star/reflection/InvocationTargetException.hpp> 37cdf0e10cSrcweir #include <com/sun/star/beans/XExactName.hpp> 38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 39cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <tools/resmgr.hxx> 42cdf0e10cSrcweir #include <tools/rcid.h> 43cdf0e10cSrcweir #include <tools/resary.hxx> 44cdf0e10cSrcweir #include <vcl/svapp.hxx> 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include <rtl/ustring.hxx> 47cdf0e10cSrcweir #include <rtl/strbuf.hxx> 48cdf0e10cSrcweir 49cdf0e10cSrcweir using namespace vos; 50cdf0e10cSrcweir using namespace rtl; 51cdf0e10cSrcweir using namespace com::sun::star::uno; 52cdf0e10cSrcweir using namespace com::sun::star::lang; 53cdf0e10cSrcweir using namespace com::sun::star::registry; 54cdf0e10cSrcweir using namespace com::sun::star::script; 55cdf0e10cSrcweir using namespace com::sun::star::beans; 56cdf0e10cSrcweir using namespace com::sun::star::reflection; 57cdf0e10cSrcweir 58cdf0e10cSrcweir //------------------------------------------------------------------------ 59cdf0e10cSrcweir //------------------------------------------------------------------------ 60cdf0e10cSrcweir //------------------------------------------------------------------------ 61cdf0e10cSrcweir class ResourceService : public cppu::WeakImplHelper3< XInvocation, XExactName, XServiceInfo > 62cdf0e10cSrcweir { 63cdf0e10cSrcweir public: 64cdf0e10cSrcweir ResourceService( const Reference< XMultiServiceFactory > & ); 65cdf0e10cSrcweir ~ResourceService(); 66cdf0e10cSrcweir 67cdf0e10cSrcweir // XServiceInfo 68cdf0e10cSrcweir OUString SAL_CALL getImplementationName() throw(); 69cdf0e10cSrcweir sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(); 70cdf0e10cSrcweir Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw(); 71cdf0e10cSrcweir 72cdf0e10cSrcweir static Sequence< OUString > getSupportedServiceNames_Static(void) throw(); 73cdf0e10cSrcweir static OUString getImplementationName_Static() throw() 74cdf0e10cSrcweir { 75cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.extensions.ResourceService")); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir // XExactName 80cdf0e10cSrcweir OUString SAL_CALL getExactName( const OUString & ApproximateName ) throw(RuntimeException); 81cdf0e10cSrcweir 82cdf0e10cSrcweir // XInvokation 83cdf0e10cSrcweir Reference< XIntrospectionAccess > SAL_CALL getIntrospection(void) throw(RuntimeException); 84cdf0e10cSrcweir Any SAL_CALL invoke(const OUString& FunctionName, const Sequence< Any >& Params, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam) throw(IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException); 85cdf0e10cSrcweir void SAL_CALL setValue(const OUString& PropertyName, const Any& Value) throw(UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException); 86cdf0e10cSrcweir Any SAL_CALL getValue(const OUString& PropertyName) throw(UnknownPropertyException, RuntimeException); 87cdf0e10cSrcweir sal_Bool SAL_CALL hasMethod(const OUString& Name) throw(RuntimeException); 88cdf0e10cSrcweir sal_Bool SAL_CALL hasProperty(const OUString& Name) throw(RuntimeException); 89cdf0e10cSrcweir private: 90cdf0e10cSrcweir Reference< XTypeConverter > getTypeConverter() const; 91cdf0e10cSrcweir Reference< XInvocation > getDefaultInvocation() const; 92cdf0e10cSrcweir 93cdf0e10cSrcweir Reference< XMultiServiceFactory > xSMgr; 94cdf0e10cSrcweir Reference< XInvocation > xDefaultInvocation; 95cdf0e10cSrcweir Reference< XTypeConverter > xTypeConverter; 96cdf0e10cSrcweir OUString aFileName; 97cdf0e10cSrcweir ResMgr * pResMgr; 98cdf0e10cSrcweir }; 99cdf0e10cSrcweir 100cdf0e10cSrcweir 101cdf0e10cSrcweir //----------------------------------------------------------------------------- 102cdf0e10cSrcweir ResourceService::ResourceService( const Reference< XMultiServiceFactory > & rSMgr ) 103cdf0e10cSrcweir : xSMgr( rSMgr ) 104cdf0e10cSrcweir , pResMgr( NULL ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir //----------------------------------------------------------------------------- 109cdf0e10cSrcweir Reference< XInterface > ResourceService::Create( const Reference< XComponentContext >& _rxContext ) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory( _rxContext->getServiceManager(), UNO_QUERY_THROW ); 112cdf0e10cSrcweir return *( new ResourceService( xFactory ) ); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir //----------------------------------------------------------------------------- 116cdf0e10cSrcweir ResourceService::~ResourceService() 117cdf0e10cSrcweir { 118cdf0e10cSrcweir delete pResMgr; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir // XServiceInfo 122cdf0e10cSrcweir OUString ResourceService::getImplementationName() throw() 123cdf0e10cSrcweir { 124cdf0e10cSrcweir return getImplementationName_Static(); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir // XServiceInfo 128cdf0e10cSrcweir sal_Bool SAL_CALL ResourceService::supportsService(const OUString& ServiceName) throw() 129cdf0e10cSrcweir { 130cdf0e10cSrcweir Sequence< OUString > aSNL = getSupportedServiceNames(); 131cdf0e10cSrcweir const OUString * pArray = aSNL.getConstArray(); 132cdf0e10cSrcweir for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) 133cdf0e10cSrcweir if( pArray[i] == ServiceName ) 134cdf0e10cSrcweir return sal_True; 135cdf0e10cSrcweir return sal_False; 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir // XServiceInfo 139cdf0e10cSrcweir Sequence< OUString > SAL_CALL ResourceService::getSupportedServiceNames(void) throw() 140cdf0e10cSrcweir { 141cdf0e10cSrcweir return getSupportedServiceNames_Static(); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir // ResourceService 145cdf0e10cSrcweir Sequence< OUString > ResourceService::getSupportedServiceNames_Static(void) throw() 146cdf0e10cSrcweir { 147cdf0e10cSrcweir Sequence< OUString > aSNS( 1 ); 148cdf0e10cSrcweir aSNS.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.resource.VclStringResourceLoader")); 149cdf0e10cSrcweir return aSNS; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir // ResourceService 153cdf0e10cSrcweir Reference< XTypeConverter > ResourceService::getTypeConverter() const 154cdf0e10cSrcweir { 155cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 156cdf0e10cSrcweir if( xSMgr.is() ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir Reference< XTypeConverter > xConv( xSMgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter" ))), UNO_QUERY ); 159cdf0e10cSrcweir ((ResourceService*)this)->xTypeConverter = xConv; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir return xTypeConverter; 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir // ResourceService 165cdf0e10cSrcweir Reference< XInvocation > ResourceService::getDefaultInvocation() const 166cdf0e10cSrcweir { 167cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 168cdf0e10cSrcweir /* f�hrt zur Zeit noch zu einer rekursion 169cdf0e10cSrcweir if( xSMgr.is() ) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir Reference< XSingleServiceFactory > xFact( xSMgr->createInstance( OUString::createFromAscii("com.sun.star.script.Invocation") ), UNO_QUERY ); 172cdf0e10cSrcweir if( xFact.is() ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir Sequence< Any > aArgs( 1 ); 175cdf0e10cSrcweir Reference< XInterface > xThis( *this ); 176cdf0e10cSrcweir aArgs.getArray()[0].set( &xThis, XInterface_Reference< get >lection() ); 177cdf0e10cSrcweir Reference< XInvokation > xI( xFact->createInstanceWithArguments( aArgs ), UNO_QUERY ); 178cdf0e10cSrcweir ((ResourceService*)this)->xDefaultInvocation = xI; 179cdf0e10cSrcweir } 180cdf0e10cSrcweir } 181cdf0e10cSrcweir */ 182cdf0e10cSrcweir return xDefaultInvocation; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir // XExactName 186cdf0e10cSrcweir OUString SAL_CALL ResourceService::getExactName( const OUString & ApproximateName ) throw(RuntimeException) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir OUString aName( ApproximateName ); 189cdf0e10cSrcweir aName = aName.toAsciiLowerCase(); 190cdf0e10cSrcweir if( aName.equalsAscii("filename") ) 191cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("FileName")); 192cdf0e10cSrcweir else if( aName.equalsAscii("getstring" )) 193cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("getString")); 194cdf0e10cSrcweir else if( aName.equalsAscii("getstrings" )) 195cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("getStrings")); 196cdf0e10cSrcweir else if( aName.equalsAscii("hasstring") ) 197cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("hasString")); 198cdf0e10cSrcweir else if( aName.equalsAscii("hasstrings") ) 199cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("hasStrings")); 200cdf0e10cSrcweir else if( aName.equalsAscii("getstringlist") ) 201cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("getStringList")); 202cdf0e10cSrcweir else if( aName.equalsAscii("hasStringList") ) 203cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("hasStringList")); 204cdf0e10cSrcweir Reference< XExactName > xEN( getDefaultInvocation(), UNO_QUERY ); 205cdf0e10cSrcweir if( xEN.is() ) 206cdf0e10cSrcweir return xEN->getExactName( ApproximateName ); 207cdf0e10cSrcweir return OUString(); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir // XInvokation 211cdf0e10cSrcweir Reference< XIntrospectionAccess > SAL_CALL ResourceService::getIntrospection(void) 212cdf0e10cSrcweir throw(RuntimeException) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir Reference< XInvocation > xI = getDefaultInvocation(); 215cdf0e10cSrcweir if( xI.is() ) 216cdf0e10cSrcweir return xI->getIntrospection(); 217cdf0e10cSrcweir return Reference< XIntrospectionAccess >(); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir 220cdf0e10cSrcweir // XInvokation 221cdf0e10cSrcweir Any SAL_CALL ResourceService::invoke 222cdf0e10cSrcweir ( 223cdf0e10cSrcweir const OUString& FunctionName, 224cdf0e10cSrcweir const Sequence< Any >& Params, 225cdf0e10cSrcweir Sequence< sal_Int16 >& OutParamIndex, 226cdf0e10cSrcweir Sequence< Any >& OutParam 227cdf0e10cSrcweir ) 228cdf0e10cSrcweir throw(IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir Any aRet; 231cdf0e10cSrcweir if( FunctionName.equalsAscii("getString") 232cdf0e10cSrcweir || FunctionName.equalsAscii("getStrings" ) 233cdf0e10cSrcweir || FunctionName.equalsAscii("hasString" ) 234cdf0e10cSrcweir || FunctionName.equalsAscii("hasStrings" ) 235cdf0e10cSrcweir ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir sal_Int32 nElements = Params.getLength(); 238cdf0e10cSrcweir if( nElements < 1 ) 239cdf0e10cSrcweir throw IllegalArgumentException(); 240cdf0e10cSrcweir if( nElements > 1 && (FunctionName.equalsAscii("getString") || FunctionName.equalsAscii("hasString") ) ) 241cdf0e10cSrcweir throw IllegalArgumentException(); 242cdf0e10cSrcweir if( !pResMgr ) 243cdf0e10cSrcweir throw IllegalArgumentException(); 244cdf0e10cSrcweir 245cdf0e10cSrcweir Sequence< OUString > aStrings( Params.getLength() ); 246cdf0e10cSrcweir Sequence< sal_Bool > aBools( Params.getLength() ); 247cdf0e10cSrcweir const Any* pIn = Params.getConstArray(); 248cdf0e10cSrcweir OUString* pOutString = aStrings.getArray(); 249cdf0e10cSrcweir sal_Bool* pOutBool = aBools.getArray(); 250cdf0e10cSrcweir 251cdf0e10cSrcweir Reference< XTypeConverter > xC = getTypeConverter(); 252cdf0e10cSrcweir bool bGetBranch = FunctionName.equalsAscii( "getString" ) || FunctionName.equalsAscii( "getStrings" ); 253cdf0e10cSrcweir 254cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 255cdf0e10cSrcweir for( sal_Int32 n = 0; n < nElements; n++ ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir sal_Int32 nId = 0; 258cdf0e10cSrcweir if( !(pIn[n] >>= nId) ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir if( xC.is() ) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir xC->convertToSimpleType( pIn[n], TypeClass_LONG ) >>= nId; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir else 265cdf0e10cSrcweir throw CannotConvertException(); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir if( nId > 0xFFFF || nId < 0 ) 268cdf0e10cSrcweir throw IllegalArgumentException(); 269cdf0e10cSrcweir 270cdf0e10cSrcweir if( bGetBranch ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir ResId aId( (sal_uInt16)nId, *pResMgr ); 273cdf0e10cSrcweir aId.SetRT( RSC_STRING ); 274cdf0e10cSrcweir if( pResMgr->IsAvailable( aId ) ) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir String aStr( aId ); 277cdf0e10cSrcweir pOutString[n] = aStr; 278cdf0e10cSrcweir } 279cdf0e10cSrcweir else 280cdf0e10cSrcweir throw IllegalArgumentException(); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir else // hasString(s) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir sal_Bool bRet = sal_False; 285cdf0e10cSrcweir if( pResMgr ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir ResId aId( (sal_uInt16)nId, *pResMgr ); 288cdf0e10cSrcweir aId.SetRT( RSC_STRING ); 289cdf0e10cSrcweir bRet = pResMgr->IsAvailable( aId ); 290cdf0e10cSrcweir } 291cdf0e10cSrcweir pOutBool[n] = bRet; 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir if( FunctionName.equalsAscii("getString") ) 295cdf0e10cSrcweir aRet <<= pOutString[0]; 296cdf0e10cSrcweir else if( FunctionName.equalsAscii("getStrings" ) ) 297cdf0e10cSrcweir aRet <<= aStrings; 298cdf0e10cSrcweir else if( FunctionName.equalsAscii("hasString" ) ) 299cdf0e10cSrcweir aRet <<= pOutBool[0]; 300cdf0e10cSrcweir else 301cdf0e10cSrcweir aRet <<= aBools; 302cdf0e10cSrcweir } 303cdf0e10cSrcweir else if( FunctionName.equalsAscii("getStringList") || FunctionName.equalsAscii("hasStringList" ) ) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir if( Params.getLength() != 1 ) 306cdf0e10cSrcweir throw IllegalArgumentException(); 307cdf0e10cSrcweir Reference< XTypeConverter > xC = getTypeConverter(); 308cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 309cdf0e10cSrcweir 310cdf0e10cSrcweir sal_Int32 nId = 0; 311cdf0e10cSrcweir if( !(Params.getConstArray()[0] >>= nId) ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir if( xC.is() ) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir xC->convertToSimpleType( Params.getConstArray()[0], TypeClass_LONG ) >>= nId; 316cdf0e10cSrcweir } 317cdf0e10cSrcweir else 318cdf0e10cSrcweir throw CannotConvertException(); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir if( FunctionName.equalsAscii("getStringList") ) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir ResId aId( (sal_uInt16)nId, *pResMgr ); 324cdf0e10cSrcweir aId.SetRT( RSC_STRINGARRAY ); 325cdf0e10cSrcweir if( pResMgr->IsAvailable( aId ) ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir ResStringArray aStr( aId ); 328cdf0e10cSrcweir int nEntries = aStr.Count(); 329cdf0e10cSrcweir Sequence< PropertyValue > aPropSeq( nEntries ); 330cdf0e10cSrcweir PropertyValue* pOut = aPropSeq.getArray(); 331cdf0e10cSrcweir for( int i = 0; i < nEntries; i++ ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir pOut[i].Name = aStr.GetString( i ); 334cdf0e10cSrcweir pOut[i].Handle = -1; 335cdf0e10cSrcweir pOut[i].Value <<= aStr.GetValue( i ); 336cdf0e10cSrcweir pOut[i].State = PropertyState_DIRECT_VALUE; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir aRet <<= aPropSeq; 339cdf0e10cSrcweir } 340cdf0e10cSrcweir else 341cdf0e10cSrcweir throw IllegalArgumentException(); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir else // hasStringList 344cdf0e10cSrcweir { 345cdf0e10cSrcweir sal_Bool bRet = sal_False; 346cdf0e10cSrcweir if( pResMgr ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir ResId aId( (sal_uInt16)nId, *pResMgr ); 349cdf0e10cSrcweir aId.SetRT( RSC_STRINGARRAY ); 350cdf0e10cSrcweir bRet = pResMgr->IsAvailable( aId ); 351cdf0e10cSrcweir } 352cdf0e10cSrcweir aRet <<= bRet; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir } 355cdf0e10cSrcweir else 356cdf0e10cSrcweir { 357cdf0e10cSrcweir Reference< XInvocation > xI = getDefaultInvocation(); 358cdf0e10cSrcweir if( xI.is() ) 359cdf0e10cSrcweir return xI->invoke( FunctionName, Params, OutParamIndex, OutParam ); 360cdf0e10cSrcweir else 361cdf0e10cSrcweir throw IllegalArgumentException(); 362cdf0e10cSrcweir } 363cdf0e10cSrcweir return aRet; 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir // XInvokation 367cdf0e10cSrcweir void SAL_CALL ResourceService::setValue(const OUString& PropertyName, const Any& Value) 368cdf0e10cSrcweir throw(UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir if( PropertyName.equalsAscii("FileName") ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir OUString aName; 373cdf0e10cSrcweir if( !(Value >>= aName) ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir Reference< XTypeConverter > xC = getTypeConverter(); 376cdf0e10cSrcweir if( xC.is() ) 377cdf0e10cSrcweir xC->convertToSimpleType( Value, TypeClass_STRING ) >>= aName; 378cdf0e10cSrcweir else 379cdf0e10cSrcweir throw CannotConvertException(); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 383cdf0e10cSrcweir OStringBuffer aBuf( aName.getLength()+8 ); 384cdf0e10cSrcweir aBuf.append( OUStringToOString( aName, osl_getThreadTextEncoding() ) ); 385cdf0e10cSrcweir ResMgr * pRM = ResMgr::CreateResMgr( aBuf.getStr() ); 386cdf0e10cSrcweir if( !pRM ) 387cdf0e10cSrcweir throw InvocationTargetException(); 388cdf0e10cSrcweir if( pResMgr ) 389cdf0e10cSrcweir delete pResMgr; 390cdf0e10cSrcweir pResMgr = pRM; 391cdf0e10cSrcweir aFileName = OStringToOUString( aBuf.makeStringAndClear(), osl_getThreadTextEncoding() ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir else 394cdf0e10cSrcweir { 395cdf0e10cSrcweir Reference< XInvocation > xI = getDefaultInvocation(); 396cdf0e10cSrcweir if( xI.is() ) 397cdf0e10cSrcweir xI->setValue( PropertyName, Value ); 398cdf0e10cSrcweir else 399cdf0e10cSrcweir throw UnknownPropertyException(); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir // XInvokation 404cdf0e10cSrcweir Any SAL_CALL ResourceService::getValue(const OUString& PropertyName) 405cdf0e10cSrcweir throw(UnknownPropertyException, RuntimeException) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 408cdf0e10cSrcweir if( PropertyName.equalsAscii("FileName" )) 409cdf0e10cSrcweir return makeAny( aFileName ); 410cdf0e10cSrcweir 411cdf0e10cSrcweir Reference< XInvocation > xI = getDefaultInvocation(); 412cdf0e10cSrcweir if( xI.is() ) 413cdf0e10cSrcweir return xI->getValue( PropertyName ); 414cdf0e10cSrcweir 415cdf0e10cSrcweir throw UnknownPropertyException(); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir // XInvokation 419cdf0e10cSrcweir sal_Bool SAL_CALL ResourceService::hasMethod(const OUString& Name) 420cdf0e10cSrcweir throw(RuntimeException) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir if( Name.equalsAscii("getString") || 423cdf0e10cSrcweir Name.equalsAscii("getStrings") || 424cdf0e10cSrcweir Name.equalsAscii("hasString") || 425cdf0e10cSrcweir Name.equalsAscii("hasStrings") || 426cdf0e10cSrcweir Name.equalsAscii("getStringList") || 427cdf0e10cSrcweir Name.equalsAscii("hasStringList") 428cdf0e10cSrcweir ) 429cdf0e10cSrcweir return sal_True; 430cdf0e10cSrcweir else 431cdf0e10cSrcweir { 432cdf0e10cSrcweir Reference< XInvocation > xI = getDefaultInvocation(); 433cdf0e10cSrcweir if( xI.is() ) 434cdf0e10cSrcweir return xI->hasMethod( Name ); 435cdf0e10cSrcweir else 436cdf0e10cSrcweir return sal_False; 437cdf0e10cSrcweir } 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir // XInvokation 441cdf0e10cSrcweir sal_Bool SAL_CALL ResourceService::hasProperty(const OUString& Name) 442cdf0e10cSrcweir throw(RuntimeException) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir if( Name.equalsAscii("FileName") ) 445cdf0e10cSrcweir return sal_True; 446cdf0e10cSrcweir else 447cdf0e10cSrcweir { 448cdf0e10cSrcweir Reference< XInvocation > xI = getDefaultInvocation(); 449cdf0e10cSrcweir if( xI.is() ) 450cdf0e10cSrcweir return xI->hasProperty( Name ); 451cdf0e10cSrcweir else 452cdf0e10cSrcweir return sal_False; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir namespace res 457cdf0e10cSrcweir { 458cdf0e10cSrcweir ComponentInfo getComponentInfo_VclStringResourceLoader() 459cdf0e10cSrcweir { 460cdf0e10cSrcweir ComponentInfo aInfo; 461cdf0e10cSrcweir aInfo.aSupportedServices = ResourceService::getSupportedServiceNames_Static(); 462cdf0e10cSrcweir aInfo.sImplementationName = ResourceService::getImplementationName_Static(); 463cdf0e10cSrcweir aInfo.pFactory = &ResourceService::Create; 464cdf0e10cSrcweir return aInfo; 465cdf0e10cSrcweir } 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468