diff --git a/src/BaseDoc.py b/src/BaseDoc.py index 9ce7ca0e5..f388bb5f8 100644 --- a/src/BaseDoc.py +++ b/src/BaseDoc.py @@ -63,7 +63,14 @@ __version__ = "Revision:$" # #------------------------------------------------------------------------- import os -#import Utils +from math import pi, cos, sin + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +import Utils #------------------------------------------------------------------------- # @@ -1086,6 +1093,12 @@ class BaseDoc: def set_mode(self, mode): self.mode = mode + + def start_page(self): + pass + + def end_page(self): + pass def print_requested (self): self.print_req = 1 @@ -1124,6 +1137,18 @@ class BaseDoc: """ 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 + def creator(self,name): "Returns the owner name" self.name = name @@ -1173,7 +1198,7 @@ class BaseDoc: "Forces a line break within a paragraph" pass - def page_break(self, mode=-1): + def page_break(self): "Forces a page break, creating a new page" pass diff --git a/src/docgen/OpenOfficeDoc.py b/src/docgen/OpenOfficeDoc.py index d45c7ea75..9d6620d0f 100644 --- a/src/docgen/OpenOfficeDoc.py +++ b/src/docgen/OpenOfficeDoc.py @@ -28,6 +28,7 @@ import tempfile import string import zipfile import time +from math import pi, cos, sin #------------------------------------------------------------------------- # @@ -39,6 +40,7 @@ import BaseDoc import const import Plugins import ImgManip +import FontScale #------------------------------------------------------------------------- # @@ -67,10 +69,6 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): def set_mode(self, mode): self.mode = mode - if self.first_page == 0: - self.page_break(mode) - else: - self.first_page = 0 def open(self,filename): t = time.localtime(time.time()) @@ -89,10 +87,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.f = open(self.content_xml,"wb") except IOError,msg: errmsg = "%s\n%s" % (_("Could not create %s") % self.content_xml, msg) - pass raise Errors.ReportError(errmsg) except: - pass raise Errors.ReportError("Could not create %s" % self.content_xml) self.f.write('\n') @@ -133,16 +129,10 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): for style_name in self.draw_styles.keys(): style = self.draw_styles[style_name] - self.f.write('\n') + self.f.write('\n') self.f.write('\n') + self.f.write('\n') + + self.f.write('\n') + self.f.write('\n') self.f.write('\n') for style_name in self.style_list.keys(): style = self.style_list[style_name] - self.f.write('\n\n') + self.f.write('\n' % style_name) + self.f.write('"\n') self.f.write('\n') + self.f.write('\n') + self.f.write('') + self.f.write('\n') + for style_name in self.table_styles.keys(): style = self.table_styles[style_name] - self.f.write('\n') table_width = float(self.get_usable_width()) table_width_str = "%.4f" % table_width self.f.write('\n') + vself.f.write('/>\n') self.f.write('\n') for col in range(0,style.get_columns()): self.f.write('' % width_str) self.f.write('\n') + for cell in self.cell_styles.keys(): cell_style = self.cell_styles[cell] - self.f.write('\n') + self.f.write('\n') self.f.write('\n') @@ -559,17 +565,14 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.f.write('\n') self.f.close() - def page_break(self, graphics=-1): - if self.mode == BaseDoc.GRAPHICS_MODE: - self.f.write('\n') - if graphics != -1: - self.mode = graphics - - if self.mode == BaseDoc.GRAPHICS_MODE: - self.page = self.page + 1 - self.f.write('') - else: - self.new_page = 1 + def page_break(self): + self.new_page = 1 + + def start_page(self): + self.f.write('') + + def end_page(self): + self.f.write('') def start_paragraph(self,style_name,leader=None): style = self.style_list[style_name] @@ -712,8 +715,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.f.write('draw:layer="layout" svg:width="%.3fcm" ' % wcm) self.f.write('svg:height="%.3fpt" ' % hcm) self.f.write('draw:transform="rotate (%.8f) ' % rangle) - xloc = x-((wcm/2.0)*cos(-rangle)) + self.lmargin - yloc = y-((hcm)*sin(-rangle)) + self.tmargin + xloc = x-((wcm/2.0)*cos(-rangle)) + yloc = y-((hcm)*sin(-rangle)) self.f.write('translate (%.3fcm %.3fcm)"' % (xloc,yloc)) self.f.write('>') self.f.write('' % pname) @@ -735,8 +738,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): maxy = max(point[1],maxy) self.f.write('\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 box_style = self.draw_styles[style] self.f.write('\n' % (float(y)+0.2)) + self.f.write('\n') + + self.f.write('\n' % float(y)) if text != "": + self.f.write('' % para_name) + self.f.write('' % para_name) text = string.replace(text,'\t','') text = string.replace(text,'\n','') - self.f.write('>\n') - self.f.write('') - self.f.write('' % para_name) self.f.write(text) - self.f.write('\n') - self.f.write('\n') - else: - self.f.write('/>\n') + self.f.write('') + self.f.write('\n') + self.f.write('\n') -print_label = None -if os.access ("/usr/bin/oowriter", os.X_OK): - print_label = _("Open in OpenOffice.org") - #-------------------------------------------------------------------------- # # Register plugins # #-------------------------------------------------------------------------- +print_label = None +if os.access ("/usr/bin/oowriter", os.X_OK): + print_label = _("Open in OpenOffice.org") + Plugins.register_text_doc(_("OpenOffice.org Writer"),OpenOfficeDoc,1,1,1, ".sxw",print_label) Plugins.register_book_doc(_("OpenOffice.org Writer"),OpenOfficeDoc,1,1,1,".sxw") +print_label = None +if os.access ("/usr/bin/oodraw", os.X_OK): + print_label = _("Open in OpenOffice.org") + +Plugins.register_draw_doc(_("OpenOffice.org Draw"),OpenOfficeDoc,1,1,".sxd", + print_label);