diff --git a/gramps/src/HtmlDoc.py b/gramps/src/HtmlDoc.py
index a21034f56..29130e006 100644
--- a/gramps/src/HtmlDoc.py
+++ b/gramps/src/HtmlDoc.py
@@ -40,9 +40,7 @@ try:
except:
no_pil = 1
-t_one_line_re = re.compile(r"^(.*)
.*(.*)$")
-t_start_re = re.compile(r"^(.*).*$")
-t_stop_re = re.compile(r"^(.*)")
+t_header_line_re = re.compile(r"(.*).*(.*)", re.DOTALL)
#------------------------------------------------------------------------
#
@@ -53,23 +51,23 @@ _top = [
'\n',
'\n',
'\n',
- '\n',
- '\n',
- '\n',
- '\n',
+ ' \n',
+ ' \n',
+ ' \n',
+ ' \n',
'\n',
'\n',
- '\n'
+ ' \n'
]
_bottom = [
- '\n',
+ ' \n',
'\n',
'\n'
]
@@ -87,6 +85,9 @@ class HtmlDoc(TextDoc):
self.base = ""
self.load_template()
+ self.build_header()
+ self.build_style_declaration()
+
else:
self.f = None
self.filename = source.filename
@@ -94,6 +95,10 @@ class HtmlDoc(TextDoc):
self.top = source.top
self.bottom = source.bottom
self.base = source.base
+ self.file_header = source.file_header
+ self.style_declaration = source.style_declaration
+ self.table_styles = source.table_styles;
+ self.cell_styles = source.cell_styles;
def load_template(self):
start = re.compile(r"")
@@ -150,108 +155,85 @@ class HtmlDoc(TextDoc):
self.base = os.path.dirname(self.filename)
self.f = open(self.filename,"w")
+ self.f.write(self.file_header % self.title)
+ self.f.write(self.style_declaration)
- need_start = 1
- need_stop = 0
+ def build_header(self):
+ top = string.join(self.top, "")
+ match = t_header_line_re.match(top)
+ if match:
+ m = match.groups()
+ self.file_header = '%s%%s%s\n' % (m[0],m[1])
+ else:
+ self.file_header = None
+
+ def build_style_declaration(self):
fl2txt = utils.fl2txt
- for line in self.top:
- if need_start:
- match = t_one_line_re.match(line)
- if match:
- m = match.groups()
- self.f.write('%s%s%s\n' % (m[0],self.title,m[1]))
- need_start = 0
- continue
- match = t_start_re.match(line)
- if match:
- m = match.groups()
- self.f.write('%s%s\n' % (m[0],self.title))
- need_start = 0
- need_stop = 1
- continue
- elif need_stop:
- if t_stop_re.match(line):
- self.f.write('\n')
- need_stop = 0
- continue
- self.f.write(line)
-
- self.f.write('\n')
+ family = '"Times New Roman","Times","serif"'
+
+ text.append('.%s {\n' \
+ '\tfont-size: %dpt; color: %s;\n' \
+ '\ttext-align: %s; text-indent: %scm;\n' \
+ '\tmargin-right: %scm; margin-left: %scm;\n' \
+ '\tborder-top:%s; border-bottom:%s;\n' \
+ '\tborder-left:%s; border-right:%s;\n' \
+ '\t%s%sfont-family:%s;\n}' \
+ % (key, font_size, font_color,
+ align, text_indent,
+ right_margin, left_margin,
+ top, bottom, left, right,
+ italic, bold, family))
+
+ text.append('-->\n')
+ self.style_declaration = string.join(text,'\n')
def close(self):
for line in self.bottom:
diff --git a/gramps/src/TextDoc.py b/gramps/src/TextDoc.py
index 01781a71a..7ee91f090 100644
--- a/gramps/src/TextDoc.py
+++ b/gramps/src/TextDoc.py
@@ -370,6 +370,17 @@ class ParagraphStyle:
def get_alignment(self):
return self.align
+ def get_alignment_text(self):
+ if self.align == PARA_ALIGN_LEFT:
+ return "left"
+ elif self.align == PARA_ALIGN_CENTER:
+ return "center"
+ elif self.align == PARA_ALIGN_RIGHT:
+ return "right"
+ elif self.align == PARA_ALIGN_JUSTIFY:
+ return "justify"
+ return "unknown"
+
def set_left_margin(self,value):
"sets the left paragraph margin in centimeters"
self.lmargin = value
diff --git a/gramps/src/plugins/WebPage.py b/gramps/src/plugins/WebPage.py
index 3f8e4c21c..15e7ce01d 100644
--- a/gramps/src/plugins/WebPage.py
+++ b/gramps/src/plugins/WebPage.py
@@ -86,22 +86,6 @@ class IndividualPage:
self.slist = []
self.scnt = 1
- tbl = TableStyle()
- tbl.set_width(100)
- tbl.set_column_widths([15,85])
- self.doc.add_table_style("IndTable",tbl)
-
- cell = TableCellStyle()
- self.doc.add_cell_style("NormalCell",cell)
-
- cell = TableCellStyle()
- cell.set_padding(0.2)
- self.doc.add_cell_style("ImageCell",cell)
-
- cell = TableCellStyle()
- cell.set_padding(0.2)
- self.doc.add_cell_style("NoteCell",cell)
-
name = person.getPrimaryName().getRegularName()
self.doc.set_title(_("Summary of %s") % name)
@@ -743,6 +727,9 @@ class WebReport(Report):
self.progress_bar_setup(float(len(ind_list)))
doc = HtmlLinkDoc(self.selected_style,self.template_name)
+ self.add_styles(doc)
+ doc.build_style_declaration()
+
my_map = {}
for l in ind_list:
my_map[l] = 1
@@ -762,6 +749,24 @@ class WebReport(Report):
self.progress_bar_done()
+ def add_styles(self,doc):
+ tbl = TableStyle()
+ tbl.set_width(100)
+ tbl.set_column_widths([15,85])
+ doc.add_table_style("IndTable",tbl)
+
+ cell = TableCellStyle()
+ doc.add_cell_style("NormalCell",cell)
+
+ cell = TableCellStyle()
+ cell.set_padding(0.2)
+ doc.add_cell_style("ImageCell",cell)
+
+ cell = TableCellStyle()
+ cell.set_padding(0.2)
+ doc.add_cell_style("NoteCell",cell)
+
+
#------------------------------------------------------------------------
#
#