Kaydet (Commit) 3ec25899 authored tarafından Michael Stahl's avatar Michael Stahl

sw: fix temp file leak in SwIoSystem::GetFileFilter()

Change-Id: Id483d58a9de27a247880aedfe6bb3fe1d410129c
üst 3b6ee586
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
/** Detect for the given file which filter should be used. The filter name /** Detect for the given file which filter should be used. The filter name
is returned. If no filter could be found, the name of the ASCII filter is returned. If no filter could be found, the name of the ASCII filter
is returned! */ is returned! */
static const SfxFilter* GetFileFilter( const OUString& rFileName, const OUString& rPrefFltName, SfxMedium* pMedium = 0 ); static const SfxFilter* GetFileFilter(const OUString& rFileName);
static bool IsValidStgFilter( SotStorage& , const SfxFilter& ); static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
static bool IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter); static bool IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter);
......
...@@ -198,9 +198,7 @@ void TerminateBuffer(sal_Char *pBuffer, sal_uLong nBytesRead, sal_uLong nBufferL ...@@ -198,9 +198,7 @@ void TerminateBuffer(sal_Char *pBuffer, sal_uLong nBytesRead, sal_uLong nBufferL
// Check the type of the stream (file) by searching for corresponding set of bytes. // Check the type of the stream (file) by searching for corresponding set of bytes.
// If no known type is found, return ASCII for now! // If no known type is found, return ASCII for now!
// Returns the internal FilterName. // Returns the internal FilterName.
// rPrefFltName is the internal FilterName that was chosen by the user in the Open Dlg. const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName)
const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName,
const OUString& rPrefFltName, SfxMedium* pMedium)
{ {
SfxFilterContainer aCntSw( OUString(sSWRITER) ); SfxFilterContainer aCntSw( OUString(sSWRITER) );
SfxFilterContainer aCntSwWeb( OUString(sSWRITERWEB) ); SfxFilterContainer aCntSwWeb( OUString(sSWRITERWEB) );
...@@ -212,21 +210,20 @@ const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName, ...@@ -212,21 +210,20 @@ const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName,
if ( !pFilter ) if ( !pFilter )
return 0; return 0;
if( pMedium ? ( pMedium->IsStorage() || SotStorage::IsStorageFile( pMedium->GetInStream() ) ) : SotStorage::IsStorageFile( rFileName ) ) ::boost::scoped_ptr<SfxMedium> pMedium;
if (SotStorage::IsStorageFile(rFileName))
{ {
// package storage or OLEStorage based format // package storage or OLEStorage based format
SotStorageRef xStg; SotStorageRef xStg;
if (!pMedium )
{
INetURLObject aObj; INetURLObject aObj;
aObj.SetSmartProtocol( INET_PROT_FILE ); aObj.SetSmartProtocol( INET_PROT_FILE );
aObj.SetSmartURL( rFileName ); aObj.SetSmartURL( rFileName );
pMedium = new SfxMedium( aObj.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READ ); pMedium.reset(new SfxMedium(aObj.GetMainURL(INetURLObject::NO_DECODE), STREAM_STD_READ));
}
// templates should not get precedence over "normal" filters (#i35508, #i33168) // templates should not get precedence over "normal" filters (#i35508, #i33168)
const SfxFilter* pTemplateFilter = 0; const SfxFilter* pTemplateFilter = 0;
const SfxFilter* pOldFilter = pFCntnr->GetFilter4FilterName( rPrefFltName ); const SfxFilter* pOldFilter = pFCntnr->GetFilter4FilterName("");
assert(!pOldFilter);
bool bLookForTemplate = pOldFilter && pOldFilter->IsOwnTemplateFormat(); bool bLookForTemplate = pOldFilter && pOldFilter->IsOwnTemplateFormat();
if ( pMedium->IsStorage() ) if ( pMedium->IsStorage() )
{ {
......
...@@ -867,7 +867,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, ...@@ -867,7 +867,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
if( bMergeShell || !pSourceDocSh->IsModified() ) if( bMergeShell || !pSourceDocSh->IsModified() )
{ {
const SfxFilter* pStoreToFilter = SwIoSystem::GetFileFilter( const SfxFilter* pStoreToFilter = SwIoSystem::GetFileFilter(
pSourceDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), ::aEmptyOUStr ); pSourceDocSh->GetMedium()->GetURLObject().GetMainURL(INetURLObject::NO_DECODE));
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer(); SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
const OUString* pStoreToFilterOptions = 0; const OUString* pStoreToFilterOptions = 0;
......
...@@ -2570,8 +2570,7 @@ bool SwTransferable::_PasteFileName( TransferableDataHelper& rData, ...@@ -2570,8 +2570,7 @@ bool SwTransferable::_PasteFileName( TransferableDataHelper& rData,
//Own FileFormat? --> insert, not for StarWriter/Web //Own FileFormat? --> insert, not for StarWriter/Web
OUString sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link(), false ); OUString sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link(), false );
const SfxFilter* pFlt = SW_PASTESDR_SETATTR == nAction const SfxFilter* pFlt = SW_PASTESDR_SETATTR == nAction
? 0 : SwIoSystem::GetFileFilter( ? 0 : SwIoSystem::GetFileFilter(sFileURL);
sFileURL, aEmptyOUStr );
if( pFlt && !rSh.GetView().GetDocShell()->ISA(SwWebDocShell) ) if( pFlt && !rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
{ {
// and then pull up the insert-region-dialog by PostUser event // and then pull up the insert-region-dialog by PostUser event
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment