diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-11-27 11:47:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-11-28 08:30:09 +0100 |
commit | cc4dbe473b0b68dbe120065c1d6a64a087f41ba2 (patch) | |
tree | 4a79023e31188c96819beaedb8f48bc52b7e1d28 | |
parent | 2bf687bebb30defe576ddb20c1c9680979ed3086 (diff) |
tdf#128898 import text from file with text-decode failed
regression from
commit 8f6f9e4217d03d874fb1ce391730a1c893ab6844
tdf#127958 crash adding 2 or more files into writer master document
just make SfxMedium use shared_ptr, rather than the sometimes yes,
sometimes no, ownership.
Change-Id: I77559e9f766d84aca0f9dc0bd1b856c69f0f62f1
Reviewed-on: https://gerrit.libreoffice.org/83930
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/sfx2/docfile.hxx | 27 | ||||
-rw-r--r-- | include/sfx2/docinsert.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 14 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unocrsrhelper.cxx | 6 |
5 files changed, 22 insertions, 35 deletions
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx index ab2ea96aba28..2019b5738c01 100644 --- a/include/sfx2/docfile.hxx +++ b/include/sfx2/docfile.hxx @@ -69,35 +69,22 @@ class SFX2_DLLPUBLIC SfxMedium final : public SvRefBase public: SfxMedium(); - /** - * @param pSet Takes ownership - */ SfxMedium( const OUString &rName, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter = nullptr, - std::unique_ptr<SfxItemSet> pSet = nullptr ); - /** - * @param pSet Takes ownership - */ + const std::shared_ptr<SfxItemSet>& pSet = nullptr ); SfxMedium( const OUString &rName, const OUString &rReferer, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter = nullptr, - std::unique_ptr<SfxItemSet> pSet = nullptr ); - - /** - * @param pSet does NOT take ownership - */ + const std::shared_ptr<SfxItemSet>& pSet = nullptr ); SfxMedium( const css::uno::Reference< css::embed::XStorage >& xStorage, - const OUString& rBaseURL, - const SfxItemSet* pSet=nullptr ); - /** - * @param pSet does NOT take ownership - */ + const OUString& rBaseURL, + const std::shared_ptr<SfxItemSet>& pSet = nullptr ); SfxMedium( const css::uno::Reference< css::embed::XStorage >& xStorage, - const OUString& rBaseURL, - const OUString& rTypeName, - const SfxItemSet* pSet=nullptr ); + const OUString& rBaseURL, + const OUString& rTypeName, + const std::shared_ptr<SfxItemSet>& pSet = nullptr ); SfxMedium( const css::uno::Sequence< css::beans::PropertyValue >& aArgs ); virtual ~SfxMedium() override; diff --git a/include/sfx2/docinsert.hxx b/include/sfx2/docinsert.hxx index 0148b854fed2..ae819299079c 100644 --- a/include/sfx2/docinsert.hxx +++ b/include/sfx2/docinsert.hxx @@ -50,7 +50,7 @@ private: std::unique_ptr<sfx2::FileDialogHelper> m_pFileDlg; - std::unique_ptr<SfxItemSet> m_xItemSet; + std::shared_ptr<SfxItemSet> m_xItemSet; std::vector<OUString> m_pURLList; DECL_LINK(DialogClosedHdl, sfx2::FileDialogHelper*, void); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 7f77ccc924dc..0e646ae723b5 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -287,7 +287,7 @@ public: OUString m_aLogicName; OUString m_aLongName; - mutable std::unique_ptr<SfxItemSet> m_pSet; + mutable std::shared_ptr<SfxItemSet> m_pSet; mutable std::unique_ptr<INetURLObject> m_pURLObj; std::shared_ptr<const SfxFilter> m_pFilter; @@ -3210,20 +3210,20 @@ void SfxMedium::CompleteReOpen() pImpl->bUseInteractionHandler = bUseInteractionHandler; } -SfxMedium::SfxMedium(const OUString &rName, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, std::unique_ptr<SfxItemSet> pInSet) : +SfxMedium::SfxMedium(const OUString &rName, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, const std::shared_ptr<SfxItemSet>& pInSet) : pImpl(new SfxMedium_Impl) { - pImpl->m_pSet = std::move( pInSet ); + pImpl->m_pSet = pInSet; pImpl->m_pFilter = std::move(pFilter); pImpl->m_aLogicName = rName; pImpl->m_nStorOpenMode = nOpenMode; Init_Impl(); } -SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, std::unique_ptr<SfxItemSet> pInSet) : +SfxMedium::SfxMedium(const OUString &rName, const OUString &rReferer, StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter, const std::shared_ptr<SfxItemSet>& pInSet) : pImpl(new SfxMedium_Impl) { - pImpl->m_pSet = std::move(pInSet); + pImpl->m_pSet = pInSet; SfxItemSet * s = GetItemSet(); if (s->GetItem(SID_REFERER) == nullptr) { s->Put(SfxStringItem(SID_REFERER, rReferer)); @@ -3302,7 +3302,7 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : } -SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUString& rBaseURL, const SfxItemSet* p ) : +SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUString& rBaseURL, const std::shared_ptr<SfxItemSet>& p ) : pImpl(new SfxMedium_Impl) { OUString aType = SfxFilter::GetTypeFromStorage(rStor); @@ -3320,7 +3320,7 @@ SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUS } -SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUString& rBaseURL, const OUString &rTypeName, const SfxItemSet* p ) : +SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUString& rBaseURL, const OUString &rTypeName, const std::shared_ptr<SfxItemSet>& p ) : pImpl(new SfxMedium_Impl) { pImpl->m_pFilter = SfxGetpApp()->GetFilterMatcher().GetFilter4EA( rTypeName ); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index c841644cc98c..f6068448e531 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3739,11 +3739,11 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >& if ( !m_pData->m_pObjectShell.is() ) throw io::IOException(); // TODO: - SfxAllItemSet aSet( m_pData->m_pObjectShell->GetPool() ); - TransformParameters( SID_SAVEASDOC, aMediaDescriptor, aSet ); + std::shared_ptr<SfxAllItemSet> xSet( new SfxAllItemSet(m_pData->m_pObjectShell->GetPool()) ); + TransformParameters( SID_SAVEASDOC, aMediaDescriptor, *xSet ); // TODO/LATER: maybe a special URL "private:storage" should be used - const SfxStringItem* pItem = aSet.GetItem<SfxStringItem>(SID_FILTER_NAME, false); + const SfxStringItem* pItem = xSet->GetItem<SfxStringItem>(SID_FILTER_NAME, false); sal_Int32 nVersion = SOFFICE_FILEFORMAT_CURRENT; if( pItem ) { @@ -3765,7 +3765,7 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >& m_pData->m_pObjectShell->SetupStorage( xStorage, nVersion, false ); // BaseURL is part of the ItemSet - SfxMedium aMedium( xStorage, OUString(), &aSet ); + SfxMedium aMedium( xStorage, OUString(), xSet ); aMedium.CanDisposeStorage_Impl( false ); if ( aMedium.GetFilter() ) { diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 5e973c2b7c99..291f3a8f0d34 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -1021,8 +1021,8 @@ void InsertFile(SwUnoCursor* pUnoCursor, const OUString& rURL, } else pMed.reset(xReadStorage.is() ? - new SfxMedium(xReadStorage, sBaseURL, nullptr ) : - new SfxMedium(sFileName, StreamMode::READ, nullptr, nullptr )); + new SfxMedium(xReadStorage, sBaseURL ) : + new SfxMedium(sFileName, StreamMode::READ )); if( !sBaseURL.isEmpty() ) pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) ); @@ -1044,7 +1044,7 @@ void InsertFile(SwUnoCursor* pUnoCursor, const OUString& rURL, { if( xReadStorage.is() ) { - pMed.reset(new SfxMedium(xReadStorage, sBaseURL, nullptr )); + pMed.reset(new SfxMedium(xReadStorage, sBaseURL )); pMed->SetFilter( pFilter ); } else |