Open apumex opened 4 years ago
I'm unlikely to work on this near-term, but I think the choices are:
1) Refactor the methods for SimpleMergeFields()
and ComplexMergeFields()
from https://github.com/chrisfcarroll/MailMerge/blob/master/MailMerge/KnownWordProcessingMLTransforms.cs so as to turn each method into two steps, the first of which would be 'list all the mergefields'
2) Be able to write an XPath query to replace the loop in ComplexMergeFields()
with a single query. Then the XPath extension method at https://github.com/chrisfcarroll/MailMerge#extension-methods--helpers would make it a one liner.
e.g. for simple merge fields the one liner starts with the XPath query:
var simpleFieldNames=stream
.AsXPathDocOfWordprocessingMainDocument(isEditable)
.SelectNodes("//w:fldSimple[contains(@w:instr,'MERGEFIELD ')]"
, OoXmlNamespace.Manager);
And then AllMergeFields
is the union of the SimpleMergeFields
and the ComplexMergeFields
It would be great if we have an api to list all the merge fields.