Remove the write_at function. Use draw_text instead. Add center_text to SVGDoc

svn: r8089
This commit is contained in:
Brian Matherly
2007-02-12 04:55:11 +00:00
parent 02096637b8
commit 2a6e0cb197
11 changed files with 41 additions and 94 deletions

View File

@@ -412,9 +412,6 @@ class GtkDoc(BaseDoc.BaseDoc):
def draw_line(self,style,x1,y1,x2,y2):
pass
def write_at(self, style, text, x, y):
pass
def draw_bar(self, style, x1, y1, x2, y2):
pass

View File

@@ -1101,17 +1101,6 @@ class LPRDoc(BaseDoc.BaseDoc):
self.gpc.show(line)
start_y -= fontstyle.get_size() * _EXTRA_SPACING_FACTOR
def write_at (self, style, text, x, y):
self.brand_new_page = 0
para_style = self.style_list[style]
fontstyle = para_style.get_font()
self.gpc.setfont(find_font_from_fontstyle(fontstyle))
x = self.left_margin + cm2u(x)
y = self.top_margin - cm2u(y) - fontstyle.get_size() * _EXTRA_SPACING_FACTOR
self.gpc.moveto(x,y)
self.gpc.show(text)
def draw_bar(self, style, x1, y1, x2, y2):
self.brand_new_page = 0

View File

@@ -1145,31 +1145,6 @@ class ODFDoc(BaseDoc.BaseDoc):
self.cntnt.write('</draw:text-box>')
self.cntnt.write('</draw:frame>\n')
def write_at(self,style,text,x,y):
pstyle = self.style_list[style]
font = pstyle.get_font()
size = 1.2*(FontScale.string_width(font,text)/72.0) * 2.54
self.cntnt.write('<draw:frame text:anchor-type="paragraph" ')
self.cntnt.write('draw:z-index="0" ')
self.cntnt.write('draw:style-name="F%s" ' % style)
self.cntnt.write('svg:width="%.2fcm" ' % size)
self.cntnt.write('svg:height="%.2fpt" ' % font.get_size())
self.cntnt.write('svg:x="%.2fcm" ' % x)
self.cntnt.write('svg:y="%.2fcm">\n' % float(y))
if text != "":
self.cntnt.write('<draw:text-box>')
self.cntnt.write('<text:p text:style-name="%s">' % style)
self.cntnt.write('<text:span text:style-name="X%s">' % style)
self.cntnt.write(text)
self.cntnt.write('</text:span>\n')
self.cntnt.write('</text:p>\n')
self.cntnt.write('</draw:text-box>')
self.cntnt.write('</draw:frame>\n')
#--------------------------------------------------------------------------
#
# Register plugins

View File

@@ -986,26 +986,6 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
self.cntnt.write('</text:p>\n')
self.cntnt.write('</draw:text-box>\n')
def write_at(self,style,text,x,y):
pstyle = self.style_list[style]
font = pstyle.get_font()
size = 1.1*(FontScale.string_width(font,text)/72.0) * 2.54
self.cntnt.write('<draw:text-box text:anchor-type="paragraph" ')
self.cntnt.write('draw:z-index="0" ')
self.cntnt.write('svg:width="%.3fcm" ' % size)
self.cntnt.write('svg:height="%.3fpt" ' % font.get_size())
self.cntnt.write('svg:x="%.3fcm" ' % x)
self.cntnt.write('svg:y="%.3fcm">\n' % float(y))
if text != "":
self.cntnt.write('<text:p text:style-name="X%s">' % style)
self.cntnt.write(text)
self.cntnt.write('</text:p>\n')
self.cntnt.write('</draw:text-box>\n')
#--------------------------------------------------------------------------
#
# Register plugins

View File

@@ -354,19 +354,6 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('%s %s %s setrgbcolor stroke\n' % lrgb(stype.get_color()))
self.f.write('grestore\n')
def write_at(self,style,text,x,y):
para_style = self.style_list[style]
x = x + self.lmargin
y = y + self.tmargin
(text,fdef) = self.encode_text(para_style,text)
self.f.write('gsave\n')
self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x,y)))
self.f.write(fdef)
self.f.write('(%s) show grestore\n' % text)
def draw_bar(self,style,x1,y1,x2,y2):
x1 = x1 + self.lmargin
x2 = x2 + self.lmargin

View File

@@ -431,16 +431,6 @@ class PdfDoc(BaseDoc.BaseDoc):
strokeDashArray=line_array)
self.drawing.add(l)
def write_at(self, style, text, x, y):
para_style = self.style_list[style]
font_style = para_style.get_font()
size = font_style.get_size()
y = self.get_usable_height() - y
if text != "":
lines = text.split('\n')
self.left_print(lines,font_style,x*cm,y*cm - size)
def draw_bar(self, style, x1, y1, x2, y2):
style = self.draw_styles[style]
fill_color = make_color(style.get_fill_color())

View File

@@ -166,7 +166,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
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('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())
@@ -251,6 +251,16 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
self.f.write(text)
self.f.write('</text>\n')
def center_text(self, style, text, x, y):
box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style()
p = self.style_list[para_name]
font = p.get_font()
font_size = font.get_size()
width = self.string_width(font,text) / 72
x = x - width
self.draw_text(style,text,x,y)
def units(val):
return (val[0]*35.433, val[1]*35.433)