sw/inc/fldbas.hxx | 2 ++ sw/inc/fmtfld.hxx | 5 +++++ sw/source/core/fields/ddefld.cxx | 15 +++++++++++---- sw/source/core/fields/ddetbl.cxx | 4 ++++ sw/source/core/fields/fldbas.cxx | 5 +++++ 5 files changed, 27 insertions(+), 4 deletions(-)
New commits: commit a4f9fba0ba49ae6e27c2f1fa2ef9b21d0ae7c522 Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Sun Oct 24 23:17:24 2021 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Oct 25 15:08:40 2021 +0200 tdf#138531: Also update DDE tables, not only fields Change-Id: I0cbf8ce355b460b2f7ea73c8fae653641c980979 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124129 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 98247b039baea4697e6c387025afcf6a2963c043) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124020 diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 847e9d2ef356..c13cff3e2a23 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -32,6 +32,7 @@ class SwDoc; class SwField; class SwFormatField; +class SwDDETable; class SwRootFrame; class SvNumberFormatter; class IDocumentRedlineAccess; @@ -281,6 +282,7 @@ public: void GatherNodeIndex(std::vector<sal_uLong>& rvNodeIndex); void GatherRefFields(std::vector<SwGetRefField*>& rvRFields, const sal_uInt16 nTyp); void GatherFields(std::vector<SwFormatField*>& rvFormatFields, bool bCollectOnlyInDocNodes=true) const; + void GatherDdeTables(std::vector<SwDDETable*>& rvTables) const; }; /** Base class of all fields. diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx index f65f7d437464..4c0b3c58b11e 100644 --- a/sw/inc/fmtfld.hxx +++ b/sw/inc/fmtfld.hxx @@ -33,6 +33,7 @@ class SwField; class SwTextField; class SwView; class SwFieldType; +class SwDDETable; class SwFormatField; class IDocumentRedlineAccess; namespace com::sun::star::text { class XTextField; } @@ -72,6 +73,10 @@ namespace sw { std::vector<SwFormatField*>& m_rvFields; GatherFieldsHint(std::vector<SwFormatField*>& rvFields, bool bCollectOnlyInDocNodes = true) : m_bCollectOnlyInDocNodes(bCollectOnlyInDocNodes), m_rvFields(rvFields) {}; }; + struct GatherDdeTablesHint final : SfxHint { + std::vector<SwDDETable*>& m_rvTables; + GatherDdeTablesHint(std::vector<SwDDETable*>& rvTables) : m_rvTables(rvTables) {}; + }; } diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx index 9c4ba9c762cb..fb417375df5f 100644 --- a/sw/source/core/fields/ddefld.cxx +++ b/sw/source/core/fields/ddefld.cxx @@ -32,6 +32,7 @@ #include <editsh.hxx> #include <fmtfld.hxx> #include <ddefld.hxx> +#include <swddetbl.hxx> #include <swbaslnk.hxx> #include <unofldmid.h> #include <hints.hxx> @@ -102,7 +103,7 @@ public: OSL_ENSURE(m_rFieldType.GetDoc(), "no pDoc"); // no dependencies left? - if (m_rFieldType.HasWriterListeners() && !m_rFieldType.IsModifyLocked() && !ChkNoDataFlag()) + if (!m_rFieldType.IsModifyLocked() && !ChkNoDataFlag()) { SwViewShell* pSh = m_rFieldType.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); SwEditShell* pESh = m_rFieldType.GetDoc()->GetEditShell(); @@ -112,8 +113,11 @@ public: m_rFieldType.LockModify(); std::vector<SwFormatField*> vFields; + std::vector<SwDDETable*> vTables; m_rFieldType.GatherFields(vFields, false); - if(vFields.size()) + m_rFieldType.GatherDdeTables(vTables); + const bool bDoAction = vFields.size() || vTables.size(); + if(bDoAction) { if(pESh) pESh->StartAllAction(); @@ -121,16 +125,19 @@ public: pSh->StartAction(); } + // DDE fields attribute in the text for(auto pFormatField: vFields) { - // a DDE table or a DDE field attribute in the text if(pFormatField->GetTextField()) pFormatField->UpdateTextNode( nullptr, &aUpdateDDE ); } + // a DDE tables in the text + for(auto pTable: vTables) + pTable->ChangeContent(); m_rFieldType.UnlockModify(); - if(vFields.size()) + if(bDoAction) { if(pESh) pESh->EndAllAction(); diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx index 53f6c2c3f7e7..7954e18f5d4c 100644 --- a/sw/source/core/fields/ddetbl.cxx +++ b/sw/source/core/fields/ddetbl.cxx @@ -25,6 +25,7 @@ #include <ndtxt.hxx> #include <swtable.hxx> #include <swddetbl.hxx> +#include <fmtfld.hxx> #include <ddefld.hxx> #include <ndindex.hxx> #include <fldupde.hxx> @@ -116,6 +117,9 @@ void SwDDETable::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) pInRangeHint->m_nSttNd < pTableNd->EndOfSectionIndex() && pInRangeHint->m_nEndNd > pTableNd->GetIndex() ) pInRangeHint->m_rIsInRange = true; + } else if (const auto pGatherDdeTablesHint = dynamic_cast<const sw::GatherDdeTablesHint*>(&rHint)) + { + pGatherDdeTablesHint->m_rvTables.push_back(this); } else if (auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint)) { diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index b1220181df54..cbc73b27bcfb 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -207,6 +207,11 @@ void SwFieldType::GatherFields(std::vector<SwFormatField*>& rvFields, bool bColl CallSwClientNotify(sw::GatherFieldsHint(rvFields, bCollectOnlyInDocNodes)); } +void SwFieldType::GatherDdeTables(std::vector<SwDDETable*>& rvTables) const +{ + CallSwClientNotify(sw::GatherDdeTablesHint(rvTables)); +} + void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const { xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes"));