summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-04-24 22:36:40 +0300
committerTor Lillqvist <tml@collabora.com>2018-05-31 21:58:21 +0300
commitf8addac6dd8ece33ea62c56ca199dcbdc4d3bdb7 (patch)
treedda57a43a2015befc509d23cf56c50c50830af15 /stoc
parent378921f0f69539fe500214b467059451e0d77830 (diff)
Do same trick in setValue() as earlier in getValue() for Automation clients
Also, it is UnknownPropertyException that we need to catch, not RuntimeException. Did I not actually exercise my change to getValue() back in February? Change-Id: If13eaa9bbecd15f5330a4102ae932f2ec0c7ecd4
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/invocation/invocation.cxx130
1 files changed, 69 insertions, 61 deletions
diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx
index bf003165b2a9..b1f2a4d3e8da 100644
--- a/stoc/source/invocation/invocation.cxx
+++ b/stoc/source/invocation/invocation.cxx
@@ -499,7 +499,7 @@ Any Invocation_Impl::getValue( const OUString& PropertyName )
if (_xDirect.is())
return _xDirect->getValue( PropertyName );
}
- catch (RuntimeException &)
+ catch (UnknownPropertyException &)
{
if (!mbFromOLE)
throw;
@@ -535,74 +535,82 @@ Any Invocation_Impl::getValue( const OUString& PropertyName )
void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
{
- if (_xDirect.is())
- _xDirect->setValue( PropertyName, Value );
- else
+ try
{
- try
- {
- // 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( "no type converter service!" );
- }
- // NameContainer
- else if( _xNameContainer.is() )
- {
- // Note: This misfeature deliberately not adapted to apply to objects which
- // have XNameReplace but not XNameContainer
- 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( "no type converter service!" );
-
- // Replace if present, otherwise insert
- if (_xNameContainer->hasByName( PropertyName ))
- _xNameContainer->replaceByName( PropertyName, aConv );
- else
- _xNameContainer->insertByName( PropertyName, aConv );
- }
- else
- throw UnknownPropertyException( "no introspection nor name container!" );
- }
- catch (UnknownPropertyException &)
- {
- throw;
- }
- catch (CannotConvertException &)
+ if (_xDirect.is())
{
- throw;
+ _xDirect->setValue( PropertyName, Value );
+ return;
}
- catch (InvocationTargetException &)
- {
+ }
+ catch (UnknownPropertyException &)
+ {
+ if (!mbFromOLE)
throw;
- }
- catch (RuntimeException &)
+ }
+ try
+ {
+ // Properties
+ if( _xIntrospectionAccess.is() && _xPropertySet.is()
+ && _xIntrospectionAccess->hasProperty(
+ PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
{
- throw;
+ 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( "no type converter service!" );
}
- catch (const Exception & exc)
+ // NameContainer
+ else if( _xNameContainer.is() )
{
- throw InvocationTargetException(
- "exception occurred in setValue(): " + exc.Message,
- Reference< XInterface >(), makeAny( exc /* though sliced */ ) );
+ // Note: This misfeature deliberately not adapted to apply to objects which
+ // have XNameReplace but not XNameContainer
+ 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( "no type converter service!" );
+
+ // Replace if present, otherwise insert
+ if (_xNameContainer->hasByName( PropertyName ))
+ _xNameContainer->replaceByName( PropertyName, aConv );
+ else
+ _xNameContainer->insertByName( PropertyName, aConv );
}
+ else
+ throw UnknownPropertyException( "no introspection nor name container!" );
+ }
+ catch (UnknownPropertyException &)
+ {
+ throw;
+ }
+ catch (CannotConvertException &)
+ {
+ throw;
+ }
+ catch (InvocationTargetException &)
+ {
+ throw;
+ }
+ catch (RuntimeException &)
+ {
+ throw;
+ }
+ catch (const Exception & exc)
+ {
+ throw InvocationTargetException(
+ "exception occurred in setValue(): " + exc.Message,
+ Reference< XInterface >(), makeAny( exc /* though sliced */ ) );
}
}