From 4b510b098c27041995b6bbe8a69d1c991e818745 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Sun, 25 Feb 2007 21:53:38 +0000 Subject: [PATCH] * src/BaseDoc.py: * src/docgen/PSDrawDoc.py: * src/docgen/SvgDrawDoc.py: * src/docgen/PdfDoc.py: * src/docgen/OpenOfficeDoc.py: * src/docgen/GtkPrint.py: * src/docgen/LPRDoc.py: * src/docgen/ODFDoc.py: * src/plugins/AncestorChart2.py: * src/plugins/DescendChart.py: * src/plugins/StatisticsChart.py: * src/plugins/TimeLine.py: Remove height and width from GraphicsStyle svn: r8237 --- ChangeLog | 15 +++++++++++++++ src/BaseDoc.py | 18 +----------------- src/docgen/GtkPrint.py | 2 +- src/docgen/LPRDoc.py | 6 +++--- src/docgen/ODFDoc.py | 20 ++++++++------------ src/docgen/OpenOfficeDoc.py | 16 ++++++---------- src/docgen/PSDrawDoc.py | 26 ++++++++++++-------------- src/docgen/PdfDoc.py | 9 +++------ src/docgen/SvgDrawDoc.py | 22 ++++++++++------------ src/plugins/AncestorChart2.py | 11 ++++++----- src/plugins/DescendChart.py | 10 ++++++---- src/plugins/StatisticsChart.py | 1 - src/plugins/TimeLine.py | 1 - 13 files changed, 71 insertions(+), 86 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17f1f1b0a..84ccd223c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-02-25 Brian Matherly + * src/BaseDoc.py: + * src/docgen/PSDrawDoc.py: + * src/docgen/SvgDrawDoc.py: + * src/docgen/PdfDoc.py: + * src/docgen/OpenOfficeDoc.py: + * src/docgen/GtkPrint.py: + * src/docgen/LPRDoc.py: + * src/docgen/ODFDoc.py: + * src/plugins/AncestorChart2.py: + * src/plugins/DescendChart.py: + * src/plugins/StatisticsChart.py: + * src/plugins/TimeLine.py: + Remove height and width from GraphicsStyle + 2007-02-25 Benny Malengier * src/gramps_main.py: new icons, register them * src/DateEdit.py : use icon diff --git a/src/BaseDoc.py b/src/BaseDoc.py index 1f93a3504..e515a57d0 100644 --- a/src/BaseDoc.py +++ b/src/BaseDoc.py @@ -1133,8 +1133,6 @@ class GraphicsStyle: object. """ if obj: - self.height = obj.height - self.width = obj.width self.para_name = obj.para_name self.shadow = obj.shadow self.shadow_space = obj.shadow_space @@ -1143,8 +1141,6 @@ class GraphicsStyle: self.lwidth = obj.lwidth self.lstyle = obj.lstyle else: - self.height = 0 - self.width = 0 self.para_name = "" self.shadow = 0 self.shadow_space = 0.2 @@ -1171,12 +1167,6 @@ class GraphicsStyle: def set_line_style(self, val): self.lstyle = val - def set_height(self, val): - self.height = val - - def set_width(self, val): - self.width = val - def set_paragraph_style(self, val): self.para_name = val @@ -1193,12 +1183,6 @@ class GraphicsStyle: def set_fill_color(self, val): self.fill_color = val - def get_height(self): - return self.height - - def get_width(self): - return self.width - def get_paragraph_style(self): return self.para_name @@ -1454,7 +1438,7 @@ class BaseDoc: def draw_path(self, style, path): pass - def draw_box(self, style, text, x, y): + def draw_box(self, style, text, x, y, w, h): pass def draw_bar(self, style, x1, y1, x2, y2): diff --git a/src/docgen/GtkPrint.py b/src/docgen/GtkPrint.py index 43304eec8..4ff41cb54 100644 --- a/src/docgen/GtkPrint.py +++ b/src/docgen/GtkPrint.py @@ -418,7 +418,7 @@ class GtkDoc(BaseDoc.BaseDoc): def draw_path(self,style,path): pass - def draw_box(self,style,text,x,y): + def draw_box(self,style,text,x,y, w, h): pass def draw_text(self,style,text,x,y): diff --git a/src/docgen/LPRDoc.py b/src/docgen/LPRDoc.py index ee92f38c0..8c7545751 100644 --- a/src/docgen/LPRDoc.py +++ b/src/docgen/LPRDoc.py @@ -1056,7 +1056,7 @@ class LPRDoc(BaseDoc.BaseDoc): self.gpc.setrgbcolor(0,0,0) - def draw_box(self,style,text,x,y): + def draw_box(self,style,text,x,y, w, h): #assuming that we start drawing box from current position self.brand_new_page = 0 @@ -1067,8 +1067,8 @@ class LPRDoc(BaseDoc.BaseDoc): para_name = box_style.get_paragraph_style() para_style = self.style_list[para_name] fontstyle = para_style.get_font() - bh = cm2u(box_style.get_height()) - bw = cm2u(box_style.get_width()) + bh = cm2u(h) + bw = cm2u(w) if box_style.get_shadow(): ss = cm2u(box_style.get_shadow_space()) diff --git a/src/docgen/ODFDoc.py b/src/docgen/ODFDoc.py index 8300ea092..9e88a37aa 100644 --- a/src/docgen/ODFDoc.py +++ b/src/docgen/ODFDoc.py @@ -62,6 +62,7 @@ _esc_map = { '\x1a' : '', '\x0c' : '', '\n' : '', + '\t' : '', '<super>' : '', '</super>' : '', } @@ -1049,10 +1050,7 @@ class ODFDoc(BaseDoc.BaseDoc): pstyle = self.style_list[para_name] font = pstyle.get_font() - if box_style.get_width(): - sw = box_style.get_width()*1.2 - else: - sw = ReportUtils.pt2cm(FontScale.string_width(font,text))*1.3 + sw = ReportUtils.pt2cm(FontScale.string_width(font,text))*1.3 self.cntnt.write('' % float(y)) self.cntnt.write('\n') - def draw_box(self,style,text,x,y): + def draw_box(self,style,text,x,y, w, h): box_style = self.draw_styles[style] para_name = box_style.get_paragraph_style() shadow_width = box_style.get_shadow_space() @@ -1094,8 +1092,8 @@ class ODFDoc(BaseDoc.BaseDoc): self.cntnt.write('draw:style-name="%s_shadow" ' % style) self.cntnt.write('draw:z-index="0" ') self.cntnt.write('draw:text-style-name="%s" ' % para_name) - self.cntnt.write('svg:width="%.2fcm" ' % box_style.get_width()) - self.cntnt.write('svg:height="%.2fcm" ' % box_style.get_height()) + self.cntnt.write('svg:width="%.2fcm" ' % w) + self.cntnt.write('svg:height="%.2fcm" ' % h) self.cntnt.write('svg:x="%.2fcm" ' % (float(x)+shadow_width)) self.cntnt.write('svg:y="%.2fcm">\n' % (float(y)+shadow_width)) self.cntnt.write('\n') @@ -1104,16 +1102,14 @@ class ODFDoc(BaseDoc.BaseDoc): self.cntnt.write('draw:style-name="%s" ' % style) self.cntnt.write('draw:text-style-name="%s" ' % para_name) self.cntnt.write('draw:z-index="1" ') - self.cntnt.write('svg:width="%.2fcm" ' % box_style.get_width()) - self.cntnt.write('svg:height="%.2fcm" ' % box_style.get_height()) + self.cntnt.write('svg:width="%.2fcm" ' % w) + self.cntnt.write('svg:height="%.2fcm" ' % h) self.cntnt.write('svg:x="%.2fcm" ' % float(x)) self.cntnt.write('svg:y="%.2fcm">\n' % float(y)) if text != "": self.cntnt.write('' % para_name) self.cntnt.write('' % para_name) - text = text.replace('\t','') - text = text.replace('\n','') - self.cntnt.write(escape(text)) + self.cntnt.write(escape(text,_esc_map)) self.cntnt.write('') self.cntnt.write('\n') self.cntnt.write('\n') diff --git a/src/docgen/OpenOfficeDoc.py b/src/docgen/OpenOfficeDoc.py index bee62faea..af3f2c6b3 100644 --- a/src/docgen/OpenOfficeDoc.py +++ b/src/docgen/OpenOfficeDoc.py @@ -896,11 +896,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): pstyle = self.style_list[para_name] font = pstyle.get_font() - if box_style.get_width(): - sw = box_style.get_width() - else: - sw = ReportUtils.pt2cm(FontScale.string_width(font,text))*1.3 - + sw = ReportUtils.pt2cm(FontScale.string_width(font,text))*1.3 self.cntnt.write('' % float(y)) self.cntnt.write('\n') - def draw_box(self,style,text,x,y): + def draw_box(self,style,text,x,y, w, h): box_style = self.draw_styles[style] para_name = box_style.get_paragraph_style() shadow_width = box_style.get_shadow_space() @@ -939,8 +935,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('draw:style-name="%s_shadow" ' % style) self.cntnt.write('draw:text-style-name="%s" ' % para_name) self.cntnt.write('draw:z-index="0" ') - self.cntnt.write('svg:width="%.3fcm" ' % box_style.get_width()) - self.cntnt.write('svg:height="%.3fcm" ' % box_style.get_height()) + self.cntnt.write('svg:width="%.3fcm" ' % w) + self.cntnt.write('svg:height="%.3fcm" ' % h) self.cntnt.write('svg:x="%.3fcm" ' % (float(x)+shadow_width)) self.cntnt.write('svg:y="%.3fcm">\n' % (float(y)+shadow_width)) self.cntnt.write('\n') @@ -949,8 +945,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('draw:style-name="%s" ' % style) self.cntnt.write('draw:text-style-name="%s" ' % para_name) self.cntnt.write('draw:z-index="1" ') - self.cntnt.write('svg:width="%.3fcm" ' % box_style.get_width()) - self.cntnt.write('svg:height="%.3fcm" ' % box_style.get_height()) + self.cntnt.write('svg:width="%.3fcm" ' % w) + self.cntnt.write('svg:height="%.3fcm" ' % h) self.cntnt.write('svg:x="%.3fcm" ' % float(x)) self.cntnt.write('svg:y="%.3fcm">\n' % float(y)) if text != "": diff --git a/src/docgen/PSDrawDoc.py b/src/docgen/PSDrawDoc.py index cc6ffaf1f..103a5d2a4 100644 --- a/src/docgen/PSDrawDoc.py +++ b/src/docgen/PSDrawDoc.py @@ -324,42 +324,40 @@ class PSDrawDoc(BaseDoc.BaseDoc): self.f.write('%s %s %s setrgbcolor stroke\n' % lrgb(color)) self.f.write('grestore\n') - def draw_box(self,style,text,x,y): + def draw_box(self,style,text,x,y, w, h): x = x + self.paper.get_left_margin() y = y + self.paper.get_top_margin() box_style = self.draw_styles[style] para_name = box_style.get_paragraph_style() p = self.style_list[para_name] - - bh = box_style.get_height() - bw = box_style.get_width() + self.f.write('gsave\n') shadsize = box_style.get_shadow_space() if box_style.get_shadow(): self.f.write('newpath\n') self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x+shadsize,y+shadsize))) - self.f.write('0 -%s cm rlineto\n' % gformat(bh)) - self.f.write('%s cm 0 rlineto\n' % gformat(bw)) - self.f.write('0 %s cm rlineto\n' % gformat(bh)) + self.f.write('0 -%s cm rlineto\n' % gformat(h)) + self.f.write('%s cm 0 rlineto\n' % gformat(w)) + self.f.write('0 %s cm rlineto\n' % gformat(h)) self.f.write('closepath\n') self.f.write('.5 setgray\n') self.f.write('fill\n') self.f.write('newpath\n') self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x,y))) - self.f.write('0 -%s cm rlineto\n' % gformat(bh)) - self.f.write('%s cm 0 rlineto\n' % gformat(bw)) - self.f.write('0 %s cm rlineto\n' % gformat(bh)) + self.f.write('0 -%s cm rlineto\n' % gformat(h)) + self.f.write('%s cm 0 rlineto\n' % gformat(w)) + self.f.write('0 %s cm rlineto\n' % gformat(h)) self.f.write('closepath\n') self.f.write('1 setgray\n') self.f.write('fill\n') self.f.write('newpath\n') if box_style.get_line_width(): self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x,y))) - self.f.write('0 -%s cm rlineto\n' % gformat(bh)) - self.f.write('%s cm 0 rlineto\n' % gformat(bw)) - self.f.write('0 %s cm rlineto\n' % gformat(bh)) + self.f.write('0 -%s cm rlineto\n' % gformat(h)) + self.f.write('%s cm 0 rlineto\n' % gformat(w)) + self.f.write('0 %s cm rlineto\n' % gformat(h)) self.f.write('closepath\n') self.f.write('%s setlinewidth\n' % gformat(box_style.get_line_width())) self.f.write('%s %s %s setrgbcolor stroke\n' % lrgb(box_style.get_color())) @@ -372,7 +370,7 @@ class PSDrawDoc(BaseDoc.BaseDoc): mar = 10/28.35 f_in_cm = p.get_font().get_size()/28.35 fs = f_in_cm * 1.2 - center = y + (bh + fs)/2.0 + (fs*shadsize) + center = y + (h + fs)/2.0 + (fs*shadsize) ystart = center - (fs/2.0) * nlines for i in range(nlines): ypos = ystart + (i * fs) diff --git a/src/docgen/PdfDoc.py b/src/docgen/PdfDoc.py index 511f40e02..2f325ee1a 100644 --- a/src/docgen/PdfDoc.py +++ b/src/docgen/PdfDoc.py @@ -472,22 +472,19 @@ class PdfDoc(BaseDoc.BaseDoc): p.closePath() self.drawing.add(p) - def draw_box(self,style,text,x,y): + def draw_box(self,style,text,x,y, w, h): y = self.get_usable_height() - y box_style = self.draw_styles[style] para_name = box_style.get_paragraph_style() p = self.style_list[para_name] - w = box_style.get_width()*cm - h = box_style.get_height()*cm - sspace = box_style.get_shadow_space() if box_style.get_shadow(): col = make_color((0xc0,0xc0,0xc0)) r = reportlab.graphics.shapes.Rect((x+sspace)*cm, (y-sspace)*cm-h, - w,h, + w*cm,h*cm, fillColor=col, strokeColor=col) self.drawing.add(r) @@ -495,7 +492,7 @@ class PdfDoc(BaseDoc.BaseDoc): sw = box_style.get_line_width() fc = box_style.get_fill_color() sc = box_style.get_color() - r = reportlab.graphics.shapes.Rect((x)*cm,(y*cm)-h,w,h, + r = reportlab.graphics.shapes.Rect((x)*cm,(y*cm)-(h*cm),w*cm,h*cm, strokeWidth=sw, fillColor=fc, strokeColor=sc) diff --git a/src/docgen/SvgDrawDoc.py b/src/docgen/SvgDrawDoc.py index 6ee933ac6..1eceb9e4a 100644 --- a/src/docgen/SvgDrawDoc.py +++ b/src/docgen/SvgDrawDoc.py @@ -170,28 +170,26 @@ class SvgDrawDoc(BaseDoc.BaseDoc): self.f.write('stroke:#%02x%02x%02x; ' % s.get_color()) self.f.write('stroke-width:%.2f;"/>\n' % s.get_line_width()) - def draw_box(self,style,text,x,y): + def draw_box(self,style,text,x,y, w, h): x = x + self.paper.get_left_margin() y = y + self.paper.get_top_margin() - box_style = self.draw_styles[style] - para_name = box_style.get_paragraph_style() - p = self.style_list[para_name] - - bh = box_style.get_height() - bw = box_style.get_width() + box_style = self.draw_styles[style] + para_name = box_style.get_paragraph_style() + p = self.style_list[para_name] + if box_style.get_shadow(): self.f.write('\n') self.f.write('\n' % box_style.get_line_width()) @@ -202,7 +200,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc): nlines = len(lines) mar = 10/28.35 fs = (font_size/28.35) * 1.2 - center = y + (bh + fs)/2.0 + (fs*0.2) + center = y + (h + fs)/2.0 + (fs*0.2) ystart = center - (fs/2.0) * nlines for i in range(nlines): ypos = ystart + (i * fs) diff --git a/src/plugins/AncestorChart2.py b/src/plugins/AncestorChart2.py index 2e75deeae..760c6b61e 100644 --- a/src/plugins/AncestorChart2.py +++ b/src/plugins/AncestorChart2.py @@ -328,8 +328,6 @@ class AncestorChart(Report): self.font.set_size(self.font.get_size()/self.scale) g = BaseDoc.GraphicsStyle() - g.set_height(self.box_height) - g.set_width(self.box_width) g.set_paragraph_style("AC2-Normal") g.set_shadow(1,0.2/self.scale) g.set_fill_color((255,255,255)) @@ -340,7 +338,6 @@ class AncestorChart(Report): g.set_color((0,0,0)) g.set_fill_color((255,255,255)) g.set_line_width(0) - g.set_width(self.doc.get_usable_width()) self.doc.add_draw_style("AC2-title",g) g = BaseDoc.GraphicsStyle() @@ -370,8 +367,12 @@ class AncestorChart(Report): if type(value) == tuple: (person,index) = value text = '\n'.join(self.text[index]) - self.doc.draw_box("AC2-box",text,phys_x*self.delta, - phys_y*self.box_height+self.offset) + self.doc.draw_box("AC2-box", + text, + phys_x*self.delta, + phys_y*self.box_height+self.offset, + self.box_width, + self.box_height ) elif value == 2: self.doc.draw_line("AC2-line", phys_x*self.delta+self.box_width*0.5, diff --git a/src/plugins/DescendChart.py b/src/plugins/DescendChart.py index ab82d7c31..ec1517076 100644 --- a/src/plugins/DescendChart.py +++ b/src/plugins/DescendChart.py @@ -304,8 +304,6 @@ class DescendChart(Report): self.font.set_size(self.font.get_size()/self.scale) g = BaseDoc.GraphicsStyle() - g.set_height(self.box_height) - g.set_width(self.box_width) g.set_paragraph_style("DC2-Normal") g.set_shadow(1,min(self.box_gap,0.2)) @@ -318,7 +316,6 @@ class DescendChart(Report): g.set_color((0,0,0)) g.set_fill_color((255,255,255)) g.set_line_width(0) - g.set_width(self.doc.get_usable_width()) self.doc.add_draw_style("DC2-title",g) g = BaseDoc.GraphicsStyle() @@ -349,7 +346,12 @@ class DescendChart(Report): text = '\n'.join(self.text[(x,y)]) xbegin = phys_x*self.delta yend = phys_y*bh+self.offset - self.doc.draw_box("DC2-box",text,xbegin,yend) + self.doc.draw_box("DC2-box", + text, + xbegin, + yend, + self.box_width, + self.box_height) elif value == _LINE_HORIZONTAL: xbegin = phys_x*self.delta ystart = (phys_y*bh + self.box_height/2.0) + self.offset diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index da677505e..558b3c7f6 100644 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -572,7 +572,6 @@ class StatisticsChart(Report): g.set_color((0,0,0)) g.set_fill_color((255,255,255)) g.set_line_width(0) - g.set_width(self.doc.get_usable_width()) self.doc.add_draw_style("SC-title",g) g = BaseDoc.GraphicsStyle() diff --git a/src/plugins/TimeLine.py b/src/plugins/TimeLine.py index 9559d7ebc..21302b60d 100644 --- a/src/plugins/TimeLine.py +++ b/src/plugins/TimeLine.py @@ -148,7 +148,6 @@ class TimeLine(Report): g.set_color((0,0,0)) g.set_fill_color((255,255,255)) g.set_line_width(0) - g.set_width(self.doc.get_usable_width()) self.doc.add_draw_style("TLG-title",g) g = BaseDoc.GraphicsStyle()