public void saveRTF(Writer fileout, int depth, HashMap colorTable)
            throws IOException {
        String pre = "{" + "\\li" + depth * 350;
        String level;
        if (depth <= 8) {
            level = "\\outlinelevel" + depth;
        } else {
            level = "";
        }
        String fontsize = "";
        if (color != null) {
            pre += "\\cf" + ((Integer) colorTable.get(getColor())).intValue();
        }

        if (isItalic()) {
            pre += "\\i ";
        }
        if (isBold()) {
            pre += "\\b ";
        }
        if (font != null && font.getSize() != 0) {
            fontsize = "\\fs" + Math.round(1.5 * getFont().getSize());
            pre += fontsize;
        }

        pre += "{}"; // make sure setting of properties is separated from the
        // text itself

        fileout.write("\\li" + depth * 350 + level + "{}");
        if (this.toString().matches(" *")) {
            fileout.write("o");
        } else {
            String text = saveRFT_escapeUnicodeAndSpecialCharacters(this
                    .getPlainTextContent());
            if (getLink() != null) {
                String link = saveRFT_escapeUnicodeAndSpecialCharacters(getLink());
                if (link.equals(this.toString())) {
                    fileout.write(pre + "<{\\ul\\cf1 " + link + "}>" + "}");
                } else {
                    fileout.write("{" + fontsize + pre + text + "} ");
                    fileout.write("<{\\ul\\cf1 " + link + "}}>");
                }
            } else {
                fileout.write(pre + text + "}");
            }
        }

        fileout.write("\\par");
        fileout.write("\n");

        saveChildrenRTF(fileout, depth, colorTable);
    }