diff --git a/src/plugins/docgen/HtmlDoc.py b/src/plugins/docgen/HtmlDoc.py index 53b82f7a5..0db5eaa44 100644 --- a/src/plugins/docgen/HtmlDoc.py +++ b/src/plugins/docgen/HtmlDoc.py @@ -68,6 +68,14 @@ class HtmlDoc(BaseDoc, TextDoc): """Implementation of the BaseDoc and TextDoc gen.plug.docgen api for the creation of Html files. This is achieved by writing on a HtmlBackend object + + div id's defined here: + id="grampstextdoc" : the entire text report + id="grampsheading" : a small defined heading, but not h1 to h6 ! + id="grampsstylednote" : start of part with a styled note, divided in + paragraphs + id="grampsnote" : start of part with a note. This id is normally not + used """ def __init__(self, styles, paper_style): @@ -80,6 +88,8 @@ class HtmlDoc(BaseDoc, TextDoc): self._col = 0 self._tbl = None self._empty = 1 + self.title = '' + self.__title_written = -1 # -1 = not written, 0 = writing, 1 = written def set_css_filename(self, css_filename): """ @@ -93,9 +103,10 @@ class HtmlDoc(BaseDoc, TextDoc): Overwrite base method """ self._backend = HtmlBackend(filename) - #self._backend.set_title(....) self._backend.open() self.htmllist += [self._backend.html_body] + #start a gramps report + self.htmllist += [Html('div', id="grampstextdoc")] self.build_header() @@ -145,7 +156,7 @@ class HtmlDoc(BaseDoc, TextDoc): left = 'thin solid #000000' if style.get_right_border(): right = 'thin solid #000000' - text.append('.%s {\n' + text.append('#grampstextdoc .%s {\n' '\tpadding: %s %s %s %s;\n' '\tborder-top:%s; border-bottom:%s;\n' '\tborder-left:%s; border-right:%s;\n}' @@ -156,7 +167,7 @@ class HtmlDoc(BaseDoc, TextDoc): style = styles.get_paragraph_style(style_name) font = style.get_font() font_size = font.get_size() - font_color = '#%02x%02x%02x' % font.get_color() + #font_color = '#%02x%02x%02x' % font.get_color() align = style.get_alignment_text() text_indent = "%.2f" % style.get_first_indent() right_margin = "%.2f" % style.get_right_margin() @@ -179,25 +190,27 @@ class HtmlDoc(BaseDoc, TextDoc): italic = 'font-style:italic; ' if font.get_bold(): bold = 'font-weight:bold; ' - if font.get_type_face() == FONT_SANS_SERIF: - family = '"Helvetica","Arial","sans-serif"' - else: - family = '"Times New Roman","Times","serif"' - - text.append('.%s {\n' - '\tfont-size: %dpt; color: %s;\n' + #if font.get_type_face() == FONT_SANS_SERIF: + # family = '"Helvetica","Arial","sans-serif"' + #else: + # family = '"Times New Roman","Times","serif"' + # do not allow color, set in base css ! + # so no : 'color: %s' % font_color + # so no : 'font-family:%s;' % family + text.append('#grampstextdoc .%s {\n' + '\tfont-size: %dpt;\n' '\ttext-align: %s; text-indent: %scm;\n' '\tmargin-right: %scm; margin-left: %scm;\n' '\tmargin-top: %scm; margin-bottom: %scm;\n' '\tborder-top:%s; border-bottom:%s;\n' '\tborder-left:%s; border-right:%s;\n' - '\t%s%sfont-family:%s;\n}' - % (style_name, font_size, font_color, + '\t%s%s\n}' + % (style_name, font_size, align, text_indent, right_margin, left_margin, top_margin, bottom_margin, top, bottom, left, right, - italic, bold, family)) + italic, bold)) text.append('-->\n') self.style_declaration = '\n'.join(text) @@ -273,6 +286,8 @@ class HtmlDoc(BaseDoc, TextDoc): """ if not markup: text = self._backend.ESCAPE_FUNC()(text) + if self.__title_written == 0 : + self.title += text self.htmllist[-1] += text def __empty_char(self): @@ -289,7 +304,15 @@ class HtmlDoc(BaseDoc, TextDoc): if text != "": self._empty = 0 self.__write_text(text, mark) - + + def write_title(self): + """ + Add title field to header + """ + self._backend.html_header += Html('title', self.title, + inline=True, indent=True) + + def start_table(self, name, style): """ Overwrite base method @@ -303,6 +326,7 @@ class HtmlDoc(BaseDoc, TextDoc): """ Overwrite base method """ + self.write_text('\n') self.__reduce_list() def start_row(self): @@ -316,6 +340,7 @@ class HtmlDoc(BaseDoc, TextDoc): """ Overwrite base method """ + self.write_text('\n') self.__reduce_list() def start_cell(self, style_name, span=1): @@ -326,26 +351,47 @@ class HtmlDoc(BaseDoc, TextDoc): #self.f.write('