diff --git a/ChangeLog b/ChangeLog index ac87c14ab..c5f281b06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ -2003-12-11 Alex Roitman +2003-12-12 Alex Roitman * src/docgen/HtmlDoc.py (write_note): Set monospace font family for a preformatted note. + * src/docgen/LaTeXDoc.py (write_note): Implement function. + * src/docgen/PdfDoc.py (write_note): Implement function. + * src/docgen/RTFDoc.py (write_note): Implement function. + * src/docgen/AbiWordDoc.py (write_note): Implement function. + * src/docgen/AbiWord2Doc.py (write_note): Implement function. 2003-12-11 Don Allingham * src/plugins/WriteFtree.py (FtreeWriter.export): make sure that the diff --git a/src/docgen/AbiWord2Doc.py b/src/docgen/AbiWord2Doc.py index aaa71437f..2abe88d42 100644 --- a/src/docgen/AbiWord2Doc.py +++ b/src/docgen/AbiWord2Doc.py @@ -27,6 +27,7 @@ Provides a BaseDoc based interface to the AbiWord document format. # #------------------------------------------------------------------------- import base64 +import string import BaseDoc import Errors @@ -220,6 +221,20 @@ class AbiWordDoc(BaseDoc.BaseDoc): def end_paragraph(self): self.f.write('

\n') + def write_note(self,text,format,style_name): + if format == 1: + for line in text.split('\n'): + self.start_paragraph(style_name) + self.write_text(line) + self.end_paragraph() + elif format == 0: + for line in text.split('\n\n'): + self.start_paragraph(style_name) + line = line.replace('\n',' ') + line = string.join(string.split(line)) + self.write_text(line) + self.end_paragraph() + def write_text(self,text): text = text.replace('&','&'); # Must be first text = text.replace('<','<'); diff --git a/src/docgen/AbiWordDoc.py b/src/docgen/AbiWordDoc.py index d1bc15019..70826c291 100644 --- a/src/docgen/AbiWordDoc.py +++ b/src/docgen/AbiWordDoc.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000 Donald N. Allingham +# Copyright (C) 2000-2003 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 @@ -28,6 +28,7 @@ Provides a BaseDoc based interface to the AbiWord document format. #------------------------------------------------------------------------- import os import base64 +import string import BaseDoc from latin_utf8 import latin_to_utf8 @@ -234,6 +235,20 @@ class AbiWordDoc(BaseDoc.BaseDoc): else: self.f.write('

