* 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/StatisticsChart.py:
* src/plugins/Calendar.py:
* src/ReportBase/_ReportUtils.py:
Remove draw_bar function

svn: r8254
This commit is contained in:
Brian Matherly
2007-02-27 04:10:43 +00:00
parent 1f11a01c89
commit d7d7ed340b
12 changed files with 43 additions and 132 deletions

View File

@@ -411,10 +411,7 @@ class GtkDoc(BaseDoc.BaseDoc):
def draw_line(self,style,x1,y1,x2,y2):
pass
def draw_bar(self, style, x1, y1, x2, y2):
pass
def draw_path(self,style,path):
pass

View File

@@ -1064,9 +1064,6 @@ class LPRDoc(BaseDoc.BaseDoc):
y = self.top_margin - cm2u(y)
box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style()
para_style = self.style_list[para_name]
fontstyle = para_style.get_font()
bh = cm2u(h)
bw = cm2u(w)
@@ -1090,6 +1087,9 @@ class LPRDoc(BaseDoc.BaseDoc):
self.gpc.rect_stroked(x,y,bw,-bh)
if text:
para_name = box_style.get_paragraph_style()
para_style = self.style_list[para_name]
fontstyle = para_style.get_font()
lines = text.split('\n')
start_x = x + 0.5 * fontstyle.get_size()
start_y = y - fontstyle.get_size() * _EXTRA_SPACING_FACTOR
@@ -1101,25 +1101,6 @@ class LPRDoc(BaseDoc.BaseDoc):
self.gpc.show(line)
start_y -= fontstyle.get_size() * _EXTRA_SPACING_FACTOR
def draw_bar(self, style, x1, y1, x2, y2):
self.brand_new_page = 0
stype = self.draw_styles[style]
self.gpc.setlinewidth(stype.get_line_width())
fill_color = rgb_color(stype.get_fill_color())
color = rgb_color(stype.get_color())
x = self.left_margin + cm2u(x1)
y = self.top_margin - cm2u(y1)
bh = cm2u(y2-y1)
bw = cm2u(x2-x1)
self.gpc.setrgbcolor(fill_color[0],fill_color[1],fill_color[2])
self.gpc.rect_filled(x,y,bw,-bh)
self.gpc.setrgbcolor(color[0],color[1],color[2])
self.gpc.rect_stroked(x,y,bw,-bh)
self.gpc.setrgbcolor(0,0,0)
def draw_text(self,style,text,x,y):
self.brand_new_page = 0
box_style = self.draw_styles[style]

View File

@@ -1070,18 +1070,6 @@ class ODFDoc(BaseDoc.BaseDoc):
self.cntnt.write('</draw:text-box>\n')
self.cntnt.write('</draw:frame>\n')
def draw_bar(self,style,x,y,x2,y2):
box_style = self.draw_styles[style]
self.cntnt.write('<draw:rect text:anchor-type="paragraph" draw:style-name="')
self.cntnt.write(style)
self.cntnt.write('" draw:z-index="0" ')
self.cntnt.write('svg:width="%.2fcm" ' % float(x2-x))
self.cntnt.write('svg:height="%.2fcm" ' % float(y2-y))
self.cntnt.write('svg:x="%.2fcm" ' % float(x))
self.cntnt.write('svg:y="%.2fcm">' % float(y))
self.cntnt.write('</draw:rect>\n')
def draw_box(self,style,text,x,y, w, h):
box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style()
@@ -1120,11 +1108,11 @@ class ODFDoc(BaseDoc.BaseDoc):
pstyle = self.style_list[para_name]
font = pstyle.get_font()
size = 1.2*(FontScale.string_width(font,text)/72.0) * 2.54
size = (FontScale.string_width(font,text)/72.0) * 2.54
self.cntnt.write('<draw:frame text:anchor-type="paragraph" ')
self.cntnt.write('draw:style-name="%s" ' % style)
self.cntnt.write('draw:z-index="0" ')
self.cntnt.write('draw:z-index="2" ')
self.cntnt.write('svg:width="%.2fcm" ' % size)
self.cntnt.write('svg:height="%.2fpt" ' % font.get_size())

View File

@@ -913,18 +913,6 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
self.cntnt.write('</text:span></text:p>')
self.cntnt.write('</draw:text-box>\n')
def draw_bar(self,style,x,y,x2,y2):
box_style = self.draw_styles[style]
self.cntnt.write('<draw:rect text:anchor-type="paragraph" draw:style-name="')
self.cntnt.write(style)
self.cntnt.write('" draw:z-index="0" ')
self.cntnt.write('svg:width="%.3fcm" ' % float(x2-x))
self.cntnt.write('svg:height="%.3fcm" ' % float(y2-y))
self.cntnt.write('svg:x="%.3fcm" ' % float(x))
self.cntnt.write('svg:y="%.3fcm">' % float(y))
self.cntnt.write('</draw:rect>\n')
def draw_box(self,style,text,x,y, w, h):
box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style()
@@ -965,11 +953,11 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
pstyle = self.style_list[para_name]
font = pstyle.get_font()
size = 1.1*(FontScale.string_width(font,text)/72.0) * 2.54
size = (FontScale.string_width(font,text)/72.0) * 2.54
self.cntnt.write('<draw:text-box text:anchor-type="paragraph" ')
self.cntnt.write('draw:style-name="%s" ' % style)
self.cntnt.write('draw:z-index="0" ')
self.cntnt.write('draw:z-index="2" ')
self.cntnt.write('svg:width="%.3fcm" ' % size)
self.cntnt.write('svg:height="%.3fpt" ' % (font.get_size()*1.1))

