From cba921ea0b293acc4b4e64f043f2e56d3e4cb15b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 31 Oct 2012 18:24:23 +0100 Subject: [PATCH] Work around new calls to GetFilter()->GetMimeType() on null filter ...introduced with 75bc673b60d3eb40713868ce3d1b4f62dd6e1208 "Travelled MIME type through UCB for CMIS UCP to use it when creating documents" and causing crashes in sc_unoapi test. Many SfxMedium instances appear to have a null filter, so this workaround at least fixes the crashes. No idea what a good fix should look like, so will ask Cedric to review his commit. Change-Id: I27180265b6c79c7ed5f459b03c9e188ff6a0f56d --- sfx2/source/doc/docfile.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index b36a44155b79..9be89f51114a 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -314,6 +314,9 @@ public: SfxMedium_Impl( SfxMedium* pAntiImplP ); ~SfxMedium_Impl(); + + OUString getFilterMimeType() + { return m_pFilter == 0 ? OUString() : m_pFilter->GetMimeType(); } }; //------------------------------------------------------------------ @@ -2006,7 +2009,7 @@ void SfxMedium::Transfer_Impl() try { - rtl::OUString aMimeType = GetFilter()->GetMimeType( ); + rtl::OUString aMimeType = pImp->getFilterMimeType(); ::ucbhelper::InsertOperation eOperation = ::ucbhelper::InsertOperation_COPY; bool bMajor = false; rtl::OUString sComment; @@ -2087,7 +2090,7 @@ void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalCont { try { - rtl::OUString sMimeType = GetFilter()->GetMimeType( ); + rtl::OUString sMimeType = pImp->getFilterMimeType(); if( aBackupCont.transferContent( aOriginalContent, ::ucbhelper::InsertOperation_COPY, aBackupName, @@ -2175,7 +2178,7 @@ void SfxMedium::DoBackup_Impl() try { // do the transfer ( copy source file to backup dir ) - rtl::OUString sMimeType = GetFilter()->GetMimeType( ); + rtl::OUString sMimeType = pImp->getFilterMimeType(); bSuccess = aContent.transferContent( aSourceContent, ::ucbhelper::InsertOperation_COPY, aFileName, @@ -3307,7 +3310,7 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace ) if ( !aFileName.isEmpty() && aTmpURLObj.removeSegment() ) { ::ucbhelper::Content aTargetContent( aTmpURLObj.GetMainURL( INetURLObject::NO_DECODE ), xComEnv, comphelper::getProcessComponentContext() ); - rtl::OUString sMimeType = GetFilter()->GetMimeType( ); + rtl::OUString sMimeType = pImp->getFilterMimeType(); if ( aTargetContent.transferContent( pImp->aContent, ::ucbhelper::InsertOperation_COPY, aFileName, NameClash::OVERWRITE, sMimeType ) ) { SetWritableForUserOnly( aTmpURL );