* 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:
Brian Matherly
2007-02-24 21:15:21 +00:00
parent f5bfffad4e
commit 5aa3a0f4b0
15 changed files with 213 additions and 145 deletions

View File

@ -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> 2007-02-24 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/Makefile.am: update * src/Makefile.am: update
* src/BasicUtils/Makefile.am: update * src/BasicUtils/Makefile.am: update

View File

@ -211,6 +211,72 @@ class PaperSize:
"Returns the page width in inches" "Returns the page width in inches"
return self.width / 2.54 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 # FontStyle
@ -1173,8 +1239,7 @@ class BaseDoc:
such as OpenOffice, AbiWord, and LaTeX are derived from this base such as OpenOffice, AbiWord, and LaTeX are derived from this base
class, providing a common interface to all document generators. class, providing a common interface to all document generators.
""" """
def __init__(self, styles, paper_type, template, def __init__(self, styles, paper_style, template):
orientation=PAPER_PORTRAIT):
""" """
Creates a BaseDoc instance, which provides a document generation Creates a BaseDoc instance, which provides a document generation
interface. This class should never be instantiated directly, but interface. This class should never be instantiated directly, but
@ -1189,19 +1254,8 @@ class BaseDoc:
@param orientation: page orientation, either PAPER_PORTRAIT or @param orientation: page orientation, either PAPER_PORTRAIT or
PAPER_LANDSCAPE PAPER_LANDSCAPE
""" """
self.orientation = orientation
self.template = template self.template = template
if orientation == PAPER_PORTRAIT: self.paper = paper_style
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.title = "" self.title = ""
self.draw_styles = {} self.draw_styles = {}
@ -1243,26 +1297,14 @@ class BaseDoc:
Returns the width of the text area in centimeters. The value is Returns the width of the text area in centimeters. The value is
the page width less the margins. 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): def get_usable_height(self):
""" """
Returns the height of the text area in centimeters. The value is Returns the height of the text area in centimeters. The value is
the page height less the margins. the page height less the margins.
""" """
return self.height - (self.tmargin + self.bmargin) return self.paper.get_size().get_height() - (self.paper.get_top_margin() + self.paper.get_bottom_margin())
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
def creator(self, name): def creator(self, name):
"Returns the owner name" "Returns the owner name"

View File

