diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-28 10:39:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-09-28 13:03:03 +0200 |
commit | c9a405b3bcc0d3f5fdb6b4386831a4d4b2897c74 (patch) | |
tree | 18a0d92d5c3c0444fcc759566102b07bde400dee | |
parent | 6e111548d9de8eacff79d614e4400719df792228 (diff) |
tdf#144532 closing mail merge wizard preview removed document's data source
Filter out the "EmbeddedDatabaseName" property from the document
settings on saving document that will be loaded by the mail merge
preview so that when the temp mailmerge preview document is closed it
doesn't unregister the database of the same name which was registered by
the document this is a copy of.
This looks like a similar problem to tdf#118634 addressed by:
commit edc62adae9a354ca1305e83b10c98a545f58d341
Date: Mon Jul 9 19:49:34 2018 +1000
tdf#118634: Don't save embedded data source to a temporary preview document
Change-Id: I3fecc2ace1c9e06354b145609f0130dbbb2c036b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122763
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/filter/xml/wrtxml.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/xml/wrtxml.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlexp.cxx | 29 |
3 files changed, 45 insertions, 5 deletions
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 859140d9f950..aa969c9d40e6 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -81,8 +81,8 @@ SwXMLWriter::~SwXMLWriter() { } -ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xStatusIndicator, - const OUString& aDocHierarchicalName ) +ErrCode SwXMLWriter::Write_(const uno::Reference < task::XStatusIndicator >& xStatusIndicator, + const OUString& aDocHierarchicalName, bool bNoEmbDS) { // Get service factory uno::Reference< uno::XComponentContext > xContext = @@ -160,6 +160,10 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS beans::PropertyAttribute::MAYBEVOID, 0 }, { OUString("TargetStorage"),0, cppu::UnoType<embed::XStorage>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 }, + // tdf#144532 + { OUString("NoEmbDataSet"), 0, + cppu::UnoType<bool>::get(), + beans::PropertyAttribute::MAYBEVOID, 0 }, { OUString(), 0, css::uno::Type(), 0, 0 } }; uno::Reference< beans::XPropertySet > xInfoSet( @@ -168,6 +172,8 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS xInfoSet->setPropertyValue( "TargetStorage", Any( m_xStg ) ); + xInfoSet->setPropertyValue("NoEmbDataSet", makeAny(bNoEmbDS)); + if (m_bShowProgress) { // set progress range and start status indicator @@ -441,13 +447,15 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS ErrCode SwXMLWriter::WriteStorage() { - return Write_( uno::Reference < task::XStatusIndicator >(), OUString() ); + return Write_(uno::Reference<task::XStatusIndicator>(), OUString(), false); } ErrCode SwXMLWriter::WriteMedium( SfxMedium& aTargetMedium ) { uno::Reference < task::XStatusIndicator > xStatusIndicator; OUString aName; + bool bNoEmbDS(false); + const SfxUnoAnyItem* pStatusBarItem = static_cast<const SfxUnoAnyItem*>( aTargetMedium.GetItemSet()->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) ); if ( pStatusBarItem ) @@ -456,8 +464,11 @@ ErrCode SwXMLWriter::WriteMedium( SfxMedium& aTargetMedium ) aTargetMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) ); if ( pDocHierarchItem ) aName = pDocHierarchItem->GetValue(); + const SfxBoolItem* pNoEmbDS = SfxItemSet::GetItem(aTargetMedium.GetItemSet(), SID_NO_EMBEDDED_DS, false); + if (pNoEmbDS) + bNoEmbDS = pNoEmbDS->GetValue(); - return Write_( xStatusIndicator, aName ); + return Write_(xStatusIndicator, aName, bNoEmbDS); } ErrCode SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed, diff --git a/sw/source/filter/xml/wrtxml.hxx b/sw/source/filter/xml/wrtxml.hxx index c82afcc97436..7e4ed6580c15 100644 --- a/sw/source/filter/xml/wrtxml.hxx +++ b/sw/source/filter/xml/wrtxml.hxx @@ -40,7 +40,7 @@ namespace com::sun::star { class SwXMLWriter : public StgWriter { - ErrCode Write_( const css::uno::Reference < css::task::XStatusIndicator>&, const OUString& ); + ErrCode Write_(const css::uno::Reference < css::task::XStatusIndicator>&, const OUString&, bool bNoEmbDS); using StgWriter::Write; diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 7ddf32da76cb..bcc9729ebbab 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -393,6 +393,35 @@ void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps) return; SvXMLUnitConverter::convertPropertySet( rProps, xProps ); + + // tdf#144532 if NoEmbDataSet was set, to indicate not to write an embedded + // database for the case of a temporary mail merge preview document, then + // also filter out the "EmbeddedDatabaseName" property from the document + // settings so that when the temp mailmerge preview document is closed it + // doesn't unregister the database of the same name which was registered by + // the document this is a copy of + Reference<XPropertySet> rInfoSet = getExportInfo(); + + if (!rInfoSet.is() || !rInfoSet->getPropertySetInfo()->hasPropertyByName(u"NoEmbDataSet")) + return; + + Any aAny = rInfoSet->getPropertyValue(u"NoEmbDataSet"); + bool bNoEmbDataSet = *o3tl::doAccess<bool>(aAny); + if (!bNoEmbDataSet) + return; + + Sequence<PropertyValue> aFilteredProps(rProps.getLength()); + sal_Int32 nFilteredPropLen = 0; + PropertyValue *pValue = rProps.getArray(); + for (sal_Int32 i = 0; i < rProps.getLength(); ++i) + { + if (pValue[i].Name == "EmbeddedDatabaseName") + continue; + aFilteredProps[nFilteredPropLen] = rProps[i]; + ++nFilteredPropLen; + } + aFilteredProps.realloc(nFilteredPropLen); + std::swap(rProps, aFilteredProps); } sal_Int32 SwXMLExport::GetDocumentSpecificSettings( std::vector< SettingsGroup >& _out_rSettings ) |