View File

@@ -302,35 +302,11 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('%s %s %s setrgbcolor stroke\n' % lrgb(stype.get_color()))
self.f.write('grestore\n')
def draw_bar(self,style,x1,y1,x2,y2):
x1 = x1 + self.paper.get_left_margin()
x2 = x2 + self.paper.get_left_margin()
y1 = y1 + self.paper.get_top_margin()
y2 = y2 + self.paper.get_top_margin()
box_type = self.draw_styles[style]
fill_color = box_type.get_fill_color()
color = box_type.get_color()
self.f.write('gsave\n')
self.f.write("%s cm %s cm moveto\n" % coords(self.translate(x1,y1)))
self.f.write("%s cm %s cm lineto\n" % coords(self.translate(x1,y2)))
self.f.write("%s cm %s cm lineto\n" % coords(self.translate(x2,y2)))
self.f.write("%s cm %s cm lineto\n" % coords(self.translate(x2,y1)))
self.f.write("%s cm %s cm lineto\n" % coords(self.translate(x1,y1)))
self.f.write('closepath\n')
self.f.write("%s setlinewidth\n" % gformat(box_type.get_line_width()))
self.f.write('gsave %s %s %s setrgbcolor fill grestore\n' % lrgb(fill_color))
self.f.write('%s %s %s setrgbcolor stroke\n' % lrgb(color))
self.f.write('grestore\n')
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]
self.f.write('gsave\n')
@@ -350,8 +326,12 @@ class PSDrawDoc(BaseDoc.BaseDoc):
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')
fill_color = box_style.get_fill_color()
color = box_style.get_color()
self.f.write('gsave %s %s %s setrgbcolor fill grestore\n' % lrgb(fill_color))
self.f.write('%s %s %s setrgbcolor stroke\n' % lrgb(color))
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)))
@@ -362,6 +342,9 @@ class PSDrawDoc(BaseDoc.BaseDoc):
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()))
if text != "":
para_name = box_style.get_paragraph_style()
assert( para_name != '' )
p = self.style_list[para_name]
(text,fdef) = self.encode_text(p,text)
self.f.write(fdef)
lines = text.split('\n')

View File

@@ -433,22 +433,6 @@ class PdfDoc(BaseDoc.BaseDoc):
strokeDashArray=line_array)
self.drawing.add(l)
def draw_bar(self, style, x1, y1, x2, y2):
style = self.draw_styles[style]
fill_color = make_color(style.get_fill_color())
color = make_color(style.get_color())
line_width = style.get_line_width()
w = (x2-x1)*cm
h = (y2-y1)*cm
y1 = self.get_usable_height() - y1
r = reportlab.graphics.shapes.Rect((x1)*cm,(y1*cm)-h,w,h,
strokeWidth=line_width,
fillColor=fill_color,
strokeColor=color)
self.drawing.add(r)
def draw_path(self,style,path):
stype = self.draw_styles[style]
color = make_color(stype.get_fill_color())
@@ -474,10 +458,7 @@ class PdfDoc(BaseDoc.BaseDoc):
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]
sspace = box_style.get_shadow_space()
if box_style.get_shadow():
@@ -498,10 +479,11 @@ class PdfDoc(BaseDoc.BaseDoc):
strokeColor=sc)
self.drawing.add(r)
size = p.get_font().get_size()
x = x + sspace
if text != "":
para_name = box_style.get_paragraph_style()
p = self.style_list[para_name]
size = p.get_font().get_size()
x = x + sspace
lines = text.split('\n')
self.left_print(lines,p.get_font(),x*cm,y*cm - size)

View File

@@ -153,30 +153,12 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
for point in path[1:]:
self.f.write(' %.2f,%.2f' % units((point[0]+self.paper.get_left_margin(),point[1]+self.paper.get_top_margin())))
self.f.write('"/>\n')
def draw_bar(self,style,x1,y1,x2,y2):
x1 = x1 + self.paper.get_left_margin()
x2 = x2 + self.paper.get_left_margin()
y1 = y1 + self.paper.get_top_margin()
y2 = y2 + self.paper.get_top_margin()
s = self.draw_styles[style]
self.f.write('<rect ')
self.f.write('x="%4.2fcm" ' % x1)
self.f.write('y="%4.2fcm" ' % y1)
self.f.write('width="%4.2fcm" ' % (x2-x1))
self.f.write('height="%4.2fcm" ' % (y2-y1))
self.f.write('style="fill:#%02x%02x%02x; ' % s.get_fill_color())
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, 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]
if box_style.get_shadow():
self.f.write('<rect ')
@@ -194,6 +176,9 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
self.f.write('stroke:#%02x%02x%02x; ' % box_style.get_color())
self.f.write('stroke-width:%f;"/>\n' % box_style.get_line_width())
if text != "":
para_name = box_style.get_paragraph_style()
assert( para_name != '' )
p = self.style_list[para_name]
font = p.get_font()
font_size = font.get_size()
lines = text.split('\n')