none
How to get copied content controls RRS feed

  • Question

  • Hi,

    I'm using a Ribbon XML to override copy and paste events, just like this:

    public void OnCopy(IRibbonControl control, bool cancelDefault)
    {
    	Report.Document.Application.Selection.Copy();
    }
    
    public void OnPaste(IRibbonControl control, bool cancelDefault)
    {
    	Report.Document.Application.Selection.Paste();
    }

    And it works perfectly. I've put some MessageBox.show("something") just to be sure and they got fired, so it works. And I've debugged into the methods too.

    Ok. Now what I want is to get the content controls that are copied when the user presses "ctrl+C". They must be in the clipboard but I can't find any way to get them. In other words, I want to get a list of ContentControl from the clipboard data.

    Thanks in advance,

    Javier Montoro


    Tuesday, June 11, 2013 2:06 PM

Answers

  • I had a look at the various things posted on the clipboard and in my view, the only format that contains this information and is reasonably easy to understand is the HTML one.


    Peter Jamieson

    Wednesday, June 12, 2013 6:49 PM

All replies

  • Have you tried using the .NET System.Windows.Clipboard class to examine the contents of the clipboard? Sorry, I don't have an example right now, but if you can retrieve XML using that technique you should be able to extract the various <w:sdt> elements reasonably easily. If not, you might be able to find them in the HTML representation, and failing that, I'm prettty sure you'll find them in the RTF, although that might be somewhat harder to process.

    Peter Jamieson


    Tuesday, June 11, 2013 5:27 PM
  • II assume that it's impossible but thought I had better mention the obvious: if you are always going to be able to intercept the Selection.Copy() (as in your first method), then you really ought to be able to examine the selection (and everything in it) at that point. 

    Peter Jamieson

    Tuesday, June 11, 2013 7:02 PM
  • I had a look at the various things posted on the clipboard and in my view, the only format that contains this information and is reasonably easy to understand is the HTML one.


    Peter Jamieson

    Wednesday, June 12, 2013 6:49 PM
  • Hi Peter,

    Sorry for later answer! I've been quite busy and had to leave this feature for the moment. You're right, HTML is the only "solution". It's not good enough in my opinion, since it's not possible to convert it to XML directly using XMLReader, yet working with strings and splitting and so it is possible to find a solution.

    Thanks!

    Thursday, July 4, 2013 2:43 PM
  • There was some reason why I didn't suggest that you retrieved the .WordOpenXML of the Selection, but I now forget why I didn't. The .WordOpenXML is in Flat OPC format, which is pretty straightforward although I don't think there's a published schema for the elements/attributes used to wrap each part.

    Peter Jamieson

    Thursday, July 4, 2013 2:58 PM