This is certainly a cool feature, thank you!
Regarding the code I have a few comments and suggestions, though.
The first thing that caught my eye:
there are no unit tests. I think new features should be covered by automated tests right from the beginning (Ideally you start with the tests: no failing tests means nothing to do
). IIRC @chennes recently added tests for Copy/Paste in the spread sheet module, so there should be some code to look at already.
Then I suggest to break the long methods into smaller, dedicated methods. A single method with 120 lines and 8-9 levels of indentations are too much for my taste. You already wrote comments over each "section". Those give nice method names. Overall this makes the code easier to read (also for your future self).
You also put FreeCAD's XML fragment as "text/plain" into the clipboard. Followed by some string magic to check if it is that XML when reading it back. I suggest to use a dedicated media type instead and check for that directly when pasting.
Does anyone know whether we have a media type for FreeCAD's xml format already defined somewhere? Something like "application/vnd.freecad.fcstd-document+xml" or here specifically "application/vnd.freecad.fcstd-document-fragment+xml"?
(One could even think of adding the same data in different formats, for different purpose. i.e. one for pasting between/within FreeCAD, one as "image/svg+xml" for direct pasting in inkscape, a human readable version as "test/plain", ...)