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:

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... :-?
        }
    }
}

 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

Parents
  • 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:

    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
    						break;
    					case RevisionType.Insert:
    						//insert action
    						break;
    				}
    			}
    		}
    	}
    }

     

    Cheers,

    Andreas

Reply
  • 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:

    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
    						break;
    					case RevisionType.Insert:
    						//insert action
    						break;
    				}
    			}
    		}
    	}
    }

     

    Cheers,

    Andreas

Children