Work around new calls to GetFilter()->GetMimeType() on null filter

...introduced with 75bc673b60 "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
This commit is contained in:
Stephan Bergmann
2012-10-31 18:24:23 +01:00
parent c936fcb0f3
commit cba921ea0b

View File

@@ -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 );