diff options
author | Muthu Subramanian <sumuthu@suse.com> | 2012-09-11 12:44:44 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-09-20 19:34:25 +0100 |
commit | 9b1ba36bce25cf5abd41835d5d4c156893e8eca6 (patch) | |
tree | e763a793d4f669ec87fcbe175ebdaa05fab95b72 | |
parent | 2fca05d5e4dee32feb6f9c9ba5f2c3792b72d5d1 (diff) |
fdo#54609, fdo#45366: Exception while importing xlsx.
* Handle any exception thrown during document properties
import. This is not so critical so as to stop the import.
We anyways check for hasElements().
* Also lclGetRelatedStreams might throw IllegalArgumentException
Change-Id: I5206ff1ab07f2853e6a20aebea3f892460b881ad
Signed-off-by: Kohei Yoshida <kohei.yoshida@gmail.com>
Signed-off-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Signed-off-by: Michael Meeks <michael.meeks@suse.com>
-rw-r--r-- | oox/source/docprop/ooxmldocpropimport.cxx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/oox/source/docprop/ooxmldocpropimport.cxx b/oox/source/docprop/ooxmldocpropimport.cxx index ef651734fc50..b80069e68515 100644 --- a/oox/source/docprop/ooxmldocpropimport.cxx +++ b/oox/source/docprop/ooxmldocpropimport.cxx @@ -77,7 +77,7 @@ Reference< XInterface > SAL_CALL DocumentPropertiesImport_createInstance( const namespace { -Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >& rxStorage, const OUString& rStreamType ) throw (RuntimeException) +Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >& rxStorage, const OUString& rStreamType ) throw (RuntimeException, IllegalArgumentException) { Reference< XRelationshipAccess > xRelation( rxStorage, UNO_QUERY_THROW ); Reference< XHierarchicalStorageAccess > xHierarchy( rxStorage, UNO_QUERY_THROW ); @@ -147,19 +147,27 @@ void SAL_CALL DocumentPropertiesImport::importProperties( const Reference< XStorage >& rxSource, const Reference< XDocumentProperties >& rxDocumentProperties ) throw (RuntimeException, IllegalArgumentException, SAXException, Exception) { + Sequence< InputSource > aCoreStreams; + Sequence< InputSource > aExtStreams; + Sequence< InputSource > aCustomStreams; + if( !mxContext.is() ) throw RuntimeException(); if( !rxSource.is() || !rxDocumentProperties.is() ) throw IllegalArgumentException(); - Sequence< InputSource > aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "metadata/core-properties" ) ); - // MS Office seems to have a bug, so we have to do similar handling - if( !aCoreStreams.hasElements() ) - aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_PACKAGE_RELATION_TYPE( "metadata/core-properties" ) ); + try + { + aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "metadata/core-properties" ) ); + // MS Office seems to have a bug, so we have to do similar handling + if( !aCoreStreams.hasElements() ) + aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_PACKAGE_RELATION_TYPE( "metadata/core-properties" ) ); - Sequence< InputSource > aExtStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "extended-properties" ) ); - Sequence< InputSource > aCustomStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "custom-properties" ) ); + aExtStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "extended-properties" ) ); + aCustomStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "custom-properties" ) ); + } + catch (const Exception&) {} if( aCoreStreams.hasElements() || aExtStreams.hasElements() || aCustomStreams.hasElements() ) { |