summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-11-27 11:47:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-11-29 12:10:21 +0100
commitf5e58a4287bc589d9a3349e162473a0603e4a86f (patch)
tree6122f8b3ff0744994e156921a5a248548ec3dc22
parent1021d7a635b5567a62f0711263eed3c3011ec687 (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. Reviewed-on: https://gerrit.libreoffice.org/83930 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit cc4dbe473b0b68dbe120065c1d6a64a087f41ba2) Resolves: tdf#129082 insert sheet from file fails since... tdf#127958 crash adding 2 or more files into writer master document commit 8f6f9e4217d03d874fb1ce391730a1c893ab6844 Date: Mon Oct 7 09:40:41 2019 +0200 used the SfxItemSet copy ctor to make a copy of the itemset, but the orig itemset was a SfxAllItemSet not a SfxItemSet. an SfxAllItemSet allows all items to be added but a plain SfxItemSet only allows items in certain ranges to be inserted. Upshot is that later on the filename property cannot be set in the itemset, so file can't be opened. since... tdf#128898 import text from file with text-decode failed commit cc4dbe473b0b68dbe120065c1d6a64a087f41ba2 Date: Wed Nov 27 11:47:57 2019 +0200 tdf#128898 import text from file with text-decode failed these are std::shared_ptr so we can return to passing in the original SfxAllItemSet again to fix the problem 63a4230a96f9dae7726d854297ebb2b51df4868d Change-Id: I77559e9f766d84aca0f9dc0bd1b856c69f0f62f1 Reviewed-on: https://gerrit.libreoffice.org/84029 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 5572f20c0f256140aaab38d3d1b3e53f8588112f) Reviewed-on: https://gerrit.libreoffice.org/84045 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Xisco Faulí <xiscofauli@libreoffice.org>
-rw-r--r--include/sfx2/docfile.hxx27
-rw-r--r--include/sfx2/docinsert.hxx2
-rw-r--r--sfx2/source/doc/docfile.cxx14
-rw-r--r--sfx2/source/doc/docinsert.cxx10
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx10
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx6
6 files changed, 25 insertions, 44 deletions
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index 77950a473197..120508b6d91e 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -69,35 +69,22 @@ class SFX2_DLLPUBLIC SfxMedium : 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 265fd4edd5b4..308d539218f7 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -286,7 +286,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;
@@ -3194,20 +3194,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));
@@ -3286,7 +3286,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);
@@ -3304,7 +3304,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/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index d763d047eea4..0dc030488d5e 100644
--- a/sfx2/source/doc/docinsert.cxx
+++ b/sfx2/source/doc/docinsert.cxx
@@ -105,12 +105,9 @@ std::unique_ptr<SfxMedium> DocumentInserter::CreateMedium(char const*const pFall
if (!m_nError && m_xItemSet && !m_pURLList.empty())
{
DBG_ASSERT( m_pURLList.size() == 1, "DocumentInserter::CreateMedium(): invalid URL list count" );
- std::unique_ptr<SfxItemSet> xItemSet;
- if (m_xItemSet)
- xItemSet = std::make_unique<SfxItemSet>(*m_xItemSet);
pMedium.reset(new SfxMedium(
m_pURLList[0], SFX_STREAM_READONLY,
- SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), std::move(xItemSet) ));
+ SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_xItemSet ));
pMedium->UseInteractionHandler( true );
std::unique_ptr<SfxFilterMatcher> pMatcher;
if ( !m_sDocFactory.isEmpty() )
@@ -145,12 +142,9 @@ SfxMediumList DocumentInserter::CreateMediumList()
{
for (auto const& url : m_pURLList)
{
- std::unique_ptr<SfxItemSet> xItemSet;
- if (m_xItemSet)
- xItemSet = std::make_unique<SfxItemSet>(*m_xItemSet);
std::unique_ptr<SfxMedium> pMedium(new SfxMedium(
url, SFX_STREAM_READONLY,
- SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), std::move(xItemSet) ));
+ SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_xItemSet ));
pMedium->UseInteractionHandler( true );
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 1f39d9f3efef..e281ff9a74ee 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -3678,11 +3678,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: may be a special URL "private:storage" should be used
- const SfxStringItem* pItem = aSet.GetItem<SfxStringItem>(SID_FILTER_NAME, false);
+ // TODO/LATER: maybe a special URL "private:storage" should be used
+ const SfxStringItem* pItem = xSet->GetItem<SfxStringItem>(SID_FILTER_NAME, false);
sal_Int32 nVersion = SOFFICE_FILEFORMAT_CURRENT;
if( pItem )
{
@@ -3704,7 +3704,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 2e935b87477c..7581c46b16e9 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1023,8 +1023,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 ) );
@@ -1046,7 +1046,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