@ -258,7 +258,9 @@ def cl_report(database,name,category,report_class,
# write report # write report
try: try:
clr.option_class.handler.doc = clr.format( 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 = report_class(database, clr.person, clr.option_class)
MyReport.doc.init() MyReport.doc.init()
MyReport.begin_report() MyReport.begin_report()

View File

@ -57,6 +57,7 @@ from _BareReportDialog import BareReportDialog
from _FileEntry import FileEntry from _FileEntry import FileEntry
from _PaperMenu import PaperComboBox, OrientationComboBox, paper_sizes from _PaperMenu import PaperComboBox, OrientationComboBox, paper_sizes
from _TemplateParser import _template_map, _default_template, _user_template from _TemplateParser import _template_map, _default_template, _user_template
from BaseDoc import PaperStyle
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -177,8 +178,9 @@ class ReportDialog(BareReportDialog):
def make_document(self): def make_document(self):
"""Create a document of the type requested by the user.""" """Create a document of the type requested by the user."""
self.doc = self.format(self.selected_style,self.paper, self.doc = self.format(self.selected_style,
self.template_name,self.orien) PaperStyle(self.paper,self.orien),
self.template_name )
self.options.set_document(self.doc) self.options.set_document(self.doc)
if self.print_report.get_active (): if self.print_report.get_active ():
self.doc.print_requested () self.doc.print_requested ()

View File

@ -54,10 +54,10 @@ class AbiWordDoc(BaseDoc.BaseDoc):
"""AbiWord document generator. Inherits from the BaseDoc generic """AbiWord document generator. Inherits from the BaseDoc generic
document interface class.""" document interface class."""
def __init__(self,styles,type,template,orientation): def __init__(self,styles,type,template):
"""Initializes the AbiWordDoc class, calling the __init__ routine """Initializes the AbiWordDoc class, calling the __init__ routine
of the parent BaseDoc class""" of the parent BaseDoc class"""
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation) BaseDoc.BaseDoc.__init__(self,styles,type,template)
self.f = None self.f = None
self.level = 0 self.level = 0
self.new_page = 0 self.new_page = 0
@ -104,17 +104,17 @@ class AbiWordDoc(BaseDoc.BaseDoc):
# page size section # page size section
self.f.write('<pagesize ') self.f.write('<pagesize ')
self.f.write('pagetype="%s" ' % self.paper.get_name()) 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" ') 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="%.4f" ' % (self.paper.get_size().get_width()/2.54))
self.f.write('height="%.4f" ' % (self.height/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('units="inch" page-scale="1.000000"/>\n')
self.f.write('<section ') self.f.write('<section ')
rmargin = float(self.rmargin)/2.54 rmargin = float(self.paper.get_right_margin())/2.54
lmargin = float(self.lmargin)/2.54 lmargin = float(self.paper.get_left_margin())/2.54
self.f.write('props="page-margin-right:%.4fin; ' % rmargin) self.f.write('props="page-margin-right:%.4fin; ' % paper.get_right_margin())
self.f.write('page-margin-left:%.4fin"' % lmargin) self.f.write('page-margin-left:%.4fin"' % lmargin)
self.f.write('>\n') self.f.write('>\n')

View File

@ -96,8 +96,8 @@ _bottom = [
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class HtmlDoc(BaseDoc.BaseDoc): class HtmlDoc(BaseDoc.BaseDoc):
def __init__(self,styles,type,template,orientation): def __init__(self,styles,type,template):
BaseDoc.BaseDoc.__init__(self,styles,BaseDoc.PaperSize("",0,0),template,None) BaseDoc.BaseDoc.__init__(self,styles,None,template)
self.year = time.localtime(time.time())[0] self.year = time.localtime(time.time())[0]
self.ext = '.html' self.ext = '.html'
self.meta = "" self.meta = ""

View File

@ -98,24 +98,25 @@ class KwordDoc(BaseDoc.BaseDoc):
self.f.write('editor="KWord" >\n') self.f.write('editor="KWord" >\n')
self.mtime = time.time() 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" ') self.f.write('<PAPER format="0" ')
elif self.paper.name == "A4": elif paper_name == "A4":
self.f.write('<PAPER format="1" ') self.f.write('<PAPER format="1" ')
elif self.paper.name == "A5": elif paper_name == "A5":
self.f.write('<PAPER format="2" ') self.f.write('<PAPER format="2" ')
elif self.paper.name == "Letter": elif paper_name == "Letter":
self.f.write('<PAPER format="3" ') self.f.write('<PAPER format="3" ')
elif self.paper.name == "Legal": elif paper_name == "Legal":
self.f.write('<PAPER format="4" ') self.f.write('<PAPER format="4" ')
elif self.paper.name == "B5": elif paper_name == "B5":
self.f.write('<PAPER format="7" ') self.f.write('<PAPER format="7" ')
else: else:
self.f.write('<PAPER format="6" ') self.f.write('<PAPER format="6" ')
self.f.write('width="%d" ' % points(self.width)) self.f.write('width="%d" ' % points(self.paper.get_size().get_width()))
self.f.write('height="%d" ' % points(self.height)) self.f.write('height="%d" ' % points(self.paper.get_size().get_height()))
if self.orientation == BaseDoc.PAPER_PORTRAIT: if self.paper.get_orientation() == BaseDoc.PAPER_PORTRAIT:
self.f.write('orientation="0" ') self.f.write('orientation="0" ')
else: else:
self.f.write('orientation="1" ') self.f.write('orientation="1" ')
@ -126,10 +127,10 @@ class KwordDoc(BaseDoc.BaseDoc):
self.f.write('spHeadBody="9" ') self.f.write('spHeadBody="9" ')
self.f.write('spFootBody="9">\n') self.f.write('spFootBody="9">\n')
self.f.write('<PAPERBORDERS ') self.f.write('<PAPERBORDERS ')
self.f.write('top="%d" ' % points(self.tmargin)) self.f.write('top="%d" ' % points(self.paper.get_top_margin()))
self.f.write('right="%d" ' % points(self.rmargin)) self.f.write('right="%d" ' % points(self.paper.get_right_margin()))
self.f.write('bottom="%d" ' % points(self.bmargin)) self.f.write('bottom="%d" ' % points(self.paper.get_bottom_margin()))
self.f.write('left="%d"/>' % points(self.lmargin)) self.f.write('left="%d"/>' % points(self.paper.get_left_margin()))
self.f.write('</PAPER>\n') self.f.write('</PAPER>\n')
self.f.write('<ATTRIBUTES processing="0" ') self.f.write('<ATTRIBUTES processing="0" ')
self.f.write('standardpage="1" ') self.f.write('standardpage="1" ')
@ -141,10 +142,10 @@ class KwordDoc(BaseDoc.BaseDoc):
self.f.write('<FRAMESET frameType="1" ') self.f.write('<FRAMESET frameType="1" ')
self.f.write('frameInfo="0" ') self.f.write('frameInfo="0" ')
self.f.write('name="Frameset 1">\n') self.f.write('name="Frameset 1">\n')
self.f.write('<FRAME left="%d" ' % points(self.lmargin)) self.f.write('<FRAME left="%d" ' % points(self.paper.get_left_margin()))
self.f.write('top="%d" ' % points(self.tmargin)) self.f.write('top="%d" ' % points(self.paper.get_top_margin()))
self.f.write('right="%d" ' % points(self.width-self.rmargin)) self.f.write('right="%d" ' % points(self.paper.get_size().get_width()-self.paper.get_right_margin()))
self.f.write('bottom="%d" ' % points(self.height-self.bmargin)) self.f.write('bottom="%d" ' % points(self.paper.get_size().get_height()-self.paper.get_bottom_margin()))
self.f.write('runaround="1" />\n') self.f.write('runaround="1" />\n')
self.cell_row= 0 self.cell_row= 0
@ -402,8 +403,8 @@ class KwordDoc(BaseDoc.BaseDoc):
def start_table(self,name,style_name): def start_table(self,name,style_name):
self.tbl= self.table_styles[style_name] self.tbl= self.table_styles[style_name]
self.cell_left= (self.lmargin * 72)/ 2.54 self.cell_left= (self.paper.get_left_margin() * 72)/ 2.54
self.tbl_width= ((self.width - self.lmargin - self.rmargin) * 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: if self.frameset_flg == 1:
self.f.write(' </FRAMESET> \n') self.f.write(' </FRAMESET> \n')
self.cell_row= 0 self.cell_row= 0
@ -419,7 +420,7 @@ class KwordDoc(BaseDoc.BaseDoc):
def end_row(self): def end_row(self):
self.cell_row= self.cell_row + 1 self.cell_row= self.cell_row + 1
self.cell_col= 0 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): def start_cell(self,style_name,span=1):
self.cell_span= span self.cell_span= span

View File

@ -152,21 +152,22 @@ class LaTeXDoc(BaseDoc.BaseDoc):
options = "12pt" options = "12pt"
if self.orientation == BaseDoc.PAPER_LANDSCAPE: if self.paper.get_orientation() == BaseDoc.PAPER_LANDSCAPE:
options = options + ",landscape" options = options + ",landscape"
# Paper selections are somewhat limited on a stock installation. # Paper selections are somewhat limited on a stock installation.
# If the user picks something not listed here, we'll just accept # If the user picks something not listed here, we'll just accept
# the default of the user's LaTeX installation (usually letter). # 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" options = options + ",a4paper"
elif self.paper.name == "A5": elif paper_name == "A5":
options = options + ",a5paper" options = options + ",a5paper"
elif self.paper.name == "B5": elif paper_name == "B5":
options = options + ",b4paper" options = options + ",b4paper"
elif self.paper.name == "Legal": elif paper_name == "Legal":
options = options + ",legalpaper" options = options + ",legalpaper"
elif self.paper.name == "Letter": elif paper_name == "Letter":
options = options + ",letterpaper" options = options + ",letterpaper"
# Use the article template, T1 font encodings, and specify # Use the article template, T1 font encodings, and specify

View File

@ -73,8 +73,8 @@ _esc_map = {
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ODFDoc(BaseDoc.BaseDoc): class ODFDoc(BaseDoc.BaseDoc):
def __init__(self,styles,type,template,orientation=BaseDoc.PAPER_PORTRAIT): def __init__(self,styles,type,template):
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation) BaseDoc.BaseDoc.__init__(self,styles,type,template)
self.cntnt = None self.cntnt = None
self.filename = None self.filename = None
self.level = 0 self.level = 0
@ -745,17 +745,17 @@ class ODFDoc(BaseDoc.BaseDoc):
self.sfile.write('style:justify-single-word="false"/>') self.sfile.write('style:justify-single-word="false"/>')
self.sfile.write('</style:style>\n') self.sfile.write('</style:style>\n')
self.sfile.write('<style:page-layout style:name="pm1">\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('<style:page-layout-properties fo:page-width="%.2fcm" ' % self.paper.get_size().get_width())
self.sfile.write('fo:page-height="%.2fcm" ' % self.height) self.sfile.write('fo:page-height="%.2fcm" ' % self.paper.get_size().get_height())
self.sfile.write('style:num-format="1" ') 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" ') self.sfile.write('style:print-orientation="portrait" ')
else: else:
self.sfile.write('style:print-orientation="landscape" ') self.sfile.write('style:print-orientation="landscape" ')
self.sfile.write('fo:margin-top="%.2fcm" ' % self.tmargin) self.sfile.write('fo:margin-top="%.2fcm" ' % self.paper.get_top_margin())
self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.bmargin) self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.paper.get_bottom_margin())
self.sfile.write('fo:margin-left="%.2fcm" ' % self.lmargin) self.sfile.write('fo:margin-left="%.2fcm" ' % self.paper.get_left_margin())
self.sfile.write('fo:margin-right="%.2fcm" ' % self.rmargin) self.sfile.write('fo:margin-right="%.2fcm" ' % self.paper.get_right_margin())
self.sfile.write('style:writing-mode="lr-tb" ') self.sfile.write('style:writing-mode="lr-tb" ')
self.sfile.write('style:footnote-max-height="0cm">\n') self.sfile.write('style:footnote-max-height="0cm">\n')
self.sfile.write('<style:footnote-sep style:width="0.018cm" ') self.sfile.write('<style:footnote-sep style:width="0.018cm" ')

View File

@ -70,8 +70,8 @@ _esc_map = {
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class OpenOfficeDoc(BaseDoc.BaseDoc): class OpenOfficeDoc(BaseDoc.BaseDoc):
def __init__(self,styles,type,template,orientation=BaseDoc.PAPER_PORTRAIT): def __init__(self,styles,type,template):
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation) BaseDoc.BaseDoc.__init__(self,styles,type,template)
self.cntnt = None self.cntnt = None
self.filename = None self.filename = None
self.level = 0 self.level = 0
@ -638,17 +638,17 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
self.sfile.write('</office:styles>\n') self.sfile.write('</office:styles>\n')
self.sfile.write('<office:automatic-styles>\n') self.sfile.write('<office:automatic-styles>\n')
self.sfile.write('<style:page-master style:name="pm1">\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('<style:properties fo:page-width="%.3fcm" ' % self.paper.get_size().get_width())
self.sfile.write('fo:page-height="%.3fcm" ' % self.height) self.sfile.write('fo:page-height="%.3fcm" ' % self.paper.get_size().get_height())
self.sfile.write('style:num-format="1" ') 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" ') self.sfile.write('style:print-orientation="portrait" ')
else: else:
self.sfile.write('style:print-orientation="landscape" ') self.sfile.write('style:print-orientation="landscape" ')
self.sfile.write('fo:margin-top="%.2fcm" ' % self.tmargin) self.sfile.write('fo:margin-top="%.2fcm" ' % self.paper.get_top_margin())
self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.bmargin) self.sfile.write('fo:margin-bottom="%.2fcm" ' % self.paper.get_bottom_margin())
self.sfile.write('fo:margin-left="%.2fcm" ' % self.lmargin) self.sfile.write('fo:margin-left="%.2fcm" ' % self.paper.get_left_margin())
self.sfile.write('fo:margin-right="%.2fcm" ' % self.rmargin) 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-max-height="0cm">\n')
self.sfile.write('<style:footnote-sep style:width="0.018cm" ') self.sfile.write('<style:footnote-sep style:width="0.018cm" ')
self.sfile.write('style:distance-before-sep="0.101cm" ') self.sfile.write('style:distance-before-sep="0.101cm" ')

View File

@ -70,8 +70,8 @@ if print_label == None:
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class PSDrawDoc(BaseDoc.BaseDoc): class PSDrawDoc(BaseDoc.BaseDoc):
def __init__(self,styles,type,template,orientation): def __init__(self,styles,type,template):
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation) BaseDoc.BaseDoc.__init__(self,styles,type,template)
self.f = None self.f = None
self.filename = None self.filename = None
self.level = 0 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()) return "%s find-latin-font %d scalefont setfont\n" % (font_name,font.get_size())
def translate(self,x,y): def translate(self,x,y):
return (x,self.height-y) return (x,self.paper.get_size().get_height()-y)
def open(self,filename): def open(self,filename):
if filename[-3:] != ".ps": if filename[-3:] != ".ps":
@ -125,7 +125,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('%%LanguageLevel: 2\n') self.f.write('%%LanguageLevel: 2\n')
self.f.write('%%Pages: (atend)\n') self.f.write('%%Pages: (atend)\n')
self.f.write('%%PageOrder: Ascend\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') self.f.write('%%Orientation: Landscape\n')
else: else:
self.f.write('%%Orientation: Portrait\n') self.f.write('%%Orientation: Portrait\n')
@ -169,9 +169,9 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.page = self.page + 1 self.page = self.page + 1
self.f.write("%%Page:") self.f.write("%%Page:")
self.f.write("%d %d\n" % (self.page,self.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' % ( 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): def end_page(self):
self.f.write('showpage\n') self.f.write('showpage\n')
@ -195,8 +195,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
pname = stype.get_paragraph_style() pname = stype.get_paragraph_style()
p = self.style_list[pname] p = self.style_list[pname]
x += self.lmargin x += self.paper.get_left_margin()
y = y + self.tmargin + ReportUtils.pt2cm(p.get_font().get_size()) y = y + self.paper.get_top_margin() + ReportUtils.pt2cm(p.get_font().get_size())
(text,fdef) = self.encode_text(p,text) (text,fdef) = self.encode_text(p,text)
@ -213,8 +213,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
para_name = stype.get_paragraph_style() para_name = stype.get_paragraph_style()
p = self.style_list[para_name] p = self.style_list[para_name]
x1 = x1 + self.lmargin x1 = x1 + self.paper.get_left_margin()
y1 = y1 + self.tmargin + ReportUtils.pt2cm(p.get_font().get_size()) y1 = y1 + self.paper.get_top_margin() + ReportUtils.pt2cm(p.get_font().get_size())
(text,fdef) = self.encode_text(p,text) (text,fdef) = self.encode_text(p,text)
@ -225,8 +225,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
def rotate_text(self,style,text,x,y,angle): def rotate_text(self,style,text,x,y,angle):
x += self.lmargin x += self.paper.get_left_margin()
y += self.tmargin y += self.paper.get_top_margin()
stype = self.draw_styles[style] stype = self.draw_styles[style]
pname = stype.get_paragraph_style() pname = stype.get_paragraph_style()
@ -268,13 +268,13 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('[2 4] 0 setdash\n') self.f.write('[2 4] 0 setdash\n')
point = path[0] point = path[0]
x1 = point[0]+self.lmargin x1 = point[0]+self.paper.get_left_margin()
y1 = point[1]+self.tmargin y1 = point[1]+self.paper.get_top_margin()
self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x1,y1))) self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x1,y1)))
for point in path[1:]: for point in path[1:]:
x1 = point[0]+self.lmargin x1 = point[0]+self.paper.get_left_margin()
y1 = point[1]+self.tmargin 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('%s cm %s cm lineto\n' % coords(self.translate(x1,y1)))
self.f.write('closepath\n') self.f.write('closepath\n')
@ -284,10 +284,10 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('grestore\n') self.f.write('grestore\n')
def draw_line(self,style,x1,y1,x2,y2): def draw_line(self,style,x1,y1,x2,y2):
x1 = x1 + self.lmargin x1 = x1 + self.paper.get_left_margin()
x2 = x2 + self.lmargin x2 = x2 + self.paper.get_left_margin()
y1 = y1 + self.tmargin y1 = y1 + self.paper.get_top_margin()
y2 = y2 + self.tmargin y2 = y2 + self.paper.get_top_margin()
stype = self.draw_styles[style] stype = self.draw_styles[style]
self.f.write('gsave newpath\n') self.f.write('gsave newpath\n')
self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x1,y1))) 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') self.f.write('grestore\n')
def draw_bar(self,style,x1,y1,x2,y2): def draw_bar(self,style,x1,y1,x2,y2):
x1 = x1 + self.lmargin x1 = x1 + self.paper.get_left_margin()
x2 = x2 + self.lmargin x2 = x2 + self.paper.get_left_margin()
y1 = y1 + self.tmargin y1 = y1 + self.paper.get_top_margin()
y2 = y2 + self.tmargin y2 = y2 + self.paper.get_top_margin()
box_type = self.draw_styles[style] box_type = self.draw_styles[style]
fill_color = box_type.get_fill_color() fill_color = box_type.get_fill_color()
@ -325,8 +325,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('grestore\n') self.f.write('grestore\n')
def draw_box(self,style,text,x,y): def draw_box(self,style,text,x,y):
x = x + self.lmargin x = x + self.paper.get_left_margin()
y = y + self.tmargin y = y + self.paper.get_top_margin()
box_style = self.draw_styles[style] box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style() para_name = box_style.get_paragraph_style()

