Word Processing (WinForms, WPF, Office File API) – Track Changes (v19.2)

Office-Inspired Products
21 October 2019

Our Word Processing Document API and Rich Edit Controls (WinForms and WPF) now ship with Track Changes support. With this new feature, you and your end-users can obtain, accept or reject changes made to a document. Documents - along with their revisions - can be printed and exported to PDF as needed.

New User Interface elements in our WinForms and WPF Rich Edit Controls allow end-users to activate Track Changes. End-users can specify a password to prevent others from disabling change tracking and can use new ribbon and context menu items to navigate between revisions and accept or reject changes when appropriate.

You can specify how revisions are displayed and printed in code and via the control’s User Interface. Our word processing components support the following revision display modes:

  • All Markup - displays detailed revision information.
  • Simple Markup - uses a red line within the margin to highlight revisions made.
  • No Markup - displays the document without visible revision information (as if all revisions are accepted).

Our Track Changes API allows you to execute the following actions:

  • Manage Existing Revisions
  • Create New Revisions
  • Specify Display Options for Revisions

Manage Existing Revisions

You can obtain revision parameters (date, type and author) and accept or reject revisions. You can accept or reject a specific revision, all revisions or revisions that meet a given criteria.

The code sample below demonstrates how to retrieve a collection of revisions/accept and reject revisions:

RevisionCollection documentRevisions = wordProcessor.Document.Revisions;

// Reject all revisions in the header of the first page:
SubDocument header = 
	wordProcessor.Document.Sections[0].BeginUpdateHeader(HeaderFooterType.First);
documentRevisions.RejectAll(header);
wordProcessor.Document.Sections[0].EndUpdateHeader(header);

// Reject all revisions from a specific author on the first section:
var sectionRevisions = documentRevisions.Get(wordProcessor.Document.Sections[0].Range)
										.Where(x => x.Author == "Janet Leverling");
foreach (Revision revision in sectionRevisions)
	revision.Reject();

// Accept all format changes:
documentRevisions.AcceptAll(x => x.Type == RevisionType.CharacterPropertyChanged || 
								 x.Type == RevisionType.ParagraphPropertyChanged || 
                                 x.Type == RevisionType.SectionPropertyChanged);

Create New Revisions

You can enable Track Changes and specify what to track (formatting changes, movements) so that new edits are added as revisions.

The code sample below demonstrates how to activate Track Changes and change the document’s character properties (a new revision will be added to the collection):

Document document = wordProcessor.Document;

// Enable Track Changes:           
DocumentTrackChangesOptions documentTrackChangesOptions = document.TrackChanges;
documentTrackChangesOptions.Enabled = true;
documentTrackChangesOptions.TrackFormatting = true;

// Format the document range:
CharacterProperties characterProperties = document.BeginUpdateCharacters(document.Range);
characterProperties.FontName = "Segoe UI";
characterProperties.Bold = true;
document.EndUpdateCharacters(characterProperties);

Specify Display Options for Revisions

You can change the review mode, color and format used for each revision type. These changes are applied when you print or export the document to PDF.

The code sample below shows how to change the review mode and specify format options for insertions and formatting changes:

TrackChangesOptions trackChangesOptions = richEditControl.Options.Annotations.TrackChanges;

// Specify the review mode:
trackChangesOptions.DisplayForReviewMode = DisplayForReviewMode.AllMarkup;

// Change display options for formatting changes:
trackChangesOptions.DisplayFormatting = DisplayFormatting.ColorOnly;
trackChangesOptions.FormattingColor = RevisionColor.ClassicBlue;

// Change display options for insertions:
trackChangesOptions.DisplayInsertionStyle = DisplayInsertionStyle.Underline;
trackChangesOptions.InsertionColor = RevisionColor.DarkRed;

Complete code sample projects are available on GitHub:

Limitations

Our current Track Changes implementation ships with the following limitations:

  • Revisions in OpenDocument (.odt) format are not supported.
  • No Original mode to view changes. This mode displays the document without suggested changes.
  • No user interface elements to specify color and format for each revision type.
  • The Reviewing Pane does not display revisions.
  • Revisions are not displayed in balloons within the document margin.

Your Feedback Matters

As always, we’d love to hear from you. If you’re using our Rich Edit Controls or our Word Processing API, feel free to comment below and share your experiences with the entire DevExpress community.

2 comment(s)
Selim Kandilli
Selim Kandilli

Hi

Does this feature also exist in asp.net web form?

22 October, 2019
Vladimir Frizen (DevExpress)
Vladimir Frizen (DevExpress)

Hi Selim,

We do not plan to implement this feature in the ASP.NET RichEdit component in the near time.

 

30 October, 2019

Please login or register to post comments.