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,
Kai

Parents
  • Former Member
    0 Former Member

    var a = SdlTradosStudio.Application.GetController<EditorController>().ActiveDocument.Selection.Target;
    var b = (IContentSelection)a.GetType().GetProperty("ContentSelection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(a);
    b.Normalize();
    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)
    MessageBox.Show(d.ToString());

Reply
  • Former Member
    0 Former Member

    var a = SdlTradosStudio.Application.GetController<EditorController>().ActiveDocument.Selection.Target;
    var b = (IContentSelection)a.GetType().GetProperty("ContentSelection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(a);
    b.Normalize();
    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)
    MessageBox.Show(d.ToString());

Children