View File

@ -126,19 +126,21 @@ class PdfDoc(BaseDoc.BaseDoc):
else: else:
self.filename = filename 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, self.doc = GrampsDocTemplate(self.filename,
pagesize=self.pagesize, pagesize=self.pagesize,
allowSplitting=1, allowSplitting=1,
_pageBreakQuick=0, _pageBreakQuick=0,
leftMargin=self.lmargin*cm, leftMargin=self.paper.get_left_margin()*cm,
rightMargin=self.rmargin*cm, rightMargin=self.paper.get_right_margin()*cm,
topMargin=self.tmargin*cm, topMargin=self.paper.get_top_margin()*cm,
bottomMargin=self.bmargin*cm) bottomMargin=self.paper.get_bottom_margin()*cm)
frameT = Frame(0,0,self.width*cm,self.height*cm, frameT = Frame(0,0,page_w,page_h,
self.lmargin*cm, self.bmargin*cm, self.paper.get_left_margin()*cm, self.paper.get_bottom_margin()*cm,
self.rmargin*cm,self.tmargin*cm, self.paper.get_right_margin()*cm,self.paper.get_top_margin()*cm,
id='normal') id='normal')
ptemp = PageTemplate(frames=frameT,pagesize=self.pagesize) ptemp = PageTemplate(frames=frameT,pagesize=self.pagesize)
self.doc.addPageTemplates([ptemp]) self.doc.addPageTemplates([ptemp])

