* 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.


svn: r2513
This commit is contained in:
Alex Roitman 2003-12-13 04:05:01 +00:00
parent e962ebe517
commit 570fd76a2f
6 changed files with 108 additions and 8 deletions

View File

@ -1,6 +1,11 @@
2003-12-11 Alex Roitman <shura@alex.neuro.umn.edu> 2003-12-12 Alex Roitman <shura@alex.neuro.umn.edu>
* src/docgen/HtmlDoc.py (write_note): Set monospace font family * src/docgen/HtmlDoc.py (write_note): Set monospace font family
for a preformatted note. 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 <dallingham@users.sourceforge.net> 2003-12-11 Don Allingham <dallingham@users.sourceforge.net>
* src/plugins/WriteFtree.py (FtreeWriter.export): make sure that the * src/plugins/WriteFtree.py (FtreeWriter.export): make sure that the

View File

@ -27,6 +27,7 @@ Provides a BaseDoc based interface to the AbiWord document format.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import base64 import base64
import string
import BaseDoc import BaseDoc
import Errors import Errors
@ -220,6 +221,20 @@ class AbiWordDoc(BaseDoc.BaseDoc):
def end_paragraph(self): def end_paragraph(self):
self.f.write('</p>\n') self.f.write('</p>\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): def write_text(self,text):
text = text.replace('&','&amp;'); # Must be first text = text.replace('&','&amp;'); # Must be first
text = text.replace('<','&lt;'); text = text.replace('<','&lt;');

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # 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 # 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 # 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 os
import base64 import base64
import string
import BaseDoc import BaseDoc
from latin_utf8 import latin_to_utf8 from latin_utf8 import latin_to_utf8
@ -234,6 +235,20 @@ class AbiWordDoc(BaseDoc.BaseDoc):
else: else:
self.f.write('</c></p>\n') self.f.write('</c></p>\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): def write_text(self,text):
text = text.replace('&','&amp;'); # Must be first text = text.replace('&','&amp;'); # Must be first
text = text.replace('<','&lt;'); text = text.replace('<','&lt;');

View File

@ -6,6 +6,9 @@
# Modifications and feature additions: # Modifications and feature additions:
# 2002-2003 Donald A. Peterson # 2002-2003 Donald A. Peterson
# #
# Formatted notes addition:
# 2003 Alex Roitman
#
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
@ -21,6 +24,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id$
"""LaTeX document generator""" """LaTeX document generator"""
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -399,6 +403,16 @@ class LaTeXDoc(BaseDoc.BaseDoc):
else: else:
self.f.write('\\centerline{\\includegraphics[%s]{%s}}\n' % (mysize,picf)) 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): def write_text(self,text):
"""Write the text to the file""" """Write the text to the file"""
if text == '\n': if text == '\n':

View File

@ -18,6 +18,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id$
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# gramps modules # gramps modules
@ -31,8 +33,12 @@ from gettext import gettext as _
_H = 'Helvetica' _H = 'Helvetica'
_HB = 'Helvetica-Bold' _HB = 'Helvetica-Bold'
_HO = 'Helvetica-Oblique'
_HBO = 'Helvetica-BoldOblique'
_T = 'Times-Roman' _T = 'Times-Roman'
_TB = 'Times-Bold' _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_type_face() == BaseDoc.FONT_SERIF:
if font.get_bold(): if font.get_bold():
if font.get_italic(): if font.get_italic():
pdf_style.fontName = "Times-BoldItalic" pdf_style.fontName = _TBI
else: else:
pdf_style.fontName = "Times-Bold" pdf_style.fontName = _TB
else: else:
if font.get_italic(): if font.get_italic():
pdf_style.fontName = _TB pdf_style.fontName = _TI
else: else:
pdf_style.fontName = _T pdf_style.fontName = _T
else: else:
if font.get_bold(): if font.get_bold():
if font.get_italic(): if font.get_italic():
pdf_style.fontName = "Helvetica-BoldOblique" pdf_style.fontName = _HBO
else: else:
pdf_style.fontName = _HB pdf_style.fontName = _HB
else: else:
if font.get_italic(): if font.get_italic():
pdf_style.fontName = "Helvetica-Oblique" pdf_style.fontName = _TBI
else: else:
pdf_style.fontName = _H pdf_style.fontName = _H
pdf_style.bulletFontName = pdf_style.fontName pdf_style.bulletFontName = pdf_style.fontName
@ -307,6 +313,28 @@ class PdfDoc(BaseDoc.BaseDoc):
self.story.append(Spacer(1,0.5*cm)) self.story.append(Spacer(1,0.5*cm))
self.image = 1 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 = "<font size=%d><super>" % (self.my_para.get_font().get_size()-2)
self.image = 0
text = text.replace('&','&amp;') # Must be first
text = text.replace('<','&lt;')
text = text.replace('>','&gt;')
text = text.replace('&lt;super&gt;',self.super)
text = text.replace('&lt;/super&gt;','</super></font>')
if self.in_table == 0:
if format == 1:
text = '<para firstLineIndent="0" fontname="Courier">%s</para>' % 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): def write_text(self,text):
text = text.replace('&','&amp;') # Must be first text = text.replace('&','&amp;') # Must be first
text = text.replace('<','&lt;') text = text.replace('<','&lt;')

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # 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 # 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 # 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 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id$
#------------------------------------------------------------------------
#
# python modules
#
#------------------------------------------------------------------------
import string
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Load the base BaseDoc class # Load the base BaseDoc class
@ -355,6 +364,20 @@ class RTFDoc(BaseDoc.BaseDoc):
index = index+1 index = index+1
self.f.write('}}\\par\n') 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 # Writes text. If braces are not currently open, open them. Loop