When merging the stories into a new article, the generated 'body' text had always the default typographical format (called 'body').
Now it is possible to conditionally set the format of the merged body text, overwriting the 'CreateObjects' method.
For example, to set the 'agate' format when the user selects the 'agate' xml rendering mode in merging dialog:
1) overwrite the MergeToNewArticle() method in CustomTed4MainAddIn class (CustomTed.vb in TedCustomAddIn).
Copy the standard method from the Ted4MainAddin class (Ted.vb in TedSystemAddIn) and change
Dim articleMerge As New ArticleMerge
with
Dim articleMerge As New CustomArticleMerge
This is to make the client calling the custom methods instead of the standard ones.
2) overwrite the 'CreateObjects' method in CustomArticleMerge class (CustomArticle.vb in TedCustomAddIn), this way:
Public Class CustomArticleMerge
Inherits ArticleMerge
Public Sub New(ByRef owner As Window)
MyBase.New(owner)
End Sub
Public Overloads Overrides Sub CreateObjects(ByVal designer As ITxtDesigner, ByVal mergePosition As EditorialClient.MergePosition)
'conditionally set the format of the merged texts
If MergeItems IsNot Nothing Then
For Each item As EditorialClient.MergeItem In MergeItems
If item Is Nothing OrElse TypeOf item IsNot EditorialClient.XmlMergeItem Then Continue For
Dim xmlMergeItem As EditorialClient.XmlMergeItem = TryCast(item, EditorialClient.XmlMergeItem)
If xmlMergeItem Is Nothing OrElse xmlMergeItem.TxtFormatId > 0 Then Continue For 'format already set
'set 'AGATE' typographic format if the merging story has 'AGATE' xml rendering mode
If String.Compare(xmlMergeItem.XmlModeName, "agate", True) = 0 Then
xmlMergeItem.TxtFormatId = GetFormatId("agate")
End If
Next
End If
MyBase.CreateObjects(designer, mergePosition)
End Sub
End Class
|