issue 2688: some wrong bindings and <super> not working yet. All should work now

svn: r11957
This commit is contained in:
Benny Malengier 2009-02-10 23:07:35 +00:00
parent a9a8cb47dc
commit cfadb3fafc
9 changed files with 80 additions and 55 deletions

View File

@ -1402,6 +1402,7 @@ class BaseDoc:
"Closes the document"
raise NotImplementedError
#------------------------------------------------------------------------
#
# TextDoc
@ -1552,6 +1553,36 @@ class TextDoc:
"""
text = str(styledtext)
self.write_note(text, format, style_name)
def write_text_citation(self, text, mark=None):
"""Method to write text with GRAMPS <super> citation marks"""
if not text:
return
parts = text.split("<super>")
markset = False
for piece in parts:
if not piece:
# a text '<super>text ...' splits as '', 'text..'
continue
piecesplit = piece.split("</super>")
if len(piecesplit) == 2:
self.start_superscript()
self.write_text(piecesplit[0])
self.end_superscript()
if not piecesplit[1]:
#text ended with ' ... </super>'
continue
if not markset:
self.write_text(piecesplit[1], mark)
markset = True
else:
self.write_text(piecesplit[1])
else:
if not markset:
self.write_text(piece, mark)
markset = True
else:
self.write_text(piece)
def add_media_object(self, name, align, w_cm, h_cm):
"""

View File

@ -3,6 +3,7 @@
#
# Copyright (C) 2000-2006 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2009 Benny Malengier <benny.malengier@gramps-project.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -362,8 +363,6 @@ class AsciiDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
# Writes text.
#--------------------------------------------------------------------
def write_text(self,text,mark=None):
text = text.replace('<super>','[')
text = text.replace('</super>',']')
self.text = self.text + text
#------------------------------------------------------------------------

View File

