diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-11 06:43:06 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-11 06:38:15 +0000 |
commit | e94d5233dd7939c54eb52fff456e817cecdf0a4c (patch) | |
tree | 24acd3465e88b1a2a26246272a41236edfbe9b21 /sfx2 | |
parent | fb827f2a342602f7e62dbdebb638326193315eb6 (diff) |
work on sane lifecylce for SfxFilter
all SfxFilter instances should now be hold inside of a std::shared_ptr.
This fixes a number of huge memory leaks in the test framework and
removes one huge source of memory issue in sfx2. SfxMedium contains a
pointer to the SfxFilter but does not own. Therefore it is required that
any SfxFilter belonging to a SfxMedium lives longer. However this seems
to work mostly by hoping that all SfxFilter instances are stored in a
global array. As we have seen with the tests this is not true (there are
also some cases inside of sd that seem to not follow that pattern as
well).
Change-Id: I12fd04a504cc4efc0a94967abd91c6fe2c6a8ce8
Reviewed-on: https://gerrit.libreoffice.org/23140
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/arrdecl.hxx | 3 | ||||
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/appl/sfxpicklist.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/shutdownicon.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/bastyp/fltfnc.cxx | 165 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 23 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlgimpl.hxx | 6 | ||||
-rw-r--r-- | sfx2/source/dialog/filtergrouping.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/dialog/filtergrouping.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/doc/docfac.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 26 | ||||
-rw-r--r-- | sfx2/source/doc/docfilt.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/docinsert.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/objcont.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 22 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/frame.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/frmload.cxx | 18 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/view/viewprn.cxx | 2 |
23 files changed, 172 insertions, 179 deletions
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(); |