diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-04-24 22:36:40 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2018-05-31 15:29:44 +0300 |
commit | dee3ca5695927900a2fa33f43adc7357f85781b9 (patch) | |
tree | bb3a5a4a65dab92511e6323b6fa90f705e6ffcfc /stoc/source | |
parent | 5cc28c5e9455a7923153f82dcf18e76570e36717 (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/source')
-rw-r--r-- | stoc/source/invocation/invocation.cxx | 132 |
1 files changed, 70 insertions, 62 deletions
diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 68ea0ce3ccc3..5ffbb9cf586e 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -482,7 +482,7 @@ Any Invocation_Impl::getValue( const OUString& PropertyName ) if (_xDirect.is()) return _xDirect->getValue( PropertyName ); } - catch (RuntimeException &) + catch (UnknownPropertyException &) { if (!mbFromOLE) throw; @@ -518,75 +518,83 @@ 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() ) { - css::uno::Any anyEx = cppu::getCaughtException(); - throw InvocationTargetException( - "exception occurred in setValue(): " + exc.Message, - Reference< XInterface >(), anyEx ); + // 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) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw InvocationTargetException( + "exception occurred in setValue(): " + exc.Message, + Reference< XInterface >(), anyEx ); } } |