* src/BaseDoc.py:
* src/ReportBase/_CommandLineReport.py: * src/ReportBase/_ReportDialgo.py: * src/docgen/PdfDoc.py: * src/docgen/OpenOfficeDoc.py: * src/docgen/ODFDoc.py: * src/docgen/RDFDoc.py: * src/docgen/KwordDoc.py: * src/docgen/PSDrawDoc.py: * src/docgen/SvgDrawDoc.py: * src/docgen/HtmlDoc.py: * src/docgen/AbiWord2Doc.py: * src/docgen/LaTeXDoc.py: * src/plugins/BookReport.py: Add PaperStyle to BaseDoc svn: r8229
This commit is contained in:
parent
f5bfffad4e
commit
5aa3a0f4b0
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
||||
2007-02-24 Brian Matherly <brian@gramps-project.org>
|
||||
* src/BaseDoc.py:
|
||||
* src/ReportBase/_CommandLineReport.py:
|
||||
* src/ReportBase/_ReportDialgo.py:
|
||||
* src/docgen/PdfDoc.py:
|
||||
* src/docgen/OpenOfficeDoc.py:
|
||||
* src/docgen/ODFDoc.py:
|
||||
* src/docgen/RDFDoc.py:
|
||||
* src/docgen/KwordDoc.py:
|
||||
* src/docgen/PSDrawDoc.py:
|
||||
* src/docgen/SvgDrawDoc.py:
|
||||
* src/docgen/HtmlDoc.py:
|
||||
* src/docgen/AbiWord2Doc.py:
|
||||
* src/docgen/LaTeXDoc.py:
|
||||
* src/plugins/BookReport.py:
|
||||
Add PaperStyle to BaseDoc
|
||||
|
||||
2007-02-24 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
|
||||
* src/Makefile.am: update
|
||||
* src/BasicUtils/Makefile.am: update
|
||||
|
@ -211,6 +211,72 @@ class PaperSize:
|
||||
"Returns the page width in inches"
|
||||
return self.width / 2.54
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# PaperStyle
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class PaperStyle:
|
||||
"""
|
||||
Defines the various options for a sheet of paper.
|
||||
"""
|
||||
def __init__(self, size, orientation):
|
||||
"""
|
||||
Creates a new paper style.
|
||||
|
||||
@param size: size of the new style
|
||||
@type size: PaperSize
|
||||
@param orientation: page orientation
|
||||
@type orientation: PAPER_PORTRAIT or PAPER_LANDSCAPE
|
||||
"""
|
||||
|
||||
self.__orientation = orientation
|
||||
if orientation == PAPER_PORTRAIT:
|
||||
self.__size = PaperSize( size.get_name(),
|
||||
size.get_height(),
|
||||
size.get_width() )
|
||||
else:
|
||||
self.__size = PaperSize( size.get_name(),
|
||||
size.get_width(),
|
||||
size.get_height() )
|
||||
|
||||
self.__tmargin = 2.54
|
||||
self.__bmargin = 2.54
|
||||
self.__lmargin = 2.54
|
||||
self.__rmargin = 2.54
|
||||
|
||||
def get_size(self):
|
||||
return self.__size
|
||||
|
||||
def get_orientation(self):
|
||||
return self.__orientation
|
||||
|
||||
def get_usable_width(self):
|
||||
"""
|
||||
Returns the width of the page area in centimeters. The value is
|
||||
the page width less the margins.
|
||||
"""
|
||||
return self.__size.get_width() - (self.__rmargin + self.__lmargin)
|
||||
|
||||
def get_usable_height(self):
|
||||
"""
|
||||
Returns the height of the page area in centimeters. The value is
|
||||
the page height less the margins.
|
||||
"""
|
||||
return self.__size.get_height() - (self.__tmargin + self.__bmargin)
|
||||
|
||||
def get_right_margin(self):
|
||||
return self.__rmargin
|
||||
|
||||
def get_left_margin(self):
|
||||
return self.__lmargin
|
||||
|
||||
def get_top_margin(self):
|
||||
return self.__tmargin
|
||||
|
||||
def get_bottom_margin(self):
|
||||
return self.__bmargin
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# FontStyle
|
||||
@ -1173,8 +1239,7 @@ class BaseDoc:
|
||||
such as OpenOffice, AbiWord, and LaTeX are derived from this base
|
||||
class, providing a common interface to all document generators.
|
||||
"""
|
||||
def __init__(self, styles, paper_type, template,
|
||||
orientation=PAPER_PORTRAIT):
|
||||
def __init__(self, styles, paper_style, template):
|
||||
"""
|
||||
Creates a BaseDoc instance, which provides a document generation
|
||||
interface. This class should never be instantiated directly, but
|
||||
@ -1189,19 +1254,8 @@ class BaseDoc:
|
||||
@param orientation: page orientation, either PAPER_PORTRAIT or
|
||||
PAPER_LANDSCAPE
|
||||
"""
|
||||
self.orientation = orientation
|
||||
self.template = template
|
||||
if orientation == PAPER_PORTRAIT:
|
||||
self.width = paper_type.get_width()
|
||||
self.height = paper_type.get_height()
|
||||
else:
|
||||
self.width = paper_type.get_height()
|
||||
self.height = paper_type.get_width()
|
||||
self.paper = paper_type
|
||||
self.tmargin = 2.54
|
||||
self.bmargin = 2.54
|
||||
self.lmargin = 2.54
|
||||
self.rmargin = 2.54
|
||||
self.paper = paper_style
|
||||
self.title = ""
|
||||
|
||||
self.draw_styles = {}
|
||||
@ -1243,26 +1297,14 @@ class BaseDoc:
|
||||
Returns the width of the text area in centimeters. The value is
|
||||
the page width less the margins.
|
||||
"""
|
||||
return self.width - (self.rmargin + self.lmargin)
|
||||
return self.paper.get_size().get_width() - (self.paper.get_right_margin() + self.paper.get_left_margin())
|
||||
|
||||
def get_usable_height(self):
|
||||
"""
|
||||
Returns the height of the text area in centimeters. The value is
|
||||
the page height less the margins.
|
||||
"""
|
||||
return self.height - (self.tmargin + self.bmargin)
|
||||
|
||||
def get_right_margin(self):
|
||||
return self.rmargin
|
||||
|
||||
def get_left_margin(self):
|
||||
return self.lmargin
|
||||
|
||||
def get_top_margin(self):
|
||||
return self.tmargin
|
||||
|
||||
def get_bottom_margin(self):
|
||||
return self.bmargin
|
||||
return self.paper.get_size().get_height() - (self.paper.get_top_margin() + self.paper.get_bottom_margin())
|
||||
|
||||
def creator(self, name):
|
||||
"Returns the owner name"
|
||||
|
@ -258,7 +258,9 @@ def cl_report(database,name,category,report_class,
|
||||
# write report
|
||||
try:
|
||||
clr.option_class.handler.doc = clr.format(
|
||||
clr.selected_style,clr.paper,clr.template_name,clr.orien)
|
||||
clr.selected_style,
|
||||
BaseDoc.PaperStyle(clr.paper,clr.orien),
|
||||
clr.template_name)
|
||||
MyReport = report_class(database, clr.person, clr.option_class)
|
||||
MyReport.doc.init()
|
||||
MyReport.begin_report()
|
||||
|
@ -57,6 +57,7 @@ from _BareReportDialog import BareReportDialog
|
||||
from _FileEntry import FileEntry
|
||||
from _PaperMenu import PaperComboBox, OrientationComboBox, paper_sizes
|
||||
from _TemplateParser import _template_map, _default_template, _user_template
|
||||
from BaseDoc import PaperStyle
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -177,8 +178,9 @@ class ReportDialog(BareReportDialog):
|
||||
def make_document(self):
|
||||
"""Create a document of the type requested by the user."""
|
||||
|
||||
self.doc = self.format(self.selected_style,self.paper,
|
||||
self.template_name,self.orien)
|
||||
self.doc = self.format(self.selected_style,
|
||||
PaperStyle(self.paper,self.orien),
|
||||
self.template_name )
|
||||
self.options.set_document(self.doc)
|
||||
if self.print_report.get_active ():
|
||||
self.doc.print_requested ()
|
||||
|
@ -54,10 +54,10 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
||||
"""AbiWord document generator. Inherits from the BaseDoc generic
|
||||
document interface class."""
|
||||
|
||||
def __init__(self,styles,type,template,orientation):
|
||||
def __init__(self,styles,type,template):
|
||||
"""Initializes the AbiWordDoc class, calling the __init__ routine
|
||||
of the parent BaseDoc class"""
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation)
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template)
|
||||
self.f = None
|
||||
self.level = 0
|
||||
self.new_page = 0
|
||||
@ -104,17 +104,17 @@ class AbiWordDoc(BaseDoc.BaseDoc):
|
||||
# page size section
|
||||
self.f.write('<pagesize ')
|
||||
self.f.write('pagetype="%s" ' % self.paper.get_name())
|
||||
if self.orientation == BaseDoc.PAPER_PORTRAIT:
|
||||
if self.paper.get_orientation() == BaseDoc.PAPER_PORTRAIT:
|
||||
self.f.write('orientation="portrait" ')
|
||||
else:
|
||||
self.f.write('orientation="landscape" ')
|
||||
self.f.write('width="%.4f" ' % (self.width/2.54))
|
||||
self.f.write('height="%.4f" ' % (self.height/2.54))
|
||||
self.f.write('width="%.4f" ' % (self.paper.get_size().get_width()/2.54))
|
||||
self.f.write('height="%.4f" ' % (self.paper.get_size().get_height()/2.54))
|
||||
self.f.write('units="inch" page-scale="1.000000"/>\n')
|
||||
self.f.write('<section ')
|
||||
rmargin = float(self.rmargin)/2.54
|
||||
lmargin = float(self.lmargin)/2.54
|
||||
self.f.write('props="page-margin-right:%.4fin; ' % rmargin)
|
||||
rmargin = float(self.paper.get_right_margin())/2.54
|
||||
lmargin = float(self.paper.get_left_margin())/2.54
|
||||
self.f.write('props="page-margin-right:%.4fin; ' % paper.get_right_margin())
|
||||
self.f.write('page-margin-left:%.4fin"' % lmargin)
|
||||
self.f.write('>\n')
|
||||
|
||||
|
@ -96,8 +96,8 @@ _bottom = [
|
||||
#------------------------------------------------------------------------
|
||||
class HtmlDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def __init__(self,styles,type,template,orientation):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,BaseDoc.PaperSize("",0,0),template,None)
|
||||
def __init__(self,styles,type,template):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,None,template)
|
||||
self.year = time.localtime(time.time())[0]
|
||||
self.ext = '.html'
|
||||
self.meta = ""
|
||||
|
@ -98,24 +98,25 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('editor="KWord" >\n')
|
||||
self.mtime = time.time()
|
||||
|
||||
if self.paper.name == "A3":
|
||||
paper_name = self.paper.get_size().get_name()
|
||||
if paper_name == "A3":
|
||||
self.f.write('<PAPER format="0" ')
|
||||
elif self.paper.name == "A4":
|
||||
elif paper_name == "A4":
|
||||
self.f.write('<PAPER format="1" ')
|
||||
elif self.paper.name == "A5":
|
||||
elif paper_name == "A5":
|
||||
self.f.write('<PAPER format="2" ')
|
||||
elif self.paper.name == "Letter":
|
||||
elif paper_name == "Letter":
|
||||
self.f.write('<PAPER format="3" ')
|
||||
elif self.paper.name == "Legal":
|
||||
elif paper_name == "Legal":
|
||||
self.f.write('<PAPER format="4" ')
|
||||
elif self.paper.name == "B5":
|
||||
elif paper_name == "B5":
|
||||
self.f.write('<PAPER format="7" ')
|
||||
else:
|
||||
self.f.write('<PAPER format="6" ')
|
||||
|
||||
self.f.write('width="%d" ' % points(self.width))
|
||||
self.f.write('height="%d" ' % points(self.height))
|
||||
if self.orientation == BaseDoc.PAPER_PORTRAIT:
|
||||
self.f.write('width="%d" ' % points(self.paper.get_size().get_width()))
|
||||
self.f.write('height="%d" ' % points(self.paper.get_size().get_height()))
|
||||
if self.paper.get_orientation() == BaseDoc.PAPER_PORTRAIT:
|
||||
self.f.write('orientation="0" ')
|
||||
else:
|
||||
self.f.write('orientation="1" ')
|
||||
@ -126,10 +127,10 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('spHeadBody="9" ')
|
||||
self.f.write('spFootBody="9">\n')
|
||||
self.f.write('<PAPERBORDERS ')
|
||||
self.f.write('top="%d" ' % points(self.tmargin))
|
||||
self.f.write('right="%d" ' % points(self.rmargin))
|
||||
self.f.write('bottom="%d" ' % points(self.bmargin))
|
||||
self.f.write('left="%d"/>' % points(self.lmargin))
|
||||
self.f.write('top="%d" ' % points(self.paper.get_top_margin()))
|
||||
self.f.write('right="%d" ' % points(self.paper.get_right_margin()))
|
||||
self.f.write('bottom="%d" ' % points(self.paper.get_bottom_margin()))
|
||||
self.f.write('left="%d"/>' % points(self.paper.get_left_margin()))
|
||||
self.f.write('</PAPER>\n')
|
||||
self.f.write('<ATTRIBUTES processing="0" ')
|
||||
self.f.write('standardpage="1" ')
|
||||
@ -141,10 +142,10 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('<FRAMESET frameType="1" ')
|
||||
self.f.write('frameInfo="0" ')
|
||||
self.f.write('name="Frameset 1">\n')
|
||||
self.f.write('<FRAME left="%d" ' % points(self.lmargin))
|
||||
self.f.write('top="%d" ' % points(self.tmargin))
|
||||
self.f.write('right="%d" ' % points(self.width-self.rmargin))
|
||||
self.f.write('bottom="%d" ' % points(self.height-self.bmargin))
|
||||
self.f.write('<FRAME left="%d" ' % points(self.paper.get_left_margin()))
|
||||
self.f.write('top="%d" ' % points(self.paper.get_top_margin()))
|
||||
self.f.write('right="%d" ' % points(self.paper.get_size().get_width()-self.paper.get_right_margin()))
|
||||
self.f.write('bottom="%d" ' % points(self.paper.get_size().get_height()-self.paper.get_bottom_margin()))
|
||||
self.f.write('runaround="1" />\n')
|
||||
|
||||
self.cell_row= 0
|
||||
@ -402,8 +403,8 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def start_table(self,name,style_name):
|
||||
self.tbl= self.table_styles[style_name]
|
||||
self.cell_left= (self.lmargin * 72)/ 2.54
|
||||
self.tbl_width= ((self.width - self.lmargin - self.rmargin) * 72 ) / 2.54
|
||||
self.cell_left= (self.paper.get_left_margin() * 72)/ 2.54
|
||||
self.tbl_width= ((self.paper.get_size().get_width() - self.paper.get_left_margin() - self.paper.get_right_margin()) * 72 ) / 2.54
|
||||
if self.frameset_flg == 1:
|
||||
self.f.write(' </FRAMESET> \n')
|
||||
self.cell_row= 0
|
||||
@ -419,7 +420,7 @@ class KwordDoc(BaseDoc.BaseDoc):
|
||||
def end_row(self):
|
||||
self.cell_row= self.cell_row + 1
|
||||
self.cell_col= 0
|
||||
self.cell_left= (self.lmargin * 72)/ 2.54
|
||||
self.cell_left= (self.paper.get_left_margin() * 72)/ 2.54
|
||||
|
||||
def start_cell(self,style_name,span=1):
|
||||
self.cell_span= span
|
||||
|
@ -152,21 +152,22 @@ class LaTeXDoc(BaseDoc.BaseDoc):
|
||||
|
||||
options = "12pt"
|
||||
|
||||
if self.orientation == BaseDoc.PAPER_LANDSCAPE:
|
||||
if self.paper.get_orientation() == BaseDoc.PAPER_LANDSCAPE:
|
||||
options = options + ",landscape"
|
||||
|
||||
# Paper selections are somewhat limited on a stock installation.
|
||||
# If the user picks something not listed here, we'll just accept
|
||||
# the default of the user's LaTeX installation (usually letter).
|
||||
if self.paper.name == "A4":
|
||||
paper_name = self.paper.get_size().get_name()
|
||||
if paper_name == "A4":
|
||||
options = options + ",a4paper"
|
||||
elif self.paper.name == "A5":
|
||||
elif paper_name == "A5":
|
||||
options = options + ",a5paper"
|
||||
elif self.paper.name == "B5":
|
||||
elif paper_name == "B5":
|
||||
options = options + ",b4paper"
|
||||
elif self.paper.name == "Legal":
|
||||
elif paper_name == "Legal":
|
||||
options = options + ",legalpaper"
|
||||
elif self.paper.name == "Letter":
|
||||
elif paper_name == "Letter":
|
||||
options = options + ",letterpaper"
|
||||
|
||||
# Use the article template, T1 font encodings, and specify
|
||||
|
@ -73,8 +73,8 @@ _esc_map = {
|
||||
#-------------------------------------------------------------------------
|
||||
class ODFDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def __init__(self,styles,type,template,orientation=BaseDoc.PAPER_PORTRAIT):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation)
|
||||
def __init__(self,styles,type,template):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template)
|
||||
self.cntnt = None
|
||||
self.filename = None
|
||||
self.level = 0
|
||||
@ -745,17 +745,17 @@ class ODFDoc(BaseDoc.BaseDoc):
|
||||
self.sfile.write('style:justify-single-word="false"/>')
|
||||
self.sfile.write('</style:style>\n')
|
||||
self.sfile.write('<style:page-layout style:name="pm1">\n')
|
||||
self.sfile.write('<style:page-layout-properties fo:page-width="%.2fcm" ' % self.width)
|
||||
self.sfile.write('fo:page-height="%.2fcm" ' % self.height)
|
||||
self.sfile.write('<style:page-layout-properties fo:page-width="%.2fcm" ' % self.paper.get_size().get_width())
|
||||
self.sfile.write('fo:page-height="%.2fcm" ' % self.paper.get_size().get_height())
|
||||
self.sfile.write('style:num-format="1" ')
|
||||
if self.orientation == BaseDoc.PAPER_PORTRAIT:
|
||||
if self.paper.get_orientation() == BaseDoc.PAPER_PORTRAIT:
|
||||
self.sfile.write('style:print-orientation="portrait" ')
|
||||
else:
|
||||
self.sfile.write('style:print-orientation="landscape" ')
|
||||
self.sfile.write('fo:margin-top="%.2fcm" ' % self.tmargin)
|
||||
self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.bmargin)
|
||||
self.sfile.write('fo:margin-left="%.2fcm" ' % self.lmargin)
|
||||
self.sfile.write('fo:margin-right="%.2fcm" ' % self.rmargin)
|
||||
self.sfile.write('fo:margin-top="%.2fcm" ' % self.paper.get_top_margin())
|
||||
self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.paper.get_bottom_margin())
|
||||
self.sfile.write('fo:margin-left="%.2fcm" ' % self.paper.get_left_margin())
|
||||
self.sfile.write('fo:margin-right="%.2fcm" ' % self.paper.get_right_margin())
|
||||
self.sfile.write('style:writing-mode="lr-tb" ')
|
||||
self.sfile.write('style:footnote-max-height="0cm">\n')
|
||||
self.sfile.write('<style:footnote-sep style:width="0.018cm" ')
|
||||
|
@ -70,8 +70,8 @@ _esc_map = {
|
||||
#-------------------------------------------------------------------------
|
||||
class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def __init__(self,styles,type,template,orientation=BaseDoc.PAPER_PORTRAIT):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation)
|
||||
def __init__(self,styles,type,template):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template)
|
||||
self.cntnt = None
|
||||
self.filename = None
|
||||
self.level = 0
|
||||
@ -638,17 +638,17 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
|
||||
self.sfile.write('</office:styles>\n')
|
||||
self.sfile.write('<office:automatic-styles>\n')
|
||||
self.sfile.write('<style:page-master style:name="pm1">\n')
|
||||
self.sfile.write('<style:properties fo:page-width="%.3fcm" ' % self.width)
|
||||
self.sfile.write('fo:page-height="%.3fcm" ' % self.height)
|
||||
self.sfile.write('<style:properties fo:page-width="%.3fcm" ' % self.paper.get_size().get_width())
|
||||
self.sfile.write('fo:page-height="%.3fcm" ' % self.paper.get_size().get_height())
|
||||
self.sfile.write('style:num-format="1" ')
|
||||
if self.orientation == BaseDoc.PAPER_PORTRAIT:
|
||||
if self.paper.get_orientation() == BaseDoc.PAPER_PORTRAIT:
|
||||
self.sfile.write('style:print-orientation="portrait" ')
|
||||
else:
|
||||
self.sfile.write('style:print-orientation="landscape" ')
|
||||
self.sfile.write('fo:margin-top="%.2fcm" ' % self.tmargin)
|
||||
self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.bmargin)
|
||||
self.sfile.write('fo:margin-left="%.2fcm" ' % self.lmargin)
|
||||
self.sfile.write('fo:margin-right="%.2fcm" ' % self.rmargin)
|
||||
self.sfile.write('fo:margin-top="%.2fcm" ' % self.paper.get_top_margin())
|
||||
self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.paper.get_bottom_margin())
|
||||
self.sfile.write('fo:margin-left="%.2fcm" ' % self.paper.get_left_margin())
|
||||
self.sfile.write('fo:margin-right="%.2fcm" ' % self.paper.get_right_margin())
|
||||
self.sfile.write('style:footnote-max-height="0cm">\n')
|
||||
self.sfile.write('<style:footnote-sep style:width="0.018cm" ')
|
||||
self.sfile.write('style:distance-before-sep="0.101cm" ')
|
||||
|
@ -70,8 +70,8 @@ if print_label == None:
|
||||
#-------------------------------------------------------------------------
|
||||
class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def __init__(self,styles,type,template,orientation):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation)
|
||||
def __init__(self,styles,type,template):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template)
|
||||
self.f = None
|
||||
self.filename = None
|
||||
self.level = 0
|
||||
@ -105,7 +105,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
return "%s find-latin-font %d scalefont setfont\n" % (font_name,font.get_size())
|
||||
|
||||
def translate(self,x,y):
|
||||
return (x,self.height-y)
|
||||
return (x,self.paper.get_size().get_height()-y)
|
||||
|
||||
def open(self,filename):
|
||||
if filename[-3:] != ".ps":
|
||||
@ -125,7 +125,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('%%LanguageLevel: 2\n')
|
||||
self.f.write('%%Pages: (atend)\n')
|
||||
self.f.write('%%PageOrder: Ascend\n')
|
||||
if self.orientation != BaseDoc.PAPER_PORTRAIT:
|
||||
if self.paper.get_orientation() != BaseDoc.PAPER_PORTRAIT:
|
||||
self.f.write('%%Orientation: Landscape\n')
|
||||
else:
|
||||
self.f.write('%%Orientation: Portrait\n')
|
||||
@ -169,9 +169,9 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.page = self.page + 1
|
||||
self.f.write("%%Page:")
|
||||
self.f.write("%d %d\n" % (self.page,self.page))
|
||||
if self.orientation != BaseDoc.PAPER_PORTRAIT:
|
||||
if self.paper.get_orientation() != BaseDoc.PAPER_PORTRAIT:
|
||||
self.f.write('90 rotate %s cm %s cm translate\n' % (
|
||||
gformat(0),gformat(-1*self.height)))
|
||||
gformat(0),gformat(-1*self.paper.get_size().get_height())))
|
||||
|
||||
def end_page(self):
|
||||
self.f.write('showpage\n')
|
||||
@ -195,8 +195,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
pname = stype.get_paragraph_style()
|
||||
p = self.style_list[pname]
|
||||
|
||||
x += self.lmargin
|
||||
y = y + self.tmargin + ReportUtils.pt2cm(p.get_font().get_size())
|
||||
x += self.paper.get_left_margin()
|
||||
y = y + self.paper.get_top_margin() + ReportUtils.pt2cm(p.get_font().get_size())
|
||||
|
||||
(text,fdef) = self.encode_text(p,text)
|
||||
|
||||
@ -213,8 +213,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
para_name = stype.get_paragraph_style()
|
||||
p = self.style_list[para_name]
|
||||
|
||||
x1 = x1 + self.lmargin
|
||||
y1 = y1 + self.tmargin + ReportUtils.pt2cm(p.get_font().get_size())
|
||||
x1 = x1 + self.paper.get_left_margin()
|
||||
y1 = y1 + self.paper.get_top_margin() + ReportUtils.pt2cm(p.get_font().get_size())
|
||||
|
||||
(text,fdef) = self.encode_text(p,text)
|
||||
|
||||
@ -225,8 +225,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def rotate_text(self,style,text,x,y,angle):
|
||||
|
||||
x += self.lmargin
|
||||
y += self.tmargin
|
||||
x += self.paper.get_left_margin()
|
||||
y += self.paper.get_top_margin()
|
||||
|
||||
stype = self.draw_styles[style]
|
||||
pname = stype.get_paragraph_style()
|
||||
@ -268,13 +268,13 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('[2 4] 0 setdash\n')
|
||||
|
||||
point = path[0]
|
||||
x1 = point[0]+self.lmargin
|
||||
y1 = point[1]+self.tmargin
|
||||
x1 = point[0]+self.paper.get_left_margin()
|
||||
y1 = point[1]+self.paper.get_top_margin()
|
||||
self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x1,y1)))
|
||||
|
||||
for point in path[1:]:
|
||||
x1 = point[0]+self.lmargin
|
||||
y1 = point[1]+self.tmargin
|
||||
x1 = point[0]+self.paper.get_left_margin()
|
||||
y1 = point[1]+self.paper.get_top_margin()
|
||||
self.f.write('%s cm %s cm lineto\n' % coords(self.translate(x1,y1)))
|
||||
self.f.write('closepath\n')
|
||||
|
||||
@ -284,10 +284,10 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('grestore\n')
|
||||
|
||||
def draw_line(self,style,x1,y1,x2,y2):
|
||||
x1 = x1 + self.lmargin
|
||||
x2 = x2 + self.lmargin
|
||||
y1 = y1 + self.tmargin
|
||||
y2 = y2 + self.tmargin
|
||||
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()
|
||||
stype = self.draw_styles[style]
|
||||
self.f.write('gsave newpath\n')
|
||||
self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x1,y1)))
|
||||
@ -303,10 +303,10 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('grestore\n')
|
||||
|
||||
def draw_bar(self,style,x1,y1,x2,y2):
|
||||
x1 = x1 + self.lmargin
|
||||
x2 = x2 + self.lmargin
|
||||
y1 = y1 + self.tmargin
|
||||
y2 = y2 + self.tmargin
|
||||
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()
|
||||
@ -325,8 +325,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('grestore\n')
|
||||
|
||||
def draw_box(self,style,text,x,y):
|
||||
x = x + self.lmargin
|
||||
y = y + self.tmargin
|
||||
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()
|
||||
|
@ -126,19 +126,21 @@ class PdfDoc(BaseDoc.BaseDoc):
|
||||
else:
|
||||
self.filename = filename
|
||||
|
||||
self.pagesize = (self.width*cm,self.height*cm)
|
||||
page_w = self.paper.get_size().get_width() * cm
|
||||
page_h = self.paper.get_size().get_height() * cm
|
||||
self.pagesize = (page_w,page_h)
|
||||
|
||||
self.doc = GrampsDocTemplate(self.filename,
|
||||
pagesize=self.pagesize,
|
||||
allowSplitting=1,
|
||||
_pageBreakQuick=0,
|
||||
leftMargin=self.lmargin*cm,
|
||||
rightMargin=self.rmargin*cm,
|
||||
topMargin=self.tmargin*cm,
|
||||
bottomMargin=self.bmargin*cm)
|
||||
frameT = Frame(0,0,self.width*cm,self.height*cm,
|
||||
self.lmargin*cm, self.bmargin*cm,
|
||||
self.rmargin*cm,self.tmargin*cm,
|
||||
leftMargin=self.paper.get_left_margin()*cm,
|
||||
rightMargin=self.paper.get_right_margin()*cm,
|
||||
topMargin=self.paper.get_top_margin()*cm,
|
||||
bottomMargin=self.paper.get_bottom_margin()*cm)
|
||||
frameT = Frame(0,0,page_w,page_h,
|
||||
self.paper.get_left_margin()*cm, self.paper.get_bottom_margin()*cm,
|
||||
self.paper.get_right_margin()*cm,self.paper.get_top_margin()*cm,
|
||||
id='normal')
|
||||
ptemp = PageTemplate(frames=frameT,pagesize=self.pagesize)
|
||||
self.doc.addPageTemplates([ptemp])
|
||||
|
@ -107,12 +107,12 @@ class RTFDoc(BaseDoc.BaseDoc):
|
||||
index = index + 1
|
||||
self.f.write('}\n')
|
||||
self.f.write('\\kerning0\\cf0\\viewkind1')
|
||||
self.f.write('\\paperw%d' % twips(self.width))
|
||||
self.f.write('\\paperh%d' % twips(self.height))
|
||||
self.f.write('\\margl%d' % twips(self.lmargin))
|
||||
self.f.write('\\margr%d' % twips(self.rmargin))
|
||||
self.f.write('\\margt%d' % twips(self.tmargin))
|
||||
self.f.write('\\margb%d' % twips(self.bmargin))
|
||||
self.f.write('\\paperw%d' % twips(self.paper.get_size().get_width()))
|
||||
self.f.write('\\paperh%d' % twips(self.paper.get_size().get_height()))
|
||||
self.f.write('\\margl%d' % twips(self.paper.get_left_margin()))
|
||||
self.f.write('\\margr%d' % twips(self.paper.get_right_margin()))
|
||||
self.f.write('\\margt%d' % twips(self.paper.get_top_margin()))
|
||||
self.f.write('\\margb%d' % twips(self.paper.get_bottom_margin()))
|
||||
self.f.write('\\widowctl\n')
|
||||
self.in_table = 0
|
||||
self.text = ""
|
||||
|
@ -43,8 +43,8 @@ import Errors
|
||||
#-------------------------------------------------------------------------
|
||||
class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
|
||||
def __init__(self,styles,type,template,orientation):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation)
|
||||
def __init__(self,styles,type,template):
|
||||
BaseDoc.BaseDoc.__init__(self,styles,type,template)
|
||||
self.f = None
|
||||
self.filename = None
|
||||
self.level = 0
|
||||
@ -77,7 +77,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n')
|
||||
self.f.write('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" ')
|
||||
self.f.write('"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">\n')
|
||||
self.f.write('<svg width="%5.2fcm" height="%5.2fcm" ' % (self.width,self.height))
|
||||
self.f.write('<svg width="%5.2fcm" height="%5.2fcm" ' % (self.paper.get_size().get_width(),self.paper.get_size().get_height()))
|
||||
self.f.write('xmlns="http://www.w3.org/2000/svg">\n')
|
||||
|
||||
def rotate_text(self,style,text,x,y,angle):
|
||||
@ -93,7 +93,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
width = max(width,self.string_width(font,line))
|
||||
|
||||
# rangle = -((pi/180.0) * angle)
|
||||
centerx,centery = units((x+self.lmargin,y+self.tmargin))
|
||||
centerx,centery = units((x+self.paper.get_left_margin(),y+self.paper.get_top_margin()))
|
||||
|
||||
yh = 0
|
||||
for line in text:
|
||||
@ -130,10 +130,10 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.close()
|
||||
|
||||
def draw_line(self,style,x1,y1,x2,y2):
|
||||
x1 = x1 + self.lmargin
|
||||
x2 = x2 + self.lmargin
|
||||
y1 = y1 + self.tmargin
|
||||
y2 = y2 + self.tmargin
|
||||
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]
|
||||
|
||||
@ -149,16 +149,16 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('<polygon fill="#%02x%02x%02x"' % stype.get_fill_color())
|
||||
self.f.write(' style="stroke:#%02x%02x%02x; ' % stype.get_color())
|
||||
self.f.write(' stroke-width:%.2fpt;"' % stype.get_line_width())
|
||||
self.f.write(' points="%.2f,%.2f' % units((point[0]+self.lmargin,point[1]+self.tmargin)))
|
||||
self.f.write(' points="%.2f,%.2f' % units((point[0]+self.paper.get_left_margin(),point[1]+self.paper.get_top_margin())))
|
||||
for point in path[1:]:
|
||||
self.f.write(' %.2f,%.2f' % units((point[0]+self.lmargin,point[1]+self.tmargin)))
|
||||
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.lmargin
|
||||
x2 = x2 + self.lmargin
|
||||
y1 = y1 + self.tmargin
|
||||
y2 = y2 + self.tmargin
|
||||
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 ')
|
||||
@ -171,8 +171,8 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('stroke-width:%.2f;"/>\n' % s.get_line_width())
|
||||
|
||||
def draw_box(self,style,text,x,y):
|
||||
x = x + self.lmargin
|
||||
y = y + self.tmargin
|
||||
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()
|
||||
@ -224,8 +224,8 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
|
||||
self.f.write('</text>\n')
|
||||
|
||||
def draw_text(self,style,text,x,y):
|
||||
x = x + self.lmargin
|
||||
y = y + self.tmargin
|
||||
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()
|
||||
|
@ -1053,8 +1053,9 @@ class BookReportDialog(ReportDialog):
|
||||
|
||||
def make_document(self):
|
||||
"""Create a document of the type requested by the user."""
|
||||
self.doc = self.format(self.selected_style,self.paper,
|
||||
self.template_name,self.orien)
|
||||
self.doc = self.format(self.selected_style,
|
||||
BaseDoc.PaperStyle(self.paper,self.orien),
|
||||
self.template_name)
|
||||
|
||||
self.rptlist = []
|
||||
newpage = 0
|
||||
|
Loading…
Reference in New Issue
Block a user