Fixed python's changing of "." to "," for internationized formats

svn: r96
This commit is contained in:
Don Allingham 2001-06-07 15:55:45 +00:00
parent e4bc9f3c37
commit da1776071e
3 changed files with 55 additions and 32 deletions

View File

@ -25,6 +25,8 @@ from TextDoc import *
from latin_utf8 import latin_to_utf8 from latin_utf8 import latin_to_utf8
import const import const
import string import string
import utils
cnv = utils.fl2txt
try: try:
import Image import Image
@ -57,14 +59,16 @@ class AbiWordDoc(TextDoc):
self.f.write('orientation="portrait" ') self.f.write('orientation="portrait" ')
else: else:
self.f.write('orientation="landscape" ') self.f.write('orientation="landscape" ')
self.f.write('width="%.4f" ' % (self.width/2.54)) self.f.write('width="%s" ' % cnv("%.4f",self.width/2.54))
self.f.write('height="%.4f" ' % (self.height/2.54)) self.f.write('height="%s" ' % cnv("%.4f",self.height/2.54))
self.f.write('units="inch" page-scale="1.000000"/>\n') self.f.write('units="inch" page-scale="1.000000"/>\n')
self.f.write('<section ') self.f.write('<section ')
rmargin = float(self.rmargin)/2.54 rmargin = float(self.rmargin)/2.54
lmargin = float(self.lmargin)/2.54 lmargin = float(self.lmargin)/2.54
self.f.write('props="page-margin-right:%.4fin; ' % rmargin) self.f.write('props="page-margin-right:%sin; ' % \
self.f.write('page-margin-left:%.4fin"' % lmargin) cnv("%.4f",rmargin))
self.f.write('page-margin-left:%sin"' % \
cnv("%.4f",lmargin))
self.f.write('>\n') self.f.write('>\n')
def close(self): def close(self):
@ -114,8 +118,10 @@ class AbiWordDoc(TextDoc):
self.f.write('<image dataid="') self.f.write('<image dataid="')
self.f.write(tag) self.f.write(tag)
self.f.write('" props="width:%.3fin; ' % ((float(act_width)/72.0)/2.54)) width = cnv("%.3f",((float(act_width)/72.0)/2.54))
self.f.write('height:%.3fin"/>' % ((float(act_height)/72.0)/2.54)) height = cnv("%.3f",((float(act_height)/72.0)/2.54))
self.f.write('" props="width:%sin; ' % width)
self.f.write('height:%sin"/>' % height)
def start_paragraph(self,style_name): def start_paragraph(self,style_name):
style = self.style_list[style_name] style = self.style_list[style_name]
@ -129,13 +135,13 @@ class AbiWordDoc(TextDoc):
self.f.write('text-align:center;') self.f.write('text-align:center;')
else: else:
self.f.write('text-align:justify;') self.f.write('text-align:justify;')
rmargin = float(style.get_right_margin())/2.54 rmargin = cnv("%.4f",float(style.get_right_margin())/2.54)
lmargin = float(style.get_left_margin())/2.54 lmargin = cnv("%.4f",float(style.get_left_margin())/2.54)
indent = float(style.get_first_indent())/2.54 indent = cnv("%.4f",float(style.get_first_indent())/2.54)
self.f.write(' margin-right:%.4fin;' % rmargin) self.f.write(' margin-right:%sin;' % rmargin)
self.f.write(' margin-left:%.4fin;' % lmargin) self.f.write(' margin-left:%sin;' % lmargin)
self.f.write(' tabstops:%.4fin/L;' % lmargin) self.f.write(' tabstops:%sin/L;' % lmargin)
self.f.write(' text-indent:%.4fin' % indent) self.f.write(' text-indent:%sin' % indent)
self.f.write('">') self.f.write('">')
font = style.get_font() font = style.get_font()
self.f.write('<c props="font-family:') self.f.write('<c props="font-family:')

View File

