Surname prefix support, landscape support for SVG and PS

svn: r1215
This commit is contained in:
Don Allingham 2002-12-01 03:40:47 +00:00
parent a3864a76df
commit efd7282292
6 changed files with 51 additions and 28 deletions

Binary file not shown.

View File

@ -45,4 +45,4 @@ if [ "$preload" != "" ]; then
export LD_PRELOAD="$preload" export LD_PRELOAD="$preload"
fi fi
@PYTHON@ $GRAMPSDIR/gramps.py $* exec @PYTHON@ $GRAMPSDIR/gramps.py $*

View File

@ -77,6 +77,8 @@ class PSDrawDoc(DrawDoc):
self.f.write('%%LanguageLevel: 2\n') self.f.write('%%LanguageLevel: 2\n')
self.f.write('%%Pages: (atend)\n') self.f.write('%%Pages: (atend)\n')
self.f.write('%%PageOrder: Ascend\n') self.f.write('%%PageOrder: Ascend\n')
if self.orientation != PAPER_PORTRAIT:
self.f.write('%%Orientation: Landscape\n')
self.f.write('%%EndComments\n') self.f.write('%%EndComments\n')
self.f.write('/cm { 28.34 mul } def\n') self.f.write('/cm { 28.34 mul } def\n')
@ -100,6 +102,8 @@ class PSDrawDoc(DrawDoc):
self.page = self.page + 1 self.page = self.page + 1
self.f.write("%%Page:") self.f.write("%%Page:")
self.f.write("%d %d\n" % (self.page,self.page)) self.f.write("%d %d\n" % (self.page,self.page))
if self.orientation != PAPER_PORTRAIT:
self.f.write('90 rotate %5.2f cm %5.2f cm translate\n' % (0,-1*self.height))
def end_page(self): def end_page(self):
self.f.write('showpage\n') self.f.write('showpage\n')

View File

@ -63,19 +63,25 @@ class SvgDrawDoc(DrawDoc):
name = "%s.svg" % self.root name = "%s.svg" % self.root
self.f = open(name,"w") self.f = open(name,"w")
self.f.write('<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>\n') self.f.write('<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n')
self.f.write('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" ') self.f.write('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" ')
self.f.write('"http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd">\n') self.f.write('"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">\n')
self.f.write('<svg xml:space="preserve" width="8.5in" height="11in">\n') self.f.write('<svg width="%5.2fcm" height="%5.2fcm" ' % (self.width,self.height))
self.f.write('xmlns="http://www.w3.org/2000/svg">\n')
if self.orientation != PAPER_PORTRAIT:
self.f.write('<g transform="rotate(-90); ')
self.f.write(' translate(-%5.2fcm,0)">\n' % self.height)
def end_page(self): def end_page(self):
if self.orientation != PAPER_PORTRAIT:
self.f.write('</g>\n')
self.f.write('</svg>\n') self.f.write('</svg>\n')
self.f.close() self.f.close()
def draw_line(self,style,x1,y1,x2,y2): def draw_line(self,style,x1,y1,x2,y2):
self.f.write('<line x1="%4.2f" y1="%4.2f" ' % (x1*28.35,y1*28.35)) self.f.write('<line x1="%4.2fcm" y1="%4.2fcm" ' % (x1*28.35,y1*28.35))
self.f.write('x2="%4.2fcm" y2="%4.2fcm" ' % (x2*28.35,y2*28.35)) self.f.write('x2="%4.2fcm" y2="%4.2fcm" ' % (x2*28.35,y2*28.35))
self.f.write('style="stroke:#000000;stroke-width:1"/>\n') self.f.write(' style="stroke:#000000;stroke-width=1"/>\n')
def draw_box(self,style,text,x,y): def draw_box(self,style,text,x,y):
box_style = self.draw_styles[style] box_style = self.draw_styles[style]

View File

