diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-02-06 09:59:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-02-06 11:57:45 +0000 |
commit | f8a1adaaa395a51e952e42ae61ff8af70741dd56 (patch) | |
tree | 90d68dc015f6e62d2d5463dd9768b19a6e3f5b46 /sfx2 | |
parent | b0bd6e9e6ed90a14224e30e9e93a6ddff00dbc5d (diff) |
coverity#1158398 Uncaught exception
Change-Id: I943b6233554d91e1a14f545e30f95528ca592924
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/frmload.cxx | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index d9be43c8622e..ddb17a1c4316 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -420,45 +420,51 @@ SfxObjectShellRef SfxFrameLoader_Impl::impl_findObjectShell( const Reference< XM // -------------------------------------------------------------------------------------------------------------------- bool SfxFrameLoader_Impl::impl_determineTemplateDocument( ::comphelper::NamedValueCollection& io_rDescriptor ) const { - const OUString sTemplateRegioName = io_rDescriptor.getOrDefault( "TemplateRegionName", OUString() ); - const OUString sTemplateName = io_rDescriptor.getOrDefault( "TemplateName", OUString() ); - const OUString sServiceName = io_rDescriptor.getOrDefault( "DocumentService", OUString() ); - const OUString sURL = io_rDescriptor.getOrDefault( "URL", OUString() ); - - // determine the full URL of the template to use, if any - OUString sTemplateURL; - if ( !sTemplateRegioName.isEmpty() && !sTemplateName.isEmpty() ) - { - SfxDocumentTemplates aTmpFac; - aTmpFac.GetFull( sTemplateRegioName, sTemplateName, sTemplateURL ); - } - else + try { - if ( !sServiceName.isEmpty() ) - sTemplateURL = SfxObjectFactory::GetStandardTemplate( sServiceName ); + const OUString sTemplateRegioName = io_rDescriptor.getOrDefault( "TemplateRegionName", OUString() ); + const OUString sTemplateName = io_rDescriptor.getOrDefault( "TemplateName", OUString() ); + const OUString sServiceName = io_rDescriptor.getOrDefault( "DocumentService", OUString() ); + const OUString sURL = io_rDescriptor.getOrDefault( "URL", OUString() ); + + // determine the full URL of the template to use, if any + OUString sTemplateURL; + if ( !sTemplateRegioName.isEmpty() && !sTemplateName.isEmpty() ) + { + SfxDocumentTemplates aTmpFac; + aTmpFac.GetFull( sTemplateRegioName, sTemplateName, sTemplateURL ); + } else - sTemplateURL = SfxObjectFactory::GetStandardTemplate( SfxObjectShell::GetServiceNameFromFactory( sURL ) ); - } + { + if ( !sServiceName.isEmpty() ) + sTemplateURL = SfxObjectFactory::GetStandardTemplate( sServiceName ); + else + sTemplateURL = SfxObjectFactory::GetStandardTemplate( SfxObjectShell::GetServiceNameFromFactory( sURL ) ); + } - if ( !sTemplateURL.isEmpty() ) - { - // detect the filter for the template. Might still be NULL (if the template is broken, or does not - // exist, or some such), but this is handled by our caller the same way as if no template/URL was present. - const SfxFilter* pTemplateFilter = impl_detectFilterForURL( sTemplateURL, io_rDescriptor, SFX_APP()->GetFilterMatcher() ); - if ( pTemplateFilter ) + if ( !sTemplateURL.isEmpty() ) { - // load the template document, but, well, "as template" - io_rDescriptor.put( "FilterName", OUString( pTemplateFilter->GetName() ) ); - io_rDescriptor.put( "FileName", OUString( sTemplateURL ) ); - io_rDescriptor.put( "AsTemplate", sal_True ); - - // #i21583# - // the DocumentService property will finally be used to create the document. Thus, override any possibly - // present value with the document service of the template. - io_rDescriptor.put( "DocumentService", OUString( pTemplateFilter->GetServiceName() ) ); - return true; + // detect the filter for the template. Might still be NULL (if the template is broken, or does not + // exist, or some such), but this is handled by our caller the same way as if no template/URL was present. + const SfxFilter* pTemplateFilter = impl_detectFilterForURL( sTemplateURL, io_rDescriptor, SFX_APP()->GetFilterMatcher() ); + if ( pTemplateFilter ) + { + // load the template document, but, well, "as template" + io_rDescriptor.put( "FilterName", OUString( pTemplateFilter->GetName() ) ); + io_rDescriptor.put( "FileName", OUString( sTemplateURL ) ); + io_rDescriptor.put( "AsTemplate", sal_True ); + + // #i21583# + // the DocumentService property will finally be used to create the document. Thus, override any possibly + // present value with the document service of the template. + io_rDescriptor.put( "DocumentService", OUString( pTemplateFilter->GetServiceName() ) ); + return true; + } } } + catch (...) + { + } return false; } |