@ -23,6 +23,7 @@ import tempfile
import string import string
import re import re
import intl import intl
import utils
_ = intl.gettext _ = intl.gettext
@ -128,7 +129,7 @@ class HtmlDoc(TextDoc):
self.f.write('.') self.f.write('.')
self.f.write(key) self.f.write(key)
pad = "%.3fcm " % style.get_padding() pad = utils.fl2txt("%.3fcm ",style.get_padding())
self.f.write(' { padding:' + pad + pad + pad + pad +'; ') self.f.write(' { padding:' + pad + pad + pad + pad +'; ')
if style.get_top_border(): if style.get_top_border():
self.f.write('border-top:thin solid #000000; ') self.f.write('border-top:thin solid #000000; ')
@ -165,9 +166,12 @@ class HtmlDoc(TextDoc):
self.f.write('text-align:right; ') self.f.write('text-align:right; ')
elif align == PARA_ALIGN_JUSTIFY: elif align == PARA_ALIGN_JUSTIFY:
self.f.write('text-align:justify; ') self.f.write('text-align:justify; ')
self.f.write('text-indent:%.2fcm; ' % style.get_first_indent()) self.f.write('text-indent:%scm; ' % \
self.f.write('margin-right:%.2fcm; ' % style.get_right_margin()) utils.fl2txt("%.2f",style.get_first_indent()))
self.f.write('margin-left:%.2fcm; ' % style.get_left_margin()) self.f.write('margin-right:%scm; ' % \
utils.fl2txt("%.2f",style.get_right_margin()))
self.f.write('margin-left:%scm; ' % \
utils.fl2txt("%.2f",style.get_left_margin()))
if font.get_italic(): if font.get_italic():
self.f.write('font-style:italic; ') self.f.write('font-style:italic; ')
if font.get_bold(): if font.get_bold():

View File

