# # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # import os import tempfile from TextDoc import * from latin_utf8 import latin_to_utf8 import const class AbiWordDoc(TextDoc): def __init__(self,type,orientation): TextDoc.__init__(self,type,orientation) self.f = None self.level = 0 def open(self,filename): if filename[-4:] != ".abw": self.filename = filename + ".abw" else: self.filename = filename self.f = open(filename,"w") self.f.write('\n') self.f.write('\n') self.f.write('\n') self.f.write('
\n') def close(self): self.f.write('
\n') self.f.write('
\n') self.f.close() def start_paragraph(self,style_name): style = self.style_list[style_name] self.f.write('

') font = style.get_font() self.f.write('') def end_paragraph(self): self.f.write('

\n') def write_text(self,text): self.f.write(text) if __name__ == "__main__": doc = AbiWordDoc(PAPER_US_LETTER,PAPER_PORTRAIT) foo = FontStyle() foo.set_type_face(FONT_SANS_SERIF) foo.set_color((255,0,0)) foo.set_size(24) para = ParagraphStyle() para.set_font(foo) para.set_alignment(PARA_ALIGN_RIGHT) doc.add_style("MyTitle",para) para = ParagraphStyle() para.set_left_margin(1) para.set_right_margin(1) para.set_alignment(PARA_ALIGN_JUSTIFY) doc.add_style("Normal",para) doc.open("/home/dona/oo_test.abw") doc.start_paragraph("MyTitle") doc.write_text("This is my Title") doc.end_paragraph() doc.start_paragraph("Normal") doc.write_text("This is a test of the emergency broadcast system. ") doc.write_text("This is a only a test. Repeat. This is only a test. ") doc.write_text("Had this been an actual emergency, we would not be here ") doc.write_text("to give you this message.") doc.end_paragraph() doc.close()