View File

@ -107,12 +107,12 @@ class RTFDoc(BaseDoc.BaseDoc):
index = index + 1 index = index + 1
self.f.write('}\n') self.f.write('}\n')
self.f.write('\\kerning0\\cf0\\viewkind1') self.f.write('\\kerning0\\cf0\\viewkind1')
self.f.write('\\paperw%d' % twips(self.width)) self.f.write('\\paperw%d' % twips(self.paper.get_size().get_width()))
self.f.write('\\paperh%d' % twips(self.height)) self.f.write('\\paperh%d' % twips(self.paper.get_size().get_height()))
self.f.write('\\margl%d' % twips(self.lmargin)) self.f.write('\\margl%d' % twips(self.paper.get_left_margin()))
self.f.write('\\margr%d' % twips(self.rmargin)) self.f.write('\\margr%d' % twips(self.paper.get_right_margin()))
self.f.write('\\margt%d' % twips(self.tmargin)) self.f.write('\\margt%d' % twips(self.paper.get_top_margin()))
self.f.write('\\margb%d' % twips(self.bmargin)) self.f.write('\\margb%d' % twips(self.paper.get_bottom_margin()))
self.f.write('\\widowctl\n') self.f.write('\\widowctl\n')
self.in_table = 0 self.in_table = 0
self.text = "" self.text = ""

