Skip to content

Office.DocumentStyleManager

apobekiaris edited this page Oct 17, 2020 · 9 revisions

GitHub issues GitHub close issues

About

The DocumentStyleManager can re-brand a large number of documents using style templates.

Details


Credits: to the Company (wants anonymity) that sponsor the initial implementation of this module.


This is a platform agnostic module that you can use to configure style replacement templates. Applying them to XAF domain components with RTF document members results in document re-branding.

Model Configuration

  • To configure which members populate the StyleManager SingleChoiceAction you can use the model as in the next image.

    image

  • In the ImportStyles node (see previous image) you can configure which Domain Components will be used in case you need to import styles from other documents while you generating the template.

    image

  • The ApplyTemplateListViews node contains the ListViews where the generated template can be applied. A SimpleAction Apply Styles with be activated only for there.

    image

  • Additional options are available as DocumentStyManager attributes. They help you override the default style properties. When a new RTF style is created and properties not set then default properties are used and they affect the style behavior.

    image

Template Generation

The StyLeManager SingleChoiceAction is available only for Detailviews. Execute it to display the view in the next image in a popup WIndow using the DetailView.CurrentObject.

TestApplication Win_TFWorDs5wg

This is a non persistent view and changes sent back to the owner view when Accept is executed. The Owner object gets modified but the transaction not committed.

On the right side we have two RichEditPropertyEditors. The top one displays the changed content and the bottom the original.

On the left side we have two ListViews populated with styles from the top-changed document. The green color means that the style is used. The Replacement Styles contains only styles that match the type (Paragraph/Character) of the All Styles selected object.

The following operations can be performed at the top left editor (use the bottom editor for compare with the original):

  1. Apply Style: Position the cursor at any place in the top-left editor and change either the paragraph or the character style by selecting from the Apply Styles ListView and executing the action.
  2. Delete Styles: Select one or many styles from the All Styles ListView and execute the action. Additionally execute the DeleteStyles.Unused to remove all unused styles from the top-left editor.
  3. Replace Styles: Select one or many styles from the All Styles ListView to replace them with the single selection of the Replacement Styles ListView. To persist this operation in a template for later usage activate the Linked styles template and execute the Template Styles action. image
  4. Import Styles: Display a popup ListView containing the styles parsed from the Domain Components configured in the XAF model as discussed in the configuration section. image
  5. Accept: Accept the changes to persist the template. In addition this action will sent any changes of the top-left editor back to the owner Domain Component member.

Apply the generated template to a list of documents.

Navigate to a predefined view that has the Apply Styles action enabled as discussed in the configuration section and execute the action to display the Apply Template Style DetailView.

image

After you select the previously generated template, you can optionally preview it and for a final verification by selecting the documents from the left side ListView. On the Change Styles view you get a report of the changes that will occur for each document. The changes won't apply unless you execute the Save Changes action.

Possible future improvements:

Any other need you may have.

Let me know if you want me to implement them for you.


Examples

In the screencase we see:

  1. First we note the three documents by navigating through each of them. For the two first paragraphs, two different paragraph styles are used. In the third paragraph a character style is applied to a few words. Next, we will generate a template to re-brand these documents.
  2. The Style Manager SingleChoice action is configured to activate in the DetailView of the DocumentObject type. So we open this DetailView and execute the action..
  3. When the DocumentManager DetailView opens we use the Delete Unused styles to clear the unwanted styles (optional).
  4. To import additional styles we use the ImportStyles action which will parse a predefined list of documents and will extract and display their styles.
  5. Then we replace the first paragraph style with its version 2 style (Quote->QuoteV2). Once the change is previewed and we feel ok with it, we undo the operation and we add the style to the modification template.
  6. We perform the steps from 5 again for paragraph 2 and 3
  7. We accept the changes and the template is saved.
  8. We select all three documents and use the Apply Styles to preview that the template is applied correctly
  9. We SaveChanges
  10. We go again through all document to verify that they now re-branded.

At the bottom the Reactive.Logger.Client.Win is reporting as the module is used.

Xpand XAF Modules DocumentStyleManager

image

Installation

  1. First you need the nuget package so issue this command to the VS Nuget package console

    Install-Package Xpand.XAF.Modules.Office.DocumentStyleManager.

    The above only references the dependencies and next steps are mandatory.

  2. Ways to Register a Module or simply add the next call to your module constructor

    RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.Office.DocumentStyleManagerModule));

Versioning

The module is not bound to DevExpress versioning, which means you can use the latest version with your old DevExpress projects Read more.

The module follows the Nuget Version Basics.

Dependencies

.NetFramework: net461

DevExpress.Persistent.Base Any
DevExpress.Xpo Any
DevExpress.ExpressApp.Office Any
DevExpress.ExpressApp.ConditionalAppearance Any
Fasterflect.Xpand 2.0.7
JetBrains.Annotations 2020.1.0
Newtonsoft.Json 12.0.3
System.Collections.Immutable 1.7.0
System.Interactive 4.1.1
System.Reactive 4.4.1
System.ValueTuple 4.5.0
Xpand.Extensions 2.202.57
Xpand.Extensions.Reactive 2.202.58
Xpand.Extensions.XAF 2.202.58
Xpand.Extensions.XAF.Xpo 2.202.54
Xpand.XAF.Modules.HideToolBar 2.202.58
Xpand.XAF.Modules.Reactive 2.202.58
Xpand.XAF.Modules.SuppressConfirmation 2.202.58
Xpand.XAF.Modules.ViewItemValue 2.202.24
Xpand.VersionConverter 2.202.10

Issues-Debugging-Troubleshooting

To Step in the source code you need to enable Source Server support in your Visual Studio/Tools/Options/Debugging/Enable Source Server Support. See also How to boost your DevExpress Debugging Experience.

If the package is installed in a way that you do not have access to uninstall it, then you can unload it with the next call at the constructor of your module.

Xpand.XAF.Modules.Reactive.ReactiveModuleBase.Unload(typeof(Xpand.XAF.Modules.Office.DocumentStyleManager.Office.Office.DocumentStyleManagerModule))

Tests

The module is tested on Azure for each build with these tests. All Tests run as per our Compatibility Matrix