[Libreoffice-commits] core.git: cui/source dbaccess/source desktop/source extensions/source filter/source include/sfx2 include/vbahelper reportdesign/source sc/inc sc/qa sc/source sd/qa sd/source sfx2/inc sfx2/source starmath/qa starmath/source svx/source sw/inc sw/qa sw/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Fri Mar 11 06:38:46 UTC 2016
cui/source/dialogs/hldocntp.cxx | 2
cui/source/options/doclinkdialog.cxx | 2
dbaccess/source/ui/app/AppController.cxx | 4
dbaccess/source/ui/dlg/dbwizsetup.cxx | 2
dbaccess/source/ui/dlg/generalpage.cxx | 2
dbaccess/source/ui/inc/UITools.hxx | 4
dbaccess/source/ui/misc/UITools.cxx | 4
desktop/source/app/dispatchwatcher.cxx | 12 -
extensions/source/abpilot/abpfinalpage.cxx | 6
extensions/source/dbpilots/commonpagesdbp.cxx | 2
extensions/source/propctrlr/formcomponenthandler.cxx | 2
filter/source/msfilter/msdffimp.cxx | 2
filter/source/msfilter/msoleexp.cxx | 2
include/sfx2/docfac.hxx | 2
include/sfx2/docfile.hxx | 13 -
include/sfx2/docfilt.hxx | 8
include/sfx2/fcontnr.hxx | 44 ++--
include/sfx2/filedlghelper.hxx | 4
include/vbahelper/vbaaccesshelper.hxx | 2
reportdesign/source/core/api/ReportEngineJFree.cxx | 2
reportdesign/source/ui/inspection/GeometryHandler.cxx | 2
sc/inc/tablink.hxx | 2
sc/qa/unit/helper/qahelper.cxx | 19 --
sc/qa/unit/subsequent_export-test.cxx | 6
sc/qa/unit/subsequent_filters-test.cxx | 8
sc/source/ui/docshell/arealink.cxx | 2
sc/source/ui/docshell/docsh.cxx | 4
sc/source/ui/docshell/docsh4.cxx | 2
sc/source/ui/docshell/externalrefmgr.cxx | 2
sc/source/ui/docshell/tablink.cxx | 12 -
sc/source/ui/miscdlgs/linkarea.cxx | 4
sc/source/ui/unoobj/scdetect.cxx | 2
sc/source/ui/view/viewfun4.cxx | 4
sd/qa/unit/filters-test.cxx | 8
sd/qa/unit/sdmodeltestbase.hxx | 19 +-
sd/source/core/drawdoc3.cxx | 4
sd/source/filter/xml/sdxmlwrp.cxx | 2
sd/source/ui/dlg/navigatr.cxx | 4
sd/source/ui/docshell/docshel4.cxx | 6
sd/source/ui/func/fuinsfil.cxx | 10 -
sd/source/ui/unoidl/sddetect.cxx | 2
sd/source/ui/view/sdview4.cxx | 4
sfx2/inc/arrdecl.hxx | 3
sfx2/source/appl/appopen.cxx | 6
sfx2/source/appl/sfxpicklist.cxx | 2
sfx2/source/appl/shutdownicon.cxx | 2
sfx2/source/bastyp/fltfnc.cxx | 165 ++++++++----------
sfx2/source/dialog/dinfdlg.cxx | 2
sfx2/source/dialog/filedlghelper.cxx | 23 +-
sfx2/source/dialog/filedlgimpl.hxx | 6
sfx2/source/dialog/filtergrouping.cxx | 16 -
sfx2/source/dialog/filtergrouping.hxx | 7
sfx2/source/doc/docfac.cxx | 7
sfx2/source/doc/docfile.cxx | 26 +-
sfx2/source/doc/docfilt.cxx | 10 -
sfx2/source/doc/docinsert.cxx | 8
sfx2/source/doc/objcont.cxx | 2
sfx2/source/doc/objserv.cxx | 4
sfx2/source/doc/objstor.cxx | 22 +-
sfx2/source/doc/sfxbasemodel.cxx | 10 -
sfx2/source/doc/templatedlg.cxx | 2
sfx2/source/view/frame.cxx | 2
sfx2/source/view/frmload.cxx | 18 -
sfx2/source/view/viewfrm.cxx | 6
sfx2/source/view/viewprn.cxx | 2
starmath/qa/extras/mmlimport-test.cxx | 6
starmath/source/document.cxx | 2
starmath/source/view.cxx | 4
svx/source/unodraw/unoshap2.cxx | 4
sw/inc/dbmgr.hxx | 6
sw/inc/iodetect.hxx | 4
sw/qa/core/filters-test.cxx | 12 -
sw/qa/core/uwriter.cxx | 6
sw/qa/extras/uiwriter/uiwriter.cxx | 12 -
sw/source/core/doc/docglbl.cxx | 2
sw/source/core/unocore/unocrsrhelper.cxx | 4
sw/source/filter/basflt/iodetect.cxx | 10 -
sw/source/ui/config/optcomp.cxx | 2
sw/source/ui/dbui/mmdocselectpage.cxx | 2
sw/source/ui/dbui/mmlayoutpage.cxx | 2
sw/source/ui/dbui/mmoutputpage.cxx | 8
sw/source/ui/misc/glossary.cxx | 2
sw/source/uibase/app/docsh.cxx | 6
sw/source/uibase/app/docsh2.cxx | 20 +-
sw/source/uibase/dbui/dbmgr.cxx | 12 -
sw/source/uibase/dochdl/gloshdl.cxx | 4
sw/source/uibase/dochdl/swdtflvr.cxx | 2
sw/source/uibase/uiview/srcview.cxx | 4
sw/source/uibase/uiview/view2.cxx | 4
sw/source/uibase/uno/unomailmerge.cxx | 2
90 files changed, 371 insertions(+), 371 deletions(-)
New commits:
commit e94d5233dd7939c54eb52fff456e817cecdf0a4c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Mar 11 06:43:06 2016 +0100
work on sane lifecylce for SfxFilter
all SfxFilter instances should now be hold inside of a std::shared_ptr.
This fixes a number of huge memory leaks in the test framework and
removes one huge source of memory issue in sfx2. SfxMedium contains a
pointer to the SfxFilter but does not own. Therefore it is required that
any SfxFilter belonging to a SfxMedium lives longer. However this seems
to work mostly by hoping that all SfxFilter instances are stored in a
global array. As we have seen with the tests this is not true (there are
also some cases inside of sd that seem to not follow that pattern as
well).
Change-Id: I12fd04a504cc4efc0a94967abd91c6fe2c6a8ce8
Reviewed-on: https://gerrit.libreoffice.org/23140
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index e38b02e..ec6026e 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 b22ca4b..de5f1e8 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 55aa240..60fac0f 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 776fc95..81e6e06 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 839fbff..bbf185e 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 b9a45cf..7964c79 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 42353aa..fecce2b 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 49dce81..3ba4e15 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 d51c356..9c2e48e 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 dbd3ed2..3a7b53c 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 b544f62..c44d3d9 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 c62dea4..07e5c12 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 02f2fd0..54c6a86 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 0e98186..547ad58 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 12b25ef..bbf9c4e 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 f67a69f..0a68d80 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 54f4850..ce5681c 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 741507a..9e49d1d 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 5284f72..3d14a39 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 d2be19e..cdff2e2 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 4c51faf..ab49ccf 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 de2490e..f50ad00 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 031f6bb..e94adc5 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 1228ada..c01426a 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 144e19e..92648a8 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 2dfba95..f403093 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 0309e1d..4c69ed1 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 98f094b..62b27d8 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 8319e5e..c2ace4a 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 2b2572c..aedb902 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 98b1958..2306e69 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 66dcac2..0f8c1ba 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 6fac2e8b..0e23548 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 836fa64..c08f6c0 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 5fdddf0..f40efa6 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 7e11c55..176cc32 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 5829e61..91ba7a6 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 bbee98c..8003a4a 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 ff5999d..71ac8e4 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 e057342..04aba71 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 4eff4b1..5ad76a4 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 ffda4fe..c13639f 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 837f909..67387e0 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 dd8b200..879ac5c 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 9edb6ff..0f69bbd 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 6d0571e..f26e474 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 3e2837c..80cb675 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 7d2ae61..792f831 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 ba34cbc..5351de9 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 f4a49ef..1ea880b 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 f14c57f..ff86a2d 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 87635c1..bba379f 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 a244622..14031e7 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 5edba7b..c48be3a 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 ac457c0..061cf8f 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 84f1ce5..56a84ee 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 28d972e..e6c0ee9 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 19b1072..92ba81e 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 )
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list