[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - include/sfx2 sfx2/source sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 29 06:59:04 UTC 2019
include/sfx2/docfile.hxx | 27 +++++++--------------------
include/sfx2/docinsert.hxx | 2 +-
sfx2/source/doc/docfile.cxx | 14 +++++++-------
sfx2/source/doc/docinsert.cxx | 10 ++--------
sfx2/source/doc/sfxbasemodel.cxx | 8 ++++----
sw/source/core/unocore/unocrsrhelper.cxx | 6 +++---
6 files changed, 24 insertions(+), 43 deletions(-)
New commits:
commit f3d4c125775b00432a2ef8db329c23c793abc40f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Nov 27 11:47:57 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Nov 29 07:58:26 2019 +0100
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 at 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 at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
Change-Id: I77559e9f766d84aca0f9dc0bd1b856c69f0f62f1
Reviewed-on: https://gerrit.libreoffice.org/84025
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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/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() )
{
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
More information about the Libreoffice-commits
mailing list