summaryrefslogtreecommitdiff
path: root/sfx2
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 07:58:26 +0100
commitf3d4c125775b00432a2ef8db329c23c793abc40f (patch)
tree64da0e1b0638fde5bc5502c8a97347e5dd616ecd /sfx2
parent09e86f7cef6ca3e2ca451cbbae439006820c71d4 (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 Reviewed-on: https://gerrit.libreoffice.org/84024 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> Change-Id: I77559e9f766d84aca0f9dc0bd1b856c69f0f62f1 Reviewed-on: https://gerrit.libreoffice.org/84025 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/docfile.cxx14
-rw-r--r--sfx2/source/doc/docinsert.cxx10
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx8
3 files changed, 13 insertions, 19 deletions
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/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index ec25e6a39fd5..7b7fa8516e95 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 74b1497829bc..394475c40129 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -3724,11 +3724,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 )
{
@@ -3750,7 +3750,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() )
{