\n') + def write_note(self,text,format,style_name): + if format == 1: + for line in text.split('\n'): + self.start_paragraph(style_name) + self.write_text(line) + self.end_paragraph() + elif format == 0: + for line in text.split('\n\n'): + self.start_paragraph(style_name) + line = line.replace('\n',' ') + line = string.join(string.split(line)) + self.write_text(line) + self.end_paragraph() + def write_text(self,text): text = text.replace('&','&'); # Must be first text = text.replace('<','<'); diff --git a/src/docgen/LaTeXDoc.py b/src/docgen/LaTeXDoc.py index 1f165dd33..707643ff1 100644 --- a/src/docgen/LaTeXDoc.py +++ b/src/docgen/LaTeXDoc.py @@ -5,6 +5,9 @@ # # Modifications and feature additions: # 2002-2003 Donald A. Peterson +# +# Formatted notes addition: +# 2003 Alex Roitman # # 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 @@ -21,6 +24,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ """LaTeX document generator""" #------------------------------------------------------------------------ @@ -399,6 +403,16 @@ class LaTeXDoc(BaseDoc.BaseDoc): else: self.f.write('\\centerline{\\includegraphics[%s]{%s}}\n' % (mysize,picf)) + def write_note(self,text,format,style_name): + """Write the note's text to the file, respecting the format""" + self.start_paragraph(style_name) + if format == 1: + self.f.write('\\begin{verbatim}') + self.write_text(text) + if format == 1: + self.f.write('\\end{verbatim}') + self.end_paragraph() + def write_text(self,text): """Write the text to the file""" if text == '\n': diff --git a/src/docgen/PdfDoc.py b/src/docgen/PdfDoc.py index b6dd32813..2ccf89982 100644 --- a/src/docgen/PdfDoc.py +++ b/src/docgen/PdfDoc.py @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + #------------------------------------------------------------------------ # # gramps modules @@ -31,8 +33,12 @@ from gettext import gettext as _ _H = 'Helvetica' _HB = 'Helvetica-Bold' +_HO = 'Helvetica-Oblique' +_HBO = 'Helvetica-BoldOblique' _T = 'Times-Roman' _TB = 'Times-Bold' +_TI = 'Times-Italic' +_TBI = 'Times-BoldItalic' #------------------------------------------------------------------------ # @@ -113,23 +119,23 @@ class PdfDoc(BaseDoc.BaseDoc): if font.get_type_face() == BaseDoc.FONT_SERIF: if font.get_bold(): if font.get_italic(): - pdf_style.fontName = "Times-BoldItalic" + pdf_style.fontName = _TBI else: - pdf_style.fontName = "Times-Bold" + pdf_style.fontName = _TB else: if font.get_italic(): - pdf_style.fontName = _TB + pdf_style.fontName = _TI else: pdf_style.fontName = _T else: if font.get_bold(): if font.get_italic(): - pdf_style.fontName = "Helvetica-BoldOblique" + pdf_style.fontName = _HBO else: pdf_style.fontName = _HB else: if font.get_italic(): - pdf_style.fontName = "Helvetica-Oblique" + pdf_style.fontName = _TBI else: pdf_style.fontName = _H pdf_style.bulletFontName = pdf_style.fontName @@ -307,6 +313,28 @@ class PdfDoc(BaseDoc.BaseDoc): self.story.append(Spacer(1,0.5*cm)) self.image = 1 + def write_note(self,text,format,style_name): + current_para = self.pdfstyles[style_name] + self.my_para = self.style_list[style_name] + self.super = "" % (self.my_para.get_font().get_size()-2) + self.image = 0 + + text = text.replace('&','&') # Must be first + text = text.replace('<','<') + text = text.replace('>','>') + text = text.replace('<super>',self.super) + text = text.replace('</super>','') + + if self.in_table == 0: + if format == 1: + text = '%s' % text.replace('\t',' '*8) + self.story.append(XPreformatted(text,current_para)) + elif format == 0: + for line in text.split('\n\n'): + self.story.append(Paragraph(line,current_para)) + else: + self.image = 0 + def write_text(self,text): text = text.replace('&','&') # Must be first text = text.replace('<','<') diff --git a/src/docgen/RTFDoc.py b/src/docgen/RTFDoc.py index 6c29f058d..67bec7f79 100644 --- a/src/docgen/RTFDoc.py +++ b/src/docgen/RTFDoc.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000 Donald N. Allingham +# Copyright (C) 2000-2003 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 @@ -18,6 +18,15 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + +#------------------------------------------------------------------------ +# +# python modules +# +#------------------------------------------------------------------------ +import string + #------------------------------------------------------------------------ # # Load the base BaseDoc class @@ -355,6 +364,20 @@ class RTFDoc(BaseDoc.BaseDoc): index = index+1 self.f.write('}}\\par\n') + def write_note(self,text,format,style_name): + if format == 1: + for line in text.split('\n'): + self.start_paragraph(style_name) + self.write_text(line) + self.end_paragraph() + elif format == 0: + for line in text.split('\n\n'): + self.start_paragraph(style_name) + line = line.replace('\n',' ') + line = string.join(string.split(line)) + self.write_text(line) + self.end_paragraph() + #-------------------------------------------------------------------- # # Writes text. If braces are not currently open, open them. Loop