View File

@ -43,8 +43,8 @@ import Errors
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class SvgDrawDoc(BaseDoc.BaseDoc): class SvgDrawDoc(BaseDoc.BaseDoc):
def __init__(self,styles,type,template,orientation): def __init__(self,styles,type,template):
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation) BaseDoc.BaseDoc.__init__(self,styles,type,template)
self.f = None self.f = None
self.filename = None self.filename = None
self.level = 0 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('<?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('<!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('"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') self.f.write('xmlns="http://www.w3.org/2000/svg">\n')
def rotate_text(self,style,text,x,y,angle): 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)) width = max(width,self.string_width(font,line))
# rangle = -((pi/180.0) * angle) # 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 yh = 0
for line in text: for line in text:
@ -130,10 +130,10 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
self.f.close() self.f.close()
def draw_line(self,style,x1,y1,x2,y2): def draw_line(self,style,x1,y1,x2,y2):
x1 = x1 + self.lmargin x1 = x1 + self.paper.get_left_margin()
x2 = x2 + self.lmargin x2 = x2 + self.paper.get_left_margin()
y1 = y1 + self.tmargin y1 = y1 + self.paper.get_top_margin()
y2 = y2 + self.tmargin y2 = y2 + self.paper.get_top_margin()
s = self.draw_styles[style] 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('<polygon fill="#%02x%02x%02x"' % stype.get_fill_color())
self.f.write(' style="stroke:#%02x%02x%02x; ' % stype.get_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(' 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:]: 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') self.f.write('"/>\n')
def draw_bar(self,style,x1,y1,x2,y2): def draw_bar(self,style,x1,y1,x2,y2):
x1 = x1 + self.lmargin x1 = x1 + self.paper.get_left_margin()
x2 = x2 + self.lmargin x2 = x2 + self.paper.get_left_margin()
y1 = y1 + self.tmargin y1 = y1 + self.paper.get_top_margin()
y2 = y2 + self.tmargin y2 = y2 + self.paper.get_top_margin()
s = self.draw_styles[style] s = self.draw_styles[style]
self.f.write('<rect ') self.f.write('<rect ')
@ -171,8 +171,8 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
self.f.write('stroke-width:%.2f;"/>\n' % s.get_line_width()) 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):
x = x + self.lmargin x = x + self.paper.get_left_margin()
y = y + self.tmargin y = y + self.paper.get_top_margin()
box_style = self.draw_styles[style] box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style() para_name = box_style.get_paragraph_style()
@ -224,8 +224,8 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
self.f.write('</text>\n') self.f.write('</text>\n')
def draw_text(self,style,text,x,y): def draw_text(self,style,text,x,y):
x = x + self.lmargin x = x + self.paper.get_left_margin()
y = y + self.tmargin y = y + self.paper.get_top_margin()
box_style = self.draw_styles[style] box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style() para_name = box_style.get_paragraph_style()

View File

@ -1053,8 +1053,9 @@ class BookReportDialog(ReportDialog):
def make_document(self): def make_document(self):
"""Create a document of the type requested by the user.""" """Create a document of the type requested by the user."""
self.doc = self.format(self.selected_style,self.paper, self.doc = self.format(self.selected_style,
self.template_name,self.orien) BaseDoc.PaperStyle(self.paper,self.orien),
self.template_name)
self.rptlist = [] self.rptlist = []
newpage = 0 newpage = 0