@ -1073,8 +1073,8 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
BaseDoc.TextDoc.FONTSIZE : 'size',
}
# overwrite base class attributes
BaseDoc.TextDoc.SUPPORTED_MARKUP = [
# overwrite base class attributes, they become static var of CairoDoc
SUPPORTED_MARKUP = [
BaseDoc.TextDoc.BOLD,
BaseDoc.TextDoc.ITALIC,
BaseDoc.TextDoc.UNDERLINE,
@ -1084,14 +1084,14 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
BaseDoc.TextDoc.HIGHLIGHT,
BaseDoc.TextDoc.SUPERSCRIPT ]
BaseDoc.TextDoc.STYLETAG_MARKUP = {
STYLETAG_MARKUP = {
BaseDoc.TextDoc.BOLD : ("<b>", "</b>"),
BaseDoc.TextDoc.ITALIC : ("<i>", "</i>"),
BaseDoc.TextDoc.UNDERLINE : ("<u>", "</u>"),
BaseDoc.TextDoc.SUPERSCRIPT : ("<sup>", "</sup>"),
}
BaseDoc.TextDoc.ESCAPE_FUNC = lambda x: escape
ESCAPE_FUNC = lambda x: escape
# BaseDoc implementation

View File

@ -3,6 +3,7 @@
#
# Copyright (C) 2000-2006 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2009 Benny Malengier <benny.malengier@gramps-project.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -464,8 +465,6 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
text = text.replace('<','&lt;');
text = text.replace('>','&gt;');
text = text.replace('\n','<br>')
text = text.replace('&lt;super&gt;','<sup>')
text = text.replace('&lt;/super&gt;','</sup>')
if text != "":
self.empty = 0
self.f.write(text)

View File

@ -168,8 +168,8 @@ def latexescapeverbatim(text):
class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
"""LaTeX document interface class. Derived from BaseDoc"""
# overwrite base class attributes
BaseDoc.TextDoc.SUPPORTED_MARKUP = [
# overwrite base class attributes, they become static var of LaTeXDoc
SUPPORTED_MARKUP = [
BaseDoc.TextDoc.BOLD,
BaseDoc.TextDoc.ITALIC,
BaseDoc.TextDoc.UNDERLINE,
@ -177,14 +177,14 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
BaseDoc.TextDoc.FONTFACE,
BaseDoc.TextDoc.SUPERSCRIPT ]
BaseDoc.TextDoc.STYLETAG_MARKUP = {
STYLETAG_MARKUP = {
BaseDoc.TextDoc.BOLD : ("\\textbf{", "}"),
BaseDoc.TextDoc.ITALIC : ("\\textit{", "}"),
BaseDoc.TextDoc.UNDERLINE : ("\\underline{", "}"),
BaseDoc.TextDoc.SUPERSCRIPT : ("\\textsuperscript{", "}"),
}
BaseDoc.TextDoc.ESCAPE_FUNC = lambda x: latexescape
ESCAPE_FUNC = lambda x: latexescape
def page_break(self):
"Forces a page break, creating a new page"
@ -553,7 +553,8 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
text = '\\newline\n'
text = latexescape(text)
#hard coded replace of the underline used for missing names/data
text = text.replace('\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_','\\underline{\hspace{3cm}}')
text = text.replace('\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_',
'\\underline{\hspace{3cm}}')
self.f.write(text)
def write_styled_note(self, styledtext, format, style_name):

View File

@ -67,9 +67,7 @@ _esc_map = {
'\x1a' : '',
'\x0c' : '',
'\n' : '<text:line-break/>',
'\t' : '<text:tab />',
'&lt;super&gt;' : '<text:span text:style-name="GSuper">',
'&lt;/super&gt;' : '</text:span>',
'\t' : '<text:tab />',
}
#-------------------------------------------------------------------------

View File

@ -430,9 +430,6 @@ class RTFDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
else:
self.text = self.text + i
self.text = self.text.replace('<super>','{{\*\updnprop5801}\up10 ')
self.text = self.text.replace('</super>','}')
#------------------------------------------------------------------------
#
# Register the document generator with the GRAMPS plugin system

View File

@ -5,6 +5,7 @@
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2008 James Friedmann <jfriedmannj@gmail.com>
# Copyright (C) 2009 Benny Malengier <benny.malengier@gramps-project.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -209,9 +210,9 @@ class DetAncestorReport(Report):
self.doc.start_bold()
self.doc.write_text(name,mark)
if name[-1:] == '.':
self.doc.write_text("%s " % self.endnotes(person))
self.doc.write_text_citation("%s " % self.endnotes(person))
else:
self.doc.write_text("%s. " % self.endnotes(person))
self.doc.write_text_citation("%s. " % self.endnotes(person))
self.doc.end_bold()
if self.dupperson:
@ -243,18 +244,18 @@ class DetAncestorReport(Report):
birth = self.database.get_event_from_handle(birth_ref.ref)
text = text.rstrip(". ")
text = text + self.endnotes(birth) + ". "
self.doc.write_text(text)
self.doc.write_text_citation(text)
first = 0
text = ReportUtils.baptised_str(self.database, person, first, self.verbose,
self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.doc.write_text_citation(text)
text = ReportUtils.christened_str(self.database, person, first, self.verbose,
self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.doc.write_text_citation(text)
span = self.calc_age(person)
text = ReportUtils.died_str(self.database, person, first, self.verbose,
@ -265,13 +266,13 @@ class DetAncestorReport(Report):
death = self.database.get_event_from_handle(death_ref.ref)
text = text.rstrip(". ")
text = text + self.endnotes(death) + ". "
self.doc.write_text(text)
self.doc.write_text_citation(text)
first = 0
text = ReportUtils.buried_str(self.database, person, first, self.verbose,
self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.doc.write_text_citation(text)
first = ReportUtils.common_name(person,self.usecall)
@ -306,7 +307,7 @@ class DetAncestorReport(Report):
first = False
self.doc.start_paragraph('DAR-MoreDetails')
atype = str( alt_name.get_type() )
self.doc.write_text(
self.doc.write_text_citation(
_('%(name_kind)s: %(name)s%(endnotes)s') % {
'name_kind' : atype,
'name' : alt_name.get_regular_name(),
@ -346,7 +347,7 @@ class DetAncestorReport(Report):
if date:
self.doc.write_text( '%s, ' % date )
self.doc.write_text( text )
self.doc.write_text( self.endnotes(addr) )
self.doc.write_text_citation( self.endnotes(addr) )
self.doc.end_paragraph()
if self.inc_attrs:
@ -364,7 +365,7 @@ class DetAncestorReport(Report):
'type' : attr.get_type(),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr) }
self.doc.write_text( text )
self.doc.write_text_citation( text )
self.doc.end_paragraph()
return 0 # Not duplicate person
@ -403,7 +404,7 @@ class DetAncestorReport(Report):
'event_name' : _(evtName),
'event_text' : text }
self.doc.write_text(text)
self.doc.write_text_citation(text)
if self.inc_attrs:
text = ""
@ -417,7 +418,7 @@ class DetAncestorReport(Report):
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr) }
text = " " + text
self.doc.write_text(text)
self.doc.write_text_citation(text)
self.doc.end_paragraph()
@ -428,9 +429,8 @@ class DetAncestorReport(Report):
notelist.extend(event_ref.get_note_list())
for notehandle in notelist:
note = self.database.get_note_from_handle(notehandle)
self.doc.start_paragraph('DAR-MoreDetails')
self.doc.write_text(note.get())
self.doc.end_paragraph()
self.doc.write_styled_note(note.get_styledtext(),
note.get_format(),"DAR-MoreDetails")
def write_parents(self, person, firstName):
family_handle = person.get_main_parents_family_handle()
@ -482,7 +482,7 @@ class DetAncestorReport(Report):
is_first)
if text:
self.doc.write_text(text,spouse_mark)
self.doc.write_text_citation(text,spouse_mark)
is_first = False
def write_children(self, family):
@ -614,9 +614,9 @@ class DetAncestorReport(Report):
self.doc.write_text(name, mark)
if name[-1:] == '.':
self.doc.write_text("%s " % self.endnotes(ind))
self.doc.write_text_citation("%s " % self.endnotes(ind))
else:
self.doc.write_text("%s. " % self.endnotes(ind))
self.doc.write_text_citation("%s. " % self.endnotes(ind))
first_name = ReportUtils.common_name(ind, self.usecall)
print_name = first_name
@ -631,7 +631,7 @@ class DetAncestorReport(Report):
self.verbose, self.endnotes, self.EMPTY_DATE,
self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.doc.write_text_citation(text)
print_name = 0
span = self.calc_age(ind)
@ -647,7 +647,7 @@ class DetAncestorReport(Report):
self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.doc.write_text_citation(text)
print_name = 0
if print_name == 0:

View File

@ -6,6 +6,7 @@
# Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2007 Robert Cawley <rjc@cawley.id.au>
# Copyright (C) 2008-2009 James Friedmann <jfriedmannj@gmail.com>
# Copyright (C) 2009 Benny Malengier <benny.malengier@gramps-project.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -245,9 +246,9 @@ class DetDescendantReport(Report):
self.doc.start_bold()
self.doc.write_text(name, mark)
if name[-1:] == '.':
self.doc.write_text("%s " % self.endnotes(person))
self.doc.write_text_citation("%s " % self.endnotes(person))
else:
self.doc.write_text("%s. " % self.endnotes(person))
self.doc.write_text_citation("%s. " % self.endnotes(person))
self.doc.end_bold()
if self.dubperson:
@ -325,7 +326,7 @@ class DetDescendantReport(Report):
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr) }
text = " " + text
self.doc.write_text(text)
self.doc.write_text_citation(text)
self.doc.end_paragraph()
@ -336,9 +337,8 @@ class DetDescendantReport(Report):
notelist.extend(event_ref.get_note_list())
for notehandle in notelist:
note = self.database.get_note_from_handle(notehandle)
self.doc.start_paragraph('DDR-MoreDetails')
self.doc.write_text(note.get())
self.doc.end_paragraph()
self.doc.write_styled_note(note.get_styledtext(),
note.get_format(),"DDR-MoreDetails")
def write_parents(self, person, firstName):
family_handle = person.get_main_parents_family_handle()
@ -390,7 +390,7 @@ class DetDescendantReport(Report):
is_first)
if text:
self.doc.write_text(text, spouse_mark)
self.doc.write_text_citation(text, spouse_mark)
is_first = False
def __write_mate(self, person, family):
@ -414,7 +414,7 @@ class DetDescendantReport(Report):
self.doc.write_text(_("Relationship with: %s") % name, mark)
if name[-1:] != '.':
self.doc.write_text(".")
self.doc.write_text(self.endnotes(mate))
self.doc.write_text_citation(self.endnotes(mate))
self.doc.end_paragraph()
self.write_person_info(mate)
@ -532,20 +532,20 @@ class DetDescendantReport(Report):
birth = self.database.get_event_from_handle(birth_ref.ref)
text = text.rstrip(". ")
text = text + self.endnotes(birth) + ". "
self.doc.write_text(text)
self.doc.write_text_citation(text)
first = 0
text = ReportUtils.baptised_str(self.database, person, first,
self.verbose, self.endnotes,
self.EMPTY_DATE, self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.doc.write_text_citation(text)
text = ReportUtils.christened_str(self.database, person, first,
self.verbose, self.endnotes,
self.EMPTY_DATE, self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.doc.write_text_citation(text)
span = self.calc_age(person)
text = ReportUtils.died_str(self.database, person, first, self.verbose,
@ -556,14 +556,14 @@ class DetDescendantReport(Report):
death = self.database.get_event_from_handle(death_ref.ref)
text = text.rstrip(". ")
text = text + self.endnotes(death) + ". "
self.doc.write_text(text)
self.doc.write_text_citation(text)
first = 0
text = ReportUtils.buried_str(self.database, person, first,
self.verbose, self.endnotes,
self.EMPTY_DATE, self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.doc.write_text_citation(text)
first = ReportUtils.common_name(person, self.usecall)
@ -594,7 +594,7 @@ class DetDescendantReport(Report):
self.doc.start_paragraph('DDR-MoreDetails')
atype = str( alt_name.get_type() )
aname = alt_name.get_regular_name()
self.doc.write_text(_('%(name_kind)s: %(name)s%(endnotes)s') % {
self.doc.write_text_citation(_('%(name_kind)s: %(name)s%(endnotes)s') % {
'name_kind' : atype,
'name' : aname,
'endnotes' : self.endnotes(alt_name),
@ -628,7 +628,7 @@ class DetDescendantReport(Report):
if date:
self.doc.write_text( '%s, ' % date )
self.doc.write_text( text )
self.doc.write_text( self.endnotes(addr) )
self.doc.write_text_citation( self.endnotes(addr) )
self.doc.end_paragraph()
if self.inc_attrs:
@ -646,7 +646,7 @@ class DetDescendantReport(Report):
'type' : attr.get_type(),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr) }
self.doc.write_text( text )
self.doc.write_text_citation( text )
self.doc.end_paragraph()
def calc_age(self,ind):