Add name keys for indexing in reports
svn: r6809
This commit is contained in:
parent
4527627bd9
commit
1d225c91db
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
2006-05-28 Brian Matherly <brian@gramps-project.org>
|
2006-05-28 Brian Matherly <brian@gramps-project.org>
|
||||||
* src/docgen/OpenOfficeDoc.py: Allow large cells to span pages (bug 0000165)
|
* src/docgen/OpenOfficeDoc.py: Allow large cells to span pages (bug 0000165)
|
||||||
|
* src/BaseDoc.py: Add key to write_text.
|
||||||
|
* src/docgen/*: Add key to write_text.
|
||||||
|
* src/PluginUtils/_ReportUtils.py: Add get_name_key.
|
||||||
|
* src/plugins/FamilyGroup.py: insert name keys for indexing.
|
||||||
|
|
||||||
2006-05-27 Alex Roitman <shura@gramps-project.org>
|
2006-05-27 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/plugins/Verify.py: More updates.
|
* src/plugins/Verify.py: More updates.
|
||||||
|
@ -1409,12 +1409,13 @@ class BaseDoc:
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def write_text(self, text):
|
def write_text(self, text, key=""):
|
||||||
"""
|
"""
|
||||||
Writes the text in the current paragraph. Should only be used after a
|
Writes the text in the current paragraph. Should only be used after a
|
||||||
start_paragraph and before an end_paragraph.
|
start_paragraph and before an end_paragraph.
|
||||||
|
|
||||||
@param text: text to write.
|
@param text: text to write.
|
||||||
|
@param key: key to use for indexing (if supported)
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -2196,3 +2196,37 @@ def common_name(person,use_nick=False):
|
|||||||
return person.get_nick_name()
|
return person.get_nick_name()
|
||||||
else:
|
else:
|
||||||
return person.get_primary_name().get_first_name()
|
return person.get_primary_name().get_first_name()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Indexing function
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def get_person_key(db,person):
|
||||||
|
"""
|
||||||
|
Returns a key that can be used to index a person in a report
|
||||||
|
|
||||||
|
@param db: the GRAMPS database instance
|
||||||
|
@param person: the the key is for
|
||||||
|
"""
|
||||||
|
name = person.get_primary_name().get_name()
|
||||||
|
birth = " "
|
||||||
|
death = " "
|
||||||
|
key = ""
|
||||||
|
|
||||||
|
birth_ref = person.get_birth_ref()
|
||||||
|
if birth_ref:
|
||||||
|
birthEvt = db.get_event_from_handle(birth_ref.ref)
|
||||||
|
birth = DateHandler.get_date(birthEvt)
|
||||||
|
|
||||||
|
death_ref = person.get_death_ref()
|
||||||
|
if death_ref:
|
||||||
|
deathEvt = db.get_event_from_handle(death_ref.ref)
|
||||||
|
death = DateHandler.get_date(deathEvt)
|
||||||
|
|
||||||
|
if birth == " " and death == " ":
|
||||||
|
key = name
|
||||||
|
else:
|
||||||
|
key = "%s (%s - %s)" % (name,birth,death)
|
||||||
|
|
||||||
|
return key
|
||||||
|
@ -265,7 +265,7 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
|||||||
self.write_text(line)
|
self.write_text(line)
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
text = text.replace('&','&'); # Must be first
|
text = text.replace('&','&'); # Must be first
|
||||||
text = text.replace('<','<');
|
text = text.replace('<','<');
|
||||||
text = text.replace('>','>');
|
text = text.replace('>','>');
|
||||||
|
@ -369,7 +369,7 @@ class AsciiDoc(BaseDoc.BaseDoc):
|
|||||||
#
|
#
|
||||||
# Writes text.
|
# Writes text.
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
text = text.replace('<super>','[')
|
text = text.replace('<super>','[')
|
||||||
text = text.replace('</super>',']')
|
text = text.replace('</super>',']')
|
||||||
self.text = self.text + text
|
self.text = self.text + text
|
||||||
|
@ -480,7 +480,7 @@ class HtmlDoc(BaseDoc.BaseDoc):
|
|||||||
self.write_text(line.strip().replace('\n',' '))
|
self.write_text(line.strip().replace('\n',' '))
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
text = text.replace('&','&'); # Must be first
|
text = text.replace('&','&'); # Must be first
|
||||||
text = text.replace('<','<');
|
text = text.replace('<','<');
|
||||||
text = text.replace('>','>');
|
text = text.replace('>','>');
|
||||||
|
@ -482,7 +482,7 @@ class KwordDoc(BaseDoc.BaseDoc):
|
|||||||
self.write_text(line)
|
self.write_text(line)
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
text = text.replace('&','&'); # Must be first
|
text = text.replace('&','&'); # Must be first
|
||||||
text = text.replace('<','<');
|
text = text.replace('<','<');
|
||||||
text = text.replace('>','>');
|
text = text.replace('>','>');
|
||||||
|
@ -778,7 +778,7 @@ class LPRDoc(BaseDoc.BaseDoc):
|
|||||||
y = y - height
|
y = y - height
|
||||||
return (x,y)
|
return (x,y)
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
"""Add the text to the paragraph"""
|
"""Add the text to the paragraph"""
|
||||||
self.brand_new_page = 0
|
self.brand_new_page = 0
|
||||||
# Take care of superscript tags
|
# Take care of superscript tags
|
||||||
|
@ -484,7 +484,7 @@ class LaTeXDoc(BaseDoc.BaseDoc):
|
|||||||
self.f.write('\\end{verbatim}')
|
self.f.write('\\end{verbatim}')
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
"""Write the text to the file"""
|
"""Write the text to the file"""
|
||||||
if text == '\n':
|
if text == '\n':
|
||||||
text = '\\newline\n'
|
text = '\\newline\n'
|
||||||
|
@ -824,12 +824,17 @@ class ODFDoc(BaseDoc.BaseDoc):
|
|||||||
self.write_text(line)
|
self.write_text(line)
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
"""
|
"""
|
||||||
Uses the xml.sax.saxutils.escape function to convert XML
|
Uses the xml.sax.saxutils.escape function to convert XML
|
||||||
entities. The _esc_map dictionary allows us to add our own
|
entities. The _esc_map dictionary allows us to add our own
|
||||||
mappings.
|
mappings.
|
||||||
"""
|
"""
|
||||||
|
if key != "":
|
||||||
|
key = escape(key,_esc_map)
|
||||||
|
key = key.replace('"','"')
|
||||||
|
self.cntnt.write('<text:alphabetical-index-mark ')
|
||||||
|
self.cntnt.write('text:string-value="%s" />' % key)
|
||||||
self.cntnt.write(escape(text,_esc_map))
|
self.cntnt.write(escape(text,_esc_map))
|
||||||
|
|
||||||
def _write_manifest(self):
|
def _write_manifest(self):
|
||||||
|
@ -395,7 +395,7 @@ class ODSDoc(SpreadSheetDoc):
|
|||||||
def end_page(self):
|
def end_page(self):
|
||||||
self.f.write('</table:table>\n')
|
self.f.write('</table:table>\n')
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
if text == "":
|
if text == "":
|
||||||
return
|
return
|
||||||
if self.content == 0:
|
if self.content == 0:
|
||||||
|
@ -727,12 +727,18 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
|||||||
self.write_text(line)
|
self.write_text(line)
|
||||||
self.end_paragraph()
|
self.end_paragraph()
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
"""
|
"""
|
||||||
Uses the xml.sax.saxutils.escape function to convert XML
|
Uses the xml.sax.saxutils.escape function to convert XML
|
||||||
entities. The _esc_map dictionary allows us to add our own
|
entities. The _esc_map dictionary allows us to add our own
|
||||||
mappings.
|
mappings.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if key != "":
|
||||||
|
key = escape(key,_esc_map)
|
||||||
|
key = key.replace('"','"')
|
||||||
|
self.cntnt.write('<text:alphabetical-index-mark ')
|
||||||
|
self.cntnt.write('text:string-value="%s" />' % key)
|
||||||
self.cntnt.write(escape(text,_esc_map))
|
self.cntnt.write(escape(text,_esc_map))
|
||||||
|
|
||||||
def _write_manifest(self):
|
def _write_manifest(self):
|
||||||
|
@ -381,7 +381,7 @@ class OpenSpreadSheet(SpreadSheetDoc):
|
|||||||
def end_page(self):
|
def end_page(self):
|
||||||
self.f.write('</table:table>\n')
|
self.f.write('</table:table>\n')
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
if text == "":
|
if text == "":
|
||||||
return
|
return
|
||||||
if self.content == 0:
|
if self.content == 0:
|
||||||
|
@ -138,7 +138,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
|||||||
if self.print_req:
|
if self.print_req:
|
||||||
Report.run_print_dialog (self.filename)
|
Report.run_print_dialog (self.filename)
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def start_page(self):
|
def start_page(self):
|
||||||
|
@ -403,7 +403,7 @@ class PdfDoc(BaseDoc.BaseDoc):
|
|||||||
else:
|
else:
|
||||||
self.story.append(Paragraph(line,current_para))
|
self.story.append(Paragraph(line,current_para))
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
text = text.replace('&','&') # Must be first
|
text = text.replace('&','&') # Must be first
|
||||||
text = text.replace('<','<')
|
text = text.replace('<','<')
|
||||||
text = text.replace('>','>')
|
text = text.replace('>','>')
|
||||||
|
@ -401,7 +401,7 @@ class RTFDoc(BaseDoc.BaseDoc):
|
|||||||
# the form of \`XX. Make sure to escape braces.
|
# the form of \`XX. Make sure to escape braces.
|
||||||
#
|
#
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
if self.opened == 0:
|
if self.opened == 0:
|
||||||
self.opened = 1
|
self.opened = 1
|
||||||
self.text = self.text + '{%s ' % self.font_type
|
self.text = self.text + '{%s ' % self.font_type
|
||||||
|
@ -112,5 +112,5 @@ class SpreadSheetDoc:
|
|||||||
def end_cell(self):
|
def end_cell(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def write_text(self,text):
|
def write_text(self,text,key=""):
|
||||||
pass
|
pass
|
||||||
|
@ -35,7 +35,7 @@ import gtk
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
import RelLib
|
import RelLib
|
||||||
from PluginUtils import Report, ReportOptions, register_report
|
from PluginUtils import Report, ReportOptions, register_report, ReportUtils
|
||||||
import BaseDoc
|
import BaseDoc
|
||||||
import DateHandler
|
import DateHandler
|
||||||
import Utils
|
import Utils
|
||||||
@ -181,56 +181,8 @@ class FamilyGroup(Report.Report):
|
|||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
|
|
||||||
def dump_parent_line(self,name,text):
|
def dump_parent_parents(self,person):
|
||||||
self.doc.start_row()
|
|
||||||
self.doc.start_cell("FGR-TextContents")
|
|
||||||
self.doc.start_paragraph('FGR-Normal')
|
|
||||||
self.doc.write_text(name)
|
|
||||||
self.doc.end_paragraph()
|
|
||||||
self.doc.end_cell()
|
|
||||||
self.doc.start_cell("FGR-TextContentsEnd",2)
|
|
||||||
self.doc.start_paragraph('FGR-Normal')
|
|
||||||
self.doc.write_text(text)
|
|
||||||
self.doc.end_paragraph()
|
|
||||||
self.doc.end_cell()
|
|
||||||
self.doc.end_row()
|
|
||||||
|
|
||||||
def dump_parent(self,title,person_handle):
|
|
||||||
|
|
||||||
if not person_handle and not self.missingInfo:
|
|
||||||
return
|
|
||||||
elif not person_handle:
|
|
||||||
person = RelLib.Person()
|
|
||||||
else:
|
|
||||||
person = self.database.get_person_from_handle(person_handle)
|
|
||||||
|
|
||||||
self.doc.start_table(title,'FGR-ParentTable')
|
|
||||||
self.doc.start_row()
|
|
||||||
self.doc.start_cell('FGR-ParentHead',3)
|
|
||||||
self.doc.start_paragraph('FGR-ParentName')
|
|
||||||
self.doc.write_text(title + ': ')
|
|
||||||
self.doc.write_text(person.get_primary_name().get_regular_name())
|
|
||||||
self.doc.end_paragraph()
|
|
||||||
self.doc.end_cell()
|
|
||||||
self.doc.end_row()
|
|
||||||
|
|
||||||
birth_ref = person.get_birth_ref()
|
|
||||||
birth = None
|
|
||||||
evtName = str(RelLib.EventType())
|
|
||||||
if birth_ref:
|
|
||||||
birth = self.database.get_event_from_handle(birth_ref.ref)
|
|
||||||
if birth or self.missingInfo:
|
|
||||||
self.dump_parent_event(evtName,birth)
|
|
||||||
|
|
||||||
death_ref = person.get_death_ref()
|
|
||||||
death = None
|
|
||||||
evtName = str(RelLib.EventType(RelLib.EventType.DEATH))
|
|
||||||
if death_ref:
|
|
||||||
death = self.database.get_event_from_handle(death_ref.ref)
|
|
||||||
if death or self.missingInfo:
|
|
||||||
self.dump_parent_event(evtName,death)
|
|
||||||
|
|
||||||
family_handle = person.get_main_parents_family_handle()
|
family_handle = person.get_main_parents_family_handle()
|
||||||
father_name = ""
|
father_name = ""
|
||||||
mother_name = ""
|
mother_name = ""
|
||||||
@ -270,12 +222,93 @@ class FamilyGroup(Report.Report):
|
|||||||
death = DateHandler.get_date( event )
|
death = DateHandler.get_date( event )
|
||||||
if birth_ref or death_ref:
|
if birth_ref or death_ref:
|
||||||
mother_name = "%s (%s - %s)" % (mother_name,birth,death)
|
mother_name = "%s (%s - %s)" % (mother_name,birth,death)
|
||||||
|
|
||||||
|
if father_name != "":
|
||||||
|
self.doc.start_row()
|
||||||
|
self.doc.start_cell("FGR-TextContents")
|
||||||
|
self.doc.start_paragraph('FGR-Normal')
|
||||||
|
self.doc.write_text(_("Father"))
|
||||||
|
self.doc.end_paragraph()
|
||||||
|
self.doc.end_cell()
|
||||||
|
self.doc.start_cell("FGR-TextContentsEnd",2)
|
||||||
|
self.doc.start_paragraph('FGR-Normal')
|
||||||
|
key = ReportUtils.get_person_key(self.database,father)
|
||||||
|
self.doc.write_text(father_name,key)
|
||||||
|
self.doc.end_paragraph()
|
||||||
|
self.doc.end_cell()
|
||||||
|
self.doc.end_row()
|
||||||
|
elif self.missingInfo:
|
||||||
|
self.dump_parent_line(_("Father"),"")
|
||||||
|
|
||||||
if self.missingInfo or father_name != "":
|
if mother_name != "":
|
||||||
self.dump_parent_line(_("Father"),father_name)
|
self.doc.start_row()
|
||||||
|
self.doc.start_cell("FGR-TextContents")
|
||||||
|
self.doc.start_paragraph('FGR-Normal')
|
||||||
|
self.doc.write_text(_("Mother"))
|
||||||
|
self.doc.end_paragraph()
|
||||||
|
self.doc.end_cell()
|
||||||
|
self.doc.start_cell("FGR-TextContentsEnd",2)
|
||||||
|
self.doc.start_paragraph('FGR-Normal')
|
||||||
|
key = ReportUtils.get_person_key(self.database,mother)
|
||||||
|
self.doc.write_text(mother_name,key)
|
||||||
|
self.doc.end_paragraph()
|
||||||
|
self.doc.end_cell()
|
||||||
|
self.doc.end_row()
|
||||||
|
elif self.missingInfo:
|
||||||
|
self.dump_parent_line(_("Mother"),"")
|
||||||
|
|
||||||
if self.missingInfo or mother_name != "":
|
def dump_parent_line(self,name,text):
|
||||||
self.dump_parent_line(_("Mother"),mother_name)
|
self.doc.start_row()
|
||||||
|
self.doc.start_cell("FGR-TextContents")
|
||||||
|
self.doc.start_paragraph('FGR-Normal')
|
||||||
|
self.doc.write_text(name)
|
||||||
|
self.doc.end_paragraph()
|
||||||
|
self.doc.end_cell()
|
||||||
|
self.doc.start_cell("FGR-TextContentsEnd",2)
|
||||||
|
self.doc.start_paragraph('FGR-Normal')
|
||||||
|
self.doc.write_text(text)
|
||||||
|
self.doc.end_paragraph()
|
||||||
|
self.doc.end_cell()
|
||||||
|
self.doc.end_row()
|
||||||
|
|
||||||
|
def dump_parent(self,title,person_handle):
|
||||||
|
|
||||||
|
if not person_handle and not self.missingInfo:
|
||||||
|
return
|
||||||
|
elif not person_handle:
|
||||||
|
person = RelLib.Person()
|
||||||
|
else:
|
||||||
|
person = self.database.get_person_from_handle(person_handle)
|
||||||
|
name = person.get_primary_name().get_regular_name()
|
||||||
|
|
||||||
|
self.doc.start_table(title,'FGR-ParentTable')
|
||||||
|
self.doc.start_row()
|
||||||
|
self.doc.start_cell('FGR-ParentHead',3)
|
||||||
|
self.doc.start_paragraph('FGR-ParentName')
|
||||||
|
self.doc.write_text(title + ': ')
|
||||||
|
key = ReportUtils.get_person_key(self.database,person)
|
||||||
|
self.doc.write_text(name,key)
|
||||||
|
self.doc.end_paragraph()
|
||||||
|
self.doc.end_cell()
|
||||||
|
self.doc.end_row()
|
||||||
|
|
||||||
|
birth_ref = person.get_birth_ref()
|
||||||
|
birth = None
|
||||||
|
evtName = str(RelLib.EventType())
|
||||||
|
if birth_ref:
|
||||||
|
birth = self.database.get_event_from_handle(birth_ref.ref)
|
||||||
|
if birth or self.missingInfo:
|
||||||
|
self.dump_parent_event(evtName,birth)
|
||||||
|
|
||||||
|
death_ref = person.get_death_ref()
|
||||||
|
death = None
|
||||||
|
evtName = str(RelLib.EventType(RelLib.EventType.DEATH))
|
||||||
|
if death_ref:
|
||||||
|
death = self.database.get_event_from_handle(death_ref.ref)
|
||||||
|
if death or self.missingInfo:
|
||||||
|
self.dump_parent_event(evtName,death)
|
||||||
|
|
||||||
|
self.dump_parent_parents(person)
|
||||||
|
|
||||||
if self.incParEvents:
|
if self.incParEvents:
|
||||||
for event_ref in person.get_event_ref_list():
|
for event_ref in person.get_event_ref_list():
|
||||||
@ -462,9 +495,12 @@ class FamilyGroup(Report.Report):
|
|||||||
self.doc.write_text(_("%dU") % index)
|
self.doc.write_text(_("%dU") % index)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
|
|
||||||
|
name = person.get_primary_name().get_regular_name()
|
||||||
|
key = ReportUtils.get_person_key(self.database,person)
|
||||||
self.doc.start_cell('FGR-ChildName',3)
|
self.doc.start_cell('FGR-ChildName',3)
|
||||||
self.doc.start_paragraph('FGR-ChildText')
|
self.doc.start_paragraph('FGR-ChildText')
|
||||||
self.doc.write_text(person.get_primary_name().get_regular_name())
|
self.doc.write_text(name,key)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
@ -534,7 +570,8 @@ class FamilyGroup(Report.Report):
|
|||||||
death = DateHandler.get_date(event)
|
death = DateHandler.get_date(event)
|
||||||
if birth_ref or death_ref:
|
if birth_ref or death_ref:
|
||||||
spouse_name = "%s (%s - %s)" % (spouse_name,birth,death)
|
spouse_name = "%s (%s - %s)" % (spouse_name,birth,death)
|
||||||
self.doc.write_text(spouse_name)
|
key = ReportUtils.get_person_key(self.database,spouse)
|
||||||
|
self.doc.write_text(spouse_name,key)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
self.doc.end_row()
|
self.doc.end_row()
|
||||||
|
Loading…
Reference in New Issue
Block a user