• Not Answered

Access tags in clipboard data to convert them to xml

Dear Community,

I am trying to access the tag data in the clipboard after selecting and copying a source segment from the editor to change them to xml.

For example: the user selects [TagHyperlink>https://www.sdl.com<TagHyperlink] the result in the clipboard should be <some_xml_tag>www.sdl.com</some_xml_tag>

My approach so far looks like this:

IDataObject dataObject = System.Windows.Forms.Clipboard.GetDataObject();
if (dataObject.GetDataPresent(typeof(AbstractMarkupData)))

    //Trados Segment found, do something

but AbstractMarkupData seems not to be the right type. I tried Segment aswell without success.

Is there any solution to this?

Thank you very much in advance and best regards,

5 Replies Latest Replies: 8 Jun 2018 3:09 PM by Hoon Kim

5 Replies

  • interesting..
    -sorry, I have no idea how to achieve your goal

  • var a = SdlTradosStudio.Application.GetController<EditorController>().ActiveDocument.Selection.Target;
    var b = (IContentSelection)a.GetType().GetProperty("ContentSelection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(a);
    MessageBox.Show("for a hyperlinkTag \n\n" + b.From.Node);

    // for a whole segment
    var c = SdlTradosStudio.Application.GetController<EditorController>().ActiveDocument.ActiveSegmentPair.Target;
    foreach(var d in c)

  • In reply to Hoon Kim:

    Dear Hoon Kim,
    thanks a million for your answer.

    For sure it is perfect but I'm experiencing two problems:
    - GetController() returns null, although Trados is up and running (does it have to be triggered within a Trados Plugin, or can it be any C# Application?).
    - IContentSelection is not found. Unfortunately I don't know what the correct reference would be, as the reference search as well as google are not helping.

    Would be very thankful für further advise.
    Best regards,
  • In reply to Kai Piontek:

    -I assumed it is PlugIns
    -Search this place, I've found it. You'll find it too, for sure. Should you find it add another 'Like' there.
  • In reply to Hoon Kim:

    Thanks a lot, it has to be inside a plug-in to get it to work :)