diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2021-10-24 23:17:24 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-10-25 11:17:34 +0200 |
commit | 98247b039baea4697e6c387025afcf6a2963c043 (patch) | |
tree | 1456a081bc9ab04e6f29835ef5edda35802b56c5 /sw | |
parent | 6a1feb264479f0b223305882636eed1b58c80966 (diff) |
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.stahl@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/fldbas.hxx | 2 | ||||
-rw-r--r-- | sw/inc/fmtfld.hxx | 5 | ||||
-rw-r--r-- | sw/source/core/fields/ddefld.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/fields/ddetbl.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/fields/fldbas.cxx | 5 |
5 files changed, 27 insertions, 4 deletions
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 5e0dc3378ee4..03a410834219 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -33,6 +33,7 @@ class SwDoc; class SwField; class SwFormatField; +class SwDDETable; class SwRootFrame; class SvNumberFormatter; class IDocumentRedlineAccess; @@ -282,6 +283,7 @@ public: void GatherNodeIndex(std::vector<SwNodeOffset>& 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 fdceaeacb73b..32a81303c3eb 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 2e060e4ae377..590fcef86cad 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> @@ -99,7 +100,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(); @@ -109,8 +110,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(); @@ -118,16 +122,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 5feda6df9769..b1576e1a1589 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> @@ -119,6 +120,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 8fbbf1596034..7bcbef589b0a 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -210,6 +210,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 { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes")); |