summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cui/source/dialogs/hldocntp.cxx2
-rw-r--r--cui/source/options/doclinkdialog.cxx2
-rw-r--r--dbaccess/source/ui/app/AppController.cxx4
-rw-r--r--dbaccess/source/ui/dlg/dbwizsetup.cxx2
-rw-r--r--dbaccess/source/ui/dlg/generalpage.cxx2
-rw-r--r--dbaccess/source/ui/inc/UITools.hxx4
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx4
-rw-r--r--desktop/source/app/dispatchwatcher.cxx12
-rw-r--r--extensions/source/abpilot/abpfinalpage.cxx6
-rw-r--r--extensions/source/dbpilots/commonpagesdbp.cxx2
-rw-r--r--extensions/source/propctrlr/formcomponenthandler.cxx2
-rw-r--r--filter/source/msfilter/msdffimp.cxx2
-rw-r--r--filter/source/msfilter/msoleexp.cxx2
-rw-r--r--include/sfx2/docfac.hxx2
-rw-r--r--include/sfx2/docfile.hxx13
-rw-r--r--include/sfx2/docfilt.hxx8
-rw-r--r--include/sfx2/fcontnr.hxx44
-rw-r--r--include/sfx2/filedlghelper.hxx4
-rw-r--r--include/vbahelper/vbaaccesshelper.hxx2
-rw-r--r--reportdesign/source/core/api/ReportEngineJFree.cxx2
-rw-r--r--reportdesign/source/ui/inspection/GeometryHandler.cxx2
-rw-r--r--sc/inc/tablink.hxx2
-rw-r--r--sc/qa/unit/helper/qahelper.cxx19
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx6
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx8
-rw-r--r--sc/source/ui/docshell/arealink.cxx2
-rw-r--r--sc/source/ui/docshell/docsh.cxx4
-rw-r--r--sc/source/ui/docshell/docsh4.cxx2
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx2
-rw-r--r--sc/source/ui/docshell/tablink.cxx12
-rw-r--r--sc/source/ui/miscdlgs/linkarea.cxx4
-rw-r--r--sc/source/ui/unoobj/scdetect.cxx2
-rw-r--r--sc/source/ui/view/viewfun4.cxx4
-rw-r--r--sd/qa/unit/filters-test.cxx8
-rw-r--r--sd/qa/unit/sdmodeltestbase.hxx19
-rw-r--r--sd/source/core/drawdoc3.cxx4
-rw-r--r--sd/source/filter/xml/sdxmlwrp.cxx2
-rw-r--r--sd/source/ui/dlg/navigatr.cxx4
-rw-r--r--sd/source/ui/docshell/docshel4.cxx6
-rw-r--r--sd/source/ui/func/fuinsfil.cxx10
-rw-r--r--sd/source/ui/unoidl/sddetect.cxx2
-rw-r--r--sd/source/ui/view/sdview4.cxx4
-rw-r--r--sfx2/inc/arrdecl.hxx3
-rw-r--r--sfx2/source/appl/appopen.cxx6
-rw-r--r--sfx2/source/appl/sfxpicklist.cxx2
-rw-r--r--sfx2/source/appl/shutdownicon.cxx2
-rw-r--r--sfx2/source/bastyp/fltfnc.cxx165
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx2
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx23
-rw-r--r--sfx2/source/dialog/filedlgimpl.hxx6
-rw-r--r--sfx2/source/dialog/filtergrouping.cxx16
-rw-r--r--sfx2/source/dialog/filtergrouping.hxx7
-rw-r--r--sfx2/source/doc/docfac.cxx7
-rw-r--r--sfx2/source/doc/docfile.cxx26
-rw-r--r--sfx2/source/doc/docfilt.cxx10
-rw-r--r--sfx2/source/doc/docinsert.cxx8
-rw-r--r--sfx2/source/doc/objcont.cxx2
-rw-r--r--sfx2/source/doc/objserv.cxx4
-rw-r--r--sfx2/source/doc/objstor.cxx22
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx10
-rw-r--r--sfx2/source/doc/templatedlg.cxx2
-rw-r--r--sfx2/source/view/frame.cxx2
-rw-r--r--sfx2/source/view/frmload.cxx18
-rw-r--r--sfx2/source/view/viewfrm.cxx6
-rw-r--r--sfx2/source/view/viewprn.cxx2
-rw-r--r--starmath/qa/extras/mmlimport-test.cxx6
-rw-r--r--starmath/source/document.cxx2
-rw-r--r--starmath/source/view.cxx4
-rw-r--r--svx/source/unodraw/unoshap2.cxx4
-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
90 files changed, 371 insertions, 371 deletions
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index e38b02ed0b43..ec6026ec9a02 100644
--- a/cui/source/dialogs/hldocntp.cxx
+++ b/cui/source/dialogs/hldocntp.cxx
@@ -197,7 +197,7 @@ void SvxHyperlinkNewDocTp::FillDocumentList ()
aDocumentUrl = "private:factory/simpress"; // the AutoPilot for impress
// insert private-url and default-extension as user-data
- const SfxFilter* pFilter = SfxFilter::GetDefaultFilterFromFactory( aDocumentUrl );
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetDefaultFilterFromFactory( aDocumentUrl );
if ( pFilter )
{
// insert doc-name and image
diff --git a/cui/source/options/doclinkdialog.cxx b/cui/source/options/doclinkdialog.cxx
index b22ca4b02b58..de5f1e8a522f 100644
--- a/cui/source/options/doclinkdialog.cxx
+++ b/cui/source/options/doclinkdialog.cxx
@@ -164,7 +164,7 @@ namespace svx
{
::sfx2::FileDialogHelper aFileDlg(
ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, 0);
- const SfxFilter* pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
if ( pFilter )
{
aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 55aa240a9997..60fac0fc5978 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -380,7 +380,7 @@ void SAL_CALL OApplicationController::disposing()
{
OUString aFilter;
INetURLObject aURL( m_xModel->getURL() );
- const SfxFilter* pFilter = getStandardDatabaseFilter();
+ std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
if ( pFilter )
aFilter = pFilter->GetFilterName();
@@ -1126,7 +1126,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa
0, getView());
aFileDlg.SetDisplayDirectory( sUrl );
- const SfxFilter* pFilter = getStandardDatabaseFilter();
+ std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
if ( pFilter )
{
aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 776fc9505a36..81e6e0660a87 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -796,7 +796,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument()
::sfx2::FileDialogHelper aFileDlg(
ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
0, this);
- const SfxFilter* pFilter = getStandardDatabaseFilter();
+ std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
if ( pFilter )
{
INetURLObject aWorkURL( m_sWorkPath );
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx
index 839fbff56855..bbf185e98395 100644
--- a/dbaccess/source/ui/dlg/generalpage.cxx
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -719,7 +719,7 @@ namespace dbaui
::sfx2::FileDialogHelper aFileDlg(
ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
0, OUString("sdatabase") );
- const SfxFilter* pFilter = getStandardDatabaseFilter();
+ std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
if ( pFilter )
{
aFileDlg.SetCurrentFilter(pFilter->GetUIName());
diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx
index b9a45cf42620..7964c794ac93 100644
--- a/dbaccess/source/ui/inc/UITools.hxx
+++ b/dbaccess/source/ui/inc/UITools.hxx
@@ -26,6 +26,8 @@
#include <vcl/taskpanelist.hxx>
#include <connectivity/dbtools.hxx>
+#include <memory>
+
#define RET_ALL 10
// we only need forward decl here
@@ -366,7 +368,7 @@ namespace dbaui
@retrun
the filter
*/
- const SfxFilter* getStandardDatabaseFilter();
+ std::shared_ptr<const SfxFilter> getStandardDatabaseFilter();
/** opens a save dialog to store a form or report folder in the current hierarchy.
@param _pParent
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 42353aa3de1a..fecce2bf7fb7 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -899,9 +899,9 @@ bool callColumnFormatDialog(vcl::Window* _pParent,
return bRet;
}
-const SfxFilter* getStandardDatabaseFilter()
+std::shared_ptr<const SfxFilter> getStandardDatabaseFilter()
{
- const SfxFilter* pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
return pFilter;
}
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 49dce8122441..3ba4e152c29a 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -88,7 +88,7 @@ struct DispatchHolder
namespace
{
-const SfxFilter* impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const rtl::OUString& rFactory )
+std::shared_ptr<const SfxFilter> impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const rtl::OUString& rFactory )
{
// create the list of filters
OUStringBuffer sQuery(256);
@@ -105,7 +105,7 @@ const SfxFilter* impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const
xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.document.FilterFactory", xContext ),
UNO_QUERY_THROW );
- const SfxFilter* pBestMatch = nullptr;
+ std::shared_ptr<const SfxFilter> pBestMatch;
const Reference< XEnumeration > xFilterEnum(
xFilterFactory->createSubSetEnumerationByQuery( sQuery.makeStringAndClear() ), UNO_QUERY_THROW );
@@ -115,7 +115,7 @@ const SfxFilter* impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const
const rtl::OUString aName( aFilterProps.getUnpackedValueOrDefault( "Name", rtl::OUString() ) );
if ( !aName.isEmpty() )
{
- const SfxFilter* const pFilter( SfxFilter::GetFilterByName( aName ) );
+ std::shared_ptr<const SfxFilter> pFilter( SfxFilter::GetFilterByName( aName ) );
if ( pFilter && pFilter->CanExport() && pFilter->GetWildcard().Matches( rUrl ) )
{
if ( !pBestMatch || ( SfxFilterFlags::PREFERED & pFilter->GetFilterFlags() ) )
@@ -127,7 +127,7 @@ const SfxFilter* impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const
return pBestMatch;
}
-static const SfxFilter* impl_getExportFilterFromUrl(
+static std::shared_ptr<const SfxFilter> impl_getExportFilterFromUrl(
const rtl::OUString& rUrl, const rtl::OUString& rFactory)
{
try
@@ -138,7 +138,7 @@ try
UNO_QUERY_THROW );
const rtl::OUString aTypeName( xTypeDetector->queryTypeByURL( rUrl ) );
- const SfxFilter* pFilter( SfxFilterMatcher( rFactory ).GetFilter4EA( aTypeName, SfxFilterFlags::EXPORT ) );
+ std::shared_ptr<const SfxFilter> pFilter( SfxFilterMatcher( rFactory ).GetFilter4EA( aTypeName, SfxFilterFlags::EXPORT ) );
if ( !pFilter )
pFilter = impl_lookupExportFilterForUrl( rUrl, rFactory );
if ( !pFilter )
@@ -161,7 +161,7 @@ catch ( const Exception& )
OUString impl_GuessFilter( const OUString& rUrlOut, const OUString& rDocService )
{
OUString aOutFilter;
- const SfxFilter* pOutFilter = impl_getExportFilterFromUrl( rUrlOut, rDocService );
+ std::shared_ptr<const SfxFilter> pOutFilter = impl_getExportFilterFromUrl( rUrlOut, rDocService );
if (pOutFilter)
aOutFilter = pOutFilter->GetFilterName();
diff --git a/extensions/source/abpilot/abpfinalpage.cxx b/extensions/source/abpilot/abpfinalpage.cxx
index d51c35678aff..9c2e48ef6131 100644
--- a/extensions/source/abpilot/abpfinalpage.cxx
+++ b/extensions/source/abpilot/abpfinalpage.cxx
@@ -35,9 +35,9 @@ namespace abp
using namespace ::svt;
using namespace ::utl;
- const SfxFilter* lcl_getBaseFilter()
+ std::shared_ptr<const SfxFilter> lcl_getBaseFilter()
{
- const SfxFilter* pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
return pFilter;
}
@@ -111,7 +111,7 @@ namespace abp
sPath += "/";
sPath += rSettings.sDataSourceName;
- const SfxFilter* pFilter = lcl_getBaseFilter();
+ std::shared_ptr<const SfxFilter> pFilter = lcl_getBaseFilter();
if ( pFilter )
{
OUString sExt = pFilter->GetDefaultExtension();
diff --git a/extensions/source/dbpilots/commonpagesdbp.cxx b/extensions/source/dbpilots/commonpagesdbp.cxx
index dbd3ed256af9..3a7b53cfebe0 100644
--- a/extensions/source/dbpilots/commonpagesdbp.cxx
+++ b/extensions/source/dbpilots/commonpagesdbp.cxx
@@ -199,7 +199,7 @@ namespace dbp
ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, 0);
aFileDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
- const SfxFilter* pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
if ( pFilter )
{
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index b544f622c4f2..c44d3d9f74fa 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -2900,7 +2900,7 @@ namespace pcr
// is considered to be potentially expensive
aFileDlg.SetDisplayDirectory( sDataSource );
- const SfxFilter* pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName("StarOffice XML (Base)");
OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
if ( pFilter )
{
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index c62dea472fef..07e5c120ec0a 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -6916,7 +6916,7 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo
if ( sStarName.getLength() )
{
//TODO/MBA: check if (and when) storage and stream will be destroyed!
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
std::unique_ptr<SvMemoryStream> xMemStream (new SvMemoryStream);
if ( pName )
{
diff --git a/filter/source/msfilter/msoleexp.cxx b/filter/source/msfilter/msoleexp.cxx
index 02f2fd07a727..54c6a86ad104 100644
--- a/filter/source/msfilter/msoleexp.cxx
+++ b/filter/source/msfilter/msoleexp.cxx
@@ -122,7 +122,7 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef& rObj, SotSt
{
SvGlobalName aOwnGlobalName;
SvGlobalName aObjName( rObj->getClassID() );
- const SfxFilter* pExpFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pExpFilter;
{
static struct _ObjExpType {
sal_uInt32 nFlag;
diff --git a/include/sfx2/docfac.hxx b/include/sfx2/docfac.hxx
index 0e98186bc29a..547ad584b19a 100644
--- a/include/sfx2/docfac.hxx
+++ b/include/sfx2/docfac.hxx
@@ -68,7 +68,7 @@ public:
SfxViewFactory* GetViewFactoryByViewName( const OUString& i_rViewName ) const;
// Filter
- const SfxFilter* GetTemplateFilter() const;
+ std::shared_ptr<const SfxFilter> GetTemplateFilter() const;
static OUString GetStandardTemplate( const OUString& rServiceName );
static void SetStandardTemplate( const OUString& rServiceName, const OUString& rTemplateName );
static void SetSystemTemplate( const OUString& rServiceName, const OUString& rTemplateName );
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index 12b25efbcf78..bbf9c4e37298 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -74,7 +74,7 @@ public:
*/
SfxMedium( const OUString &rName,
StreamMode nOpenMode,
- const SfxFilter *pFilter = nullptr,
+ std::shared_ptr<const SfxFilter> pFilter = nullptr,
SfxItemSet *pSet = nullptr );
/**
* @param pSet Takes ownership
@@ -82,7 +82,7 @@ public:
SfxMedium( const OUString &rName,
const OUString &rReferer,
StreamMode nOpenMode,
- const SfxFilter *pFilter = nullptr,
+ std::shared_ptr<const SfxFilter> pFilter = nullptr,
SfxItemSet *pSet = nullptr );
/**
@@ -113,9 +113,12 @@ public:
void SetLoadTargetFrame(SfxFrame* pFrame );
SfxFrame* GetLoadTargetFrame() const;
- void SetFilter(const SfxFilter *pFlt);
- const SfxFilter* GetFilter() const;
- const SfxFilter* GetOrigFilter() const;
+ /**
+ * Does not take ownership of pFlt but pFlt needs to be around as long as the SfxMedium instance.
+ */
+ void SetFilter(std::shared_ptr<const SfxFilter> pFilter);
+ std::shared_ptr<const SfxFilter> GetFilter() const;
+ std::shared_ptr<const SfxFilter> GetOrigFilter() const;
const OUString& GetOrigURL() const;
SfxItemSet * GetItemSet() const;
diff --git a/include/sfx2/docfilt.hxx b/include/sfx2/docfilt.hxx
index f67a69f2f410..0a68d80e9243 100644
--- a/include/sfx2/docfilt.hxx
+++ b/include/sfx2/docfilt.hxx
@@ -31,6 +31,8 @@
#include <sfx2/dllapi.h>
#include <tools/wldcrd.hxx>
+#include <memory>
+
class SfxFilterContainer;
class SotStorage;
@@ -104,9 +106,9 @@ public:
const OUString& GetServiceName() const { return aServiceName; }
const OUString& GetProviderName() const { return maProvider;}
- static const SfxFilter* GetDefaultFilter( const OUString& rName );
- static const SfxFilter* GetFilterByName( const OUString& rName );
- static const SfxFilter* GetDefaultFilterFromFactory( const OUString& rServiceName );
+ static std::shared_ptr<const SfxFilter> GetDefaultFilter( const OUString& rName );
+ static std::shared_ptr<const SfxFilter> GetFilterByName( const OUString& rName );
+ static std::shared_ptr<const SfxFilter> GetDefaultFilterFromFactory( const OUString& rServiceName );
static OUString GetTypeFromStorage( const SotStorage& rStg );
static OUString GetTypeFromStorage(
diff --git a/include/sfx2/fcontnr.hxx b/include/sfx2/fcontnr.hxx
index 54f48508e57a..ce5681c3ace5 100644
--- a/include/sfx2/fcontnr.hxx
+++ b/include/sfx2/fcontnr.hxx
@@ -66,17 +66,17 @@ public:
const OUString GetName() const;
- const SfxFilter* GetAnyFilter( SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetFilter4EA( const OUString& rEA, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetAnyFilter( SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetFilter4EA( const OUString& rEA, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
SAL_DLLPRIVATE static void ReadFilters_Impl( bool bUpdate=false );
SAL_DLLPRIVATE static void ReadSingleFilter_Impl( const OUString& rName,
const css::uno::Reference< css::container::XNameAccess >& xTypeCFG,
const css::uno::Reference< css::container::XNameAccess >& xFilterCFG,
bool bUpdate );
- SAL_DLLPRIVATE static const SfxFilter* GetDefaultFilter_Impl( const OUString& );
+ SAL_DLLPRIVATE static std::shared_ptr<const SfxFilter> GetDefaultFilter_Impl( const OUString& );
};
class SfxFilterMatcher_Impl;
@@ -92,22 +92,22 @@ public:
SfxFilterMatcher(const SfxFilterMatcher&) = delete;
SfxFilterMatcher& operator=( const SfxFilterMatcher& ) = delete;
- SAL_DLLPRIVATE static bool IsFilterInstalled_Impl( const SfxFilter* pFilter );
+ SAL_DLLPRIVATE static bool IsFilterInstalled_Impl( std::shared_ptr<const SfxFilter> pFilter );
DECL_DLLPRIVATE_LINK_TYPED( MaybeFileHdl_Impl, OUString*, bool );
- sal_uInt32 GuessFilterIgnoringContent( SfxMedium& rMedium, const SfxFilter ** ) const;
- sal_uInt32 GuessFilter( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- sal_uInt32 GuessFilterControlDefaultUI( SfxMedium& rMedium, const SfxFilter **, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED, bool bDefUI = true ) const;
- sal_uInt32 DetectFilter( SfxMedium& rMedium, const SfxFilter ** ) const;
-
- const SfxFilter* GetFilter4Mime( const OUString& rMime, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED) const;
- const SfxFilter* GetFilter4ClipBoardId( SotClipboardFormatId nId, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetFilter4EA( const OUString& rEA, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetFilter4UIName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetFilterForProps( const css::uno::Sequence < css::beans::NamedValue >& aSeq, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
- const SfxFilter* GetAnyFilter( SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED ) const;
+ sal_uInt32 GuessFilterIgnoringContent( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>& ) const;
+ sal_uInt32 GuessFilter( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>& , SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ sal_uInt32 GuessFilterControlDefaultUI( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>&, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED, bool bDefUI = true ) const;
+ sal_uInt32 DetectFilter( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>& ) const;
+
+ std::shared_ptr<const SfxFilter> GetFilter4Mime( const OUString& rMime, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED) const;
+ std::shared_ptr<const SfxFilter> GetFilter4ClipBoardId( SotClipboardFormatId nId, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetFilter4EA( const OUString& rEA, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust = SfxFilterFlags::IMPORT, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetFilter4UIName( const OUString& rName, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetFilterForProps( const css::uno::Sequence < css::beans::NamedValue >& aSeq, SfxFilterFlags nMust = SfxFilterFlags::NONE, SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED ) const;
+ std::shared_ptr<const SfxFilter> GetAnyFilter( SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED ) const;
};
class SfxFilterContainer_Impl;
@@ -119,14 +119,14 @@ class SFX2_DLLPUBLIC SfxFilterMatcherIter
sal_uInt16 nCurrent;
const SfxFilterMatcher_Impl &m_rMatch;
- SAL_DLLPRIVATE const SfxFilter* Find_Impl();
+ SAL_DLLPRIVATE std::shared_ptr<const SfxFilter> Find_Impl();
public:
SfxFilterMatcherIter( const SfxFilterMatcher& rMatcher, SfxFilterFlags nMask = SfxFilterFlags::NONE, SfxFilterFlags nNotMask = SFX_FILTER_NOTINSTALLED );
SfxFilterMatcherIter(const SfxFilterMatcherIter&) = delete;
SfxFilterMatcherIter& operator=( const SfxFilterMatcherIter& ) = delete;
- const SfxFilter* First();
- const SfxFilter* Next();
+ std::shared_ptr<const SfxFilter> First();
+ std::shared_ptr<const SfxFilter> Next();
};
diff --git a/include/sfx2/filedlghelper.hxx b/include/sfx2/filedlghelper.hxx
index 741507af7d89..9e49d1d24794 100644
--- a/include/sfx2/filedlghelper.hxx
+++ b/include/sfx2/filedlghelper.hxx
@@ -33,6 +33,8 @@
#include <sfx2/sfxuno.hxx>
#include <sfx2/docfilt.hxx>
+#include <memory>
+
namespace com
{
namespace sun
@@ -248,7 +250,7 @@ ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType,
const css::uno::Sequence< OUString >& rBlackList = css::uno::Sequence< OUString >());
-ErrCode RequestPassword(const SfxFilter* pCurrentFilter, OUString& aURL, SfxItemSet* pSet);
+ErrCode RequestPassword(std::shared_ptr<const SfxFilter> pCurrentFilter, OUString& aURL, SfxItemSet* pSet);
}
#endif
diff --git a/include/vbahelper/vbaaccesshelper.hxx b/include/vbahelper/vbaaccesshelper.hxx
index 5284f722fc28..3d14a399548a 100644
--- a/include/vbahelper/vbaaccesshelper.hxx
+++ b/include/vbahelper/vbaaccesshelper.hxx
@@ -55,7 +55,7 @@ namespace ooo
{
bool bRes( false );
const SfxMedium *pMedium = rDocShell.GetMedium();
- const SfxFilter *pFilt = pMedium ? pMedium->GetFilter() : nullptr;
+ std::shared_ptr<const SfxFilter> pFilt = pMedium ? pMedium->GetFilter() : nullptr;
if ( pFilt && pFilt->IsAlienFormat() )
bRes = pFilt->GetMimeType().equalsAscii( pMimeType );
return bRes;
diff --git a/reportdesign/source/core/api/ReportEngineJFree.cxx b/reportdesign/source/core/api/ReportEngineJFree.cxx
index d2be19e0c9df..cdff2e247366 100644
--- a/reportdesign/source/core/api/ReportEngineJFree.cxx
+++ b/reportdesign/source/core/api/ReportEngineJFree.cxx
@@ -167,7 +167,7 @@ OUString OReportEngineJFree::getNewOutputName()
{
MimeConfigurationHelper aConfighelper(m_xContext);
const OUString sMimeType = m_xReport->getMimeType();
- const SfxFilter* pFilter = SfxFilter::GetDefaultFilter( aConfighelper.GetDocServiceNameFromMediaType(sMimeType) );
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetDefaultFilter( aConfighelper.GetDocServiceNameFromMediaType(sMimeType) );
OUString sExt(".rpt");
if ( pFilter )
sExt = ::comphelper::string::stripStart(pFilter->GetDefaultExtension(), '*');
diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx
index 4c51faff7e0d..ab49ccf40aa7 100644
--- a/reportdesign/source/ui/inspection/GeometryHandler.cxx
+++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx
@@ -1666,7 +1666,7 @@ OUString GeometryHandler::impl_ConvertMimeTypeToUI_nothrow(const OUString& _sMim
{
::comphelper::MimeConfigurationHelper aMimeHelper(m_xContext);
OUString sRet;
- const SfxFilter* pFilter = SfxFilter::GetDefaultFilter( aMimeHelper.GetDocServiceNameFromMediaType(_sMimetype) );
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetDefaultFilter( aMimeHelper.GetDocServiceNameFromMediaType(_sMimetype) );
if ( pFilter )
sRet = pFilter->GetUIName();
if ( sRet.isEmpty() )
diff --git a/sc/inc/tablink.hxx b/sc/inc/tablink.hxx
index de2490e86da6..f50ad00765cd 100644
--- a/sc/inc/tablink.hxx
+++ b/sc/inc/tablink.hxx
@@ -95,7 +95,7 @@ public:
/** Create SfxMedium for stream read with SfxFilter and filter options set
at the medium's SfxItemSet.
*/
- static SfxMedium* CreateMedium( const OUString& rFileName, const SfxFilter* pFilter, const OUString& rOptions );
+ static SfxMedium* CreateMedium( const OUString& rFileName, std::shared_ptr<const SfxFilter> pFilter, const OUString& rOptions );
static OUString GetOptions( SfxMedium& rMedium );
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 031f6bb38703..e94adc506f28 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -539,12 +539,11 @@ ScDocShellRef ScBootstrapFixture::load( bool bReadWrite,
const OUString& rTypeName, SfxFilterFlags nFilterFlags, SotClipboardFormatId nClipboardID,
sal_uIntPtr nFilterVersion, const OUString* pPassword )
{
- // TODO: will currently leak the pFilter instance
- SfxFilter* pFilter = new SfxFilter(
+ std::shared_ptr<const SfxFilter> pFilter(new SfxFilter(
rFilter,
OUString(), nFilterFlags, nClipboardID, rTypeName, 0, OUString(),
- rUserData, OUString("private:factory/scalc*"));
- pFilter->SetVersion(nFilterVersion);
+ rUserData, OUString("private:factory/scalc*")));
+ const_cast<SfxFilter*>(pFilter.get())->SetVersion(nFilterVersion);
ScDocShellRef xDocShRef = new ScDocShell;
xDocShRef->GetDocument().EnableUserInteraction(false);
@@ -632,12 +631,12 @@ ScDocShellRef ScBootstrapFixture::saveAndReload(
SotClipboardFormatId nExportFormat = SotClipboardFormatId::NONE;
if (nFormatType == ODS_FORMAT_TYPE)
nExportFormat = SotClipboardFormatId::STARCHART_8;
- std::unique_ptr<SfxFilter> pExportFilter(new SfxFilter(
+ std::shared_ptr<const SfxFilter> pExportFilter(new SfxFilter(
rFilter,
OUString(), nFormatType, nExportFormat, rTypeName, 0, OUString(),
rUserData, OUString("private:factory/scalc*") ));
- pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
- aStoreMedium.SetFilter(pExportFilter.get());
+ const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ aStoreMedium.SetFilter(pExportFilter);
pShell->DoSaveAs( aStoreMedium );
pShell->DoClose();
@@ -678,12 +677,12 @@ std::shared_ptr<utl::TempFile> ScBootstrapFixture::exportTo( ScDocShell* pShell,
SfxFilterFlags nFormatType = aFileFormats[nFormat].nFormatType;
if (nFormatType == ODS_FORMAT_TYPE)
nExportFormat = SotClipboardFormatId::STARCHART_8;
- std::unique_ptr<SfxFilter> pExportFilter(new SfxFilter(
+ std::shared_ptr<SfxFilter> pExportFilter(new SfxFilter(
aFilterName,
OUString(), nFormatType, nExportFormat, aFilterType, 0, OUString(),
OUString(), OUString("private:factory/scalc*") ));
- pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
- aStoreMedium.SetFilter(pExportFilter.get());
+ const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ aStoreMedium.SetFilter(pExportFilter);
pShell->DoSaveAs( aStoreMedium );
pShell->DoClose();
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 1228ada71231..c01426a44f65 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -279,11 +279,11 @@ ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const OUSt
SotClipboardFormatId nExportFormat = SotClipboardFormatId::NONE;
if (nFormatType == ODS_FORMAT_TYPE)
nExportFormat = SotClipboardFormatId::STARCHART_8;
- SfxFilter* pExportFilter = new SfxFilter(
+ std::shared_ptr<const SfxFilter> pExportFilter(new SfxFilter(
rFilter,
OUString(), nFormatType, nExportFormat, rTypeName, 0, OUString(),
- rUserData, OUString("private:factory/scalc*") );
- pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ rUserData, OUString("private:factory/scalc*") ));
+ const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
aStoreMedium.SetFilter(pExportFilter);
SfxItemSet* pExportSet = aStoreMedium.GetItemSet();
uno::Sequence< beans::NamedValue > aEncryptionData = comphelper::OStorageHelper::CreatePackageEncryptionData( "test" );
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 144e19e40e16..92648a8d4f7d 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1517,17 +1517,17 @@ void ScFiltersTest::testPassword_Impl(const OUString& aFileNameBase)
OUString aFilterType(getFileFormats()[0].pTypeName, strlen(getFileFormats()[0].pTypeName), RTL_TEXTENCODING_UTF8);
SotClipboardFormatId nFormat = SotClipboardFormatId::STARCALC_8;
- SfxFilter* aFilter = new SfxFilter(
+ std::shared_ptr<const SfxFilter> pFilter(new SfxFilter(
aFilterName,
OUString(), getFileFormats()[0].nFormatType, nFormat, aFilterType, 0, OUString(),
- OUString(), OUString("private:factory/scalc*") );
- aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ OUString(), OUString("private:factory/scalc*") ));
+ const_cast<SfxFilter*>(pFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
ScDocShellRef xDocSh = new ScDocShell;
SfxMedium* pMedium = new SfxMedium(aFileName, STREAM_STD_READWRITE);
SfxItemSet* pSet = pMedium->GetItemSet();
pSet->Put(SfxStringItem(SID_PASSWORD, OUString("test")));
- pMedium->SetFilter(aFilter);
+ pMedium->SetFilter(pFilter);
if (!xDocSh->DoLoad(pMedium))
{
xDocSh->DoClose();
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index 2dfba9596477..f4030935ec5f 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -236,7 +236,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter,
OUString aNewUrl( ScGlobal::GetAbsDocName( rNewFile, pImpl->m_pDocSh ) );
bool bNewUrlName = (aNewUrl != aFileName);
- const SfxFilter* pFilter = pImpl->m_pDocSh->GetFactory().GetFilterContainer()->GetFilter4FilterName(rNewFilter);
+ std::shared_ptr<const SfxFilter> pFilter = pImpl->m_pDocSh->GetFactory().GetFilterContainer()->GetFilter4FilterName(rNewFilter);
if (!pFilter)
return false;
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 0309e1dcc44a..4c69ed1965df 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1049,7 +1049,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
const SfxUInt16Item* pUpdateDocItem = SfxItemSet::GetItem<SfxUInt16Item>(rMedium.GetItemSet(), SID_UPDATEDOCMODE, false);
nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : css::document::UpdateDocMode::NO_UPDATE;
- const SfxFilter* pFilter = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
if (pFilter)
{
OUString aFltName = pFilter->GetFilterName();
@@ -1517,7 +1517,7 @@ bool ScDocShell::ConvertFrom( SfxMedium& rMedium )
bool ScDocShell::LoadExternal( SfxMedium& rMed )
{
- const SfxFilter* pFilter = rMed.GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = rMed.GetFilter();
if (!pFilter)
return false;
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 98f094b74f90..62b27d8eb215 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -718,7 +718,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
// GetFilter needs name without the prefix.
ScDocumentLoader::RemoveAppPrefix( aFilterName );
- const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
+ std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
SfxItemSet* pSet = new SfxAllItemSet( pApp->GetPool() );
if (!aOptions.isEmpty())
pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 8319e5ea0cf4..c2ace4a4e825 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2431,7 +2431,7 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
else
ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false);
ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false);
- const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName(rFilter);
+ std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName(rFilter);
if (pFileData->maRelativeName.isEmpty())
{
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index 2b2572c3a7ad..aedb902a4f7e 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -171,7 +171,7 @@ bool ScTableLink::Refresh(const OUString& rNewFile, const OUString& rNewFilter,
OUString aNewUrl = ScGlobal::GetAbsDocName(rNewFile, pImpl->m_pDocSh);
bool bNewUrlName = !aFileName.equals(aNewUrl);
- const SfxFilter* pFilter = pImpl->m_pDocSh->GetFactory().GetFilterContainer()->GetFilter4FilterName(rNewFilter);
+ std::shared_ptr<const SfxFilter> pFilter = pImpl->m_pDocSh->GetFactory().GetFilterContainer()->GetFilter4FilterName(rNewFilter);
if (!pFilter)
return false;
@@ -462,7 +462,7 @@ bool ScDocumentLoader::GetFilterName( const OUString& rFileName,
// Filter-Detection
- const SfxFilter* pSfxFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pSfxFilter;
SfxMedium* pMedium = new SfxMedium( rFileName, STREAM_STD_READ );
if ( pMedium->GetError() == ERRCODE_NONE )
{
@@ -471,9 +471,9 @@ bool ScDocumentLoader::GetFilterName( const OUString& rFileName,
SfxFilterMatcher aMatcher("scalc");
if( bWithContent )
- aMatcher.GuessFilter( *pMedium, &pSfxFilter );
+ aMatcher.GuessFilter( *pMedium, pSfxFilter );
else
- aMatcher.GuessFilterIgnoringContent( *pMedium, &pSfxFilter );
+ aMatcher.GuessFilterIgnoringContent( *pMedium, pSfxFilter );
}
bool bOK = false;
@@ -497,7 +497,7 @@ void ScDocumentLoader::RemoveAppPrefix( OUString& rFilterName )
rFilterName = rFilterName.copy( aAppPrefix.getLength());
}
-SfxMedium* ScDocumentLoader::CreateMedium( const OUString& rFileName, const SfxFilter* pFilter,
+SfxMedium* ScDocumentLoader::CreateMedium( const OUString& rFileName, std::shared_ptr<const SfxFilter> pFilter,
const OUString& rOptions )
{
// Always create SfxItemSet so ScDocShell can set options.
@@ -517,7 +517,7 @@ ScDocumentLoader::ScDocumentLoader( const OUString& rFileName,
if ( rFilterName.isEmpty() )
GetFilterName( rFileName, rFilterName, rOptions, true, bWithInteraction );
- const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( rFilterName );
+ std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( rFilterName );
pMedium = CreateMedium( rFileName, pFilter, rOptions);
if ( pMedium->GetError() != ERRCODE_NONE )
diff --git a/sc/source/ui/miscdlgs/linkarea.cxx b/sc/source/ui/miscdlgs/linkarea.cxx
index 98b1958f8e1c..2306e69c048b 100644
--- a/sc/source/ui/miscdlgs/linkarea.cxx
+++ b/sc/source/ui/miscdlgs/linkarea.cxx
@@ -220,10 +220,10 @@ IMPL_LINK_TYPED( ScLinkedAreaDlg, DialogClosedHdl, sfx2::FileDialogHelper*, _pFi
const OUString aHTMLFilterName( FILTERNAME_HTML );
const OUString aWebQFilterName( FILTERNAME_QUERY );
- const SfxFilter* pFilter = pMed->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pMed->GetFilter();
if (pFilter && aHTMLFilterName.equals(pFilter->GetFilterName()))
{
- const SfxFilter* pNewFilter =
+ std::shared_ptr<const SfxFilter> pNewFilter =
ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aWebQFilterName );
if( pNewFilter )
pMed->SetFilter( pNewFilter );
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index 66dcac2945d3..0f8c1ba8169e 100644
--- a/sc/source/ui/unoobj/scdetect.cxx
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -301,7 +301,7 @@ OUString SAL_CALL ScFilterDetect::detect( uno::Sequence<beans::PropertyValue>& l
return OUString();
SfxFilterMatcher aMatcher("scalc");
- const SfxFilter* pFilter = aMatcher.GetFilter4FilterName(OUString::createFromAscii(pSearchFilterName));
+ std::shared_ptr<const SfxFilter> pFilter = aMatcher.GetFilter4FilterName(OUString::createFromAscii(pSearchFilterName));
if (!pFilter)
return OUString();
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 6fac2e8b6fed..0e23548a18e0 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -584,7 +584,7 @@ bool ScViewFunc::PasteFile( const Point& rPos, const OUString& rFile, bool bLink
if (!bLink) // for bLink only graphics or URL
{
// 1. can I open the file?
- const SfxFilter* pFlt = nullptr;
+ std::shared_ptr<const SfxFilter> pFlt;
// search only for its own filters, without selection box (as in ScDocumentLoader)
SfxFilterMatcher aMatcher( ScDocShell::Factory().GetFilterContainer()->GetName() );
@@ -592,7 +592,7 @@ bool ScViewFunc::PasteFile( const Point& rPos, const OUString& rFile, bool bLink
// #i73992# GuessFilter no longer calls UseInteractionHandler.
// This is UI, so it can be called here.
aSfxMedium.UseInteractionHandler(true);
- ErrCode nErr = aMatcher.GuessFilter( aSfxMedium, &pFlt );
+ ErrCode nErr = aMatcher.GuessFilter( aSfxMedium, pFlt );
if ( pFlt && !nErr )
{
diff --git a/sd/qa/unit/filters-test.cxx b/sd/qa/unit/filters-test.cxx
index 836fa645fca6..c08f6c0dd142 100644
--- a/sd/qa/unit/filters-test.cxx
+++ b/sd/qa/unit/filters-test.cxx
@@ -63,15 +63,15 @@ bool SdFiltersTest::load(const OUString &rFilter, const OUString &rURL,
const OUString &rUserData, SfxFilterFlags nFilterFlags, SotClipboardFormatId nClipboardID,
unsigned int nFilterVersion)
{
- SfxFilter aFilter(
+ std::shared_ptr<const SfxFilter> pFilter(new SfxFilter(
rFilter,
OUString(), nFilterFlags, nClipboardID, OUString(), 0, OUString(),
- rUserData, OUString() );
- aFilter.SetVersion(nFilterVersion);
+ rUserData, OUString() ));
+ const_cast<SfxFilter*>(pFilter.get())->SetVersion(nFilterVersion);
::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
- pSrcMed->SetFilter(&aFilter);
+ pSrcMed->SetFilter(pFilter);
bool bLoaded = xDocShRef->DoLoad(pSrcMed);
xDocShRef->DoClose();
return bLoaded;
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 5fdddf0ff324..f40efa6f82a4 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -116,17 +116,18 @@ protected:
SotClipboardFormatId nOptions = SotClipboardFormatId::NONE;
if (pFmt->nFormatType != SfxFilterFlags::NONE)
nOptions = SotClipboardFormatId::STARCALC_8;
- SfxFilter* aFilter = new SfxFilter(
+ SfxFilter* pFilter = new SfxFilter(
OUString::createFromAscii( pFmt->pFilterName ),
OUString(), pFmt->nFormatType, nOptions,
OUString::createFromAscii( pFmt->pTypeName ),
0, OUString(),
OUString::createFromAscii( pFmt->pUserData ),
OUString("private:factory/simpress*") );
- aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ pFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ std::shared_ptr<const SfxFilter> pFilt(pFilter);
::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
- SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ, aFilter, pParams);
+ SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ, pFilt, pParams);
if ( !xDocShRef->DoLoad(pSrcMed) || !xDocShRef.Is() )
{
if (xDocShRef.Is())
@@ -152,14 +153,14 @@ protected:
SotClipboardFormatId nExportFormat = SotClipboardFormatId::NONE;
if (pFormat->nFormatType == ODP_FORMAT_TYPE)
nExportFormat = SotClipboardFormatId::STARCALC_8;
- SfxFilter* pExportFilter = new SfxFilter(
+ std::shared_ptr<const SfxFilter> pExportFilter(new SfxFilter(
OUString::createFromAscii(pFormat->pFilterName),
OUString(), pFormat->nFormatType, nExportFormat,
OUString::createFromAscii(pFormat->pTypeName),
0, OUString(),
OUString::createFromAscii(pFormat->pUserData),
- OUString("private:factory/simpress*") );
- pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ OUString("private:factory/simpress*") ));
+ const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
aStoreMedium.SetFilter(pExportFilter);
pShell->ConvertTo(aStoreMedium);
pShell->DoClose();
@@ -171,14 +172,14 @@ protected:
SotClipboardFormatId nExportFormat = SotClipboardFormatId::NONE;
if (pFormat->nFormatType == ODP_FORMAT_TYPE)
nExportFormat = SotClipboardFormatId::STARCHART_8;
- SfxFilter* pExportFilter = new SfxFilter(
+ std::shared_ptr<const SfxFilter> pExportFilter(new SfxFilter(
OUString::createFromAscii(pFormat->pFilterName),
OUString(), pFormat->nFormatType, nExportFormat,
OUString::createFromAscii(pFormat->pTypeName),
0, OUString(),
OUString::createFromAscii(pFormat->pUserData),
- OUString("private:factory/simpress*") );
- pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+ OUString("private:factory/simpress*") ));
+ const_cast<SfxFilter*>(pExportFilter.get())->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
aStoreMedium.SetFilter(pExportFilter);
pShell->DoSaveAs(aStoreMedium);
pShell->DoClose();
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 7e11c55bf7cf..176cc3257584 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -202,11 +202,11 @@ SdDrawDocument* SdDrawDocument::OpenBookmarkDoc(SfxMedium& rMedium)
bool bOK = true;
SdDrawDocument* pBookmarkDoc = nullptr;
OUString aBookmarkName = rMedium.GetName();
- const SfxFilter* pFilter = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
if ( !pFilter )
{
rMedium.UseInteractionHandler( true );
- SfxGetpApp()->GetFilterMatcher().GuessFilter( rMedium, &pFilter );
+ SfxGetpApp()->GetFilterMatcher().GuessFilter( rMedium, pFilter );
}
if ( !pFilter )
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx
index 5829e61ad552..91ba7a6c7cb0 100644
--- a/sd/source/filter/xml/sdxmlwrp.cxx
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
@@ -783,7 +783,7 @@ bool SdXMLFilter::Import( ErrCode& nError )
else
{
// check for binary formats
- const SfxFilter * pFilter = mrMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = mrMedium.GetFilter();
if( pFilter )
{
OUString typeName(pFilter->GetRealTypeName());
diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx
index bbee98c57b1c..8003a4aec1ee 100644
--- a/sd/source/ui/dlg/navigatr.cxx
+++ b/sd/source/ui/dlg/navigatr.cxx
@@ -579,7 +579,7 @@ bool SdNavigatorWin::InsertFile(const OUString& rFileName)
else
{
// show dragged-in document
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
ErrCode nErr = 0;
if (aFileName != maDropFileName)
@@ -587,7 +587,7 @@ bool SdNavigatorWin::InsertFile(const OUString& rFileName)
SfxMedium aMed(aFileName, (StreamMode::READ | StreamMode::SHARE_DENYNONE));
SfxFilterMatcher aMatch( OUString("simpress") );
aMed.UseInteractionHandler( true );
- nErr = aMatch.GuessFilter(aMed, &pFilter);
+ nErr = aMatch.GuessFilter(aMed, pFilter);
}
if ((pFilter && !nErr) || aFileName == maDropFileName)
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index ff5999d6d030..71ac8e4e45dd 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -572,7 +572,7 @@ bool DrawDocShell::ConvertTo( SfxMedium& rMedium )
if( mpDoc->GetPageCount() )
{
- const SfxFilter* pMediumFilter = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pMediumFilter = rMedium.GetFilter();
const OUString aTypeName( pMediumFilter->GetTypeName() );
SdFilter* pFilter = nullptr;
@@ -613,8 +613,6 @@ bool DrawDocShell::ConvertTo( SfxMedium& rMedium )
bRet = pFilter->Export();
if( !bRet )
mpDoc->SetSwapGraphicsMode( nOldSwapMode );
-
- delete pFilter;
}
}
@@ -945,7 +943,7 @@ bool DrawDocShell::GetObjectIsmarked(const OUString& rBookmark, bool bRealizeMul
bool DrawDocShell::SaveAsOwnFormat( SfxMedium& rMedium )
{
- const SfxFilter* pFilter = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
if (pFilter->IsOwnTemplateFormat())
{
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index e057342b7c26..04aba7188a9d 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -97,7 +97,7 @@ OUString lcl_GetExtensionsList ( ::std::vector< FilterDesc > const& rFilterDescL
}
void lcl_AddFilter ( ::std::vector< FilterDesc >& rFilterDescList,
- const SfxFilter *pFilter )
+ std::shared_ptr<const SfxFilter> pFilter )
{
if (pFilter)
rFilterDescList.push_back( ::std::make_pair( pFilter->GetUIName(), pFilter->GetDefaultExtension() ) );
@@ -165,7 +165,7 @@ void FuInsertFile::DoExecute( SfxRequest& rReq )
try
{
// Get main filter
- const SfxFilter* pFilter = SfxFilter::GetDefaultFilterFromFactory( aOwnCont );
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetDefaultFilterFromFactory( aOwnCont );
lcl_AddFilter( aFilterVector, pFilter );
// get template filter
@@ -259,9 +259,9 @@ void FuInsertFile::DoExecute( SfxRequest& rReq )
mpDocSh->SetWaitCursor( true );
std::unique_ptr<SfxMedium> xMedium(new SfxMedium(aFile, StreamMode::READ | StreamMode::NOCREATE));
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
- SfxGetpApp()->GetFilterMatcher().GuessFilter(*xMedium, &pFilter);
+ SfxGetpApp()->GetFilterMatcher().GuessFilter(*xMedium, pFilter);
bool bDrawMode = mpViewShell && dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr;
bool bInserted = false;
@@ -726,7 +726,7 @@ bool FuInsertFile::InsSDDinOlMode(SfxMedium* pMedium)
void FuInsertFile::GetSupportedFilterVector( ::std::vector< OUString >& rFilterVector )
{
SfxFilterMatcher& rMatcher = SfxGetpApp()->GetFilterMatcher();
- const SfxFilter* pSearchFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pSearchFilter;
rFilterVector.clear();
diff --git a/sd/source/ui/unoidl/sddetect.cxx b/sd/source/ui/unoidl/sddetect.cxx
index 4eff4b14fb55..5ad76a4bbeb5 100644
--- a/sd/source/ui/unoidl/sddetect.cxx
+++ b/sd/source/ui/unoidl/sddetect.cxx
@@ -123,7 +123,7 @@ OUString SAL_CALL SdFilterDetect::detect( Sequence< beans::PropertyValue >& lDes
}
SfxFilterMatcher aMatch("sdraw");
- const SfxFilter* pFilter = aMatch.GetFilter4FilterName( aName );
+ std::shared_ptr<const SfxFilter> pFilter = aMatch.GetFilter4FilterName( aName );
if ( pFilter )
return pFilter->GetRealTypeName();
}
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index ffda4fe52287..c13639fb8e16 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -446,9 +446,9 @@ IMPL_LINK_NOARG_TYPED(View, DropInsertFileHdl, Idle *, void)
}
if( !bOK )
{
- const SfxFilter* pFoundFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFoundFilter;
SfxMedium aSfxMedium( aCurrentDropFile, StreamMode::READ | StreamMode::SHARE_DENYNONE );
- ErrCode nErr = SfxGetpApp()->GetFilterMatcher().GuessFilter( aSfxMedium, &pFoundFilter );
+ ErrCode nErr = SfxGetpApp()->GetFilterMatcher().GuessFilter( aSfxMedium, pFoundFilter );
if( pFoundFilter && !nErr )
{
diff --git a/sfx2/inc/arrdecl.hxx b/sfx2/inc/arrdecl.hxx
index 837f90904fb7..67387e0f071e 100644
--- a/sfx2/inc/arrdecl.hxx
+++ b/sfx2/inc/arrdecl.hxx
@@ -20,9 +20,10 @@
#define INCLUDED_SFX2_INC_ARRDECL_HXX
#include <vector>
+#include <memory>
class SfxFilter;
-typedef ::std::vector< SfxFilter* > SfxFilterList_Impl;
+typedef ::std::vector< std::shared_ptr<const SfxFilter> > SfxFilterList_Impl;
#endif
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index dd8b20024c98..879ac5c750a5 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -280,7 +280,7 @@ sal_uInt32 CheckPasswd_Impl
sal_uIntPtr SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUString &rFileName, bool bCopy, SfxItemSet* pSet )
{
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
SfxMedium aMedium( rFileName, ( StreamMode::READ | StreamMode::SHARE_DENYNONE ) );
if ( !aMedium.GetStorage( false ).is() )
@@ -293,7 +293,7 @@ sal_uIntPtr SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUStri
}
aMedium.UseInteractionHandler( true );
- sal_uIntPtr nErr = GetFilterMatcher().GuessFilter( aMedium,&pFilter,SfxFilterFlags::TEMPLATE, SfxFilterFlags::NONE );
+ sal_uIntPtr nErr = GetFilterMatcher().GuessFilter( aMedium, pFilter, SfxFilterFlags::TEMPLATE, SfxFilterFlags::NONE );
if ( 0 != nErr)
{
delete pSet;
@@ -830,7 +830,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
aTypeName = xTypeDetection->queryTypeByURL( aURL.Main );
SfxFilterMatcher& rMatcher = SfxGetpApp()->GetFilterMatcher();
- const SfxFilter* pFilter = rMatcher.GetFilter4EA( aTypeName );
+ std::shared_ptr<const SfxFilter> pFilter = rMatcher.GetFilter4EA( aTypeName );
if (!pFilter || !lcl_isFilterNativelySupported(*pFilter))
{
// hyperlink does not link to own type => special handling (http, ftp) browser and (other external protocols) OS
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 9edb6ff3ea12..0f69bbdfaf52 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -191,7 +191,7 @@ void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh )
OUString aTitle = pDocSh->GetTitle(SFX_TITLE_PICKLIST);
OUString aFilter;
- const SfxFilter* pFilter = pMed->GetOrigFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pMed->GetOrigFilter();
if ( pFilter )
aFilter = pFilter->GetFilterName();
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx
index 6d0571eea2b9..f26e4748df63 100644
--- a/sfx2/source/appl/shutdownicon.cxx
+++ b/sfx2/source/appl/shutdownicon.cxx
@@ -446,7 +446,7 @@ IMPL_LINK_TYPED( ShutdownIcon, DialogClosedHdl_Impl, FileDialogHelper*, /*unused
if ( !aFilterName.isEmpty() )
{
- const SfxFilter* pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4UIName( aFilterName, SfxFilterFlags::NONE, SfxFilterFlags::NOTINFILEDLG );
+ std::shared_ptr<const SfxFilter> pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4UIName( aFilterName, SfxFilterFlags::NONE, SfxFilterFlags::NOTINFILEDLG );
if ( pFilter )
{
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx
index 3e2837cb9335..80cb675b3b59 100644
--- a/sfx2/source/bastyp/fltfnc.cxx
+++ b/sfx2/source/bastyp/fltfnc.cxx
@@ -118,15 +118,7 @@ namespace
{
SfxFilterList_Impl aList;
public:
- ~SfxFilterArray()
- {
- SfxFilterList_Impl::iterator aEnd = aList.end();
- for (SfxFilterList_Impl::iterator aI = aList.begin(); aI != aEnd; ++aI)
- {
- SfxFilter *pFilter = *aI;
- delete pFilter;
- }
- }
+
SfxFilterList_Impl& getList()
{
return aList;
@@ -163,7 +155,7 @@ public:
};
#define IMPL_FORWARD_LOOP( aMethod, ArgType, aArg ) \
-const SfxFilter* SfxFilterContainer::aMethod( ArgType aArg, SfxFilterFlags nMust, SfxFilterFlags nDont ) const \
+std::shared_ptr<const SfxFilter> SfxFilterContainer::aMethod( ArgType aArg, SfxFilterFlags nMust, SfxFilterFlags nDont ) const \
{\
SfxFilterMatcher aMatch( pImpl->aName ); \
return aMatch.aMethod( aArg, nMust, nDont ); \
@@ -173,7 +165,7 @@ IMPL_FORWARD_LOOP( GetFilter4EA, const OUString&, rEA );
IMPL_FORWARD_LOOP( GetFilter4Extension, const OUString&, rExt );
IMPL_FORWARD_LOOP( GetFilter4FilterName, const OUString&, rName );
-const SfxFilter* SfxFilterContainer::GetAnyFilter( SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterContainer::GetAnyFilter( SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
SfxFilterMatcher aMatch( pImpl->aName );
return aMatch.GetAnyFilter( nMust, nDont );
@@ -196,7 +188,7 @@ const OUString SfxFilterContainer::GetName() const
return pImpl->aName;
}
-const SfxFilter* SfxFilterContainer::GetDefaultFilter_Impl( const OUString& rName )
+std::shared_ptr<const SfxFilter> SfxFilterContainer::GetDefaultFilter_Impl( const OUString& rName )
{
// Try to find out the type of factory.
// Interpret given name as Service- and ShortName!
@@ -218,7 +210,7 @@ const SfxFilter* SfxFilterContainer::GetDefaultFilter_Impl( const OUString& rNam
// May the set default filter does not exists any longer or
// does not fit the given factory.
const SfxFilterMatcher aMatcher;
- const SfxFilter* pFilter = aMatcher.GetFilter4FilterName(sDefaultFilter);
+ std::shared_ptr<const SfxFilter> pFilter = aMatcher.GetFilter4FilterName(sDefaultFilter);
if (
pFilter &&
@@ -237,7 +229,7 @@ const SfxFilter* SfxFilterContainer::GetDefaultFilter_Impl( const OUString& rNam
for ( size_t i = 0, n = pFilterArr->size(); i < n; ++i )
{
- const SfxFilter* pCheckFilter = (*pFilterArr)[i];
+ std::shared_ptr<const SfxFilter> pCheckFilter = (*pFilterArr)[i];
if ( pCheckFilter->GetServiceName().equalsIgnoreAsciiCase(sServiceName) )
{
pFilter = pCheckFilter;
@@ -328,7 +320,7 @@ void SfxFilterMatcher_Impl::Update() const
pList->clear();
for ( size_t i = 0, n = pFilterArr->size(); i < n; ++i )
{
- SfxFilter* pFilter = (*pFilterArr)[i];
+ std::shared_ptr<const SfxFilter> pFilter = (*pFilterArr)[i];
if ( pFilter->GetServiceName() == aName )
pList->push_back( pFilter );
}
@@ -357,12 +349,12 @@ void SfxFilterMatcher_Impl::InitForIterating() const
}
}
-const SfxFilter* SfxFilterMatcher::GetAnyFilter( SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetAnyFilter( SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
m_rImpl.InitForIterating();
for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
{
- const SfxFilter* pFilter = (*m_rImpl.pList)[i];
+ std::shared_ptr<const SfxFilter> pFilter = (*m_rImpl.pList)[i];
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) )
return pFilter;
@@ -374,7 +366,7 @@ const SfxFilter* SfxFilterMatcher::GetAnyFilter( SfxFilterFlags nMust, SfxFilter
sal_uInt32 SfxFilterMatcher::GuessFilterIgnoringContent(
SfxMedium& rMedium,
- const SfxFilter**ppFilter ) const
+ std::shared_ptr<const SfxFilter>& rpFilter ) const
{
uno::Reference<document::XTypeDetection> xDetection(
comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.TypeDetection"), uno::UNO_QUERY);
@@ -388,27 +380,27 @@ sal_uInt32 SfxFilterMatcher::GuessFilterIgnoringContent(
{
}
- *ppFilter = nullptr;
+ rpFilter = nullptr;
if ( !sTypeName.isEmpty() )
{
// make sure filter list is initialized
m_rImpl.InitForIterating();
- *ppFilter = GetFilter4EA( sTypeName );
+ rpFilter = GetFilter4EA( sTypeName );
}
- return *ppFilter ? ERRCODE_NONE : ERRCODE_ABORT;
+ return rpFilter ? ERRCODE_NONE : ERRCODE_ABORT;
}
-sal_uInt32 SfxFilterMatcher::GuessFilter( SfxMedium& rMedium, const SfxFilter**ppFilter, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+sal_uInt32 SfxFilterMatcher::GuessFilter( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>& rpFilter, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
- return GuessFilterControlDefaultUI( rMedium, ppFilter, nMust, nDont );
+ return GuessFilterControlDefaultUI( rMedium, rpFilter, nMust, nDont );
}
-sal_uInt32 SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, const SfxFilter** ppFilter, SfxFilterFlags nMust, SfxFilterFlags nDont, bool /*bDefUI*/ ) const
+sal_uInt32 SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>& rpFilter, SfxFilterFlags nMust, SfxFilterFlags nDont, bool /*bDefUI*/ ) const
{
- const SfxFilter* pOldFilter = *ppFilter;
+ std::shared_ptr<const SfxFilter> pOldFilter = rpFilter;
// no detection service -> nothing to do !
uno::Reference<document::XTypeDetection> xDetection(
@@ -467,14 +459,14 @@ sal_uInt32 SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, c
if (!sTypeName.isEmpty())
{
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pNewFilter;
if (!aFilterName.isEmpty())
// Type detection returned a suitable filter for this. Use it.
- pFilter = SfxFilter::GetFilterByName(aFilterName);
+ pNewFilter = SfxFilter::GetFilterByName(aFilterName);
// fdo#78742 respect requested document service if set
- if (!pFilter || (!m_rImpl.aName.isEmpty()
- && m_rImpl.aName != pFilter->GetServiceName()))
+ if (!pNewFilter || (!m_rImpl.aName.isEmpty()
+ && m_rImpl.aName != pNewFilter->GetServiceName()))
{
// detect filter by given type
// In case of this matcher is bound to a particular document type:
@@ -483,12 +475,12 @@ sal_uInt32 SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, c
// This "wrong" type will be sorted out now because we match only allowed filters to the detected type
uno::Sequence< beans::NamedValue > lQuery { { "Name", css::uno::makeAny(sTypeName) } };
- pFilter = GetFilterForProps(lQuery, nMust, nDont);
+ pNewFilter = GetFilterForProps(lQuery, nMust, nDont);
}
- if (pFilter)
+ if (pNewFilter)
{
- *ppFilter = pFilter;
+ rpFilter = pNewFilter;
return ERRCODE_NONE;
}
}
@@ -500,7 +492,7 @@ sal_uInt32 SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, c
}
-bool SfxFilterMatcher::IsFilterInstalled_Impl( const SfxFilter* pFilter )
+bool SfxFilterMatcher::IsFilterInstalled_Impl( std::shared_ptr<const SfxFilter> pFilter )
{
if ( pFilter->GetFilterFlags() & SfxFilterFlags::MUSTINSTALL )
{
@@ -533,14 +525,14 @@ bool SfxFilterMatcher::IsFilterInstalled_Impl( const SfxFilter* pFilter )
}
-sal_uInt32 SfxFilterMatcher::DetectFilter( SfxMedium& rMedium, const SfxFilter**ppFilter ) const
+sal_uInt32 SfxFilterMatcher::DetectFilter( SfxMedium& rMedium, std::shared_ptr<const SfxFilter>& rpFilter ) const
/* [Description]
Here the Filter selection box is pulled up. Otherwise GuessFilter
*/
{
- const SfxFilter* pOldFilter = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pOldFilter = rMedium.GetFilter();
if ( pOldFilter )
{
if( !IsFilterInstalled_Impl( pOldFilter ) )
@@ -554,29 +546,29 @@ sal_uInt32 SfxFilterMatcher::DetectFilter( SfxMedium& rMedium, const SfxFilter**
}
}
- const SfxFilter* pFilter = pOldFilter;
+ std::shared_ptr<const SfxFilter> pFilter = pOldFilter;
bool bPreview = rMedium.IsPreview_Impl();
const SfxStringItem* pReferer = SfxItemSet::GetItem<SfxStringItem>(rMedium.GetItemSet(), SID_REFERER, false);
if ( bPreview && rMedium.IsRemote() && ( !pReferer || !pReferer->GetValue().match("private:searchfolder:") ) )
return ERRCODE_ABORT;
- ErrCode nErr = GuessFilter( rMedium, &pFilter );
+ ErrCode nErr = GuessFilter( rMedium, pFilter );
if ( nErr == ERRCODE_ABORT )
return nErr;
if ( nErr == ERRCODE_IO_PENDING )
{
- *ppFilter = pFilter;
+ rpFilter = pFilter;
return nErr;
}
if ( !pFilter )
{
- const SfxFilter* pInstallFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pInstallFilter;
// Now test the filter which are not installed (ErrCode is irrelevant)
- GuessFilter( rMedium, &pInstallFilter, SfxFilterFlags::IMPORT, SfxFilterFlags::CONSULTSERVICE );
+ GuessFilter( rMedium, pInstallFilter, SfxFilterFlags::IMPORT, SfxFilterFlags::CONSULTSERVICE );
if ( pInstallFilter )
{
if ( IsFilterInstalled_Impl( pInstallFilter ) )
@@ -587,7 +579,7 @@ sal_uInt32 SfxFilterMatcher::DetectFilter( SfxMedium& rMedium, const SfxFilter**
{
// Now test the filter, which first must be obtained by Star
// (ErrCode is irrelevant)
- GuessFilter( rMedium, &pInstallFilter, SfxFilterFlags::IMPORT, SfxFilterFlags::NONE );
+ GuessFilter( rMedium, pInstallFilter, SfxFilterFlags::IMPORT, SfxFilterFlags::NONE );
if ( pInstallFilter )
IsFilterInstalled_Impl( pInstallFilter );
}
@@ -602,14 +594,14 @@ sal_uInt32 SfxFilterMatcher::DetectFilter( SfxMedium& rMedium, const SfxFilter**
if( -1 != aFlags.indexOf( 'H' ) )
bHidden = true;
}
- *ppFilter = pFilter;
+ rpFilter = pFilter;
if ( bHidden )
nErr = pFilter ? ERRCODE_NONE : ERRCODE_ABORT;
return nErr;
}
-const SfxFilter* SfxFilterMatcher::GetFilterForProps( const css::uno::Sequence < beans::NamedValue >& aSeq, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilterForProps( const css::uno::Sequence < beans::NamedValue >& aSeq, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
uno::Reference< container::XContainerQuery > xTypeCFG;
@@ -627,7 +619,7 @@ const SfxFilter* SfxFilterMatcher::GetFilterForProps( const css::uno::Sequence <
// try to get the preferred filter (works without loading all filters!)
if ( (aProps[OUString("PreferredFilter")] >>= aValue) && !aValue.isEmpty() )
{
- const SfxFilter* pFilter = SfxFilter::GetFilterByName( aValue );
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName( aValue );
if ( !pFilter || (pFilter->GetFilterFlags() & nMust) != nMust || (pFilter->GetFilterFlags() & nDont ) )
// check for filter flags
// pFilter == 0: if preferred filter is a Writer filter, but Writer module is not installed
@@ -657,13 +649,13 @@ const SfxFilter* SfxFilterMatcher::GetFilterForProps( const css::uno::Sequence <
return nullptr;
}
-const SfxFilter* SfxFilterMatcher::GetFilter4Mime( const OUString& rMediaType, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilter4Mime( const OUString& rMediaType, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
if ( m_rImpl.pList )
{
for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
{
- const SfxFilter* pFilter = (*m_rImpl.pList)[i];
+ std::shared_ptr<const SfxFilter> pFilter = (*m_rImpl.pList)[i];
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) && pFilter->GetMimeType() == rMediaType )
return pFilter;
@@ -676,14 +668,14 @@ const SfxFilter* SfxFilterMatcher::GetFilter4Mime( const OUString& rMediaType, S
return GetFilterForProps( aSeq, nMust, nDont );
}
-const SfxFilter* SfxFilterMatcher::GetFilter4EA( const OUString& rType, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilter4EA( const OUString& rType, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
if ( m_rImpl.pList )
{
- const SfxFilter* pFirst = nullptr;
+ std::shared_ptr<const SfxFilter> pFirst;
for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
{
- const SfxFilter* pFilter = (*m_rImpl.pList)[i];
+ std::shared_ptr<const SfxFilter> pFilter = (*m_rImpl.pList)[i];
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) && pFilter->GetTypeName() == rType )
{
@@ -703,13 +695,13 @@ const SfxFilter* SfxFilterMatcher::GetFilter4EA( const OUString& rType, SfxFilte
return GetFilterForProps( aSeq, nMust, nDont );
}
-const SfxFilter* SfxFilterMatcher::GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilter4Extension( const OUString& rExt, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
if ( m_rImpl.pList )
{
for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
{
- const SfxFilter* pFilter = (*m_rImpl.pList)[i];
+ std::shared_ptr<const SfxFilter> pFilter = (*m_rImpl.pList)[i];
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) )
{
@@ -741,7 +733,7 @@ const SfxFilter* SfxFilterMatcher::GetFilter4Extension( const OUString& rExt, Sf
return GetFilterForProps( aSeq, nMust, nDont );
}
-const SfxFilter* SfxFilterMatcher::GetFilter4ClipBoardId( SotClipboardFormatId nId, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilter4ClipBoardId( SotClipboardFormatId nId, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
if (nId == SotClipboardFormatId::NONE)
return nullptr;
@@ -751,13 +743,13 @@ const SfxFilter* SfxFilterMatcher::GetFilter4ClipBoardId( SotClipboardFormatId n
return GetFilterForProps( aSeq, nMust, nDont );
}
-const SfxFilter* SfxFilterMatcher::GetFilter4UIName( const OUString& rName, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilter4UIName( const OUString& rName, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
m_rImpl.InitForIterating();
- const SfxFilter* pFirstFilter=nullptr;
+ std::shared_ptr<const SfxFilter> pFirstFilter;
for ( size_t i = 0, n = m_rImpl.pList->size(); i < n; ++i )
{
- const SfxFilter* pFilter = (*m_rImpl.pList)[i];
+ std::shared_ptr<const SfxFilter> pFilter = (*m_rImpl.pList)[i];
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ( (nFlags & nMust) == nMust &&
!(nFlags & nDont ) && pFilter->GetUIName() == rName )
@@ -771,7 +763,7 @@ const SfxFilter* SfxFilterMatcher::GetFilter4UIName( const OUString& rName, SfxF
return pFirstFilter;
}
-const SfxFilter* SfxFilterMatcher::GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
+std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilter4FilterName( const OUString& rName, SfxFilterFlags nMust, SfxFilterFlags nDont ) const
{
OUString aName( rName );
sal_Int32 nIndex = aName.indexOf(": ");
@@ -800,7 +792,7 @@ const SfxFilter* SfxFilterMatcher::GetFilter4FilterName( const OUString& rName,
{
for ( size_t i = 0, n = pFilterArr->size(); i < n; ++i )
{
- const SfxFilter* pFilter = (*pFilterArr)[i];
+ std::shared_ptr<const SfxFilter> pFilter = (*pFilterArr)[i];
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ((nFlags & nMust) == nMust && !(nFlags & nDont) && pFilter->GetFilterName().equalsIgnoreAsciiCase(aName))
return pFilter;
@@ -817,7 +809,7 @@ const SfxFilter* SfxFilterMatcher::GetFilter4FilterName( const OUString& rName,
for ( size_t i = 0, n = pList->size(); i < n; ++i )
{
- const SfxFilter* pFilter = (*pList)[i];
+ std::shared_ptr<const SfxFilter> pFilter = (*pList)[i];
SfxFilterFlags nFlags = pFilter->GetFilterFlags();
if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) && pFilter->GetFilterName().equalsIgnoreAsciiCase(aName))
return pFilter;
@@ -828,7 +820,7 @@ const SfxFilter* SfxFilterMatcher::GetFilter4FilterName( const OUString& rName,
IMPL_LINK_TYPED( SfxFilterMatcher, MaybeFileHdl_Impl, OUString*, pString, bool )
{
- const SfxFilter* pFilter = GetFilter4Extension( *pString );
+ std::shared_ptr<const SfxFilter> pFilter = GetFilter4Extension( *pString );
if (pFilter && !pFilter->GetWildcard().Matches( OUString() ) &&
!pFilter->GetWildcard().Matches("*.*") &&
!pFilter->GetWildcard().Matches(OUString('*'))
@@ -852,9 +844,9 @@ SfxFilterMatcherIter::SfxFilterMatcherIter(
}
-const SfxFilter* SfxFilterMatcherIter::Find_Impl()
+std::shared_ptr<const SfxFilter> SfxFilterMatcherIter::Find_Impl()
{
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
while( nCurrent < m_rMatch.pList->size() )
{
pFilter = (*m_rMatch.pList)[nCurrent++];
@@ -867,14 +859,14 @@ const SfxFilter* SfxFilterMatcherIter::Find_Impl()
return pFilter;
}
-const SfxFilter* SfxFilterMatcherIter::First()
+std::shared_ptr<const SfxFilter> SfxFilterMatcherIter::First()
{
nCurrent = 0;
return Find_Impl();
}
-const SfxFilter* SfxFilterMatcherIter::Next()
+std::shared_ptr<const SfxFilter> SfxFilterMatcherIter::Next()
{
return Find_Impl();
}
@@ -1063,12 +1055,10 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
sFilterName = sFilterName.copy( nStartRealName+2 );
}
- SfxFilter* pFilter = bUpdate ? const_cast<SfxFilter*>(SfxFilter::GetFilterByName( sFilterName )) : nullptr;
- bool bNew = false;
+ std::shared_ptr<const SfxFilter> pFilter = bUpdate ? SfxFilter::GetFilterByName( sFilterName ) : nullptr;
if (!pFilter)
{
- bNew = true;
- pFilter = new SfxFilter( sFilterName ,
+ pFilter.reset(new SfxFilter( sFilterName ,
sExtension ,
nFlags ,
nClipboardId ,
@@ -1076,33 +1066,34 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
(sal_uInt16)nDocumentIconId ,
sMimeType ,
sUserData ,
- sServiceName );
+ sServiceName ));
+ rList.push_back( pFilter );
}
else
{
- pFilter->maFilterName = sFilterName;
- pFilter->aWildCard = WildCard(sExtension, ';');
- pFilter->nFormatType = nFlags;
- pFilter->lFormat = nClipboardId;
- pFilter->aTypeName = sType;
- pFilter->nDocIcon = (sal_uInt16)nDocumentIconId;
- pFilter->aMimeType = sMimeType;
- pFilter->aUserData = sUserData;
- pFilter->aServiceName = sServiceName;
+ SfxFilter* pFilt = const_cast<SfxFilter*>(pFilter.get());
+ pFilt->maFilterName = sFilterName;
+ pFilt->aWildCard = WildCard(sExtension, ';');
+ pFilt->nFormatType = nFlags;
+ pFilt->lFormat = nClipboardId;
+ pFilt->aTypeName = sType;
+ pFilt->nDocIcon = (sal_uInt16)nDocumentIconId;
+ pFilt->aMimeType = sMimeType;
+ pFilt->aUserData = sUserData;
+ pFilt->aServiceName = sServiceName;
}
+ SfxFilter* pFilt = const_cast<SfxFilter*>(pFilter.get());
+
// Don't forget to set right UIName!
// Otherwise internal name is used as fallback ...
- pFilter->SetUIName( sUIName );
- pFilter->SetDefaultTemplate( sDefaultTemplate );
+ pFilt->SetUIName( sUIName );
+ pFilt->SetDefaultTemplate( sDefaultTemplate );
if( nFormatVersion )
{
- pFilter->SetVersion( nFormatVersion );
+ pFilt->SetVersion( nFormatVersion );
}
- pFilter->SetURLPattern(sPattern);
-
- if (bNew)
- rList.push_back( pFilter );
+ pFilt->SetURLPattern(sPattern);
}
}
@@ -1139,11 +1130,11 @@ void SfxFilterContainer::ReadFilters_Impl( bool bUpdate )
if( !rList.empty() )
{
bUpdate = true;
- SfxFilter* pFilter;
for ( size_t i = 0, n = rList.size(); i < n; ++i )
{
- pFilter = rList[ i ];
- pFilter->nFormatType |= SFX_FILTER_NOTINSTALLED;
+ std::shared_ptr<const SfxFilter> pFilter = rList[i];
+ SfxFilter* pNonConstFilter = const_cast<SfxFilter*>(pFilter.get());
+ pNonConstFilter->nFormatType |= SFX_FILTER_NOTINSTALLED;
}
}
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 7d2ae6184cf5..792f831d2b84 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -867,7 +867,7 @@ IMPL_STATIC_LINK_NOARG_TYPED(SfxDocumentPage, ChangePassHdl, Button*, void)
SfxItemSet* pMedSet = pShell->GetMedium()->GetItemSet();
if (!pMedSet)
break;
- const SfxFilter* pFilter = pShell->GetMedium()->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pShell->GetMedium()->GetFilter();
if (!pFilter)
break;
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index ba34cbcb95e8..5351de95441e 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -362,15 +362,14 @@ void FileDialogHelper_Impl::SaveLastUsedFilter()
SaveLastUsedFilter( *pConfigId );
}
-const SfxFilter* FileDialogHelper_Impl::getCurentSfxFilter()
+std::shared_ptr<const SfxFilter> FileDialogHelper_Impl::getCurentSfxFilter()
{
OUString aFilterName = getCurrentFilterUIName();
- const SfxFilter* pFilter = nullptr;
if ( mpMatcher && !aFilterName.isEmpty() )
- pFilter = mpMatcher->GetFilter4UIName( aFilterName, m_nMustFlags, m_nDontFlags );
+ return mpMatcher->GetFilter4UIName( aFilterName, m_nMustFlags, m_nDontFlags );
- return pFilter;
+ return nullptr;
}
bool FileDialogHelper_Impl::updateExtendedControl( sal_Int16 _nExtendedControlId, bool _bEnable )
@@ -393,7 +392,7 @@ bool FileDialogHelper_Impl::updateExtendedControl( sal_Int16 _nExtendedControlId
return bIsEnabled;
}
-bool FileDialogHelper_Impl::CheckFilterOptionsCapability( const SfxFilter* _pFilter )
+bool FileDialogHelper_Impl::CheckFilterOptionsCapability( std::shared_ptr<const SfxFilter> _pFilter )
{
bool bResult = false;
@@ -512,7 +511,7 @@ void FileDialogHelper_Impl::updateSelectionBox()
if ( bSelectionBoxFound )
{
- const SfxFilter* pFilter = getCurentSfxFilter();
+ std::shared_ptr<const SfxFilter> pFilter = getCurentSfxFilter();
mbSelectionFltrEnabled = updateExtendedControl(
ExtendedFilePickerElementIds::CHECKBOX_SELECTION,
( mbSelectionEnabled && pFilter && ( pFilter->GetFilterFlags() & SfxFilterFlags::SUPPORTSSELECTION ) ) );
@@ -528,7 +527,7 @@ void FileDialogHelper_Impl::enablePasswordBox( bool bInit )
bool bWasEnabled = mbIsPwdEnabled;
- const SfxFilter* pCurrentFilter = getCurentSfxFilter();
+ std::shared_ptr<const SfxFilter> pCurrentFilter = getCurentSfxFilter();
mbIsPwdEnabled = updateExtendedControl(
ExtendedFilePickerElementIds::CHECKBOX_PASSWORD,
pCurrentFilter && ( pCurrentFilter->GetFilterFlags() & SfxFilterFlags::ENCRYPTION )
@@ -1305,7 +1304,7 @@ void lcl_saveLastURLs(std::vector<OUString>& rpURLList,
lLastURLs.push_back(*i);
}
-void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterface >& xPicker, std::vector<OUString>& rpURLList, const SfxFilter* pFilter)
+void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterface >& xPicker, std::vector<OUString>& rpURLList, std::shared_ptr<const SfxFilter> pFilter)
{
rpURLList.clear();
@@ -1471,7 +1470,7 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList,
// set the filter
getRealFilter( rFilter );
- const SfxFilter* pCurrentFilter = getCurentSfxFilter();
+ std::shared_ptr<const SfxFilter> pCurrentFilter = getCurentSfxFilter();
// fill the rpURLList
implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter );
@@ -1553,7 +1552,7 @@ void FileDialogHelper_Impl::getRealFilter( OUString& _rFilter ) const
if ( !_rFilter.isEmpty() && mpMatcher )
{
- const SfxFilter* pFilter =
+ std::shared_ptr<const SfxFilter> pFilter =
mpMatcher->GetFilter4UIName( _rFilter, m_nMustFlags, m_nDontFlags );
_rFilter = pFilter ? pFilter->GetFilterName() : OUString("");
}
@@ -1664,7 +1663,7 @@ void FileDialogHelper_Impl::setFilter( const OUString& rFilter )
if ( !rFilter.isEmpty() && mpMatcher )
{
- const SfxFilter* pFilter = mpMatcher->GetFilter4FilterName(
+ std::shared_ptr<const SfxFilter> pFilter = mpMatcher->GetFilter4FilterName(
rFilter, m_nMustFlags, m_nDontFlags );
if ( pFilter )
maCurFilter = pFilter->GetUIName();
@@ -2600,7 +2599,7 @@ ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType,
return nRet;
}
-ErrCode RequestPassword(const SfxFilter* pCurrentFilter, OUString& aURL, SfxItemSet* pSet)
+ErrCode RequestPassword(std::shared_ptr<const SfxFilter> pCurrentFilter, OUString& aURL, SfxItemSet* pSet)
{
uno::Reference < task::XInteractionHandler2 > xInteractionHandler = task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr );
// TODO: need a save way to distinguish MS filters from other filters
diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx
index f4a49efdd20d..1ea880bd13a3 100644
--- a/sfx2/source/dialog/filedlgimpl.hxx
+++ b/sfx2/source/dialog/filedlgimpl.hxx
@@ -115,7 +115,7 @@ namespace sfx2
void loadConfig();
void saveConfig();
- const SfxFilter* getCurentSfxFilter();
+ std::shared_ptr<const SfxFilter> getCurentSfxFilter();
bool updateExtendedControl( sal_Int16 _nExtendedControlId, bool _bEnable );
ErrCode getGraphic( const OUString& rURL, Graphic& rGraphic ) const;
@@ -128,7 +128,7 @@ namespace sfx2
void setControlHelpIds( const sal_Int16* _pControlId, const char** _pHelpId );
- bool CheckFilterOptionsCapability( const SfxFilter* _pFilter );
+ bool CheckFilterOptionsCapability( std::shared_ptr<const SfxFilter> _pFilter );
bool isInOpenMode() const;
OUString getCurrentFilterUIName() const;
@@ -143,7 +143,7 @@ namespace sfx2
void implGetAndCacheFiles( const css::uno::Reference< XInterface >& xPicker ,
std::vector<OUString>& rpURLList,
- const SfxFilter* pFilter );
+ std::shared_ptr<const SfxFilter> pFilter );
DECL_LINK_TYPED( TimeOutHdl_Impl, Idle *, void);
DECL_LINK_TYPED( InitControls, void*, void );
diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx
index f14c57f1fc77..ff86a2d8e6b6 100644
--- a/sfx2/source/dialog/filtergrouping.cxx
+++ b/sfx2/source/dialog/filtergrouping.cxx
@@ -607,7 +607,7 @@ namespace sfx2
OUString sFilterWildcard;
OUString sFilterName;
// loop through all the filters
- for ( const SfxFilter* pFilter = _rFilterMatcher.First(); pFilter; pFilter = _rFilterMatcher.Next() )
+ for ( std::shared_ptr<const SfxFilter> pFilter = _rFilterMatcher.First(); pFilter; pFilter = _rFilterMatcher.Next() )
{
sFilterName = pFilter->GetFilterName();
sFilterWildcard = pFilter->GetWildcard().getGlob();
@@ -762,7 +762,7 @@ namespace sfx2
// check if there's already a filter <ALL>
- for ( const SfxFilter* pFilter = _rFilterMatcher.First(); pFilter && !bHasAll; pFilter = _rFilterMatcher.Next() )
+ for ( std::shared_ptr<const SfxFilter> pFilter = _rFilterMatcher.First(); pFilter && !bHasAll; pFilter = _rFilterMatcher.Next() )
{
if ( pFilter->GetUIName() == _rAllFilterName )
bHasAll = true;
@@ -869,21 +869,21 @@ namespace sfx2
}
- const SfxFilter* TSortedFilterList::First()
+ std::shared_ptr<const SfxFilter> TSortedFilterList::First()
{
m_nIterator = 0;
return impl_getFilter(m_nIterator);
}
- const SfxFilter* TSortedFilterList::Next()
+ std::shared_ptr<const SfxFilter> TSortedFilterList::Next()
{
++m_nIterator;
return impl_getFilter(m_nIterator);
}
- const SfxFilter* TSortedFilterList::impl_getFilter(sal_Int32 nIndex)
+ std::shared_ptr<const SfxFilter> TSortedFilterList::impl_getFilter(sal_Int32 nIndex)
{
if (nIndex<0 || nIndex>=(sal_Int32)m_lFilters.size())
return nullptr;
@@ -908,7 +908,7 @@ namespace sfx2
// retrieve the default filter for this application module.
// It must be set as first of the generated filter list.
- const SfxFilter* pDefaultFilter = SfxFilterContainer::GetDefaultFilter_Impl(_rFactory);
+ std::shared_ptr<const SfxFilter> pDefaultFilter = SfxFilterContainer::GetDefaultFilter_Impl(_rFactory);
// Only use one extension (#i32434#)
// (and always the first if there are more than one)
sExtension = pDefaultFilter->GetWildcard().getGlob().getToken(0, ';');
@@ -924,7 +924,7 @@ namespace sfx2
SAL_WARN( "sfx.dialog", "Could not append DefaultFilter" << sUIName );
}
- for ( const SfxFilter* pFilter = _rFilterMatcher.First(); pFilter; pFilter = _rFilterMatcher.Next() )
+ for ( std::shared_ptr<const SfxFilter> pFilter = _rFilterMatcher.First(); pFilter; pFilter = _rFilterMatcher.Next() )
{
if (pFilter->GetName() == pDefaultFilter->GetName())
continue;
@@ -975,7 +975,7 @@ namespace sfx2
Reference< XFilterGroupManager > xFilterGroupManager( _rxFilterManager, UNO_QUERY );
OUString sTypeName;
- for ( const SfxFilter* pFilter = _rFilterMatcher.First(); pFilter; pFilter = _rFilterMatcher.Next() )
+ for ( std::shared_ptr<const SfxFilter> pFilter = _rFilterMatcher.First(); pFilter; pFilter = _rFilterMatcher.Next() )
{
sTypeName = pFilter->GetTypeName();
sUIName = pFilter->GetUIName();
diff --git a/sfx2/source/dialog/filtergrouping.hxx b/sfx2/source/dialog/filtergrouping.hxx
index 87635c11b443..bba379f344c7 100644
--- a/sfx2/source/dialog/filtergrouping.hxx
+++ b/sfx2/source/dialog/filtergrouping.hxx
@@ -24,6 +24,7 @@
#include <com/sun/star/container/XEnumeration.hpp>
#include "filedlgimpl.hxx"
+#include <memory>
namespace sfx2
{
@@ -37,11 +38,11 @@ namespace sfx2
public:
explicit TSortedFilterList(const css::uno::Reference< css::container::XEnumeration >& xFilterList);
- const SfxFilter* First();
- const SfxFilter* Next();
+ std::shared_ptr<const SfxFilter> First();
+ std::shared_ptr<const SfxFilter> Next();
private:
- const SfxFilter* impl_getFilter(sal_Int32 nIndex);
+ std::shared_ptr<const SfxFilter> impl_getFilter(sal_Int32 nIndex);
};
diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx
index a244622f1185..14031e725345 100644
--- a/sfx2/source/doc/docfac.cxx
+++ b/sfx2/source/doc/docfac.cxx
@@ -51,6 +51,7 @@
#include <tools/globname.hxx>
#include <assert.h>
+#include <memory>
using namespace ::com::sun::star;
@@ -307,13 +308,13 @@ OUString SfxObjectFactory::GetStandardTemplate( const OUString& rServiceName )
return sTemplate;
}
-const SfxFilter* SfxObjectFactory::GetTemplateFilter() const
+std::shared_ptr<const SfxFilter> SfxObjectFactory::GetTemplateFilter() const
{
sal_uInt16 nVersion=0;
SfxFilterMatcher aMatcher ( OUString::createFromAscii( pShortName ) );
SfxFilterMatcherIter aIter( aMatcher );
- const SfxFilter *pFilter = nullptr;
- const SfxFilter *pTemp = aIter.First();
+ std::shared_ptr<const SfxFilter> pFilter;
+ std::shared_ptr<const SfxFilter> pTemp = aIter.First();
while ( pTemp )
{
if( pTemp->IsOwnFormat() && pTemp->IsOwnTemplateFormat() && ( pTemp->GetVersion() > nVersion ) )
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 5edba7b65152..c48be3a45088 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -200,13 +200,13 @@ public:
mutable SfxItemSet* m_pSet;
mutable INetURLObject* m_pURLObj;
- const SfxFilter* m_pFilter;
- std::unique_ptr<SfxFilter> m_pCustomFilter;
+ std::shared_ptr<const SfxFilter> m_pFilter;
+ std::shared_ptr<const SfxFilter> m_pCustomFilter;
SvStream* m_pInStream;
SvStream* m_pOutStream;
- const SfxFilter* pOrigFilter;
+ std::shared_ptr<const SfxFilter> pOrigFilter;
OUString aOrigURL;
DateTime aExpireTime;
SfxFrameWeakRef wLoadTargetFrame;
@@ -242,7 +242,7 @@ public:
~SfxMedium_Impl();
OUString getFilterMimeType()
- { return m_pFilter == nullptr ? OUString() : m_pFilter->GetMimeType(); }
+ { return !m_pFilter ? OUString() : m_pFilter->GetMimeType(); }
};
@@ -2666,18 +2666,18 @@ SfxMedium::GetInteractionHandler( bool bGetAlways )
}
-void SfxMedium::SetFilter( const SfxFilter* pFilterP )
+void SfxMedium::SetFilter( std::shared_ptr<const SfxFilter> pFilter )
{
- pImp->m_pFilter = pFilterP;
+ pImp->m_pFilter = pFilter;
}
-const SfxFilter* SfxMedium::GetFilter() const
+std::shared_ptr<const SfxFilter> SfxMedium::GetFilter() const
{
return pImp->m_pFilter;
}
-const SfxFilter* SfxMedium::GetOrigFilter() const
+std::shared_ptr<const SfxFilter> SfxMedium::GetOrigFilter() const
{
return pImp->pOrigFilter ? pImp->pOrigFilter : pImp->m_pFilter;
}
@@ -2951,17 +2951,17 @@ void SfxMedium::CompleteReOpen()
pImp->bUseInteractionHandler = bUseInteractionHandler;
}
-SfxMedium::SfxMedium(const OUString &rName, StreamMode nOpenMode, const SfxFilter *pFlt, SfxItemSet *pInSet) :
+SfxMedium::SfxMedium(const OUString &rName, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, SfxItemSet *pInSet) :
pImp(new SfxMedium_Impl)
{
pImp->m_pSet = pInSet;
- pImp->m_pFilter = pFlt;
+ pImp->m_pFilter = pFilter;
pImp->m_aLogicName = rName;
pImp->m_nStorOpenMode = nOpenMode;
Init_Impl();
}
-SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode nOpenMode, const SfxFilter *pFlt, SfxItemSet *pInSet) :
+SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, SfxItemSet *pInSet) :
pImp(new SfxMedium_Impl)
{
pImp->m_pSet = pInSet;
@@ -2969,7 +2969,7 @@ SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode
if (s->GetItem(SID_REFERER) == nullptr) {
s->Put(SfxStringItem(SID_REFERER, rReferer));
}
- pImp->m_pFilter = pFlt;
+ pImp->m_pFilter = pFilter;
pImp->m_aLogicName = rName;
pImp->m_nStorOpenMode = nOpenMode;
Init_Impl();
@@ -3001,7 +3001,7 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) :
{
// This filter is from an external provider such as orcus.
pImp->m_pCustomFilter.reset(new SfxFilter(aFilterProvider, aFilterName));
- pImp->m_pFilter = pImp->m_pCustomFilter.get();
+ pImp->m_pFilter = pImp->m_pCustomFilter;
}
const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pImp->m_pSet, SID_DOC_SALVAGE, false);
diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx
index ac457c07381b..061cf8f3d289 100644
--- a/sfx2/source/doc/docfilt.cxx
+++ b/sfx2/source/doc/docfilt.cxx
@@ -122,17 +122,17 @@ OUString SfxFilter::GetSuffixes() const
return aRet;
}
-const SfxFilter* SfxFilter::GetDefaultFilter( const OUString& rName )
+std::shared_ptr<const SfxFilter> SfxFilter::GetDefaultFilter( const OUString& rName )
{
return SfxFilterContainer::GetDefaultFilter_Impl( rName );
}
-const SfxFilter* SfxFilter::GetDefaultFilterFromFactory( const OUString& rFact )
+std::shared_ptr<const SfxFilter> SfxFilter::GetDefaultFilterFromFactory( const OUString& rFact )
{
return GetDefaultFilter( SfxObjectShell::GetServiceNameFromFactory( rFact ) );
}
-const SfxFilter* SfxFilter::GetFilterByName( const OUString& rName )
+std::shared_ptr<const SfxFilter> SfxFilter::GetFilterByName( const OUString& rName )
{
SfxFilterMatcher aMatch;
return aMatch.GetFilter4FilterName( rName, SfxFilterFlags::NONE, SfxFilterFlags::NONE );
@@ -169,7 +169,7 @@ OUString SfxFilter::GetTypeFromStorage( const SotStorage& rStg )
SotClipboardFormatId nClipId = ((SotStorage&)rStg).GetFormat();
if ( nClipId != SotClipboardFormatId::NONE )
{
- const SfxFilter* pFilter = SfxFilterMatcher().GetFilter4ClipBoardId( nClipId );
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilterMatcher().GetFilter4ClipBoardId( nClipId );
if ( pFilter )
return pFilter->GetTypeName();
}
@@ -206,7 +206,7 @@ OUString SfxFilter::GetTypeFromStorage(
nDont |= SfxFilterFlags::TEMPLATEPATH;
// get filter from storage MediaType
- const SfxFilter* pFilter = aMatcher.GetFilter4ClipBoardId( nClipId, nMust, nDont );
+ std::shared_ptr<const SfxFilter> pFilter = aMatcher.GetFilter4ClipBoardId( nClipId, nMust, nDont );
if ( !pFilter )
// template filter is asked for , but there isn't one; so at least the "normal" format should be detected
// or storage *is* a template, but bTemplate is not set
diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index 84f1ce5b1611..56a84ee6766f 100644
--- a/sfx2/source/doc/docinsert.cxx
+++ b/sfx2/source/doc/docinsert.cxx
@@ -95,8 +95,8 @@ SfxMedium* DocumentInserter::CreateMedium()
else
pMatcher = new SfxFilterMatcher();
- const SfxFilter* pFilter = nullptr;
- sal_uInt32 nError = pMatcher->DetectFilter( *pMedium, &pFilter );
+ std::shared_ptr<const SfxFilter> pFilter;
+ sal_uInt32 nError = pMatcher->DetectFilter( *pMedium, pFilter );
if ( nError == ERRCODE_NONE && pFilter )
pMedium->SetFilter( pFilter );
else
@@ -125,8 +125,8 @@ SfxMediumList* DocumentInserter::CreateMediumList()
pMedium->UseInteractionHandler( true );
SfxFilterMatcher aMatcher( m_sDocFactory );
- const SfxFilter* pFilter = nullptr;
- sal_uInt32 nError = aMatcher.DetectFilter( *pMedium, &pFilter );
+ std::shared_ptr<const SfxFilter> pFilter;
+ sal_uInt32 nError = aMatcher.DetectFilter( *pMedium, pFilter );
if ( nError == ERRCODE_NONE && pFilter )
pMedium->SetFilter( pFilter );
else
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 28d972eef333..e6c0ee950a28 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -507,7 +507,7 @@ void SfxObjectShell::UpdateFromTemplate_Impl( )
bool SfxObjectShell::IsHelpDocument() const
{
- const SfxFilter* pFilter = GetMedium()->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = GetMedium()->GetFilter();
return (pFilter && pFilter->GetFilterName() == "writer_web_HTML_help");
}
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 19b1072eca30..92ba81e4f522 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -278,7 +278,7 @@ bool SfxObjectShell::APISaveAs_Impl(const OUString& aFileName, SfxItemSet& rItem
const SfxStringItem* pContentTypeItem = rItemSet.GetItem<SfxStringItem>(SID_CONTENTTYPE, false);
if ( pContentTypeItem )
{
- const SfxFilter* pFilter = SfxFilterMatcher( OUString::createFromAscii(GetFactory().GetShortName()) ).GetFilter4Mime( pContentTypeItem->GetValue(), SfxFilterFlags::EXPORT );
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilterMatcher( OUString::createFromAscii(GetFactory().GetShortName()) ).GetFilter4Mime( pContentTypeItem->GetValue(), SfxFilterFlags::EXPORT );
if ( pFilter )
aFilterName = pFilter->GetName();
}
@@ -287,7 +287,7 @@ bool SfxObjectShell::APISaveAs_Impl(const OUString& aFileName, SfxItemSet& rItem
// in case no filter defined use default one
if( aFilterName.isEmpty() )
{
- const SfxFilter* pFilt = SfxFilter::GetDefaultFilterFromFactory(GetFactory().GetFactoryName());
+ std::shared_ptr<const SfxFilter> pFilt = SfxFilter::GetDefaultFilterFromFactory(GetFactory().GetFactoryName());
DBG_ASSERT( pFilt, "No default filter!\n" );
if( pFilt )
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index cfc8710804e6..b6de496cd083 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -628,7 +628,7 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed )
pMedium->CanDisposeStorage_Impl( true );
bool bOk = false;
- const SfxFilter* pFilter = pMed->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pMed->GetFilter();
SfxItemSet* pSet = pMedium->GetItemSet();
if( !pImp->nEventId )
{
@@ -893,7 +893,7 @@ sal_uInt32 SfxObjectShell::HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDo
{
try {
bool bAbort = false;
- const SfxFilter* pFilter = pMedium->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter();
Sequence < PropertyValue > aProps;
Any aAny = xFilterCFG->getByName( pFilter->GetName() );
if ( aAny >>= aProps )
@@ -1107,7 +1107,7 @@ bool SfxObjectShell::SaveTo_Impl
ModifyBlocker_Impl aMod(this);
- const SfxFilter *pFilter = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
if ( !pFilter )
{
// if no filter was set, use the default filter
@@ -1334,7 +1334,7 @@ bool SfxObjectShell::SaveTo_Impl
// document. It can be retrieved from the default filter for the desired target format
SotClipboardFormatId nFormat = rMedium.GetFilter()->GetFormat();
SfxFilterMatcher& rMatcher = SfxGetpApp()->GetFilterMatcher();
- const SfxFilter *pFilt = rMatcher.GetFilter4ClipBoardId( nFormat );
+ std::shared_ptr<const SfxFilter> pFilt = rMatcher.GetFilter4ClipBoardId( nFormat );
if ( pFilt )
{
if ( pFilt->GetServiceName() != rMedium.GetFilter()->GetServiceName() )
@@ -1957,7 +1957,7 @@ bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed )
pMedium->CanDisposeStorage_Impl( true );
}
- const SfxFilter *pFilter = pMedium ? pMedium->GetFilter() : nullptr;
+ std::shared_ptr<const SfxFilter> pFilter = pMedium ? pMedium->GetFilter() : nullptr;
if ( pNewMed )
{
if( bMedChanged )
@@ -2103,7 +2103,7 @@ void SfxObjectShell::AddToRecentlyUsedList()
if ( aUrl.GetProtocol() == INetProtocol::File )
{
- const SfxFilter* pOrgFilter = pMedium->GetOrigFilter();
+ std::shared_ptr<const SfxFilter> pOrgFilter = pMedium->GetOrigFilter();
Application::AddToRecentDocumentList( aUrl.GetURLNoPass( INetURLObject::NO_DECODE ),
(pOrgFilter) ? pOrgFilter->GetMimeType() : OUString(),
(pOrgFilter) ? pOrgFilter->GetServiceName() : OUString() );
@@ -2485,7 +2485,7 @@ bool SfxObjectShell::ConvertTo
bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs )
{
SfxMedium* pRetrMedium = GetMedium();
- const SfxFilter* pFilter = pRetrMedium->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pRetrMedium->GetFilter();
// copy the original itemset, but remove the "version" item, because pMediumTmp
// is a new medium "from scratch", so no version should be stored into it
@@ -2585,7 +2585,7 @@ bool SfxObjectShell::Save_Impl( const SfxItemSet* pSet )
{
const SfxStringItem* pFilterItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_FILTER_NAME, false);
OUString aFilterName;
- const SfxFilter *pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
if ( pFilterItem )
pFilter = SfxFilterMatcher( OUString::createFromAscii( GetFactory().GetShortName()) ).GetFilter4FilterName( aFilterName );
@@ -2644,7 +2644,7 @@ bool SfxObjectShell::CommonSaveAs_Impl(const INetURLObject& aURL, const OUString
const SfxBoolItem* pSaveToItem = rItemSet.GetItem<SfxBoolItem>(SID_SAVETO, false);
bool bSaveTo = pSaveToItem && pSaveToItem->GetValue();
- const SfxFilter* pFilter = GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
+ std::shared_ptr<const SfxFilter> pFilter = GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
if ( !pFilter
|| !pFilter->CanExport()
|| (!bSaveTo && !pFilter->CanImport()) )
@@ -2896,7 +2896,7 @@ bool SfxObjectShell::IsInformationLost()
// for the latest store then the user should be asked to store in own format
if ( !aFilterName.isEmpty() && aFilterName.equals( aPreusedFilterName ) )
{
- const SfxFilter *pFilt = GetMedium()->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilt = GetMedium()->GetFilter();
DBG_ASSERT( pFilt && aFilterName.equals( pFilt->GetName() ), "MediaDescriptor contains wrong filter!\n" );
return ( pFilt && pFilt->IsAlienFormat() );
}
@@ -3061,7 +3061,7 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium )
const bool bTemplate = rMedium.GetFilter()->IsOwnTemplateFormat()
&& nVersion > SOFFICE_FILEFORMAT_60;
- const SfxFilter* pFilter = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
bool bChart = false;
if(pFilter->GetName() == "chart8")
bChart = true;
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 0535db0e0074..4bcfdc93cbf1 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1788,7 +1788,7 @@ namespace {
OUString getFilterProvider( SfxMedium& rMedium )
{
- const SfxFilter* pFilter = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
if (!pFilter)
return OUString();
@@ -1911,7 +1911,7 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA
// file recovery: restore original filter
const SfxStringItem* pFilterItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_FILTER_NAME, false);
SfxFilterMatcher& rMatcher = SfxGetpApp()->GetFilterMatcher();
- const SfxFilter* pSetFilter = rMatcher.GetFilter4FilterName( pFilterItem->GetValue() );
+ std::shared_ptr<const SfxFilter> pSetFilter = rMatcher.GetFilter4FilterName( pFilterItem->GetValue() );
pMedium->SetFilter( pSetFilter );
m_pData->m_pObjectShell->SetModified();
}
@@ -2913,7 +2913,7 @@ bool SfxBaseModel::impl_isDisposed() const
OUString SfxBaseModel::GetMediumFilterName_Impl()
{
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
if ( pMedium )
pFilter = pMedium->GetFilter();
@@ -2946,7 +2946,7 @@ void SfxBaseModel::impl_store( const OUString& sURL
SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
if ( pMedium )
{
- const SfxFilter* pFilter = pMedium->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter();
if ( pFilter && aFilterName.equals( pFilter->GetFilterName() ) )
{
// #i119366# - If the former file saving with password, do not trying in StoreSelf anyway...
@@ -3772,7 +3772,7 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >&
if( pItem )
{
OUString aFilterName = pItem->GetValue();
- const SfxFilter* pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( aFilterName );
+ std::shared_ptr<const SfxFilter> pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( aFilterName );
if ( pFilter && pFilter->UsesStorage() )
nVersion = pFilter->GetVersion();
}
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 9408f99310be..bffbe89d07b1 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1685,7 +1685,7 @@ static bool lcl_getServiceName ( const OUString &rFileURL, OUString &rName )
SotClipboardFormatId nFormat = SotStorage::GetFormatID( xStorage );
- const SfxFilter* pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4ClipBoardId( nFormat );
+ std::shared_ptr<const SfxFilter> pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4ClipBoardId( nFormat );
if ( pFilter )
{
diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx
index 007f3ec3a5e9..47a7943b57d3 100644
--- a/sfx2/source/view/frame.cxx
+++ b/sfx2/source/view/frame.cxx
@@ -424,7 +424,7 @@ void SfxFrame::UpdateDescriptor( SfxObjectShell *pDoc )
// Mark FileOpen parameter
SfxItemSet* pItemSet = pMed->GetItemSet();
- const SfxFilter* pFilter = pMed->GetOrigFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pMed->GetOrigFilter();
OUString aFilter;
if ( pFilter )
aFilter = pFilter->GetFilterName();
diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx
index c89552c2f8dc..d3045287441c 100644
--- a/sfx2/source/view/frmload.cxx
+++ b/sfx2/source/view/frmload.cxx
@@ -129,7 +129,7 @@ protected:
virtual ~SfxFrameLoader_Impl();
private:
- const SfxFilter* impl_getFilterFromServiceName_nothrow(
+ std::shared_ptr<const SfxFilter> impl_getFilterFromServiceName_nothrow(
const OUString& i_rServiceName
) const;
@@ -138,7 +138,7 @@ private:
const OUString& i_rDocumentURL
);
- const SfxFilter* impl_detectFilterForURL(
+ std::shared_ptr<const SfxFilter> impl_detectFilterForURL(
const OUString& _rURL,
const ::comphelper::NamedValueCollection& i_rDescriptor,
const SfxFilterMatcher& rMatcher
@@ -204,7 +204,7 @@ SfxFrameLoader_Impl::~SfxFrameLoader_Impl()
}
-const SfxFilter* SfxFrameLoader_Impl::impl_detectFilterForURL( const OUString& sURL,
+std::shared_ptr<const SfxFilter> SfxFrameLoader_Impl::impl_detectFilterForURL( const OUString& sURL,
const ::comphelper::NamedValueCollection& i_rDescriptor, const SfxFilterMatcher& rMatcher ) const
{
OUString sFilter;
@@ -229,7 +229,7 @@ const SfxFilter* SfxFrameLoader_Impl::impl_detectFilterForURL( const OUString& s
OUString sType = xDetect->queryTypeByDescriptor( aQueryArgs, sal_True );
if ( !sType.isEmpty() )
{
- const SfxFilter* pFilter = rMatcher.GetFilter4EA( sType );
+ std::shared_ptr<const SfxFilter> pFilter = rMatcher.GetFilter4EA( sType );
if ( pFilter )
sFilter = pFilter->GetName();
}
@@ -244,14 +244,14 @@ const SfxFilter* SfxFrameLoader_Impl::impl_detectFilterForURL( const OUString& s
sFilter.clear();
}
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
if (!sFilter.isEmpty())
pFilter = rMatcher.GetFilter4FilterName(sFilter);
return pFilter;
}
-const SfxFilter* SfxFrameLoader_Impl::impl_getFilterFromServiceName_nothrow( const OUString& i_rServiceName ) const
+std::shared_ptr<const SfxFilter> SfxFrameLoader_Impl::impl_getFilterFromServiceName_nothrow( const OUString& i_rServiceName ) const
{
try
{
@@ -275,7 +275,7 @@ const SfxFilter* SfxFrameLoader_Impl::impl_getFilterFromServiceName_nothrow( con
if ( sFilterName.isEmpty() )
continue;
- const SfxFilter* pFilter = rMatcher.GetFilter4FilterName( sFilterName );
+ std::shared_ptr<const SfxFilter> pFilter = rMatcher.GetFilter4FilterName( sFilterName );
if ( !pFilter )
continue;
@@ -361,7 +361,7 @@ void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollecti
xInteraction = io_rDescriptor.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() );
const SfxFilterMatcher& rMatcher = SfxGetpApp()->GetFilterMatcher();
- const SfxFilter* pFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pFilter;
// get filter by its name directly ...
if ( !sFilterName.isEmpty() )
@@ -444,7 +444,7 @@ bool SfxFrameLoader_Impl::impl_determineTemplateDocument( ::comphelper::NamedVal
{
// 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, SfxGetpApp()->GetFilterMatcher() );
+ std::shared_ptr<const SfxFilter> pTemplateFilter = impl_detectFilterForURL( sTemplateURL, io_rDescriptor, SfxGetpApp()->GetFilterMatcher() );
if ( pTemplateFilter )
{
// load the template document, but, well, "as template"
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 9775ff00da44..3e45135af02b 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -154,7 +154,7 @@ void SfxViewFrame::InitInterface_Impl()
#endif
}
-static bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash, const uno::Sequence< beans::PropertyValue >& aInfo )
+static bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const OUString& aPath, std::shared_ptr<const SfxFilter> pFilter, sal_uInt32 nPasswordHash, const uno::Sequence< beans::PropertyValue >& aInfo )
{
// TODO/LATER: In future the info should replace the direct hash completely
bool bResult = ( !nPasswordHash && !aInfo.getLength() );
@@ -609,7 +609,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
DELETEZ( xOldObj->Get_Impl()->pReloadTimer );
SfxItemSet* pNewSet = nullptr;
- const SfxFilter *pFilter = pMedium->GetFilter();
+ std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter();
if( pURLItem )
{
pNewSet = new SfxAllItemSet( pApp->GetPool() );
@@ -622,7 +622,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
referer = refererItem->GetValue();
}
SfxMedium aMedium( pURLItem->GetValue(), referer, SFX_STREAM_READWRITE );
- SfxFilterMatcher().GuessFilter( aMedium, &pFilter );
+ SfxFilterMatcher().GuessFilter( aMedium, pFilter );
if ( pFilter )
pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) );
pNewSet->Put( *aMedium.GetItemSet() );
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index c431a6ab4ffa..ab9b8d41859a 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -656,7 +656,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
// document that is going to be printed!)
OUString aHelpFilterName( "writer_web_HTML_help" );
SfxMedium* pMedium = GetViewFrame()->GetObjectShell()->GetMedium();
- const SfxFilter* pFilter = pMedium ? pMedium->GetFilter() : nullptr;
+ std::shared_ptr<const SfxFilter> pFilter = pMedium ? pMedium->GetFilter() : nullptr;
bool bPrintOnHelp = ( pFilter && pFilter->GetFilterName() == aHelpFilterName );
const sal_uInt16 nId = rReq.GetSlot();
diff --git a/starmath/qa/extras/mmlimport-test.cxx b/starmath/qa/extras/mmlimport-test.cxx
index 5c808f323b26..19f9f27b21e5 100644
--- a/starmath/qa/extras/mmlimport-test.cxx
+++ b/starmath/qa/extras/mmlimport-test.cxx
@@ -44,7 +44,7 @@ private:
{
// Cf.
// filter/source/config/fragments/filters/MathML_XML__Math_.xcu
- SfxFilter* pFilter = new SfxFilter(MATHML_XML,
+ std::shared_ptr<SfxFilter> pFilter(new SfxFilter(MATHML_XML,
OUString(),
SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT | SfxFilterFlags::TEMPLATE,
SotClipboardFormatId::STARCALC_8,
@@ -52,8 +52,8 @@ private:
0,
OUString(),
OUString(),
- "private:factory/smath*");
- pFilter->SetVersion(SOFFICE_FILEFORMAT_60);
+ "private:factory/smath*"));
+ const_cast<SfxFilter*>(pFilter.get())->SetVersion(SOFFICE_FILEFORMAT_60);
mxDocShell = new SmDocShell(SfxModelFlags::EMBEDDED_OBJECT |
SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 28355b5c55aa..696a76a590d4 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -863,7 +863,7 @@ bool SmDocShell::SaveAs( SfxMedium& rMedium )
bool SmDocShell::ConvertTo( SfxMedium &rMedium )
{
bool bRet = false;
- const SfxFilter* pFlt = rMedium.GetFilter();
+ std::shared_ptr<const SfxFilter> pFlt = rMedium.GetFilter();
if( pFlt )
{
if( !pTree )
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index f3a7607f9ba0..9a3bea7da9d0 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1644,7 +1644,7 @@ void SmViewShell::Execute(SfxRequest& rReq)
{
std::unique_ptr<SfxMedium> pClipboardMedium(new SfxMedium());
pClipboardMedium->GetItemSet(); //generate initial itemset, not sure if necessary
- const SfxFilter* pMathFilter =
+ std::shared_ptr<const SfxFilter> pMathFilter =
SfxFilter::GetFilterByName(MATHML_XML);
pClipboardMedium->SetFilter(pMathFilter);
pClipboardMedium->setStreamToLoadFrom(xStrm, true /*bIsReadOnly*/);
@@ -1662,7 +1662,7 @@ void SmViewShell::Execute(SfxRequest& rReq)
{
std::unique_ptr<SfxMedium> pClipboardMedium(new SfxMedium());
pClipboardMedium->GetItemSet(); //generates initial itemset, not sure if necessary
- const SfxFilter* pMathFilter =
+ std::shared_ptr<const SfxFilter> pMathFilter =
SfxFilter::GetFilterByName(MATHML_XML);
pClipboardMedium->SetFilter(pMathFilter);
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index dc01e0f6c96d..a0876ec25020 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -1480,10 +1480,10 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
{
// normal link
OUString aFilterName;
- const SfxFilter* pSfxFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pSfxFilter;
SfxMedium aSfxMedium( aURL, referer_, StreamMode::READ | StreamMode::SHARE_DENYNONE );
- SfxGetpApp()->GetFilterMatcher().GuessFilter( aSfxMedium, &pSfxFilter );
+ SfxGetpApp()->GetFilterMatcher().GuessFilter( aSfxMedium, pSfxFilter );
if( !pSfxFilter )
{
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(), '*'));