About the conditional format of the merged wire story

Build 1501 on 14/Nov/2017  This topic last edited on: 28/Sep/2016, at 10:44

When merging wire stories into a new article, the generated 'body' text had always the default typographical format (typically the 'body' format).

Since 2.3.2824.x yu can conditionally set the format of the merged body text, overwriting the 'Create Objects' method.

For example, you may want to set automatically the 'agate' format when the user selects the 'agate' xml rendering mode in merging dialog.

1.Overwrite the MergeToNewArticle() method in the CustomTed4MainAddIn class (Custom Ted.vb in TedCustomAddIn).

2.Copy the standard method from the Ted4MainAddin class (Ted.vb in TedSystemAddIn) and replace the following;

Dim articleMerge As New ArticleMerge

with 

Dim articleMerge As New CustomArticleMerge

This forces the client to call the custom method instead of the standard one.

3.Overwrite the 'Create Objects' method in CustomArticleMerge class (CustomArticle.vb in TedCustomAddIn), in 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