Sorry, I don't know a fix for that object problem.
When I include code in my documents I use a "screen print" paragraph style:
. * Courier font, so that text lines up vertically (for tab indent formatting)
. * light grey background, to simulate an old mainframe "green screen" background (yes, I'm that "young")
. * a border line on the paragraph
The end result is the my code lines up, appears to be in a simulated screen with a border around it and a background to distinguish it from other body text.
In addition I created several character styles, based on the para style to apply text color for highlighting (like the green you use).
So I would just copy the text from RTF, pasted it in to my document, then apply the required styles.
It is a bit more work to start with, but allows me to make the code examples part of the document rather than existing as static objects..