ddn.odf.tracking

ODF 1.3 change-tracking model for text and spreadsheet documents.

Implements typed parsing and serialisation of tracked changes as defined in OpenDocument v1.3 Part 3 Section 5.4 (Text Change Tracking) and Section 8.4 (Spreadsheet Change Tracking).

Supports:

  • Text tracked changes: text:tracked-changes, text:changed-region, text:insertion, text:deletion, text:format-change
  • Spreadsheet tracked changes: table:tracked-changes, table:cell-content-change with previous and new cell values
  • Round-trip serialisation preserving author, timestamp, and raw XML
  • Accept/reject operations on tracking metadata for both text and spreadsheet changes

    Note

    Accept and reject operations remove tracking metadata only. They do not mutate document body content (applying insertions, reverting deletions, or restoring format changes).

Types 7

Identifies the kind of a tracked change operation.

Maps to ODF change-tracking child elements: text:insertion, text:deletion, text:format-change and table:insertion, table:deletion, table:cell-content-change.

INSERTION
DELETION
FORMAT_CHANGE
UNKNOWN

Represents a single text:changed-region element in a text document.

Each region captures an insertion, deletion, or format-change made by an author at a specific point in time. The id is used by text:change, text:change-start, and text:change-end inline markers to delimit the affected content.

Fields
string id
OdfChangeType changeType
string author
string timestamp
XmlElement rawXml

Represents an inline change marker (text:change, text:change-start, or text:change-end).

The changeId references an OdfTextChangeRegion.id in the document's text:tracked-changes section.

Fields
string changeId

Contains all tracked changes for a text document body.

Parsed from a text:tracked-changes element inside office:text.

Fields
Methods
bool isEmpty() @safe pure nothrow constReturns `true` if there are no change regions.

Represents a single table:cell-content-change element in a spreadsheet document.

Captures the author, timestamp, previous cell value, and new cell value for a tracked cell edit.

Fields
string id
OdfChangeType changeType
string author
string timestamp
string oldValue
string newValue
XmlElement rawXml

Contains all tracked changes for a single spreadsheet sheet.

Parsed from a table:tracked-changes element inside table:table.

Fields
OdfCellChange[] changes
Methods
bool isEmpty() @safe pure nothrow constReturns `true` if there are no cell changes.

Top-level container for all tracked changes across text and spreadsheet bodies.

Fields
OdfSheetChange sheetChanges
XmlElement[] unknownXml

Functions 19

fnOdfTextTrackedChanges parseTextTrackedChanges(XmlElement body)Parses `text:tracked-changes` from a text body element.
fnOdfSheetChange parseSheetTrackedChanges(XmlElement sheetElem)Parses `table:tracked-changes` from a sheet element.
fnOdfSheetChange parseSheetTrackedChangesFromContainer( XmlElement trackedChangesElem)Parses cell changes from a `table:tracked-changes` container element.
fnOdfTextChangeRegion[] parseChangedRegions(XmlElement trackedChangesElem)Iterates over the children of trackedChangesElem and extracts each `text:changed-region` with its id, change type, author, and timestamp.
fnstring serializeTextTrackedChanges(const ref OdfTextTrackedChanges changes)Serialises text tracked changes back to an XML string.
fnstring serializeSheetTrackedChanges(const ref OdfSheetChange changes)Serialises spreadsheet tracked changes back to an XML string.
fnOdfTextTrackedChanges acceptTextChanges(ref OdfTextTrackedChanges changes, string[] changeIds)Accepts the specified text tracked changes by removing their change regions.
fnOdfTextTrackedChanges acceptAllTextChanges( ref OdfTextTrackedChanges changes)Accepts all text tracked changes by clearing all change regions.
fnOdfTextTrackedChanges rejectTextChanges(ref OdfTextTrackedChanges changes, string[] changeIds)Rejects the specified text tracked changes by removing their change regions.
fnOdfTextTrackedChanges rejectAllTextChanges( ref OdfTextTrackedChanges changes)Rejects all text tracked changes by clearing all change regions.
fnOdfSheetChange acceptSheetChanges(ref OdfSheetChange changes, string[] changeIds)Accepts the specified sheet tracked changes by removing their cell changes.
fnOdfSheetChange acceptAllSheetChanges(ref OdfSheetChange changes)Accepts all sheet tracked changes by clearing all cell changes.
fnOdfSheetChange rejectSheetChanges(ref OdfSheetChange changes, string[] changeIds)Rejects the specified sheet tracked changes.
fnOdfSheetChange rejectAllSheetChanges(ref OdfSheetChange changes)Rejects all sheet tracked changes.
fnbool hasTrackedChanges(const ref OdfTextTrackedChanges changes)Returns true if any text change regions exist.
fnbool hasTrackedChanges(const ref OdfSheetChange changes)Returns true if any sheet cell changes exist.
private fnvoid parseChangeInfo(XmlElement opEl, ref OdfTextChangeRegion region)
private fnauto parseXmlForTest(string xml)