Dear Stress Junkie,
Thanks for the flame. However, you don't light my fire--you might have noticed that in my original post I did search on Google before posting.
The article you refer to talks about images/graphics in frames, not about creating a new style. There's no mention of inserting some other text document into a frame. While it mentions OLE objects, Writer help says an OLE object must be either a presentation, a drawing, a spreadsheet, a formula or a chart. No mention of text.
The author of the article you invoke explictly states, in a previous article, "Only one template can be applied to each document" (
http://www.linuxjournal.com/article/7447). I suspect what you did was to use different
page formats and confuse that with using different templates.
However, your idea of linking to a separate file does suggest a couple of different work-arounds, each of which seems to safely save the "code" character. In my experiments, a piece of php code that is handled with these work-arounds still works when copied and pasted back into gedit and resaved.
1. Looking at "links" in Writer help suggested that one can create a new
section and insert the text document as a link in that section (options in the New Section dialog).
2. Create the bit of code in gedit and then paste it into the Writer document. This even worked after I changed the font size and used "Increase Indent" to move the section to the right.
3. It also seems to work to create a frame and paste code from gedit into the frame. In this case the font changed to the font of the main document, but changing it to 10-pitch Courier did not corrupt the code.
4. Finally, using "Insert -> File" seems to work, with these complications:
-Writer seems to want to treat a php file that has the php code embedded in html as an html file and renders it rather than pasting in the full file. The work-around for this seems to be to select the txt File Type in the Insert File dialog.
-The inserted file takes on the font type of the main document. Having created the "TextForCode" style (see below), if I select that before inserting the file, it inserts nicely formatted as code and still works when copied back to gedit and saved.
I tried pasting in a bit of code from gedit and then selecting it to create a new style ("TextForCode"). This seemed to work visually, but when copied back to gedit and saved as a .php file, it would not open in the browser. I even tried defining the style as not linked to the Default style.
These approaches are still work-arounds, however.
One would think that if Write can properly handle text that is pasted in from gedit (the work-arounds noted here), it should be possible to define a style in Writer that does the same thing. But apparently not.