summaryrefslogtreecommitdiff
path: root/stoc/source
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2003-03-27 11:01:26 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2003-03-27 11:01:26 +0000
commit414c097c65bb7925eef9ddc158b112228b49ed12 (patch)
treede9571ec116da8f9a4c0033c55a7ad6c4fb890c5 /stoc/source
parent45bb07d39bdd63e741b4fe692a3a0d421a642a79 (diff)
MWS_SRX644: migrate branch mws_srx644 -> HEAD
Diffstat (limited to 'stoc/source')
-rw-r--r--stoc/source/corereflection/base.hxx8
-rw-r--r--stoc/source/corereflection/criface.cxx102
-rw-r--r--stoc/source/inspect/introspection.cxx22
-rw-r--r--stoc/source/invocation/invocation.cxx146
-rw-r--r--stoc/source/javaloader/javaloader.cxx5
-rw-r--r--stoc/source/javavm/javavm.cxx133
-rw-r--r--stoc/source/servicemanager/servicemanager.cxx80
-rw-r--r--stoc/source/typeconv/convert.cxx102
8 files changed, 282 insertions, 316 deletions
diff --git a/stoc/source/corereflection/base.hxx b/stoc/source/corereflection/base.hxx
index 26bbf0230675..ed433a35be9b 100644
--- a/stoc/source/corereflection/base.hxx
+++ b/stoc/source/corereflection/base.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: base.hxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: dbo $ $Date: 2002-11-11 16:41:52 $
+ * last change: $Author: hr $ $Date: 2003-03-27 12:00:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -444,8 +444,10 @@ inline sal_Bool extract(
IdlReflectionServiceImpl * pRefl )
{
rDest.clear();
- if (rObj.hasValue() && pTo)
+ if (0 != pTo)
{
+ if (! rObj.hasValue())
+ return sal_True;
if (rObj.getValueTypeClass() == TypeClass_INTERFACE)
{
return ::uno_type_assignData(
diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx
index bfc370d2cca8..ddbf86af5d87 100644
--- a/stoc/source/corereflection/criface.cxx
+++ b/stoc/source/corereflection/criface.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: criface.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: dbo $ $Date: 2002-10-17 07:49:57 $
+ * last change: $Author: hr $ $Date: 2003-03-27 12:00:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -271,7 +271,7 @@ Any IdlAttributeFieldImpl::get( const Any & rObj )
return Any(); // dummy
}
//__________________________________________________________________________________________________
-void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue )
+void IdlAttributeFieldImpl::set( Any & rObj, const Any & rValue )
throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
{
if (getTypeDescr()->bReadOnly)
@@ -363,96 +363,10 @@ void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue )
(XWeak *)(OWeakObject *)this, 0 );
}
//__________________________________________________________________________________________________
-void IdlAttributeFieldImpl::set( Any & rObj, const Any & rValue )
+void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue )
throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
{
- if (getTypeDescr()->bReadOnly)
- {
- throw IllegalAccessException(
- OUString( RTL_CONSTASCII_USTRINGPARAM("cannot set readonly attribute!") ),
- (XWeak *)(OWeakObject *)this );
- }
-
- uno_Interface * pUnoI = getReflection()->mapToUno(
- rObj, (typelib_InterfaceTypeDescription *)getDeclTypeDescr() );
- OSL_ENSURE( pUnoI, "### illegal destination object given!" );
- if (pUnoI)
- {
- TypeDescription aTD( getTypeDescr()->pAttributeTypeRef );
- typelib_TypeDescription * pTD = aTD.get();
-
- // construct uno value to be set
- void * pArgs[1];
- void * pArg = pArgs[0] = alloca( pTD->nSize );
-
- sal_Bool bAssign;
- if (pTD->eTypeClass == typelib_TypeClass_ANY)
- {
- uno_copyAndConvertData( pArg, SAL_CONST_CAST( Any *, &rValue ),
- pTD, getReflection()->getCpp2Uno().get() );
- bAssign = sal_True;
- }
- else if (typelib_typedescriptionreference_equals( rValue.getValueTypeRef(), pTD->pWeakRef ))
- {
- uno_copyAndConvertData( pArg, SAL_CONST_CAST( void *, rValue.getValue() ),
- pTD, getReflection()->getCpp2Uno().get() );
- bAssign = sal_True;
- }
- else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
- {
- Reference< XInterface > xObj;
- if (bAssign = extract( rValue, (typelib_InterfaceTypeDescription *)pTD,
- xObj, getReflection() ))
- {
- *(void **)pArg = getReflection()->getCpp2Uno().mapInterface(
- xObj.get(), (typelib_InterfaceTypeDescription *)pTD );
- }
- }
- else
- {
- typelib_TypeDescription * pValueTD = 0;
- TYPELIB_DANGER_GET( &pValueTD, rValue.getValueTypeRef() );
- // construct temp uno val to do proper assignment: todo opt
- void * pTemp = alloca( pValueTD->nSize );
- uno_copyAndConvertData(
- pTemp, (void *)rValue.getValue(), pValueTD, getReflection()->getCpp2Uno().get() );
- uno_constructData(
- pArg, pTD );
- // assignment does simple conversion
- bAssign = uno_assignData(
- pArg, pTD, pTemp, pValueTD, 0, 0, 0 );
- uno_destructData(
- pTemp, pValueTD, 0 );
- TYPELIB_DANGER_RELEASE( pValueTD );
- }
-
- if (bAssign)
- {
- uno_Any aExc;
- uno_Any * pExc = &aExc;
- (*pUnoI->pDispatcher)( pUnoI, (typelib_TypeDescription *)getTypeDescr(), 0, pArgs, &pExc );
- (*pUnoI->release)( pUnoI );
-
- uno_destructData( pArg, pTD, 0 );
- if (pExc)
- {
- // DBO TODO: throw original exception generically
- uno_any_destruct( pExc, 0 );
- throw RuntimeException(
- OUString( RTL_CONSTASCII_USTRINGPARAM("exception occured during get of attribute!") ),
- *(const Reference< XInterface > *)rObj.getValue() );
- }
- return;
- }
- (*pUnoI->release)( pUnoI );
-
- throw IllegalArgumentException(
- OUString( RTL_CONSTASCII_USTRINGPARAM("illegal value given!") ),
- *(const Reference< XInterface > *)rObj.getValue(), 1 );
- }
- throw IllegalArgumentException(
- OUString( RTL_CONSTASCII_USTRINGPARAM("illegal destination object given!") ),
- (XWeak *)(OWeakObject *)this, 0 );
+ IdlAttributeFieldImpl::set( const_cast< Any & >( rObj ), rValue );
}
@@ -781,7 +695,8 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
if (pParams[nPos].bIn)
{
sal_Bool bAssign;
- if (typelib_typedescriptionreference_equals( pCppArgs[nPos].getValueTypeRef(), pTD->pWeakRef ))
+ if (typelib_typedescriptionreference_equals(
+ pCppArgs[nPos].getValueTypeRef(), pTD->pWeakRef ))
{
uno_type_copyAndConvertData(
ppUnoArgs[nPos], (void *)pCppArgs[nPos].getValue(),
@@ -795,8 +710,7 @@ Any SAL_CALL IdlInterfaceMethodImpl::invoke( const Any & rObj, Sequence< Any > &
pCppArgs[nPos].getValueTypeRef(), getReflection()->getCpp2Uno().get() );
bAssign = sal_True;
}
- else if (pCppArgs[nPos].getValueTypeClass() == TypeClass_INTERFACE &&
- pTD->eTypeClass == typelib_TypeClass_INTERFACE)
+ else if (pTD->eTypeClass == typelib_TypeClass_INTERFACE)
{
Reference< XInterface > xDest;
if (bAssign = extract( pCppArgs[nPos], (typelib_InterfaceTypeDescription *)pTD,
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx
index 6325e3f4bc0c..6d69ab63c10b 100644
--- a/stoc/source/inspect/introspection.cxx
+++ b/stoc/source/inspect/introspection.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: introspection.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: ab $ $Date: 2002-11-07 14:54:17 $
+ * last change: $Author: hr $ $Date: 2003-03-27 12:00:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -2915,10 +2915,22 @@ IntrospectionAccessStatic_Impl* ImplIntrospection::implInspect(const Any& aToIns
{
// Eintragen
rMethodNameMap[ aMethName ] = iAllExportedMethod;
+
+ // Tabelle fuer XExactName pflegen
+ rLowerToExactNameMap[ toLower( aMethName ) ] = aMethName;
}
+ else
+ {
+ sal_Int32 iHashResult = (*aIt).second;
- // Tabelle fuer XExactName pflegen
- rLowerToExactNameMap[ toLower( aMethName ) ] = aMethName;
+ Reference<XIdlMethod> xExistingMethod = pDestMethods[ iHashResult ];
+
+ Reference< XIdlClass > xExistingMethClass =
+ xExistingMethod->getDeclaringClass();
+ Reference< XIdlClass > xNewMethClass = rxMethod->getDeclaringClass();
+ if( xExistingMethClass->equals( xNewMethClass ) )
+ continue;
+ }
pDestMethods[ iAllExportedMethod ] = rxMethod;
@@ -2977,7 +2989,7 @@ IntrospectionAccessStatic_Impl* ImplIntrospection::implInspect(const Any& aToIns
bXInterfaceIsInvalid = sal_True;
delete[] pMethodTypes;
- delete pLocalMethodConcepts;
+ delete[] pLocalMethodConcepts;
}
// Super-Klasse(n) vorhanden? Dann dort fortsetzen
diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx
index 0e5903c1f082..f27900cb3941 100644
--- a/stoc/source/invocation/invocation.cxx
+++ b/stoc/source/invocation/invocation.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: invocation.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: dbo $ $Date: 2002-06-14 13:26:29 $
+ * last change: $Author: hr $ $Date: 2003-03-27 12:00:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -582,18 +582,34 @@ Any Invocation_Impl::getValue( const OUString& PropertyName )
{
if (_xDirect.is())
return _xDirect->getValue( PropertyName );
- // PropertySet
- if( _xIntrospectionAccess.is() && _xPropertySet.is()
- && _xIntrospectionAccess->hasProperty( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
+ try
+ {
+ // PropertySet
+ if( _xIntrospectionAccess.is() && _xPropertySet.is()
+ && _xIntrospectionAccess->hasProperty
+ ( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
+ {
+ return _xPropertySet->getPropertyValue( PropertyName );
+ }
+ // NameAccess
+ if( _xNameAccess.is() && _xNameAccess->hasByName( PropertyName ) )
+ return _xNameAccess->getByName( PropertyName );
+ }
+ catch (UnknownPropertyException &)
+ {
+ throw;
+ }
+ catch (RuntimeException &)
+ {
+ throw;
+ }
+ catch (Exception &)
{
- return _xPropertySet->getPropertyValue( PropertyName );
}
- // NameAccess
- if( _xNameAccess.is() && _xNameAccess->hasByName( PropertyName ) )
- return _xNameAccess->getByName( PropertyName );
- throw UnknownPropertyException();
- return Any(); // dummy
+ throw UnknownPropertyException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("cannot get value ") ) + PropertyName,
+ Reference< XInterface >() );
}
//--------------------------------------------------------------------------------------------------
@@ -604,43 +620,74 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
_xDirect->setValue( PropertyName, Value );
else
{
- // Properties
-
- if( _xIntrospectionAccess.is() && _xPropertySet.is()
- && _xIntrospectionAccess->hasProperty( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
+ try
{
- Property aProp = _xIntrospectionAccess->getProperty( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
- Reference < XIdlClass > r = TypeToIdlClass( aProp.Type, xCoreReflection );
- if( r->isAssignableFrom(
- TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
- _xPropertySet->setPropertyValue( PropertyName, Value );
- else if( xTypeConverter.is() )
- _xPropertySet->setPropertyValue( PropertyName, xTypeConverter->convertTo( Value, aProp.Type ) );
+ // Properties
+ if( _xIntrospectionAccess.is() && _xPropertySet.is()
+ && _xIntrospectionAccess->hasProperty(
+ PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
+ {
+ Property aProp = _xIntrospectionAccess->getProperty(
+ PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
+ Reference < XIdlClass > r = TypeToIdlClass( aProp.Type, xCoreReflection );
+ if( r->isAssignableFrom( TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
+ _xPropertySet->setPropertyValue( PropertyName, Value );
+ else if( xTypeConverter.is() )
+ _xPropertySet->setPropertyValue(
+ PropertyName, xTypeConverter->convertTo( Value, aProp.Type ) );
+ else
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no type converter service!") ),
+ Reference< XInterface >() );
+ }
+ // NameContainer
+ else if( _xNameContainer.is() )
+ {
+ Any aConv;
+ Reference < XIdlClass > r =
+ TypeToIdlClass( _xNameContainer->getElementType(), xCoreReflection );
+ if( r->isAssignableFrom(TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
+ aConv = Value;
+ else if( xTypeConverter.is() )
+ aConv = xTypeConverter->convertTo( Value, _xNameContainer->getElementType() );
+ else
+ throw RuntimeException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no type converter service!") ),
+ Reference< XInterface >() );
+
+ // bei Vorhandensein ersetzen, ansonsten einfuegen
+ if (_xNameContainer->hasByName( PropertyName ))
+ _xNameContainer->replaceByName( PropertyName, aConv );
+ else
+ _xNameContainer->insertByName( PropertyName, aConv );
+ }
else
- throw CannotConvertException();
+ throw UnknownPropertyException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("no introspection nor name container!") ),
+ Reference< XInterface >() );
}
- // NameContainer
- else
-
- if( _xNameContainer.is() )
+ catch (UnknownPropertyException &)
{
- Any aConv;
- Reference < XIdlClass > r = TypeToIdlClass( _xNameContainer->getElementType(), xCoreReflection );
- if( r->isAssignableFrom(TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
- aConv = Value;
- else if( xTypeConverter.is() )
- aConv = xTypeConverter->convertTo( Value, _xNameContainer->getElementType() );
- else
- throw CannotConvertException();
-
- // bei Vorhandensein ersetzen, ansonsten einfuegen
- if (_xNameContainer->hasByName( PropertyName ))
- _xNameContainer->replaceByName( PropertyName, aConv );
- else
- _xNameContainer->insertByName( PropertyName, aConv );
+ throw;
+ }
+ catch (CannotConvertException &)
+ {
+ throw;
+ }
+ catch (InvocationTargetException &)
+ {
+ throw;
+ }
+ catch (RuntimeException &)
+ {
+ throw;
+ }
+ catch (Exception & exc)
+ {
+ throw InvocationTargetException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("exception occured in setValue(): ") ) +
+ exc.Message, Reference< XInterface >(), makeAny( exc /* though sliced */ ) );
}
- else
- throw UnknownPropertyException();
}
}
@@ -662,11 +709,15 @@ Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>&
Sequence<ParamInfo> aFParams = xMethod->getParameterInfos();
const ParamInfo* pFParams = aFParams.getConstArray();
sal_uInt32 nFParamsLen = aFParams.getLength();
+ if (nFParamsLen != InParams.getLength())
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("incorrect number of parameters passed invoking function ") ) + FunctionName,
+ (OWeakObject *) this, (sal_Int16) 1 );
+ }
// IN Parameter
const Any* pInParams = InParams.getConstArray();
- sal_uInt32 nInParamsLen = InParams.getLength();
- OSL_ENSURE( nInParamsLen == nFParamsLen, "### new convention used for XInvocation::invoke!" );
// Introspection Invoke Parameter
Sequence<Any> aInvokeParams( nFParamsLen );
@@ -689,11 +740,6 @@ Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>&
// is IN/INOUT parameter?
if (rFParam.aMode != ParamMode_OUT)
{
-// // IN parameter available?
-// if (nInIndex >= nInParamsLen)
-// throw CannotConvertException();
- //TODO: Parameter? throw( CannotConvertException( OUString( RTL_CONSTASCII_USTRINGPARAM(not enough IN parameters available!")), Reference<XInterface>(), rDestType->getTypeClass(), FailReason::NO_DEFAULT_AVAILABLE, nInIndex ) );
-
if (rDestType->isAssignableFrom( TypeToIdlClass( pInParams[nPos].getValueType(), xCoreReflection ) ))
{
pInvokeParams[nPos] = pInParams[nPos];
diff --git a/stoc/source/javaloader/javaloader.cxx b/stoc/source/javaloader/javaloader.cxx
index 28f0ce9173f6..aa10843842ad 100644
--- a/stoc/source/javaloader/javaloader.cxx
+++ b/stoc/source/javaloader/javaloader.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javaloader.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: sb $ $Date: 2002-12-06 10:51:53 $
+ * last change: $Author: hr $ $Date: 2003-03-27 12:00:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -383,6 +383,7 @@ namespace stoc_javaloader {
catch(RuntimeException & runtimeException) {
OString message = OUStringToOString(runtimeException.Message, RTL_TEXTENCODING_ASCII_US);
osl_trace("javaloader - could not init javaloader cause of %s", message.getStr());
+ throw;
}
return xRet;
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index a1a623e66d7b..d49d4c7b2a55 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: javavm.cxx,v $
*
- * $Revision: 1.52 $
+ * $Revision: 1.53 $
*
- * last change: $Author: kz $ $Date: 2002-12-10 17:05:19 $
+ * last change: $Author: hr $ $Date: 2003-03-27 12:00:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -155,6 +155,9 @@ int main( int argc, char * argv[])
#include <stack>
#include <string.h>
#include <time.h>
+#include <memory>
+
+#define OUSTR(x) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( x ))
// Properties of the javavm can be put
// as a komma separated list in this
@@ -473,77 +476,23 @@ void getDefaultLocaleFromConfig(stoc_javavm::JVM * pjvm,
xConfRegistry_simple->close();
}
-/* When the setup is started from an installation (not the first installation)
-and Java is used then this function fails, because the ConfigurationRegistry service
-is not available to the setup. That is, the javarc cannot be read and values from
-environment variables are used to initialize the JavaVM service. The javaldx, therefore,
-must not use the javarc either. Otherwise the LD_LIBRARY_PATH (set by javaldx) would be
-for a different java as the one the runtime lib is from. The runtime lib is set in
-the setup (environment variable OO_JAVA_PROPERTIES).
-*/
void getJavaPropsFromConfig(stoc_javavm::JVM * pjvm,
const css::uno::Reference<css::lang::XMultiComponentFactory> & xSMgr,
const css::uno::Reference<css::uno::XComponentContext> &xCtx) throw(css::uno::Exception)
{
- css::uno::Reference<css::uno::XInterface> xConfRegistry = xSMgr->createInstanceWithContext(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationRegistry")),
- xCtx);
- if(!xConfRegistry.is())
- throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")),
- 0);
- css::uno::Reference<css::registry::XSimpleRegistry> xConfRegistry_simple(xConfRegistry, css::uno::UNO_QUERY);
-
- if(!xConfRegistry_simple.is())
- throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: couldn't get ConfigurationRegistry")),
- 0);
- xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")), sal_True, sal_False);
-
- css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
-
- css::uno::Reference<css::registry::XRegistryKey> key_InstallPath = xRegistryRootKey->openKey(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office/ooSetupInstallPath")));
- if(!key_InstallPath.is())
- throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: can not find key: " \
- "Office/InstallPath in org.openoffice.UserProfile")),
- 0);
- rtl::OUString rcPath = key_InstallPath->getStringValue();
- key_InstallPath->closeKey();
- xRegistryRootKey->closeKey();
-
-
- rtl::OUString urlrcPath;
- if( osl::File::E_None != osl::File::getFileURLFromSystemPath( rcPath, urlrcPath ) )
- throw css::uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: could not convert a system path to URL")),
- 0);
-
- urlrcPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/config/" INI_FILE));
-
- // TODO change pIniFile, pIni2 from plain pointers to auto_ptrs or stack
- // variables; at least pIniFile is sometimes not deleted
-
- osl::File *pIniFile= new osl::File(urlrcPath);
+ rtl::OUString usInstallDir;
+ rtl::Bootstrap::get(OUSTR("UserInstallation"),
+ usInstallDir,
+ OUSTR("${$SYSBINDIR/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}"));
+ rtl::OUString urlrcPath= usInstallDir + OUSTR("/user/config/" INI_FILE);
+ std::auto_ptr<osl::File> pIniFile(new osl::File(urlrcPath));
if( pIniFile->open(OpenFlag_Read) != osl::File::E_None)
{
- // Probably network installation. A workstation installation does not need to have its own javarc.
- // Then we use the one from the network insallation ( <install-di>/share/config/javarc)
- xConfRegistry_simple->open(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common")), sal_True, sal_False);
- css::uno::Reference<css::registry::XRegistryKey> xRegistryCommonRootKey = xConfRegistry_simple->getRootKey();
-
- css::uno::Reference<css::registry::XRegistryKey> key_NetInstallPath = xRegistryCommonRootKey->openKey(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Path/Current/OfficeInstall")));
- if(!key_NetInstallPath.is()) throw css::uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("javavm.cxx: can not find key: Office/InstallPath in org.openoffice.UserProfile")),
- 0);
- rcPath = key_NetInstallPath->getStringValue();
- // convert to file url
- if( osl_File_E_None != osl::File::getFileURLFromSystemPath( rcPath, urlrcPath ) )
- {
- urlrcPath = rcPath;
- }
- urlrcPath += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/share/config/" INI_FILE));
-
- key_NetInstallPath->closeKey();
- osl::File *pIni2= new osl::File(urlrcPath);
+ rtl::Bootstrap::get(OUSTR("BaseInstallation"),
+ usInstallDir,
+ OUSTR("${$SYSBINDIR/" SAL_CONFIGFILE("bootstrap") ":BaseInstallation}"));
+ urlrcPath= usInstallDir + OUSTR("/share/config/" INI_FILE);
+ std::auto_ptr<osl::File> pIni2(new osl::File(urlrcPath));
if(pIni2->open(OpenFlag_Read) != osl::File::E_None)
{
throw css::java::JavaNotConfiguredException (
@@ -554,6 +503,8 @@ void getJavaPropsFromConfig(stoc_javavm::JVM * pjvm,
pIniFile= pIni2;
}
+ // The javarc is encoded as UTF-8
+
//Find the Java Section
rtl::OString sJavaSection("[Java]");
bool bSectionFound= false;
@@ -574,31 +525,26 @@ void getJavaPropsFromConfig(stoc_javavm::JVM * pjvm,
break;
}
- // TODO encoding of ini file???
-
//Read each line from the Java section
if(bSectionFound)
{
while(1)
{
rtl::ByteSequence seq;
- sal_Bool bEOF;
- rtl::OUString usProp;
if(pIniFile->readLine(seq) == osl::File::E_None)
{
//check if another Section starts
- rtl::OString line((sal_Char*)seq.getArray(), seq.getLength());
- if(line.indexOf('[') == 0)
+ rtl::OUString line((sal_Char*)seq.getArray(), seq.getLength(),
+ RTL_TEXTENCODING_UTF8);
+ sal_Unicode const * pIndex = line.getStr();
+ sal_Unicode const * pEnd = pIndex + line.getLength();
+ if (pIndex == pEnd || *pIndex == '[')
break;
//check if there is '=' after the first word
- bool bOk= false;
- const sal_Char *pIndex= line.getStr();
//check for jvm options, e.g. -Xdebug, -D, ..
if( *pIndex != '-')
{
//no jvm option, check for property, e.g RuntimeLib=XXX
- sal_Int32 len= line.getLength();
- const sal_Char *pEnd= pIndex + len;
// the line must not start with characters for commenting ';' ' ', etc.
if( *pIndex == ';'
|| *pIndex == '/'
@@ -617,10 +563,9 @@ void getJavaPropsFromConfig(stoc_javavm::JVM * pjvm,
goto nextLine; // no '=' found
}
// Ok, store the line
- line.trim();
- usProp= rtl::OStringToOUString(line, osl_getThreadTextEncoding());
- pjvm->pushProp(usProp);
+ pjvm->pushProp(line.trim());
nextLine:
+ sal_Bool bEOF = true;
pIniFile->isEndOfFile(&bEOF);
if(bEOF)
break;
@@ -628,9 +573,8 @@ void getJavaPropsFromConfig(stoc_javavm::JVM * pjvm,
else
break;
}
- pIniFile->close();
- delete pIniFile;
}
+ pIniFile->close();
}
void getJavaPropsFromEnvironment(stoc_javavm::JVM * pjvm) throw() {
@@ -638,15 +582,19 @@ void getJavaPropsFromEnvironment(stoc_javavm::JVM * pjvm) throw() {
const char * pClassPath = getenv("CLASSPATH");
if( pClassPath )
{
- pjvm->addSystemClasspath( rtl::OUString::createFromAscii(pClassPath) );
+ pjvm->addSystemClasspath(rtl::OUString(pClassPath, strlen(pClassPath),
+ osl_getThreadTextEncoding()));
}
- pjvm->setRuntimeLib(rtl::OUString::createFromAscii(DEF_JAVALIB));
+ pjvm->setRuntimeLib(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(DEF_JAVALIB)));
pjvm->setEnabled(1);
// See if properties have been set and parse them
const char * pOOjavaProperties = getenv(PROPERTIES_ENV);
if(pOOjavaProperties) {
- rtl::OUString properties(rtl::OUString::createFromAscii(pOOjavaProperties));
+ rtl::OUString properties(rtl::OUString(pOOjavaProperties,
+ strlen(pOOjavaProperties),
+ osl_getThreadTextEncoding()));
sal_Int32 index;
sal_Int32 lastIndex = 0;
@@ -754,6 +702,8 @@ const rtl::Bootstrap & getBootstrapHandle()
rtl::OUString retrieveComponentClassPath( const sal_Char *pVariableName )
{
+ // java_classpath file is encoded as ASCII
+
rtl::OUString ret;
rtl::OUStringBuffer buf( 128 );
buf.appendAscii( "$" ).appendAscii( pVariableName );
@@ -796,7 +746,7 @@ rtl::OUString retrieveComponentClassPath( const sal_Char *pVariableName )
while( nIndex < nSize && p[nIndex] == ' ' ) nIndex ++;
sal_Int32 nStart = nIndex;
while( nIndex < nSize && p[nIndex] != ' ' ) nIndex ++;
- rtl::OUString relativeUrl( &(p[nStart]), nIndex-nStart, RTL_TEXTENCODING_ASCII_US); // TODO encoding???
+ rtl::OUString relativeUrl( &(p[nStart]), nIndex-nStart, RTL_TEXTENCODING_ASCII_US);
relativeUrl = relativeUrl.trim();
if (0 < relativeUrl.getLength())
{
@@ -1674,7 +1624,7 @@ JavaVM * JavaVirtualMachine::createJavaVM(stoc_javavm::JVM const & jvm,
javaHome += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/jre"));
}
- rtl::OString osJavaHome = rtl::OUStringToOString(javaHome, osl_getThreadTextEncoding()); // TODO encoding???
+ rtl::OString osJavaHome = rtl::OUStringToOString(javaHome, osl_getThreadTextEncoding());
putenv(strdup(osJavaHome.getStr()));
#endif
@@ -1709,6 +1659,8 @@ JavaVM * JavaVirtualMachine::createJavaVM(stoc_javavm::JVM const & jvm,
sal_uInt16 cprops= jvm.getProperties().size();
+ // Some testing with Java 1.4 showed that JavaVMOption.optionString has to
+ // be encoded with the system encoding (i.e., osl_getThreadTextEncoding):
JavaVMInitArgs vm_args;
// we have "addOpt" additional properties to those kept in the JVM struct
@@ -1717,7 +1669,6 @@ JavaVM * JavaVirtualMachine::createJavaVM(stoc_javavm::JVM const & jvm,
rtl::OString sClassPath= rtl::OString("-Djava.class.path=")
+ rtl::OUStringToOString(jvm.getClassPath(),
osl_getThreadTextEncoding());
- // TODO encoding???
options[0].optionString= (char*)sClassPath.getStr();
options[0].extraInfo= NULL;
@@ -1741,9 +1692,9 @@ JavaVM * JavaVirtualMachine::createJavaVM(stoc_javavm::JVM const & jvm,
rtl::OString sJavaOption("-");
for( sal_uInt16 x= 0; x< cprops; x++)
{
- rtl::OString sOption(rtl::OUStringToOString(jvm.getProperties()[x],
- RTL_TEXTENCODING_ASCII_US));
- // TODO encoding???
+ rtl::OString sOption(rtl::OUStringToOString(
+ jvm.getProperties()[x],
+ osl_getThreadTextEncoding()));
if (!sOption.matchIgnoreAsciiCase(sJavaOption, 0))
arProps[x]= rtl::OString("-D") + sOption;
else
diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx
index 373cb6c386a1..c4b746a4def1 100644
--- a/stoc/source/servicemanager/servicemanager.cxx
+++ b/stoc/source/servicemanager/servicemanager.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: servicemanager.cxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: dbo $ $Date: 2002-11-15 14:09:45 $
+ * last change: $Author: hr $ $Date: 2003-03-27 12:01:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -661,6 +661,9 @@ public:
// XContentEnumerationAccess
//Sequence< OUString > getAvailableServiceNames() throw( (Exception) );
virtual Reference<XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference<XEnumeration > SAL_CALL createContentEnumeration(
+ const OUString& aServiceName, Reference< XComponentContext > const & xContext )
+ throw(::com::sun::star::uno::RuntimeException);
// XComponent
virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
@@ -683,10 +686,12 @@ public:
protected:
inline void check_undisposed() const SAL_THROW( (lang::DisposedException) );
+ virtual void SAL_CALL disposing();
sal_Bool haveFactoryWithThisImplementation(const OUString& aImplName);
- virtual Sequence< Reference< XInterface > > queryServiceFactories(const OUString& aServiceName);
+ virtual Sequence< Reference< XInterface > > queryServiceFactories(
+ const OUString& aServiceName, Reference< XComponentContext > const & xContext );
Reference< XComponentContext > m_xContext;
@@ -809,7 +814,7 @@ public:
// XContentEnumerationAccess
//Sequence< OUString > getAvailableServiceNames() throw( (Exception) );
virtual Reference<XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) throw (RuntimeException)
- { return getRoot()->createContentEnumeration( aServiceName ); }
+ { return getRoot()->createContentEnumeration( aServiceName, m_xContext ); }
// XPropertySet
Reference<XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (RuntimeException)
@@ -1077,7 +1082,10 @@ void OServiceManager::dispose()
if (rBHelper.bDisposed || rBHelper.bInDispose)
return;
t_OServiceManager_impl::dispose();
+}
+void OServiceManager::disposing()
+{
// dispose all factories
HashSet_Ref aImpls;
{
@@ -1287,7 +1295,8 @@ Reference< XInterface > OServiceManager::createInstanceWithContext(
}
#endif
- Sequence< Reference< XInterface > > factories( queryServiceFactories( rServiceSpecifier ) );
+ Sequence< Reference< XInterface > > factories(
+ queryServiceFactories( rServiceSpecifier, xContext ) );
Reference< XInterface > const * p = factories.getConstArray();
for ( sal_Int32 nPos = 0; nPos < factories.getLength(); ++nPos )
{
@@ -1348,7 +1357,8 @@ Reference< XInterface > OServiceManager::createInstanceWithArgumentsAndContext(
}
#endif
- Sequence< Reference< XInterface > > factories( queryServiceFactories( rServiceSpecifier ) );
+ Sequence< Reference< XInterface > > factories(
+ queryServiceFactories( rServiceSpecifier, xContext ) );
Reference< XInterface > const * p = factories.getConstArray();
for ( sal_Int32 nPos = 0; nPos < factories.getLength(); ++nPos )
{
@@ -1456,7 +1466,7 @@ Sequence< OUString > OServiceManager::getSupportedServiceNames()
Sequence< Reference< XInterface > > OServiceManager::queryServiceFactories(
- const OUString& aServiceName )
+ const OUString& aServiceName, Reference< XComponentContext > const & xContext )
{
Sequence< Reference< XInterface > > ret;
@@ -1493,17 +1503,24 @@ Sequence< Reference< XInterface > > OServiceManager::queryServiceFactories(
}
// XContentEnumerationAccess
-Reference<XEnumeration > OServiceManager::createContentEnumeration(const OUString& aServiceName)
+Reference<XEnumeration > OServiceManager::createContentEnumeration(
+ const OUString& aServiceName, Reference< XComponentContext > const & xContext )
throw(::com::sun::star::uno::RuntimeException)
{
check_undisposed();
Sequence< Reference< XInterface > > factories(
- OServiceManager::queryServiceFactories( aServiceName ) );
+ OServiceManager::queryServiceFactories( aServiceName, xContext ) );
if (factories.getLength())
return new ServiceEnumeration_Impl( factories );
else
return Reference< XEnumeration >();
}
+Reference<XEnumeration > OServiceManager::createContentEnumeration(
+ const OUString& aServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return createContentEnumeration( aServiceName, m_xContext );
+}
// XEnumeration
Reference<XEnumeration > OServiceManager::createEnumeration() throw(::com::sun::star::uno::RuntimeException)
@@ -1696,6 +1713,9 @@ public:
// XContentEnumerationAccess
//Sequence< OUString > getAvailableServiceNames() throw( (Exception) );
Reference<XEnumeration > SAL_CALL createContentEnumeration(const OUString& aServiceName) throw(::com::sun::star::uno::RuntimeException);
+ virtual Reference<XEnumeration > SAL_CALL createContentEnumeration(
+ const OUString& aServiceName, Reference< XComponentContext > const & xContext )
+ throw(::com::sun::star::uno::RuntimeException);
// XComponent
void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
@@ -1708,12 +1728,15 @@ public:
protected:
//OServiceManager
- Sequence< Reference< XInterface > > queryServiceFactories(const OUString& aServiceName);
+ Sequence< Reference< XInterface > > queryServiceFactories(
+ const OUString& aServiceName, Reference< XComponentContext > const & xContext );
private:
Reference<XRegistryKey > getRootKey();
- Reference<XInterface > loadWithImplementationName( const OUString & rImplName );
+ Reference<XInterface > loadWithImplementationName(
+ const OUString & rImplName, Reference< XComponentContext > const & xContext );
Sequence<OUString> getFromServiceName(const OUString& serviceName);
- Reference<XInterface > loadWithServiceName( const OUString & rImplName );
+ Reference<XInterface > loadWithServiceName(
+ const OUString & rImplName, Reference< XComponentContext > const & xContext );
void fillAllNamesFromRegistry( HashSet_OWString & );
sal_Bool m_searchedRegistry;
@@ -1792,7 +1815,7 @@ Reference<XRegistryKey > ORegistryServiceManager::getRootKey()
* Create a service provider from the registry with an implementation name
*/
Reference<XInterface > ORegistryServiceManager::loadWithImplementationName(
- const OUString& name )
+ const OUString& name, Reference< XComponentContext > const & xContext )
{
Reference<XInterface > ret;
@@ -1807,7 +1830,10 @@ Reference<XInterface > ORegistryServiceManager::loadWithImplementationName(
if( xImpKey.is() )
{
- ret = createSingleRegistryFactory( this, name, xImpKey );
+ ret = createSingleRegistryFactory(
+ Reference< lang::XMultiServiceFactory >(
+ xContext->getServiceManager(), UNO_QUERY_THROW ),
+ name, xImpKey );
insert( makeAny( ret ) );
// Remember this factory as loaded in contrast to inserted ( XSet::insert)
// factories. Those loaded factories in this set are candidates for being
@@ -1838,12 +1864,13 @@ Sequence<OUString> ORegistryServiceManager::getFromServiceName(
* Create a service provider from the registry
*/
Reference<XInterface > ORegistryServiceManager::loadWithServiceName(
- const OUString& serviceName )
+ const OUString& serviceName, Reference< XComponentContext > const & xContext )
{
Sequence<OUString> implEntries = getFromServiceName( serviceName );
for (sal_Int32 i = 0; i < implEntries.getLength(); i++)
{
- Reference< XInterface > x( loadWithImplementationName( implEntries.getConstArray()[i] ) );
+ Reference< XInterface > x(
+ loadWithImplementationName( implEntries.getConstArray()[i], xContext ) );
if (x.is())
return x;
}
@@ -1922,10 +1949,10 @@ Sequence< OUString > ORegistryServiceManager::getSupportedServiceNames()
// OServiceManager
Sequence< Reference< XInterface > > ORegistryServiceManager::queryServiceFactories(
- const OUString& aServiceName )
+ const OUString& aServiceName, Reference< XComponentContext > const & xContext )
{
Sequence< Reference< XInterface > > ret(
- OServiceManager::queryServiceFactories( aServiceName ) );
+ OServiceManager::queryServiceFactories( aServiceName, xContext ) );
if (ret.getLength())
{
return ret;
@@ -1933,15 +1960,16 @@ Sequence< Reference< XInterface > > ORegistryServiceManager::queryServiceFactori
else
{
MutexGuard aGuard( m_mutex );
- Reference< XInterface > x( loadWithServiceName( aServiceName ) );
+ Reference< XInterface > x( loadWithServiceName( aServiceName, xContext ) );
if (! x.is())
- x = loadWithImplementationName( aServiceName );
+ x = loadWithImplementationName( aServiceName, xContext );
return Sequence< Reference< XInterface > >( &x, 1 );
}
}
// XContentEnumerationAccess
-Reference<XEnumeration > ORegistryServiceManager::createContentEnumeration(const OUString& aServiceName)
+Reference<XEnumeration > ORegistryServiceManager::createContentEnumeration(
+ const OUString& aServiceName, Reference< XComponentContext > const & xContext )
throw(::com::sun::star::uno::RuntimeException)
{
check_undisposed();
@@ -1956,11 +1984,17 @@ Reference<XEnumeration > ORegistryServiceManager::createContentEnumeration(const
aImplName = aImpls.getConstArray()[i];
if ( !haveFactoryWithThisImplementation(aImplName) )
{
- loadWithImplementationName( aImplName );
+ loadWithImplementationName( aImplName, xContext );
}
}
// call the superclass to enumerate all contents
- return OServiceManager::createContentEnumeration( aServiceName );
+ return OServiceManager::createContentEnumeration( aServiceName, xContext );
+}
+Reference<XEnumeration > ORegistryServiceManager::createContentEnumeration(
+ const OUString& aServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return createContentEnumeration( aServiceName, m_xContext );
}
// OServiceManager
diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx
index 2516486bb58f..773fb050520e 100644
--- a/stoc/source/typeconv/convert.cxx
+++ b/stoc/source/typeconv/convert.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: convert.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: dbo $ $Date: 2002-07-05 12:01:09 $
+ * last change: $Author: hr $ $Date: 2003-03-27 12:01:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -325,16 +325,20 @@ class TypeConverter_Impl : public WeakImplHelper2< XTypeConverter, XServiceInfo
public:
TypeConverter_Impl();
- ~TypeConverter_Impl();
+ virtual ~TypeConverter_Impl();
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw( RuntimeException );
- virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException );
- virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
+ throw( RuntimeException );
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
+ throw( RuntimeException );
// XTypeConverter
- virtual Any SAL_CALL convertTo( const Any& aFrom, const Type& DestinationType ) throw( IllegalArgumentException, CannotConvertException, RuntimeException);
- virtual Any SAL_CALL convertToSimpleType( const Any& aFrom, TypeClass aDestinationType ) throw( IllegalArgumentException, CannotConvertException, RuntimeException);
+ virtual Any SAL_CALL convertTo( const Any& aFrom, const Type& DestinationType )
+ throw( IllegalArgumentException, CannotConvertException, RuntimeException);
+ virtual Any SAL_CALL convertToSimpleType( const Any& aFrom, TypeClass aDestinationType )
+ throw( IllegalArgumentException, CannotConvertException, RuntimeException);
};
TypeConverter_Impl::TypeConverter_Impl()
@@ -379,9 +383,6 @@ sal_Int64 TypeConverter_Impl::toHyper( const Any& rAny, sal_Int64 min, sal_uInt6
switch (aDestinationClass)
{
- // ANY
-// case TypeClass_ANY: // any sollte schon vorher entschachtelt sein...
-// break;
// ENUM
case TypeClass_ENUM:
nRet = *(sal_Int32 *)rAny.getValue();
@@ -486,7 +487,6 @@ sal_Int64 TypeConverter_Impl::toHyper( const Any& rAny, sal_Int64 min, sal_uInt6
throw CannotConvertException(
OUString( RTL_CONSTASCII_USTRINGPARAM("VALUE is out of range!") ),
Reference<XInterface>(), aDestinationClass, FailReason::OUT_OF_RANGE, 0 );
- return 0; // dummy
}
//--------------------------------------------------------------------------------------------------
@@ -498,9 +498,6 @@ double TypeConverter_Impl::toDouble( const Any& rAny, double min, double max ) c
switch (aDestinationClass)
{
- // ANY
-// case TypeClass_ANY: // any sollte schon vorher entschachtelt sein...
-// break;
// ENUM
case TypeClass_ENUM:
fRet = *(sal_Int32 *)rAny.getValue();
@@ -571,7 +568,6 @@ double TypeConverter_Impl::toDouble( const Any& rAny, double min, double max ) c
throw CannotConvertException(
OUString( RTL_CONSTASCII_USTRINGPARAM("VALUE is out of range!") ),
Reference< XInterface >(), aDestinationClass, FailReason::OUT_OF_RANGE, 0 );
- return 0.0; // dummy
}
//--------------------------------------------------------------------------------------------------
@@ -599,7 +595,7 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
// --- to STRUCT, UNION, EXCEPTION ----------------------------------------------------------
case TypeClass_STRUCT:
-// case TypeClass_UNION: // todo
+// case TypeClass_UNION: // xxx todo
case TypeClass_EXCEPTION:
{
// same types or destination type is derived source type?
@@ -613,13 +609,22 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
{
throw CannotConvertException(
OUString( RTL_CONSTASCII_USTRINGPARAM("value is not of same or derived type!") ),
- Reference< XInterface >(), aDestinationClass, FailReason::SOURCE_IS_NO_DERIVED_TYPE, 0 );
+ Reference< XInterface >(), aDestinationClass,
+ FailReason::SOURCE_IS_NO_DERIVED_TYPE, 0 );
}
break;
}
// --- to INTERFACE -------------------------------------------------------------------------
case TypeClass_INTERFACE:
{
+ if (! rVal.hasValue())
+ {
+ // void -> interface (null)
+ void * null_ref = 0;
+ aRet.setValue( &null_ref, aDestType );
+ break;
+ }
+
if (rVal.getValueTypeClass() != TypeClass_INTERFACE ||
!*(XInterface * const *)rVal.getValue())
{
@@ -627,7 +632,8 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
OUString( RTL_CONSTASCII_USTRINGPARAM("value is no interface!") ),
Reference< XInterface >(), aDestinationClass, FailReason::NO_SUCH_INTERFACE, 0 );
}
- if (! (aRet = (*(XInterface * const *)rVal.getValue())->queryInterface( aDestType )).hasValue())
+ if (! (aRet = (*(XInterface * const *)rVal.getValue())->queryInterface(
+ aDestType )).hasValue())
{
throw CannotConvertException(
OUString( RTL_CONSTASCII_USTRINGPARAM("value has no such interface!") ),
@@ -640,16 +646,19 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
{
if (aSourceClass==TypeClass_SEQUENCE)
{
- // wenn beide Sequences vom gleichen Typ sind
if( aSourceType == aDestType )
return rVal;
TypeDescription aSourceTD( aSourceType );
TypeDescription aDestTD( aDestType );
typelib_TypeDescription * pSourceElementTD = 0;
- TYPELIB_DANGER_GET( &pSourceElementTD, ((typelib_IndirectTypeDescription *)aSourceTD.get())->pType );
+ TYPELIB_DANGER_GET(
+ &pSourceElementTD,
+ ((typelib_IndirectTypeDescription *)aSourceTD.get())->pType );
typelib_TypeDescription * pDestElementTD = 0;
- TYPELIB_DANGER_GET( &pDestElementTD, ((typelib_IndirectTypeDescription *)aDestTD.get())->pType );
+ TYPELIB_DANGER_GET(
+ &pDestElementTD,
+ ((typelib_IndirectTypeDescription *)aDestTD.get())->pType );
sal_uInt32 nPos = (*(const uno_Sequence * const *)rVal.getValue())->nElements;
uno_Sequence * pRet = 0;
@@ -658,14 +667,16 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
uno_destructData( &pRet, aDestTD.get(), cpp_release ); // decr ref count
char * pDestElements = (*(uno_Sequence * const *)aRet.getValue())->elements;
- const char * pSourceElements = (*(const uno_Sequence * const *)rVal.getValue())->elements;
+ const char * pSourceElements =
+ (*(const uno_Sequence * const *)rVal.getValue())->elements;
while (nPos--)
{
char * pDestPos = pDestElements + (nPos * pDestElementTD->nSize);
const char * pSourcePos = pSourceElements + (nPos * pSourceElementTD->nSize);
- Any aElement( convertTo( Any( pSourcePos, pSourceElementTD ), pDestElementTD->pWeakRef ) );
+ Any aElement(
+ convertTo( Any( pSourcePos, pSourceElementTD ), pDestElementTD->pWeakRef ) );
sal_Bool bSucc = uno_assignData(
pDestPos, pDestElementTD,
@@ -690,7 +701,8 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
{
for ( nPos = ((typelib_EnumTypeDescription *)aEnumTD.get())->nEnumValues; nPos--; )
{
- if (((const OUString *)rVal.getValue())->equalsIgnoreAsciiCase( ((typelib_EnumTypeDescription *)aEnumTD.get())->ppEnumNames[nPos] ))
+ if (((const OUString *)rVal.getValue())->equalsIgnoreAsciiCase(
+ ((typelib_EnumTypeDescription *)aEnumTD.get())->ppEnumNames[nPos] ))
break;
}
}
@@ -708,12 +720,15 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
if (nPos >= 0)
{
- aRet.setValue( &((typelib_EnumTypeDescription *)aEnumTD.get())->pEnumValues[nPos], aEnumTD.get() );
+ aRet.setValue(
+ &((typelib_EnumTypeDescription *)aEnumTD.get())->pEnumValues[nPos],
+ aEnumTD.get() );
}
else
{
throw CannotConvertException(
- OUString( RTL_CONSTASCII_USTRINGPARAM("value cannot be converted to demanded ENUM!") ),
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM("value cannot be converted to demanded ENUM!") ),
Reference< XInterface >(), aDestinationClass, FailReason::IS_NOT_ENUM, 0 );
}
break;
@@ -723,21 +738,20 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
// else simple type conversion possible?
try
{
- aRet = convertToSimpleType( rVal, aDestinationClass ); // CannotConvertException darf durchfliegen
+ aRet = convertToSimpleType( rVal, aDestinationClass );
}
catch (IllegalArgumentException &)
{
- // ...FailReason::INVALID fliegt
+ // ...FailReason::INVALID is thrown
}
}
- if (aRet.getValueTypeClass() != TypeClass_VOID)
+ if (aRet.hasValue())
return aRet;
throw CannotConvertException(
OUString( RTL_CONSTASCII_USTRINGPARAM("conversion not possible!") ),
Reference< XInterface >(), aDestinationClass, FailReason::INVALID, 0 );
- return Any(); // dummy
}
//--------------------------------------------------------------------------------------------------
@@ -758,7 +772,9 @@ Any TypeConverter_Impl::convertToSimpleType( const Any& rVal, TypeClass aDestina
case TypeClass_ENUM:
case TypeClass_UNKNOWN:
case TypeClass_MODULE:
- throw IllegalArgumentException();
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("destination type is not simple!") ),
+ Reference< XInterface >(), (sal_Int16) 1 );
}
Type aSourceType = rVal.getValueType();
@@ -885,7 +901,9 @@ Any TypeConverter_Impl::convertToSimpleType( const Any& rVal, TypeClass aDestina
}
if (nPos >= 0)
{
- aRet.setValue( &((typelib_EnumTypeDescription *)aEnumTD.get())->ppEnumNames[nPos], ::getCppuType( (const OUString *)0 ) );
+ aRet.setValue(
+ &((typelib_EnumTypeDescription *)aEnumTD.get())->ppEnumNames[nPos],
+ ::getCppuType( (const OUString *)0 ) );
}
else
{
@@ -931,33 +949,21 @@ Any TypeConverter_Impl::convertToSimpleType( const Any& rVal, TypeClass aDestina
}
}
- if (aRet.getValueTypeClass() != TypeClass_VOID)
+ if (aRet.hasValue())
return aRet;
throw CannotConvertException(
OUString( RTL_CONSTASCII_USTRINGPARAM("conversion not possible!") ),
Reference< XInterface >(), aDestinationClass, FailReason::INVALID, 0 );
- return Any(); // dummy
}
//*************************************************************************
Reference< XInterface > SAL_CALL TypeConverter_Impl_CreateInstance(
- const Reference< XComponentContext > & rSMgr )
+ const Reference< XComponentContext > & )
throw( RuntimeException )
{
- Reference< XInterface > rRet;
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- static WeakReference < XInterface > rwInstance;
- rRet = rwInstance;
-
- if( ! rRet.is() )
- {
- rRet = (OWeakObject *)new TypeConverter_Impl();
- rwInstance = rRet;
- }
- }
- return rRet;
+ static Reference< XInterface > s_ref( (OWeakObject *) new TypeConverter_Impl() );
+ return s_ref;
}
}