fdo#54609: 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
This commit is contained in:
parent
a7805f85ad
commit
0f0bd022b6
1 changed files with 14 additions and 7 deletions
|
@ -68,7 +68,7 @@ Reference< XInterface > SAL_CALL DocumentPropertiesImport_createInstance( const
|
||||||
|
|
||||||
namespace {
|
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< XRelationshipAccess > xRelation( rxStorage, UNO_QUERY_THROW );
|
||||||
Reference< XHierarchicalStorageAccess > xHierarchy( rxStorage, UNO_QUERY_THROW );
|
Reference< XHierarchicalStorageAccess > xHierarchy( rxStorage, UNO_QUERY_THROW );
|
||||||
|
@ -138,19 +138,26 @@ void SAL_CALL DocumentPropertiesImport::importProperties(
|
||||||
const Reference< XStorage >& rxSource, const Reference< XDocumentProperties >& rxDocumentProperties )
|
const Reference< XStorage >& rxSource, const Reference< XDocumentProperties >& rxDocumentProperties )
|
||||||
throw (RuntimeException, IllegalArgumentException, SAXException, Exception)
|
throw (RuntimeException, IllegalArgumentException, SAXException, Exception)
|
||||||
{
|
{
|
||||||
|
Sequence< InputSource > aCoreStreams;
|
||||||
|
Sequence< InputSource > aExtStreams;
|
||||||
|
Sequence< InputSource > aCustomStreams;
|
||||||
|
|
||||||
if( !mxContext.is() )
|
if( !mxContext.is() )
|
||||||
throw RuntimeException();
|
throw RuntimeException();
|
||||||
|
|
||||||
if( !rxSource.is() || !rxDocumentProperties.is() )
|
if( !rxSource.is() || !rxDocumentProperties.is() )
|
||||||
throw IllegalArgumentException();
|
throw IllegalArgumentException();
|
||||||
|
|
||||||
Sequence< InputSource > aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "metadata/core-properties" ) );
|
try {
|
||||||
// MS Office seems to have a bug, so we have to do similar handling
|
aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "metadata/core-properties" ) );
|
||||||
if( !aCoreStreams.hasElements() )
|
// MS Office seems to have a bug, so we have to do similar handling
|
||||||
aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_PACKAGE_RELATION_TYPE( "metadata/core-properties" ) );
|
if( !aCoreStreams.hasElements() )
|
||||||
|
aCoreStreams = lclGetRelatedStreams( rxSource, CREATE_PACKAGE_RELATION_TYPE( "metadata/core-properties" ) );
|
||||||
|
|
||||||
Sequence< InputSource > aExtStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "extended-properties" ) );
|
aExtStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "extended-properties" ) );
|
||||||
Sequence< InputSource > aCustomStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "custom-properties" ) );
|
aCustomStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE( "custom-properties" ) );
|
||||||
|
}
|
||||||
|
catch(Exception) { }
|
||||||
|
|
||||||
if( aCoreStreams.hasElements() || aExtStreams.hasElements() || aCustomStreams.hasElements() )
|
if( aCoreStreams.hasElements() || aExtStreams.hasElements() || aCustomStreams.hasElements() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue