Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

rewrite to support formatting and nesting fields #103

Open
wants to merge 89 commits into
base: master
Choose a base branch
from

Conversation

iulica
Copy link

@iulica iulica commented Mar 8, 2022

The changes implement support for MERGE fields inside other fields, and formatting flags.

Description

Fields spanning several paragraphs are detected and proper integration with MERGEFIELDS values is implemented.
Number and text formatting and flags are implemented.
Support for date formatting is added, but not yet implemented.
A framework for easier testing of formats is also added along with tests for all changes.
Previous tests are also passed, although some tests are incorrect. For those tests a flag is implemented to be able to remove the workarounds for those tests after review.
When documents with nested fields are created, these documents need to be updated, by selecting the whole document and pressing F9. There is a flag for auto-updating all fields when opening the document. Support for setting this flag is also added (no, always, auto). Default is no, for backward compatibility.

Motivation and Context

It allows using more complex documents, that have formatting and complex fields.
Several issues are solved, mostly about using MERGEFIELDS inside other fields like IF or INCLUDEPICTURE.
#102 #88 #80 #78 #60 #52 #40

How Has This Been Tested?

All the changes have their own tests.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@iulica
Copy link
Author

iulica commented Mar 9, 2022

The rewrite code is split into 4 different classes:
MailMerge - main API, handles the reading/writing of the docx ZIP file, the parts of the document, and also getting the fields from the xml
MergeDocument - handles multi-document mail merges (separators, etc)
MergeField - one data field, handles the data formatting for one field
MergeData - factory for MergeField handles the merge of replacement data into one part (body)

iulica and others added 6 commits March 9, 2022 17:32
…ementing multiple flags (issue Bouke#40), raise warnings instead of exception on invalid field instructions
plan to release as v. 0.6.0 instead of 0.5.0, updated the documentation
Credits and link to the original repository.
Fixed the Credits topic
@iulica iulica closed this Mar 31, 2022
@iulica iulica reopened this Mar 31, 2022
iulica and others added 30 commits September 19, 2024 15:13
Updated LICENSE to include current copyright holder
…the value of those settings directly in the MailMerge document
…eld in a normal text field.

In the "before" text.
Implemented NEXTIF, SKIPIF fields.
Some fixes.
Implmeneted IF fields as experimental.
Fix error in description.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants