How can I access existing Revisions programmatically?

Hi fellow developers,


I am trying to access revisions in the editor. I wonder if that is actually possible. I have come across various methods to create revisions / comments but none to read them.

Here's what I tried:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var editor = SdlTradosStudio.Application.GetController<EditorController>();
var document = editor.ActiveDocument;
foreach (ISegmentPair seg in document.SegmentPairs)
{
if (seg.Properties.ConfirmationLevel == ConfirmationLevel.RejectedTranslation) //revised segment
{
MessageBox.Show("Hallelujah!");
document.SetActiveSegmentPair(seg.GetProjectFile(), seg.Properties.Id.Id);
var target = seg.Target;
foreach (IAbstractMarkupData item in target.AllSubItems)
{
//seems there is no IRevisionMarker in here... :-?
}
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 The "Halleluah!" is shown and the editor jumps to the first segment containing revisions so that is fine. Alas, I cannot seem to actually read these revisions.

Can anybody help me out?

P.S: If instead of using the editor I need to parse the .sdlxliff, so be it. I just preferred I could do this in the editor.

Thanks & best,

Andreas

  • Argh. Seems I've only been a little too stupid when writing "item.GetType().name" to my log file to find the revision marker.

    So for anyone needing this, here is what I will now try to build upon:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    var editor = SdlTradosStudio.Application.GetController<EditorController>();
    var document = editor.ActiveDocument;
    foreach (ISegmentPair seg in document.SegmentPairs)
    {
    if (seg.Properties.ConfirmationLevel == ConfirmationLevel.RejectedTranslation) //überarbeitetes Segment
    {
    var target = seg.Target;
    target.AcceptVisitor(new MarkupDataVisitor());
    foreach (IAbstractMarkupData item in target.AllSubItems)
    {
    if (item.GetType().Name == "RevisionMarker")
    {
    var rev = item as IRevisionMarker;
    switch (rev.Properties.RevisionType)
    {
    case RevisionType.Delete:
    //delete action
    break;
    case RevisionType.FeedbackComment:
    //comment action
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

     

    Cheers,

    Andreas

  • Hi Andreas,

    What is your MarkupDataVisitor class doing?

    Usually you would use the visitor pattern like so by implementing http://producthelp.sdl.com/SDK/FileTypeSupport/4.0/html/eba49731-734b-3a3a-d166-9a22d7f59cdf.htm

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    public class MarkupDataVisitor : IMarkupDataVisitor
    {
    public void VisitRevisionMarker(IRevisionMarker revisionMarker)
    {
    // Access revisions here
    }
    public void VisitSegment(ISegment segment)
    {
    VisitChildren(segment); // Make sure to call VisitChildren in VisitTagPair, etc. also to get all children
    }
    // Implement rest of interface here
    private void VisitChildren(IAbstractMarkupDataContainer container)
    {
    foreach (var item in container)
    {
    item.AcceptVisitor(this);
    }
    }
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX