summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-11 06:43:06 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-11 06:38:15 +0000
commite94d5233dd7939c54eb52fff456e817cecdf0a4c (patch)
tree24acd3465e88b1a2a26246272a41236edfbe9b21 /sw
parentfb827f2a342602f7e62dbdebb638326193315eb6 (diff)
work on sane lifecylce for SfxFilter
all SfxFilter instances should now be hold inside of a std::shared_ptr. This fixes a number of huge memory leaks in the test framework and removes one huge source of memory issue in sfx2. SfxMedium contains a pointer to the SfxFilter but does not own. Therefore it is required that any SfxFilter belonging to a SfxMedium lives longer. However this seems to work mostly by hoping that all SfxFilter instances are stored in a global array. As we have seen with the tests this is not true (there are also some cases inside of sd that seem to not follow that pattern as well). Change-Id: I12fd04a504cc4efc0a94967abd91c6fe2c6a8ce8 Reviewed-on: https://gerrit.libreoffice.org/23140 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/dbmgr.hxx6
-rw-r--r--sw/inc/iodetect.hxx4
-rw-r--r--sw/qa/core/filters-test.cxx12
-rw-r--r--sw/qa/core/uwriter.cxx6
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx12
-rw-r--r--sw/source/core/doc/docglbl.cxx2
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx4
-rw-r--r--sw/source/filter/basflt/iodetect.cxx10
-rw-r--r--sw/source/ui/config/optcomp.cxx2
-rw-r--r--sw/source/ui/dbui/mmdocselectpage.cxx2
-rw-r--r--sw/source/ui/dbui/mmlayoutpage.cxx2
-rw-r--r--sw/source/ui/dbui/mmoutputpage.cxx8
-rw-r--r--sw/source/ui/misc/glossary.cxx2
-rw-r--r--sw/source/uibase/app/docsh.cxx6
-rw-r--r--sw/source/uibase/app/docsh2.cxx20
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx12
-rw-r--r--sw/source/uibase/dochdl/gloshdl.cxx4
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx2
-rw-r--r--sw/source/uibase/uiview/srcview.cxx4
-rw-r--r--sw/source/uibase/uiview/view2.cxx4
-rw-r--r--sw/source/uibase/uno/unomailmerge.cxx2
21 files changed, 63 insertions, 63 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 7c58b8a20e57..fff831adb8a6 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -245,7 +245,7 @@ friend class SwConnectionDisposedListener_Impl;
SAL_DLLPRIVATE bool CreateNewTemp(OUString &sPath, const OUString &sAddress,
std::unique_ptr< utl::TempFile > &aTempFile,
- const SwMergeDescriptor& rMergeDescriptor, const SfxFilter* pStoreToFilter);
+ const SwMergeDescriptor& rMergeDescriptor, std::shared_ptr<const SfxFilter> pStoreToFilter);
SAL_DLLPRIVATE bool CreateTargetDocShell(sal_Int32 nMaxDumpDocs, bool bMergeShell, vcl::Window *pSourceWindow,
@@ -261,7 +261,7 @@ friend class SwConnectionDisposedListener_Impl;
SAL_DLLPRIVATE void UpdateExpFields(SwWrtShell& rWorkShell, SfxObjectShellLock xWorkDocSh);
- SAL_DLLPRIVATE void CreateStoreToFilter(const SfxFilter *&pStoreToFilter, const OUString *&pStoreToFilterOptions,
+ SAL_DLLPRIVATE void CreateStoreToFilter(std::shared_ptr<const SfxFilter>& pStoreToFilter, const OUString *&pStoreToFilterOptions,
SwDocShell *pSourceDocSh, bool bEMail, const SwMergeDescriptor &rMergeDescriptor);
SAL_DLLPRIVATE void MergeSingleFiles(SwDoc *pWorkDoc, SwWrtShell &rWorkShell, SwWrtShell *pTargetShell, SwDoc *pTargetDoc,
@@ -282,7 +282,7 @@ friend class SwConnectionDisposedListener_Impl;
SAL_DLLPRIVATE bool SavePrintDoc(SfxObjectShellRef xTargetDocShell, SwView *pTargetView,
const SwMergeDescriptor &rMergeDescriptor,
std::unique_ptr< utl::TempFile > &aTempFile,
- const SfxFilter *&pStoreToFilter, const OUString *&pStoreToFilterOptions,
+ std::shared_ptr<const SfxFilter>& pStoreToFilter, const OUString *&pStoreToFilterOptions,
const bool bMergeShell, bool bCreateSingleFile, const bool bPrinter);
SAL_DLLPRIVATE void SetPrinterOptions(const SwMergeDescriptor &rMergeDescriptor,
diff --git a/sw/inc/iodetect.hxx b/sw/inc/iodetect.hxx
index 4e6614ebce43..6e0bdb7369e3 100644
--- a/sw/inc/iodetect.hxx
+++ b/sw/inc/iodetect.hxx
@@ -83,14 +83,14 @@ class SwIoSystem
{
public:
/// find for an internal format name the corresponding filter entry
- SW_DLLPUBLIC static const SfxFilter*
+ SW_DLLPUBLIC static std::shared_ptr<const SfxFilter>
GetFilterOfFormat( const OUString& rFormat,
const SfxFilterContainer* pCnt = nullptr );
/** 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! */
- static const SfxFilter* GetFileFilter(const OUString& rFileName);
+ static std::shared_ptr<const SfxFilter> GetFileFilter(const OUString& rFileName);
static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
static bool IsValidStgFilter( const css::uno::Reference < css::embed::XStorage >& rStg, const SfxFilter& rFilter);
diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx
index be2e774e712c..e8ddc2a0ab90 100644
--- a/sw/qa/core/filters-test.cxx
+++ b/sw/qa/core/filters-test.cxx
@@ -80,20 +80,20 @@ bool SwFiltersTest::filter(const OUString &rFilter, const OUString &rURL,
const OUString &rUserData, SfxFilterFlags nFilterFlags,
SotClipboardFormatId nClipboardID, unsigned int nFilterVersion, bool bExport)
{
- SfxFilter* pFilter = new SfxFilter(
+ std::shared_ptr<const SfxFilter> pFilter(new SfxFilter(
rFilter, OUString(), nFilterFlags,
nClipboardID, OUString(), 0, OUString(),
- rUserData, OUString());
- pFilter->SetVersion(nFilterVersion);
+ rUserData, OUString()));
+ const_cast<SfxFilter*>(pFilter.get())->SetVersion(nFilterVersion);
SwDocShellRef xDocShRef = new SwDocShell;
SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
- const SfxFilter* pImportFilter = nullptr;
- SfxFilter* pExportFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pImportFilter;
+ std::shared_ptr<const SfxFilter> pExportFilter;
if (bExport)
{
- SfxGetpApp()->GetFilterMatcher().GuessFilter(*pSrcMed, &pImportFilter, SfxFilterFlags::IMPORT, SfxFilterFlags::NONE);
+ SfxGetpApp()->GetFilterMatcher().GuessFilter(*pSrcMed, pImportFilter, SfxFilterFlags::IMPORT, SfxFilterFlags::NONE);
pExportFilter = pFilter;
}
else
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 1e08262cded2..d616eb021a0e 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -185,11 +185,11 @@ void SwDocTest::testFileNameFields()
OUString sFileURL = aTempFileURL.GetMainURL(INetURLObject::NO_DECODE);
SfxMedium aDstMed(sFileURL, STREAM_STD_READWRITE);
- SfxFilter aFilter(
+ std::shared_ptr<SfxFilter> pFilter(new SfxFilter(
OUString("Text"),
OUString(), SfxFilterFlags::NONE, SotClipboardFormatId::NONE, OUString(), 0, OUString(),
- OUString("TEXT"), OUString() );
- aDstMed.SetFilter(&aFilter);
+ OUString("TEXT"), OUString() ));
+ aDstMed.SetFilter(pFilter);
m_xDocShRef->DoSaveAs(aDstMed);
m_xDocShRef->DoSaveCompleted(&aDstMed);
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 77e8069d3c5e..d80cacb96287 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1710,16 +1710,16 @@ void SwUiWriterTest::testTdf78742()
OUString path = m_directories.getURLFromSrc(DATA_DIRECTORY) + "calc-data-source.ods";
SfxMedium aMedium(path, StreamMode::READ | StreamMode::SHARE_DENYWRITE);
SfxFilterMatcher aMatcher(OUString("com.sun.star.text.TextDocument"));
- const SfxFilter* pFilter = nullptr;
- sal_uInt32 filter = aMatcher.DetectFilter(aMedium, &pFilter);
+ std::shared_ptr<const SfxFilter> pFilter;
+ sal_uInt32 filter = aMatcher.DetectFilter(aMedium, pFilter);
CPPUNIT_ASSERT_EQUAL(ERRCODE_IO_ABORT, filter);
//it should not return any Filter
CPPUNIT_ASSERT(!pFilter);
//testing without service type and any .ods file
SfxMedium aMedium2(path, StreamMode::READ | StreamMode::SHARE_DENYWRITE);
SfxFilterMatcher aMatcher2;
- const SfxFilter* pFilter2 = nullptr;
- sal_uInt32 filter2 = aMatcher2.DetectFilter(aMedium2, &pFilter2);
+ std::shared_ptr<const SfxFilter> pFilter2;
+ sal_uInt32 filter2 = aMatcher2.DetectFilter(aMedium2, pFilter2);
CPPUNIT_ASSERT_EQUAL(ERRCODE_CLASS_NONE, filter2);
//Filter should be returned with proper Name
CPPUNIT_ASSERT_EQUAL(OUString("calc8"), pFilter2->GetFilterName());
@@ -1727,8 +1727,8 @@ void SwUiWriterTest::testTdf78742()
OUString path2 = m_directories.getURLFromSrc(DATA_DIRECTORY) + "fdo69893.odt";
SfxMedium aMedium3(path2, StreamMode::READ | StreamMode::SHARE_DENYWRITE);
SfxFilterMatcher aMatcher3(OUString("com.sun.star.text.TextDocument"));
- const SfxFilter* pFilter3 = nullptr;
- sal_uInt32 filter3 = aMatcher3.DetectFilter(aMedium3, &pFilter3);
+ std::shared_ptr<const SfxFilter> pFilter3;
+ sal_uInt32 filter3 = aMatcher3.DetectFilter(aMedium3, pFilter3);
CPPUNIT_ASSERT_EQUAL(ERRCODE_CLASS_NONE, filter3);
//Filter should be returned with proper Name
CPPUNIT_ASSERT_EQUAL(OUString("writer8"), pFilter3->GetFilterName());
diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx
index 623883dd3c9b..6e3c911e0742 100644
--- a/sw/source/core/doc/docglbl.cxx
+++ b/sw/source/core/doc/docglbl.cxx
@@ -198,7 +198,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline,
}
}
- const SfxFilter* pFilter;
+ std::shared_ptr<const SfxFilter> pFilter;
switch( eDocType )
{
case SPLITDOC_TO_HTML:
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 0bd244589e2f..c2f4edd41b57 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -983,7 +983,7 @@ void InsertFile(SwUnoCursor* pUnoCursor, const OUString& rURL,
return;
SfxObjectFactory& rFact = pDocSh->GetFactory();
- const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( sFilterName );
+ std::shared_ptr<const SfxFilter> pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( sFilterName );
uno::Reference < embed::XStorage > xReadStorage;
if( xInputStream.is() )
{
@@ -1015,7 +1015,7 @@ void InsertFile(SwUnoCursor* pUnoCursor, const OUString& rURL,
pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
- ErrCode nErr = aMatcher.GuessFilter(*pMed, &pFilter, SfxFilterFlags::NONE);
+ ErrCode nErr = aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE);
if ( nErr || !pFilter)
return;
pMed->SetFilter( pFilter );
diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx
index ac2752d8adfc..2ac92f7c8a62 100644
--- a/sw/source/filter/basflt/iodetect.cxx
+++ b/sw/source/filter/basflt/iodetect.cxx
@@ -60,7 +60,7 @@ const OUString SwIoSystem::GetSubStorageName( const SfxFilter& rFltr )
return OUString();
}
-const SfxFilter* SwIoSystem::GetFilterOfFormat(const OUString& rFormatNm,
+std::shared_ptr<const SfxFilter> SwIoSystem::GetFilterOfFormat(const OUString& rFormatNm,
const SfxFilterContainer* pCnt)
{
SfxFilterContainer aCntSw( OUString(sSWRITER) );
@@ -72,7 +72,7 @@ const SfxFilter* SwIoSystem::GetFilterOfFormat(const OUString& rFormatNm,
{
SfxFilterMatcher aMatcher( pFltCnt->GetName() );
SfxFilterMatcherIter aIter( aMatcher );
- const SfxFilter* pFilter = aIter.First();
+ std::shared_ptr<const SfxFilter> pFilter = aIter.First();
while ( pFilter )
{
if( pFilter->GetUserData().equals(rFormatNm) )
@@ -141,7 +141,7 @@ bool SwIoSystem::IsValidStgFilter(SotStorage& rStg, const SfxFilter& rFilter)
// Check the type of the stream (file) by searching for corresponding set of bytes.
// If no known type is found, return ASCII for now!
// Returns the internal FilterName.
-const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName)
+std::shared_ptr<const SfxFilter> SwIoSystem::GetFileFilter(const OUString& rFileName)
{
SfxFilterContainer aCntSw( OUString(sSWRITER) );
SfxFilterContainer aCntSwWeb( OUString(sSWRITERWEB) );
@@ -149,7 +149,7 @@ const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName)
SfxFilterMatcher aMatcher( pFCntnr->GetName() );
SfxFilterMatcherIter aIter( aMatcher );
- const SfxFilter* pFilter = aIter.First();
+ std::shared_ptr<const SfxFilter> pFilter = aIter.First();
if ( !pFilter )
return nullptr;
@@ -163,7 +163,7 @@ const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName)
SfxMedium aMedium(aObj.GetMainURL(INetURLObject::NO_DECODE), STREAM_STD_READ);
// templates should not get precedence over "normal" filters (#i35508, #i33168)
- const SfxFilter* pTemplateFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pTemplateFilter;
if (aMedium.IsStorage())
{
uno::Reference<embed::XStorage> const xStor = aMedium.GetStorage();
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index c3963c3e93a0..04252c9b5182 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -285,7 +285,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
else if ( pObjShell && !sName.isEmpty() )
{
SfxFilterContainer* pFacCont = pObjShell->GetFactory().GetFilterContainer();
- const SfxFilter* pFilter = pFacCont->GetFilter4FilterName( sName );
+ std::shared_ptr<const SfxFilter> pFilter = pFacCont->GetFilter4FilterName( sName );
if ( pFilter )
sNewEntry = pFilter->GetUIName();
}
diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx b/sw/source/ui/dbui/mmdocselectpage.cxx
index 2617a0cf61ee..31232e600652 100644
--- a/sw/source/ui/dbui/mmdocselectpage.cxx
+++ b/sw/source/ui/dbui/mmdocselectpage.cxx
@@ -144,7 +144,7 @@ IMPL_LINK_TYPED(SwMailMergeDocSelectPage, FileSelectHdl, Button*, pButton, void)
SfxFilterMatcher aMatcher( OUString::createFromAscii(rFact.GetShortName()) );
SfxFilterMatcherIter aIter( aMatcher );
Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
- const SfxFilter* pFlt = aIter.First();
+ std::shared_ptr<const SfxFilter> pFlt = aIter.First();
while( pFlt )
{
if( pFlt && pFlt->IsAllowedAsTemplate() )
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 06446f3dcdb2..b93a3afc486a 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -96,7 +96,7 @@ SwMailMergeLayoutPage::SwMailMergeLayoutPage( SwMailMergeWizard* _pParent) :
m_pExampleContainerWIN->set_height_request(aSize.Height());
get(m_pZoomLB, "zoom");
- const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ std::shared_ptr<const SfxFilter> pSfxFlt = SwIoSystem::GetFilterOfFormat(
FILTER_XML,
SwDocShell::Factory().GetFilterContainer() );
//save the current document into a temporary file
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx
index 45e844de2e9c..d56e41e24c8a 100644
--- a/sw/source/ui/dbui/mmoutputpage.cxx
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -695,7 +695,7 @@ IMPL_LINK_TYPED(SwMailMergeOutputPage, SaveOutputHdl_Impl, Button*, pButton, voi
OUString sTargetTempURL = URIHelper::SmartRel2Abs(
INetURLObject(), utl::TempFile::CreateTempName(),
URIHelper::GetMaybeFileHdl());
- const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ std::shared_ptr<const SfxFilter> pSfxFlt = SwIoSystem::GetFilterOfFormat(
FILTER_XML,
SwDocShell::Factory().GetFilterContainer() );
@@ -998,7 +998,7 @@ IMPL_LINK_TYPED(SwMailMergeOutputPage, SendDocumentsHdl_Impl, Button*, pButton,
bool bAsBody = false;
rtl_TextEncoding eEncoding = ::osl_getThreadTextEncoding();
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
- const SfxFilter *pSfxFlt = nullptr;
+ std::shared_ptr<const SfxFilter> pSfxFlt;
sal_uLong nDocType = reinterpret_cast<sal_uLong>(m_pSendAsLB->GetSelectEntryData());
OUString sExtension = lcl_GetExtensionForDocType(nDocType);
switch( nDocType )
@@ -1025,7 +1025,7 @@ IMPL_LINK_TYPED(SwMailMergeOutputPage, SendDocumentsHdl_Impl, Button*, pButton,
//because it uses the same user data :-(
SfxFilterMatcher aMatcher( pFilterContainer->GetName() );
SfxFilterMatcherIter aIter( aMatcher );
- const SfxFilter* pFilter = aIter.First();
+ std::shared_ptr<const SfxFilter> pFilter = aIter.First();
while ( pFilter )
{
if( pFilter->GetUserData() == FILTER_WW8 && pFilter->CanExport() )
@@ -1117,7 +1117,7 @@ IMPL_LINK_TYPED(SwMailMergeOutputPage, SendDocumentsHdl_Impl, Button*, pButton,
OUString sTargetTempURL = URIHelper::SmartRel2Abs(
INetURLObject(), utl::TempFile::CreateTempName(),
URIHelper::GetMaybeFileHdl());
- const SfxFilter *pTargetSfxFlt = SwIoSystem::GetFilterOfFormat(
+ std::shared_ptr<const SfxFilter> pTargetSfxFlt = SwIoSystem::GetFilterOfFormat(
FILTER_XML,
SwDocShell::Factory().GetFilterContainer() );
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index 2ce310ccaf3b..f2aa4a11616e 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -580,7 +580,7 @@ IMPL_LINK_TYPED( SwGlossaryDlg, MenuHdl, Menu *, pMn, bool )
uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
SfxFilterMatcher aMatcher( OUString::createFromAscii(SwDocShell::Factory().GetShortName()) );
SfxFilterMatcherIter aIter( aMatcher );
- const SfxFilter* pFilter = aIter.First();
+ std::shared_ptr<const SfxFilter> pFilter = aIter.First();
while ( pFilter )
{
if( pFilter->GetUserData() == FILTER_WW8 )
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index d46c60ea1ec6..7c097d88818b 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -170,7 +170,7 @@ Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
pMedSet->GetItemState( FN_API_CALL, true, &pApiItem ) )
bAPICall = static_cast<const SfxBoolItem*>(pApiItem)->GetValue();
- const SfxFilter* pFlt = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFlt = rMedium.GetFilter();
if( !pFlt )
{
if(!bAPICall)
@@ -399,7 +399,7 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium )
{
// Task 75666 - is the Document imported by our Microsoft-Filters?
- const SfxFilter* pOldFilter = GetMedium()->GetFilter();
+ std::shared_ptr<const SfxFilter> pOldFilter = GetMedium()->GetFilter();
if( pOldFilter &&
( pOldFilter->GetUserData() == FILTER_WW8 ||
pOldFilter->GetUserData() == "CWW6" ||
@@ -534,7 +534,7 @@ static SwSrcView* lcl_GetSourceView( SwDocShell* pSh )
bool SwDocShell::ConvertTo( SfxMedium& rMedium )
{
- const SfxFilter* pFlt = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFlt = rMedium.GetFilter();
if( !pFlt )
return false;
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 2127b1ed3531..80a03b7131d6 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -510,7 +510,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
SfxFilterMatcher aMatcher( OUString::createFromAscii(rFact.GetShortName()) );
SfxFilterMatcherIter aIter( aMatcher );
uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
- const SfxFilter* pFlt = aIter.First();
+ std::shared_ptr<const SfxFilter> pFlt = aIter.First();
while( pFlt )
{
// --> OD #i117339#
@@ -524,7 +524,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
pFlt = aIter.Next();
}
bool bWeb = dynamic_cast< SwWebDocShell *>( this ) != nullptr;
- const SfxFilter *pOwnFlt =
+ std::shared_ptr<const SfxFilter> pOwnFlt =
SwDocShell::Factory().GetFilterContainer()->
GetFilter4FilterName("writer8");
@@ -591,7 +591,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
// 1 - file unsaved -> save as HTML
// 2 - file modified and HTML filter active -> save
// 3 - file saved in non-HTML -> QueryBox to save as HTML
- const SfxFilter* pHtmlFlt =
+ std::shared_ptr<const SfxFilter> pHtmlFlt =
SwIoSystem::GetFilterOfFormat(
"HTML",
SwWebDocShell::Factory().GetFilterContainer() );
@@ -599,7 +599,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
if(bLocalHasName)
{
//check for filter type
- const SfxFilter* pFlt = GetMedium()->GetFilter();
+ std::shared_ptr<const SfxFilter> pFlt = GetMedium()->GetFilter();
if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData())
{
ScopedVclPtrInstance<MessageDialog> aQuery(&pViewFrame->GetWindow(),
@@ -915,7 +915,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
aDlgHelper.SetControlHelpIds( nControlIds, pHelpIds );
uno::Reference < XFilePicker2 > xFP = aDlgHelper.GetFilePicker();
- const SfxFilter* pFlt;
+ std::shared_ptr<const SfxFilter> pFlt;
sal_uInt16 nStrId;
if( bCreateHtml )
@@ -1393,13 +1393,13 @@ sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL,
// search for filter in WebDocShell, too
SfxMedium aMed( rURL, STREAM_STD_READ );
- const SfxFilter* pFlt = nullptr;
- aMatcher.DetectFilter( aMed, &pFlt );
+ std::shared_ptr<const SfxFilter> pFlt;
+ aMatcher.DetectFilter( aMed, pFlt );
if(!pFlt)
{
OUString sWebFactory(OUString::createFromAscii(SwWebDocShell::Factory().GetShortName()));
SfxFilterMatcher aWebMatcher( sWebFactory );
- aWebMatcher.DetectFilter( aMed, &pFlt );
+ aWebMatcher.DetectFilter( aMed, pFlt );
}
// --> OD #i117339# - trigger import only for own formats
bool bImport( false );
@@ -1550,7 +1550,7 @@ int SwFindDocShell( SfxObjectShellRef& xDocSh,
if( INetProtocol::File == aTmpObj.GetProtocol() )
xMed->Download(); // Touch the medium (download it)
- const SfxFilter* pSfxFlt = nullptr;
+ std::shared_ptr<const SfxFilter> pSfxFlt;
if (!xMed->GetError())
{
SfxFilterMatcher aMatcher( OUString::createFromAscii(SwDocShell::Factory().GetShortName()) );
@@ -1568,7 +1568,7 @@ int SwFindDocShell( SfxObjectShellRef& xDocSh,
xMed->GetItemSet()->Put( SfxStringItem( SID_PASSWORD, rPasswd ));
if( !pSfxFlt )
- aMatcher.DetectFilter( *xMed, &pSfxFlt );
+ aMatcher.DetectFilter( *xMed, pSfxFlt );
if( pSfxFlt )
{
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 3a400109a8ca..02a33ecdbf7f 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -990,7 +990,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
pSfxDispatcher->Execute( pSourceDocSh->HasName() ? SID_SAVEDOC : SID_SAVEASDOC, SfxCallMode::SYNCHRON|SfxCallMode::RECORD);
if( bMergeShell || !pSourceDocSh->IsModified() )
{
- const SfxFilter* pStoreToFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pStoreToFilter;
const OUString* pStoreToFilterOptions = nullptr;
CreateStoreToFilter(pStoreToFilter, pStoreToFilterOptions, pSourceDocSh, bEMail, rMergeDescriptor);
@@ -1327,7 +1327,7 @@ void SwDBManager::GetPathAddress(OUString &sPath, OUString &sAddress, uno::Refer
bool SwDBManager::CreateNewTemp(OUString &sPath, const OUString &sAddress,
std::unique_ptr< utl::TempFile > &aTempFile,
- const SwMergeDescriptor& rMergeDescriptor, const SfxFilter* pStoreToFilter)
+ const SwMergeDescriptor& rMergeDescriptor, std::shared_ptr<const SfxFilter> pStoreToFilter)
{
INetURLObject aEntry(sPath);
OUString sLeading;
@@ -1469,7 +1469,7 @@ void SwDBManager::UpdateExpFields(SwWrtShell& rWorkShell, SfxObjectShellLock xWo
}
}
-void SwDBManager::CreateStoreToFilter(const SfxFilter *&pStoreToFilter, const OUString *&pStoreToFilterOptions,
+void SwDBManager::CreateStoreToFilter(std::shared_ptr<const SfxFilter>& pStoreToFilter, const OUString *&pStoreToFilterOptions,
SwDocShell *pSourceDocSh, bool bEMail, const SwMergeDescriptor &rMergeDescriptor)
{
pStoreToFilter = SwIoSystem::GetFileFilter(
@@ -1484,7 +1484,7 @@ void SwDBManager::CreateStoreToFilter(const SfxFilter *&pStoreToFilter, const OU
}
else if( !rMergeDescriptor.sSaveToFilter.isEmpty())
{
- const SfxFilter* pFilter =
+ std::shared_ptr<const SfxFilter> pFilter =
pFilterContainer->GetFilter4FilterName( rMergeDescriptor.sSaveToFilter );
if(pFilter)
{
@@ -1618,7 +1618,7 @@ void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pW
bool SwDBManager::SavePrintDoc(SfxObjectShellRef xTargetDocShell, SwView *pTargetView, const SwMergeDescriptor &rMergeDescriptor,
std::unique_ptr< utl::TempFile > &aTempFile,
- const SfxFilter *&pStoreToFilter, const OUString *&pStoreToFilterOptions,
+ std::shared_ptr<const SfxFilter>& pStoreToFilter, const OUString *&pStoreToFilterOptions,
const bool bMergeShell, bool bCreateSingleFile, const bool bPrinter)
{
bool bNoError = true;
@@ -2965,7 +2965,7 @@ void SwDBManager::ExecuteFormLetter( SwWrtShell& rSh,
{
//copy rSh to aTempFile
OUString sTempURL;
- const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ std::shared_ptr<const SfxFilter> pSfxFlt = SwIoSystem::GetFilterOfFormat(
FILTER_XML,
SwDocShell::Factory().GetFilterContainer() );
try
diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx
index 159ef0c60c1f..581189b35aee 100644
--- a/sw/source/uibase/dochdl/gloshdl.cxx
+++ b/sw/source/uibase/dochdl/gloshdl.cxx
@@ -710,11 +710,11 @@ bool SwGlossaryHdl::ImportGlossaries( const OUString& rName )
bool bRet = false;
if( !rName.isEmpty() )
{
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
std::unique_ptr<SfxMedium> pMed(new SfxMedium( rName, StreamMode::READ, nullptr, nullptr ));
SfxFilterMatcher aMatcher( OUString("swriter") );
pMed->UseInteractionHandler( true );
- if (!aMatcher.GuessFilter(*pMed, &pFilter, SfxFilterFlags::NONE))
+ if (!aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE))
{
SwTextBlocks *pGlossary = nullptr;
pMed->SetFilter( pFilter );
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 5dc3dfd68b91..469080f4497a 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -2568,7 +2568,7 @@ bool SwTransferable::_PasteFileName( TransferableDataHelper& rData,
//Own FileFormat? --> insert, not for StarWriter/Web
OUString sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link<OUString *, bool>(), false );
- const SfxFilter* pFlt = SwPasteSdr::SetAttr == nAction
+ std::shared_ptr<const SfxFilter> pFlt = SwPasteSdr::SetAttr == nAction
? nullptr : SwIoSystem::GetFileFilter(sFileURL);
if( pFlt && dynamic_cast< const SwWebDocShell *>( rSh.GetView().GetDocShell() ) == nullptr )
{
diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx
index 60a45b663314..abc06dd5547c 100644
--- a/sw/source/uibase/uiview/srcview.cxx
+++ b/sw/source/uibase/uiview/srcview.cxx
@@ -304,7 +304,7 @@ void SwSrcView::Execute(SfxRequest& rReq)
// search for an html filter for export
SfxFilterContainer* pFilterCont = GetObjectShell()->GetFactory().GetFilterContainer();
- const SfxFilter* pFilter =
+ std::shared_ptr<const SfxFilter> pFilter =
pFilterCont->GetFilter4Extension( "html", SfxFilterFlags::EXPORT );
if ( pFilter )
{
@@ -796,7 +796,7 @@ void SwSrcView::Load(SwDocShell* pDocShell)
aEditWin->SetTextEncoding(eDestEnc);
SfxMedium* pMedium = pDocShell->GetMedium();
- const SfxFilter* pFilter = pMedium->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter();
bool bHtml = pFilter && pFilter->GetUserData() == "HTML";
bool bDocModified = pDocShell->IsModified();
if(bHtml && !bDocModified && pDocShell->HasName())
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index 61982672d601..6fb27c85ed73 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -2110,13 +2110,13 @@ long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUS
if( !rFileName.isEmpty() )
{
SfxObjectFactory& rFact = pDocSh->GetFactory();
- const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
+ std::shared_ptr<const SfxFilter> pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
if ( !pFilter )
{
pMed = new SfxMedium(rFileName, StreamMode::READ, nullptr, nullptr );
SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
pMed->UseInteractionHandler( true );
- ErrCode nErr = aMatcher.GuessFilter(*pMed, &pFilter, SfxFilterFlags::NONE);
+ ErrCode nErr = aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE);
if ( nErr )
DELETEZ(pMed);
else
diff --git a/sw/source/uibase/uno/unomailmerge.cxx b/sw/source/uibase/uno/unomailmerge.cxx
index dcfa83aee316..dcf1b39154d0 100644
--- a/sw/source/uibase/uno/unomailmerge.cxx
+++ b/sw/source/uibase/uno/unomailmerge.cxx
@@ -774,7 +774,7 @@ uno::Any SAL_CALL SwXMailMerge::execute(
}
// save document with temporary filename
- const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ std::shared_ptr<const SfxFilter> pSfxFlt = SwIoSystem::GetFilterOfFormat(
FILTER_XML,
SwDocShell::Factory().GetFilterContainer() );
OUString aExtension(comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(), '*'));