-
-
Notifications
You must be signed in to change notification settings - Fork 44
Office.DocumentStyleManager
The DocumentStyleManager can massively re-brand a large number of documents using style templates.
Credits: to the Company (wants anonymity) that sponsor the initial implementation of this module.
This is a platform agnostic module that can be used to configure templates that can be applied to XAF domain components that contain members which store RTF documents.
-
To configure for which members populate the StyleManager SingleChoiceAction you can use the model as in the next image.

-
In the
ImportStylesnode you can configure which Domain Components will be used in case you need to import styles from other documents while you generating the template.
-
The
ApplyTemplateListViewsnode contain the ListViews where you can apply the generated template.
-
Additional options are available as DocumentStyManager attributes to help you override the default style properties.

The StyLeManager action is available only for Detailviews and will display the next view using the DetailView.CurrentObject and the already discussed model configuration.

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 will display how the changed and the bottom the original content.
On the left side we have two ListViews 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 view.
The following operations can be performed at the top left editor (use the bottom editor for compare with the original):
-
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. -
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. -
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 theTemplate Stylesaction.
-
Import Styles: Will display a popup ListView containing the styles parsed from the Domain Components configured in the XAF model as discussed in the configuration section.
- The subject
Views, the target containerCalendarand which Domain Component should be created when aNewCloudEvent.
- The CRUD
SynchronizationTypeand theCallDirection.
-
Accept: Accept the changes to persist the template and sent them to the parent object.
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.

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.
In the screencase we see:
- First we go note the three documents. We use two different paragraph styles for the two first paragraphs and a character style is applied to a few words of the third paragraph
- We then open the detailview of one document to create the style modification template that we will apply later to all three documents massively.
- When the DocumentManager detailview opens we use the
Delete Unused stylesto clear the unwanted styles (optional) - To import additional styles we use the ImportStyles action which will parse a predefined list of documents and will extract and display their styles.
- Then we replace the first paragraph style with its version 2 style. Once the change is previewed and we feel ok with it, we undo the operation and we add the style to the modification template.
- We perform the steps from 5 again for paragraph 2 and 3
- We accept the changes and the teample is saved.
- We select all three documents and use the
Apply Stylesto preview that the template is applied correctly - We
SaveChanges - We go again through all document to verify that they now rebranded
At the bottom the Reactive.Logger.Client.Win is reporting as the module is used.
-
First you need the nuget package so issue this command to the
VS Nuget package consoleInstall-Package Xpand.XAF.Modules.Office.DocumentStyleManager.The above only references the dependencies and next steps are mandatory.
-
Ways to Register a Module or simply add the next call to your module constructor
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.Office.DocumentStyleManagerModule));
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.
.NetFramework: net461
| DevExpress.Persistent.Base | Any |
| DevExpress.ExpressApp | Any |
| DevExpress.ExpressApp.Xpo | Any |
| Fasterflect.Xpand | 2.0.7 |
| Google.Apis.Auth | 1.49.0 |
| Google.Apis.Calendar.v3 | 1.49.0.2049 |
| JetBrains.Annotations | 2020.1.0 |
| Newtonsoft.Json | 12.0.3 |
| System.Reactive | 4.4.1 |
| Xpand.Extensions | 2.202.53 |
| Xpand.Extensions.Office.Cloud | 2.202.54 |
| Xpand.Extensions.Reactive | 2.202.54 |
| Xpand.Extensions.XAF | 2.202.54 |
| Xpand.Extensions.XAF.Xpo | 2.202.50 |
| Xpand.XAF.Modules.Office.Cloud.Google | 2.202.15 |
| Xpand.XAF.Modules.Reactive | 2.202.54 |
| Xpand.VersionConverter | 2.202.10 |
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))The module is tested on Azure for each build with these tests. All Tests run as per our Compatibility Matrix