@ -25,6 +25,9 @@ import string
from TextDoc import * from TextDoc import *
from latin_utf8 import latin_to_utf8 from latin_utf8 import latin_to_utf8
import const import const
import utils
cnv = utils.fl2txt
try: try:
import Image import Image
@ -112,7 +115,8 @@ class OpenOfficeDoc(TextDoc):
self.f.write('<style:style style:name="' + style_name + '" ') self.f.write('<style:style style:name="' + style_name + '" ')
self.f.write('style:family="table">\n') self.f.write('style:family="table">\n')
table_width = float(self.get_usable_width()) table_width = float(self.get_usable_width())
self.f.write('<style:properties style:width="%.3fcm" ' % table_width) table_width_str = cnv("%.4f",table_width)
self.f.write('<style:properties style:width="%scm" '%table_width_str)
self.f.write('/>\n') self.f.write('/>\n')
self.f.write('</style:style>\n') self.f.write('</style:style>\n')
for col in range(0,style.get_columns()): for col in range(0,style.get_columns()):
@ -120,7 +124,9 @@ class OpenOfficeDoc(TextDoc):
self.f.write(style_name + '.' + str(chr(ord('A')+col)) +'" ') self.f.write(style_name + '.' + str(chr(ord('A')+col)) +'" ')
self.f.write('style:family="table-column">') self.f.write('style:family="table-column">')
width = table_width * float(style.get_column_width(col)/100.0) width = table_width * float(style.get_column_width(col)/100.0)
self.f.write('<style:properties style:column-width="%.3fcm"/>' % width) width_str = cnv("%.4f",width)
self.f.write('<style:properties ')
self.f.write('style:column-width="%scm"/>' % width_str)
self.f.write('</style:style>\n') self.f.write('</style:style>\n')
for cell in self.cell_styles.keys(): for cell in self.cell_styles.keys():
cell_style = self.cell_styles[cell] cell_style = self.cell_styles[cell]
@ -128,7 +134,8 @@ class OpenOfficeDoc(TextDoc):
self.f.write(cell) self.f.write(cell)
self.f.write('" style:family="table-cell">\n') self.f.write('" style:family="table-cell">\n')
self.f.write('<style:properties') self.f.write('<style:properties')
self.f.write(' fo:padding="%.3fcm"' % cell_style.get_padding()) self.f.write(' fo:padding="%scm"' % \
cnv("%.3f",cell_style.get_padding()))
if cell_style.get_top_border(): if cell_style.get_top_border():
self.f.write(' fo:border-top="0.002cm solid #000000"') self.f.write(' fo:border-top="0.002cm solid #000000"')
else: else:
@ -181,8 +188,8 @@ class OpenOfficeDoc(TextDoc):
self.f.write('draw:name="') self.f.write('draw:name="')
self.f.write(tag) self.f.write(tag)
self.f.write('" text:anchor-type="paragraph" ') self.f.write('" text:anchor-type="paragraph" ')
self.f.write('svg:width="%.3fcm" ' % (float(act_width)/72.0)) self.f.write('svg:width="%scm" ' % cnv("%.3f",float(act_width)/72.0))
self.f.write('svg:height="%.3fcm" ' % (float(act_height)/72.0)) self.f.write('svg:height="%scm" ' % cnv((float(act_height)/72.0)))
self.f.write('draw:z-index="0" ') self.f.write('draw:z-index="0" ')
self.f.write('xlink:href="#Pictures/') self.f.write('xlink:href="#Pictures/')
self.f.write(base) self.f.write(base)
@ -304,7 +311,8 @@ class OpenOfficeDoc(TextDoc):
self.f.write('<style:properties ') self.f.write('<style:properties ')
if style.get_padding() != 0.0: if style.get_padding() != 0.0:
self.f.write('fo:padding="%.3fcm" ' % style.get_padding()) self.f.write('fo:padding="%scm" ' % \
cnv("%.3f",style.get_padding()))
align = style.get_alignment() align = style.get_alignment()
if align == PARA_ALIGN_LEFT: if align == PARA_ALIGN_LEFT:
@ -332,9 +340,12 @@ class OpenOfficeDoc(TextDoc):
if font.get_underline(): if font.get_underline():
self.f.write('style:text-underline="single" ') self.f.write('style:text-underline="single" ')
self.f.write('style:text-underline-color="font-color" ') self.f.write('style:text-underline-color="font-color" ')
self.f.write('fo:text-indent="%.2fcm" ' % style.get_first_indent()) self.f.write('fo:text-indent="%scm" ' % \
self.f.write('fo:margin-right="%.2fcm" ' % style.get_right_margin()) cnv("%.2f",style.get_first_indent()))
self.f.write('fo:margin-left="%.2fcm" ' % style.get_left_margin()) self.f.write('fo:margin-right="%scm" ' % \
cnv("%.2f",style.get_right_margin()))
self.f.write('fo:margin-left="%scm" ' % \
cnv("%.2f",style.get_left_margin()))
self.f.write('fo:margin-top="0cm" ') self.f.write('fo:margin-top="0cm" ')
self.f.write('fo:margin-bottom="0.212cm"') self.f.write('fo:margin-bottom="0.212cm"')
self.f.write('/>\n') self.f.write('/>\n')
@ -358,17 +369,19 @@ class OpenOfficeDoc(TextDoc):
self.f.write('</office:styles>\n') self.f.write('</office:styles>\n')
self.f.write('<office:automatic-styles>\n') self.f.write('<office:automatic-styles>\n')
self.f.write('<style:page-master style:name="pm1">\n') self.f.write('<style:page-master style:name="pm1">\n')
self.f.write('<style:properties fo:page-width="%.2fcm" ' % self.width) self.f.write('<style:properties fo:page-width="%scm" ' % \
self.f.write('fo:page-height="%.2fcm" ' % self.height) cnv(self.width))
self.f.write('fo:page-height="%scm" ' % \
cnv(self.height))
self.f.write('style:num-format="1" ') self.f.write('style:num-format="1" ')
if self.orientation == PAPER_PORTRAIT: if self.orientation == PAPER_PORTRAIT:
self.f.write('style:print-orientation="portrait" ') self.f.write('style:print-orientation="portrait" ')
else: else:
self.f.write('style:print-orientation="landscape" ') self.f.write('style:print-orientation="landscape" ')
self.f.write('fo:margin-top="%.2fcm" ' % self.tmargin) self.f.write('fo:margin-top="%scm" ' % cnv("%.2f",self.tmargin))
self.f.write('fo:margin-bottom="%.2fcm" ' % self.bmargin) self.f.write('fo:margin-bottom="%scm" ' % cnv("%.2f",self.bmargin))
self.f.write('fo:margin-left="%.2fcm" ' % self.lmargin) self.f.write('fo:margin-left="%scm" ' % cnv("%.2f",self.lmargin))
self.f.write('fo:margin-right="%.2fcm" ' % self.rmargin) self.f.write('fo:margin-right="%scm" ' % cnv("%.2f",self.rmargin))
self.f.write('style:footnote-max-height="0cm">\n') self.f.write('style:footnote-max-height="0cm">\n')
self.f.write('<style:footnote-sep style:width="0.018cm" ') self.f.write('<style:footnote-sep style:width="0.018cm" ')
self.f.write('style:distance-before-sep="0.101cm" ') self.f.write('style:distance-before-sep="0.101cm" ')