Is there a way for elegant source code listings in OpenOffice.org Writer?

Solution 1:

Here is a way to do it visually. It shows a "notch" on lines that are continuations. I don't know a way to do a continuation character.

code list

In OpenOffice.org Writer:

Select the text of the listing

Table > Convert > Text to table

Separate text at > Paragraph

Table > Select table (keep the whole table selected for all the following steps)

Table > Table properties
    Text flow tab
        Allow row to break across pages and columns > Unchecked
    Borders tab
        Line arrangement > Default > Set no borders
    Background tab
        For > Table
        Background color > Gray 10%

Format paragraph
    Indents & spacing tab
        Indent > Before text > 0.25”
        Indent > First line -0.25”
        Spacing > Below paragraph > 0.1”
    Text flow tab
        Options > Do not split paragraph > Checked
    Background tab
        Background color > Gray 10%

Format > Character
        Background > White

Solution 2:

Thanks! I tried to figure out if there is any other way of doing it without having lots of borders. Then I remembered good old html+css and thought about an background image that would start from the upper right and whoose size is exactly optimized to the text size. So I made a background image where the first line is empty, but the next ten lines show that desired linebreak-arrow. The trick is: I assigned that background image to my code-listing paragraph style with position upper right. Then, when I add code to my book, I just have to make sure that each line of code is exactly one paragraph with that style. So if it is just one line, the background image will not appear. If it is more then one line, it will repeat and look exactly the way I wanted it to. Although sometimes there is a linebreak arrow too much there, and the image looks a little bit washy since I resized the image a lot of times to match the text size. But it works. Las thing I did, was to add a an white border in the paragraph style, so that I could make a spacing on the right.

Solution 3:

Another way could be something like this:

alt text

Using Paragraph Style - Borders, and defining the right border without "Merge with the next paragraph" and/or bottom-right shadow with Gray 10% color or similar (on the image Gray 30% is used). A smaller shadow would be less intruding.

Solution 4:

@voyager - I liked your idea, but both yours and my original one are a little heavy looking. Here I've used a bottom border, instead of a side one and a shadow. I used red, but any color would work.

listing