@ -211,19 +211,19 @@ class Gramps:
self.default_list = self.pl_page[-1] self.default_list = self.pl_page[-1]
self.alpha_page = { self.alpha_page = {
'a' : self.pl_page[0], 'b' : self.pl_page[0], 'A' : self.pl_page[0], 'B' : self.pl_page[0],
'c' : self.pl_page[1], 'd' : self.pl_page[1], 'C' : self.pl_page[1], 'D' : self.pl_page[1],
'e' : self.pl_page[2], 'f' : self.pl_page[2], 'E' : self.pl_page[2], 'F' : self.pl_page[2],
'g' : self.pl_page[3], 'h' : self.pl_page[3], 'G' : self.pl_page[3], 'H' : self.pl_page[3],
'i' : self.pl_page[4], 'j' : self.pl_page[4], 'I' : self.pl_page[4], 'J' : self.pl_page[4],
'k' : self.pl_page[5], 'l' : self.pl_page[5], 'K' : self.pl_page[5], 'L' : self.pl_page[5],
'm' : self.pl_page[6], 'n' : self.pl_page[6], 'M' : self.pl_page[6], 'N' : self.pl_page[6],
'o' : self.pl_page[7], 'p' : self.pl_page[7], 'O' : self.pl_page[7], 'P' : self.pl_page[7],
'q' : self.pl_page[8], 'r' : self.pl_page[8], 'Q' : self.pl_page[8], 'R' : self.pl_page[8],
's' : self.pl_page[9], 't' : self.pl_page[9], 'S' : self.pl_page[9], 'T' : self.pl_page[9],
'u' : self.pl_page[10], 'v' : self.pl_page[10], 'U' : self.pl_page[10], 'V' : self.pl_page[10],
'w' : self.pl_page[11], 'x' : self.pl_page[11], 'W' : self.pl_page[11], 'X' : self.pl_page[11],
'y' : self.pl_page[12], 'z' : self.pl_page[12], 'Y' : self.pl_page[12], 'Z' : self.pl_page[12],
} }
self.model2page = { self.model2page = {
@ -1200,8 +1200,8 @@ class Gramps:
def add_to_person_list(self,person,change): def add_to_person_list(self,person,change):
key = person.getId() key = person.getId()
val = self.db.getPersonDisplay(person.getId()) val = self.db.getPersonDisplay(person.getId())
pg = val[0] pg = val[5]
pg = pg[0].lower() pg = pg[0]
if self.DataFilter.compare(person): if self.DataFilter.compare(person):
if pg and self.alpha_page.has_key(pg): if pg and self.alpha_page.has_key(pg):
model = self.alpha_page[pg] model = self.alpha_page[pg]
@ -1364,9 +1364,9 @@ class Gramps:
for key in self.db.getPersonKeys(): for key in self.db.getPersonKeys():
person = self.db.getPerson(key) person = self.db.getPerson(key)
val = self.db.getPersonDisplay(key) val = self.db.getPersonDisplay(key)
pg = val[0] pg = val[5]
if pg: if pg:
pg = pg[0].lower() pg = pg[0]
if datacomp(person): if datacomp(person):
if self.id2col.has_key(key): if self.id2col.has_key(key):
continue continue

View File

@ -39,16 +39,29 @@ import Date
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
su = string.upper su = string.upper
sp = string.split
_plist = [ 'de', 'van', 'von', 'la', 'di', 'le', 'du' ]
_prefix = {}
for i in _plist:
_prefix[i] = 1
def build_sort_name(n): def build_sort_name(n):
"""Builds a name from a RelLib.Name instance that is suitable for """Builds a name from a RelLib.Name instance that is suitable for
use as a sort key in a GtkCList. The name is converted to upper case use as a sort key in a GtkCList. The name is converted to upper case
to provide for case-insenstive sorting""" to provide for case-insenstive sorting"""
l = string.split(n.Surname)
if len(l) > 1 and _prefix.has_key(l[0].lower()):
return "%-25s%-30s%s" % (su(l[1]),su(n.FirstName),su(n.Suffix))
else:
if n.Surname: if n.Surname:
return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix)) return "%-25s%-30s%s" % (su(n.Surname),su(n.FirstName),su(n.Suffix))
else: else:
return "%s" % chr(255) return "%s" % chr(255)
def build_sort_date(n): def build_sort_date(n):
"""Builds a date from a Date.Date instance that is suitable for """Builds a date from a Date.Date instance that is suitable for
use as a sort key in a GtkCList. The resultant string is in the format use as a sort key in a GtkCList. The resultant string is in the format