From 9719ea83ee9df74c3c9552997078ca31d3f4c0d3 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 13 Sep 2003 04:56:04 +0000 Subject: [PATCH] * src/BaseDoc.py: add init function to BaseDoc to be called after all graphics formats are defined * src/docgen/OpenOfficeDoc.py: fix rotate_print and center_print * src/plugins/AncestorChart.py: support BaseDoc.init * src/plugins/AncestorReport.py: support BaseDoc.init * src/plugins/BookReport.py: support BaseDoc.init * src/plugins/CustomBookText.py: support BaseDoc.init * src/plugins/DesGraph.py: support BaseDoc.init * src/plugins/DescendReport.py: support BaseDoc.init * src/plugins/DetAncestralReport.py: support BaseDoc.init * src/plugins/DetDescendantReport.py: support BaseDoc.init * src/plugins/FamilyGroup.py: support BaseDoc.init * src/plugins/FanChart.py: support BaseDoc.init * src/plugins/FtmStyleAncestors.py: support BaseDoc.init * src/plugins/FtmStyleDescendants.py: support BaseDoc.init * src/plugins/SimpleBookTitle.py: support BaseDoc.init svn: r2119 --- gramps2/src/BaseDoc.py | 3 + gramps2/src/docgen/OpenOfficeDoc.py | 101 +++++++++++++++++++-- gramps2/src/plugins/AncestorChart.py | 2 + gramps2/src/plugins/AncestorReport.py | 1 + gramps2/src/plugins/BookReport.py | 1 + gramps2/src/plugins/CustomBookText.py | 1 + gramps2/src/plugins/DesGraph.py | 2 + gramps2/src/plugins/DescendReport.py | 1 + gramps2/src/plugins/DetAncestralReport.py | 1 + gramps2/src/plugins/DetDescendantReport.py | 1 + gramps2/src/plugins/FamilyGroup.py | 1 + gramps2/src/plugins/FanChart.py | 3 + gramps2/src/plugins/FtmStyleAncestors.py | 1 + gramps2/src/plugins/FtmStyleDescendants.py | 1 + gramps2/src/plugins/SimpleBookTitle.py | 1 + 15 files changed, 111 insertions(+), 10 deletions(-) diff --git a/gramps2/src/BaseDoc.py b/gramps2/src/BaseDoc.py index 17fe23dca..70ed2bf25 100644 --- a/gramps2/src/BaseDoc.py +++ b/gramps2/src/BaseDoc.py @@ -1091,6 +1091,9 @@ class BaseDoc: self.print_req = 0 self.mode = TEXT_MODE + def init(self): + pass + def set_mode(self, mode): self.mode = mode diff --git a/gramps2/src/docgen/OpenOfficeDoc.py b/gramps2/src/docgen/OpenOfficeDoc.py index 43555af7a..e6006a5de 100644 --- a/gramps2/src/docgen/OpenOfficeDoc.py +++ b/gramps2/src/docgen/OpenOfficeDoc.py @@ -91,6 +91,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): except: raise Errors.ReportError("Could not create %s" % self.content_xml) + + def init(self): self.f.write('\n') self.f.write('\n' % style_name) self.f.write('\n') self.f.write('\n') + + self.f.write('\n') + self.f.write(' 0: + self.f.write('fo:keep-with-next="true" ') + + align = style.get_alignment() + if align == BaseDoc.PARA_ALIGN_LEFT: + self.f.write('fo:text-align="start" ') + elif align == BaseDoc.PARA_ALIGN_RIGHT: + self.f.write('fo:text-align="end" ') + elif align == BaseDoc.PARA_ALIGN_CENTER: + self.f.write('fo:text-align="center" ') + self.f.write('style:justify-single-word="false" ') + else: + self.f.write('fo:text-align="justify" ') + self.f.write('style:justify-single-word="false" ') + font = style.get_font() + if font.get_type_face() == BaseDoc.FONT_SANS_SERIF: + self.f.write('style:font-name="Arial" ') + else: + self.f.write('style:font-name="Times New Roman" ') + self.f.write('fo:font-size="' + str(font.get_size()) + 'pt" ') + color = font.get_color() + self.f.write('fo:color="#%02x%02x%02x" ' % color) + if font.get_bold(): + self.f.write('fo:font-weight="bold" ') + if font.get_italic(): + self.f.write('fo:font-style="italic" ') + if font.get_underline(): + self.f.write('style:text-underline="single" ') + self.f.write('style:text-underline-color="font-color" ') + self.f.write('fo:text-indent="%.2fcm" ' % style.get_first_indent()) + self.f.write('fo:margin-right="%.2fcm" ' % style.get_right_margin()) + self.f.write('fo:margin-left="%.2fcm" ' % style.get_left_margin()) + self.f.write('fo:margin-top="0cm" ') + self.f.write('fo:margin-bottom="0.212cm"') + self.f.write('/>\n') + self.f.write('\n') + self.f.write('\n') self.f.write('' % font.get_size()) self.f.write('\n') - + for style_name in self.table_styles.keys(): style = self.table_styles[style_name] self.f.write('\n') + self.f.write('') if pos == "left": self.f.write('') + self.f.write('\n') def end_page(self): - self.f.write('') + self.f.write('\n') def start_paragraph(self,style_name,leader=None): style = self.style_list[style_name] @@ -593,10 +648,10 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): else: self.f.write('') + self.f.write('" text:level="' + str(self.level) + '">\n') if leader != None: self.f.write(leader) - self.f.write('') + self.f.write('\n') self.new_cell = 0 def end_paragraph(self): @@ -709,6 +764,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): size = font.get_size() height = size*(len(text)) + oneline = (size/72.0)*2.54 width = 0 for line in text: width = max(width,FontScale.string_width(font,line)) @@ -722,12 +778,14 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.f.write('svg:height="%.3fpt" ' % hcm) self.f.write('draw:transform="rotate (%.8f) ' % rangle) xloc = x-((wcm/2.0)*cos(-rangle)) - yloc = y-((hcm)*sin(-rangle)) + yloc = y-((hcm)*sin(-rangle))-(hcm/2.0) self.f.write('translate (%.3fcm %.3fcm)"' % (xloc,yloc)) self.f.write('>') - self.f.write('' % pname) + self.f.write('' % pname) + + self.f.write('\n' % pname) self.write_text(string.join(text,'\n')) - self.f.write('\n') + self.f.write('\n\n\n') def draw_path(self,style,path): stype = self.draw_styles[style] @@ -842,6 +900,29 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.f.write('\n') self.f.write('\n') + def center_text(self,style,text,x,y): + box_style = self.draw_styles[style] + para_name = box_style.get_paragraph_style() + pstyle = self.style_list[para_name] + font = pstyle.get_font() + + size = (FontScale.string_width(font,text)/72.0) * 2.54 + + self.f.write('\n' % float(y)) + + if text != "": + self.f.write('' % para_name) + self.f.write(text) + self.f.write('\n') + self.f.write('\n') + #-------------------------------------------------------------------------- # # Register plugins diff --git a/gramps2/src/plugins/AncestorChart.py b/gramps2/src/plugins/AncestorChart.py index 94b2e9fb2..ffcfea089 100644 --- a/gramps2/src/plugins/AncestorChart.py +++ b/gramps2/src/plugins/AncestorChart.py @@ -172,6 +172,8 @@ class AncestorChart: g = BaseDoc.GraphicsStyle() self.doc.add_draw_style("line",g) + if self.standalone: + self.doc.init() def get_numbers(self,start,index,vals): if index > 4: diff --git a/gramps2/src/plugins/AncestorReport.py b/gramps2/src/plugins/AncestorReport.py index f22b9eefb..7e56c1c13 100644 --- a/gramps2/src/plugins/AncestorReport.py +++ b/gramps2/src/plugins/AncestorReport.py @@ -58,6 +58,7 @@ class AncestorReport(Report.Report): if output: self.standalone = 1 self.doc.open(output) + self.doc.init() else: self.standalone = 0 diff --git a/gramps2/src/plugins/BookReport.py b/gramps2/src/plugins/BookReport.py index 2134eaf3c..714cef80f 100644 --- a/gramps2/src/plugins/BookReport.py +++ b/gramps2/src/plugins/BookReport.py @@ -970,6 +970,7 @@ class BookReportDialog(Report.ReportDialog): """The actual book report. Start it out, then go through the item list and call each item's write_book_item method.""" + self.doc.init() for item in self.rptlist: item.write_report() self.doc.close() diff --git a/gramps2/src/plugins/CustomBookText.py b/gramps2/src/plugins/CustomBookText.py index 64a812a7e..6e17eed57 100644 --- a/gramps2/src/plugins/CustomBookText.py +++ b/gramps2/src/plugins/CustomBookText.py @@ -66,6 +66,7 @@ class CustomText(Report.Report): if output: self.standalone = 1 self.doc.open(output) + self.doc.init() else: self.standalone = 0 self.sref_map = {} diff --git a/gramps2/src/plugins/DesGraph.py b/gramps2/src/plugins/DesGraph.py index 05ef41271..e9362b746 100644 --- a/gramps2/src/plugins/DesGraph.py +++ b/gramps2/src/plugins/DesGraph.py @@ -241,6 +241,8 @@ class DescendantReport: g = BaseDoc.GraphicsStyle() self.doc.add_draw_style("line",g) + if self.standalone: + self.doc.init() def print_page(self, plist,elist,r,c): self.doc.start_page() diff --git a/gramps2/src/plugins/DescendReport.py b/gramps2/src/plugins/DescendReport.py index 223cb3513..3b1e5cdcf 100644 --- a/gramps2/src/plugins/DescendReport.py +++ b/gramps2/src/plugins/DescendReport.py @@ -69,6 +69,7 @@ class DescendantReport: if output: self.standalone = 1 self.doc.open(output) + self.doc.init() else: self.standalone = 0 diff --git a/gramps2/src/plugins/DetAncestralReport.py b/gramps2/src/plugins/DetAncestralReport.py index bad834a2a..20be1d278 100644 --- a/gramps2/src/plugins/DetAncestralReport.py +++ b/gramps2/src/plugins/DetAncestralReport.py @@ -63,6 +63,7 @@ class DetAncestorReport(Report.Report): self.standalone = 1 try: self.doc.open(output) + self.doc.init() except IOError,msg: ErrorDialog(_("Could not open %s") % output + "\n" + msg) else: diff --git a/gramps2/src/plugins/DetDescendantReport.py b/gramps2/src/plugins/DetDescendantReport.py index f9199ac22..c8a671436 100644 --- a/gramps2/src/plugins/DetDescendantReport.py +++ b/gramps2/src/plugins/DetDescendantReport.py @@ -64,6 +64,7 @@ class DetDescendantReport(Report.Report): self.standalone = 1 try: self.doc.open(output) + self.doc.init() except IOError,msg: ErrorDialog(_("Could not open %s") % output + "\n" + msg) else: diff --git a/gramps2/src/plugins/FamilyGroup.py b/gramps2/src/plugins/FamilyGroup.py index 4058bacc3..153952ff3 100644 --- a/gramps2/src/plugins/FamilyGroup.py +++ b/gramps2/src/plugins/FamilyGroup.py @@ -57,6 +57,7 @@ class FamilyGroup: if output: self.standalone = 1 self.doc.open(output) + self.doc.init() else: self.standalone = 0 diff --git a/gramps2/src/plugins/FanChart.py b/gramps2/src/plugins/FanChart.py index 7b00912d5..db5b0e1db 100644 --- a/gramps2/src/plugins/FanChart.py +++ b/gramps2/src/plugins/FanChart.py @@ -76,6 +76,7 @@ class FanChart: g = BaseDoc.GraphicsStyle() g.set_paragraph_style('FC-Title') + g.set_line_width(0) self.doc.add_draw_style("t",g) g = BaseDoc.GraphicsStyle() @@ -136,6 +137,8 @@ class FanChart: self.map = [None] * 32 self.text= {} self.box_width = 0 + if self.standalone: + self.doc.init() def filter(self,person,index): """traverse the ancestors recursively until either the end diff --git a/gramps2/src/plugins/FtmStyleAncestors.py b/gramps2/src/plugins/FtmStyleAncestors.py index 66b46a382..a30c0bf99 100644 --- a/gramps2/src/plugins/FtmStyleAncestors.py +++ b/gramps2/src/plugins/FtmStyleAncestors.py @@ -57,6 +57,7 @@ class FtmAncestorReport(Report.Report): if output: self.standalone = 1 self.doc.open(output) + self.doc.init() else: self.standalone = 0 self.sref_map = {} diff --git a/gramps2/src/plugins/FtmStyleDescendants.py b/gramps2/src/plugins/FtmStyleDescendants.py index 9071e6c05..bfe935b1c 100644 --- a/gramps2/src/plugins/FtmStyleDescendants.py +++ b/gramps2/src/plugins/FtmStyleDescendants.py @@ -65,6 +65,7 @@ class FtmDescendantReport(Report.Report): if output: self.standalone = 1 self.doc.open(output) + self.doc.init() else: self.standalone = 0 self.sref_map = {} diff --git a/gramps2/src/plugins/SimpleBookTitle.py b/gramps2/src/plugins/SimpleBookTitle.py index 56ec79299..8a9b75efa 100644 --- a/gramps2/src/plugins/SimpleBookTitle.py +++ b/gramps2/src/plugins/SimpleBookTitle.py @@ -67,6 +67,7 @@ class SimpleBookTitle(Report.Report): if output: self.standalone = 1 self.doc.open(output) + self.doc.init() else: self.standalone = 0 self.sref_map = {}