part 2 basedoc: move BaseDoc.py to /gen/plug/docgen and add /gen/plug/docbackend

that was missing in part 1 
 Still to come: makefiles and splitting new basedoc.py in small files


svn: r12591
This commit is contained in:
Benny Malengier 2009-05-29 22:25:44 +00:00
parent f999ba9cc4
commit 8dd7adc607
54 changed files with 1384 additions and 594 deletions

View File

@ -1315,9 +1315,9 @@ class GuiStyleOption(GuiEnumeratedListOption):
"""The user has clicked on the 'Edit Styles' button. Create a
style sheet editor object and let them play. When they are
done, update the displayed styles."""
import BaseDoc
from gen.plug.docgen import StyleSheetList
from ReportBase._StyleEditor import StyleListDisplay
style_list = BaseDoc.StyleSheetList(self.__option.get_style_file(),
style_list = StyleSheetList(self.__option.get_style_file(),
self.__option.get_default_style())
StyleListDisplay(style_list, None, None)

View File

@ -42,7 +42,8 @@ log = logging.getLogger(".")
#-------------------------------------------------------------------------
import gen
import Utils
import BaseDoc
from gen.plug.docgen import StyleSheet, StyleSheetList, PaperStyle
from gen.plug.docgen.basedoc import (PAPER_PORTRAIT, PAPER_LANDSCAPE)
from BasicUtils import name_displayer
from ReportBase import CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK, \
CATEGORY_GRAPHVIZ
@ -185,19 +186,19 @@ class CommandLineReport(object):
if paper.get_name() != _("Custom Size") ]
self.options_help['papero'][2] = [
"%d\tPortrait" % BaseDoc.PAPER_PORTRAIT,
"%d\tLandscape" % BaseDoc.PAPER_LANDSCAPE ]
"%d\tPortrait" % PAPER_PORTRAIT,
"%d\tLandscape" % PAPER_LANDSCAPE ]
self.options_help['template'][2] = os.path.join(const.USER_HOME,
"whatever_name")
if self.category in (CATEGORY_TEXT, CATEGORY_DRAW):
default_style = BaseDoc.StyleSheet()
default_style = StyleSheet()
self.option_class.make_default_style(default_style)
# Read all style sheets available for this item
style_file = self.option_class.handler.get_stylesheet_savefile()
self.style_list = BaseDoc.StyleSheetList(style_file, default_style)
self.style_list = StyleSheetList(style_file, default_style)
self.options_help['style'][2] = self.style_list.get_style_names()
@ -330,12 +331,12 @@ class CommandLineReport(object):
self.template_name = self.options_dict['template']
if self.category in (CATEGORY_TEXT, CATEGORY_DRAW):
default_style = BaseDoc.StyleSheet()
default_style = StyleSheet()
self.option_class.make_default_style(default_style)
# Read all style sheets available for this item
style_file = self.option_class.handler.get_stylesheet_savefile()
self.style_list = BaseDoc.StyleSheetList(style_file,default_style)
self.style_list = StyleSheetList(style_file,default_style)
# Get the selected stylesheet
style_name = self.option_class.handler.get_default_stylesheet_name()
@ -401,7 +402,7 @@ def cl_report(database, name, category, report_class, options_class,
CATEGORY_GRAPHVIZ]:
clr.option_class.handler.doc = clr.format(
clr.selected_style,
BaseDoc.PaperStyle(clr.paper,clr.orien),
PaperStyle(clr.paper,clr.orien),
clr.template_name)
MyReport = report_class(database, clr.option_class)
MyReport.doc.init()

View File

@ -22,8 +22,8 @@
"""
Provide utilities for printing endnotes in text reports.
"""
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import FONT_SANS_SERIF
from gettext import gettext as _
def add_endnote_styles(style_sheet):
@ -31,11 +31,11 @@ def add_endnote_styles(style_sheet):
Add paragraph styles to a style sheet to be used for displaying endnotes.
@param style_sheet: Style sheet
@type style_sheet: L{Basedoc.StyleSheet}
@type style_sheet: L{docgen.StyleSheet}
"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=14, italic=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=14, italic=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set_top_margin(0.25)
@ -43,14 +43,14 @@ def add_endnote_styles(style_sheet):
para.set_description(_('The style used for the generation header.'))
style_sheet.add_paragraph_style("Endnotes-Header", para)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set(first_indent=-0.75, lmargin=.75)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_description(_('The basic style used for the endnotes source display.'))
style_sheet.add_paragraph_style("Endnotes-Source", para)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set(lmargin=1.5)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
@ -89,7 +89,7 @@ def write_endnotes(bibliography, database, doc):
@param database: The database that the sources come from.
@type database: GrampsDbBase
@param doc: The document to write the endnotes into.
@type doc: L{BaseDoc.TextDoc}
@type doc: L{docgen.TextDoc}
"""
if bibliography.get_citation_count() == 0:
return

View File

@ -47,7 +47,7 @@ import gobject
#
#-------------------------------------------------------------------------------
import Utils
import BaseDoc
from gen.plug.docgen import BaseDoc, GVDoc
import Config
from ReportBase import CATEGORY_GRAPHVIZ
from _ReportDialog import ReportDialog
@ -143,14 +143,14 @@ def _run_long_process_in_thread(func, header):
# GVDocBase
#
#-------------------------------------------------------------------------------
class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
class GVDocBase(BaseDoc, GVDoc):
"""
Base document generator for all Graphiz document generators. Classes that
inherit from this class will only need to implement the close function.
The close function will generate the actual file of the appropriate type.
"""
def __init__(self, options, paper_style):
BaseDoc.BaseDoc.__init__(self, None, paper_style, None)
BaseDoc.__init__(self, None, paper_style, None)
self._filename = None
self._dot = StringIO()
@ -231,7 +231,7 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
self._dot.write(text.encode('utf8', 'xmlcharrefreplace'))
def open(self, filename):
""" Implement BaseDoc.BaseDoc.open() """
""" Implement BaseDoc.open() """
self._filename = os.path.normpath(os.path.abspath(filename))
def close(self):
@ -264,7 +264,7 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
Add a node to this graph. Nodes can be different shapes like boxes and
circles.
Implements BaseDoc.GVDoc.add_node().
Implements GVDoc.add_node().
"""
text = '['
@ -298,7 +298,7 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
"""
Add a link between two nodes.
Implementes BaseDoc.GVDoc.add_link().
Implementes GVDoc.add_link().
"""
self.write(' %s -> %s' % (id1, id2))
@ -325,7 +325,7 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
"""
Add a comment.
Implementes BaseDoc.GVDoc.add_comment().
Implementes GVDoc.add_comment().
"""
tmp = comment.split('\n')
for line in tmp:
@ -338,13 +338,13 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
self.write('# %s\n' % text)
def start_subgraph(self, graph_id):
""" Implement BaseDoc.GVDoc.start_subgraph() """
""" Implement GVDoc.start_subgraph() """
self.write(' subgraph cluster_%s\n' % graph_id)
self.write(' {\n')
self.write(' style="invis";\n') # no border around subgraph (#0002176)
def end_subgraph(self):
""" Implement BaseDoc.GVDoc.end_subgraph() """
""" Implement GVDoc.end_subgraph() """
self.write(' }\n')
#-------------------------------------------------------------------------------

View File

@ -40,7 +40,8 @@ import gobject
# GRAMPS modules
#
#-------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import PaperStyle, PaperSize
from gen.plug.docgen.basedoc import (PAPER_PORTRAIT, PAPER_LANDSCAPE)
import const
import Utils
from glade import Glade
@ -104,7 +105,7 @@ class PaperComboBox(gtk.ComboBox):
#-------------------------------------------------------------------------
class OrientationComboBox(gtk.ComboBox):
def __init__(self,default=BaseDoc.PAPER_PORTRAIT):
def __init__(self,default=PAPER_PORTRAIT):
gtk.ComboBox.__init__(self)
self.store = gtk.ListStore(gobject.TYPE_STRING)
@ -116,13 +117,13 @@ class OrientationComboBox(gtk.ComboBox):
self.store.append(row=[_('Portrait')])
self.store.append(row=[_('Landscape')])
if default == BaseDoc.PAPER_PORTRAIT:
if default == PAPER_PORTRAIT:
self.set_active(0)
else:
self.set_active(1)
def set_value(self,value=0):
if value == BaseDoc.PAPER_PORTRAIT:
if value == PAPER_PORTRAIT:
self.set_active(0)
else:
self.set_active(1)
@ -132,9 +133,9 @@ class OrientationComboBox(gtk.ComboBox):
if active < 0:
return None
if active == 0:
return BaseDoc.PAPER_PORTRAIT
return PAPER_PORTRAIT
else:
return BaseDoc.PAPER_LANDSCAPE
return PAPER_LANDSCAPE
#-------------------------------------------------------------------------
#
@ -308,7 +309,7 @@ class PaperFrame(gtk.HBox):
paper_orientation = self.orientation_menu.get_value()
paper_margins = self.get_paper_margins()
pstyle = BaseDoc.PaperStyle(paper_size,
pstyle = PaperStyle(paper_size,
paper_orientation,
*paper_margins)
return pstyle
@ -343,7 +344,7 @@ class PageSizeParser(handler.ContentHandler):
name = attrs['name']
height = Utils.gfloat(attrs['height'])
width = Utils.gfloat(attrs['width'])
self.paper_list.append(BaseDoc.PaperSize(name, height,width))
self.paper_list.append(PaperSize(name, height,width))
#-------------------------------------------------------------------------
#
@ -356,27 +357,27 @@ try:
the_file = open(const.PAPERSIZE)
parser.parse(the_file)
the_file.close()
paper_sizes.append(BaseDoc.PaperSize(_("Custom Size"),-1,-1))
paper_sizes.append(PaperSize(_("Custom Size"),-1,-1))
except (IOError,OSError,SAXParseException):
paper_sizes = [
BaseDoc.PaperSize("Letter",27.94,21.59),
BaseDoc.PaperSize("Legal",35.56,21.59),
BaseDoc.PaperSize("A0",118.9,84.1),
BaseDoc.PaperSize("A1",84.1,59.4),
BaseDoc.PaperSize("A2",59.4,42.0),
BaseDoc.PaperSize("A3",42.0,29.7),
BaseDoc.PaperSize("A4",29.7,21.0),
BaseDoc.PaperSize("A5",21.0,14.8),
BaseDoc.PaperSize("B0",141.4,100.0),
BaseDoc.PaperSize("B1",100.0,70.7),
BaseDoc.PaperSize("B2",70.7,50.0),
BaseDoc.PaperSize("B3",50.0,35.3),
BaseDoc.PaperSize("B4",35.3,25.0),
BaseDoc.PaperSize("B5",25.0,17.6),
BaseDoc.PaperSize("B6",17.6,12.5),
BaseDoc.PaperSize("B",43.18,27.94),
BaseDoc.PaperSize("C",55.88,43.18),
BaseDoc.PaperSize("D",86.36, 55.88),
BaseDoc.PaperSize("E",111.76,86.36),
BaseDoc.PaperSize(_("Custom Size"),-1,-1)
PaperSize("Letter",27.94,21.59),
PaperSize("Legal",35.56,21.59),
PaperSize("A0",118.9,84.1),
PaperSize("A1",84.1,59.4),
PaperSize("A2",59.4,42.0),
PaperSize("A3",42.0,29.7),
PaperSize("A4",29.7,21.0),
PaperSize("A5",21.0,14.8),
PaperSize("B0",141.4,100.0),
PaperSize("B1",100.0,70.7),
PaperSize("B2",70.7,50.0),
PaperSize("B3",50.0,35.3),
PaperSize("B4",35.3,25.0),
PaperSize("B5",25.0,17.6),
PaperSize("B6",17.6,12.5),
PaperSize("B",43.18,27.94),
PaperSize("C",55.88,43.18),
PaperSize("D",86.36, 55.88),
PaperSize("E",111.76,86.36),
PaperSize(_("Custom Size"),-1,-1)
]

View File

@ -51,7 +51,7 @@ from QuestionDialog import ErrorDialog, OptionDialog
from ReportBase import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK,
CATEGORY_CODE, CATEGORY_WEB, CATEGORY_GRAPHVIZ,
standalone_categories)
import BaseDoc
from gen.plug.docgen import StyleSheet, StyleSheetList
import ManagedWindow
from _StyleComboBox import StyleComboBox
from _StyleEditor import StyleListDisplay
@ -291,7 +291,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
the builds a menu of all the available styles for the user to
choose from."""
# Build the default style set for this report.
self.default_style = BaseDoc.StyleSheet()
self.default_style = StyleSheet()
self.options.make_default_style(self.default_style)
if self.default_style.is_empty():
@ -316,7 +316,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
# Build the initial list of available styles sets. This
# includes the default style set and any style sets saved from
# previous invocations of gramps.
self.style_sheet_list = BaseDoc.StyleSheetList(
self.style_sheet_list = StyleSheetList(
self.options.handler.get_stylesheet_savefile(),
self.default_style)

View File

@ -55,7 +55,7 @@ except:
#-------------------------------------------------------------------------
import const
import Config
import BaseDoc
from gen.plug.docgen.basedoc import PAPER_PORTRAIT
from PluginUtils import _Options, GuiMenuOptions
#-------------------------------------------------------------------------
@ -131,7 +131,7 @@ class OptionList(_Options.OptionList):
"""
Set the orientation for the OptionList.
@param orientation: orientation to set. Possible values are
BaseDoc.PAPER_LANDSCAPE or BaseDoc.PAPER_PORTRAIT
PAPER_LANDSCAPE or PAPER_PORTRAIT
@type orientation: int
"""
self.orientation = orientation
@ -140,7 +140,7 @@ class OptionList(_Options.OptionList):
"""
Return the orientation for the OptionList.
@returns: returns the selected orientation. Valid values are
BaseDoc.PAPER_LANDSCAPE or BaseDoc.PAPER_PORTRAIT
PAPER_LANDSCAPE or PAPER_PORTRAIT
@rtype: int
"""
return self.orientation
@ -247,7 +247,7 @@ class OptionListCollection(_Options.OptionListCollection):
self.default_paper_metric = Config.get(Config.PAPER_METRIC)
self.default_paper_name = Config.get(Config.PAPER_PREFERENCE)
self.default_template_name = ""
self.default_orientation = BaseDoc.PAPER_PORTRAIT
self.default_orientation = PAPER_PORTRAIT
self.default_custom_paper_size = [29.7, 21.0]
self.default_margins = [2.54, 2.54, 2.54, 2.54]
self.default_format_name = 'print'

View File

@ -50,7 +50,8 @@ from gen.lib.person import Person
from BasicUtils import name_displayer as _nd
from Utils import media_path_full
from QuestionDialog import WarningDialog
import BaseDoc
from gen.plug.docgen import IndexMark
from gen.plug.docgen.basedoc import INDEX_TYPE_ALP
#------------------------------------------------------------------------
#
@ -3101,7 +3102,7 @@ def get_person_mark(db, person):
else:
key = "%s (%s - %s)" % (name, birth, death)
return BaseDoc.IndexMark( key, BaseDoc.INDEX_TYPE_ALP )
return IndexMark( key, INDEX_TYPE_ALP )
#-------------------------------------------------------------------------
#

View File

@ -50,7 +50,10 @@ from gtk.gdk import Color
#------------------------------------------------------------------------
import Utils
import const
import BaseDoc
from gen.plug.docgen import StyleSheet
from gen.plug.docgen.basedoc import (FONT_SERIF, FONT_SANS_SERIF,
PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT,
PARA_ALIGN_JUSTIFY)
import ListModel
import ManagedWindow
from glade import Glade
@ -189,7 +192,7 @@ class StyleEditor(object):
self.current_p = None
self.current_name = None
self.style = BaseDoc.StyleSheet(style)
self.style = StyleSheet(style)
self.parent = parent
self.top = Glade(toplevel='editor')
self.window = self.top.toplevel
@ -242,18 +245,18 @@ class StyleEditor(object):
font = p.get_font()
self.top.get_object("size").set_value(font.get_size())
if font.get_type_face() == BaseDoc.FONT_SERIF:
if font.get_type_face() == FONT_SERIF:
self.top.get_object("roman").set_active(1)
else:
self.top.get_object("swiss").set_active(1)
self.top.get_object("bold").set_active(font.get_bold())
self.top.get_object("italic").set_active(font.get_italic())
self.top.get_object("underline").set_active(font.get_underline())
if p.get_alignment() == BaseDoc.PARA_ALIGN_LEFT:
if p.get_alignment() == PARA_ALIGN_LEFT:
self.top.get_object("lalign").set_active(1)
elif p.get_alignment() == BaseDoc.PARA_ALIGN_RIGHT:
elif p.get_alignment() == PARA_ALIGN_RIGHT:
self.top.get_object("ralign").set_active(1)
elif p.get_alignment() == BaseDoc.PARA_ALIGN_CENTER:
elif p.get_alignment() == PARA_ALIGN_CENTER:
self.top.get_object("calign").set_active(1)
else:
self.top.get_object("jalign").set_active(1)
@ -303,21 +306,21 @@ class StyleEditor(object):
font.set_size(self.top.get_object("size").get_value_as_int())
if self.top.get_object("roman").get_active():
font.set_type_face(BaseDoc.FONT_SERIF)
font.set_type_face(FONT_SERIF)
else:
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font.set_type_face(FONT_SANS_SERIF)
font.set_bold(self.top.get_object("bold").get_active())
font.set_italic(self.top.get_object("italic").get_active())
font.set_underline(self.top.get_object("underline").get_active())
if self.top.get_object("lalign").get_active():
p.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
p.set_alignment(PARA_ALIGN_LEFT)
elif self.top.get_object("ralign").get_active():
p.set_alignment(BaseDoc.PARA_ALIGN_RIGHT)
p.set_alignment(PARA_ALIGN_RIGHT)
elif self.top.get_object("calign").get_active():
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
else:
p.set_alignment(BaseDoc.PARA_ALIGN_JUSTIFY)
p.set_alignment(PARA_ALIGN_JUSTIFY)
p.set_right_margin(self.top.get_object("rmargin").get_value())
p.set_left_margin(self.top.get_object("lmargin").get_value())

View File

@ -21,7 +21,9 @@
"""
Provide a simplified database access interface to the GRAMPS database.
"""
import BaseDoc
from gen.plug.docgen import StyleSheet, ParagraphStyle,\
TableStyle, TableCellStyle
from gen.plug.docgen.basedoc import FONT_SANS_SERIF, PARA_ALIGN_LEFT
class SimpleDoc(object):
"""
@ -76,69 +78,69 @@ def make_basic_stylesheet():
"""
Create the basic style sheet for the SimpleDoc class
"""
sheet = BaseDoc.StyleSheet()
sheet = StyleSheet()
pstyle = BaseDoc.ParagraphStyle()
pstyle = ParagraphStyle()
fstyle = pstyle.get_font()
fstyle.set_type_face(BaseDoc.FONT_SANS_SERIF)
fstyle.set_type_face(FONT_SANS_SERIF)
fstyle.set_size(14)
fstyle.set_bold(True)
pstyle.set_font(fstyle)
pstyle.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
pstyle.set_alignment(PARA_ALIGN_LEFT)
sheet.add_paragraph_style('Title', pstyle)
pstyle = BaseDoc.ParagraphStyle()
pstyle = ParagraphStyle()
fstyle = pstyle.get_font()
fstyle.set_type_face(BaseDoc.FONT_SANS_SERIF)
fstyle.set_type_face(FONT_SANS_SERIF)
fstyle.set_size(12)
fstyle.set_bold(True)
pstyle.set_font(fstyle)
pstyle.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
pstyle.set_alignment(PARA_ALIGN_LEFT)
pstyle.set_tabs([4, 8, 12, 16])
sheet.add_paragraph_style('Header1', pstyle)
pstyle = BaseDoc.ParagraphStyle()
pstyle = ParagraphStyle()
fstyle = pstyle.get_font()
fstyle.set_type_face(BaseDoc.FONT_SANS_SERIF)
fstyle.set_type_face(FONT_SANS_SERIF)
fstyle.set_size(10)
fstyle.set_bold(True)
pstyle.set_font(fstyle)
pstyle.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
pstyle.set_alignment(PARA_ALIGN_LEFT)
pstyle.set_tabs([4, 8, 12, 16])
sheet.add_paragraph_style('Header2', pstyle)
pstyle = BaseDoc.ParagraphStyle()
pstyle = ParagraphStyle()
fstyle = pstyle.get_font()
fstyle.set_type_face(BaseDoc.FONT_SANS_SERIF)
fstyle.set_type_face(FONT_SANS_SERIF)
fstyle.set_size(10)
fstyle.set_bold(True)
fstyle.set_italic(True)
pstyle.set_font(fstyle)
pstyle.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
pstyle.set_alignment(PARA_ALIGN_LEFT)
pstyle.set_tabs([4, 8, 12, 16])
sheet.add_paragraph_style('Header3', pstyle)
pstyle = BaseDoc.ParagraphStyle()
pstyle = ParagraphStyle()
pstyle.set_tabs([4, 8, 12, 16])
sheet.add_paragraph_style('Normal', pstyle)
# Styles for tables:
tbl = BaseDoc.TableStyle()
tbl = TableStyle()
tbl.set_width(100)
tbl.set_columns(2)
tbl.set_column_width(0,20)
tbl.set_column_width(1,80)
sheet.add_table_style("Table",tbl)
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
cell.set_top_border(1)
cell.set_bottom_border(1)
sheet.add_cell_style("TableHead",cell)
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
sheet.add_cell_style("TableNormalCell",cell)
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
cell.set_longlist(1)
sheet.add_cell_style("TableListCell",cell)

View File

@ -35,7 +35,7 @@ from gettext import gettext as _
# Gramps modules
#
#-------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen.basedoc import FONT_SERIF
from docgen import SpreadSheetDoc
import const
@ -148,7 +148,7 @@ class ODSDoc(SpreadSheetDoc):
self.f.write('fo:padding-left="%.3fcm" ' % style.get_padding())
self.f.write('style:text-outline="false" ')
self.f.write('style:text-crossing-out="none" ')
if font.get_type_face() == BaseDoc.FONT_SERIF:
if font.get_type_face() == FONT_SERIF:
self.f.write('style:font-name="Times New Roman" ')
else:
self.f.write('style:font-name="Arial" ')

View File

@ -35,7 +35,7 @@ from gettext import gettext as _
# Gramps modules
#
#-------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen.basedoc import FONT_SERIF
from SpreadSheetDoc import SpreadSheetDoc
import const
@ -142,7 +142,7 @@ class OpenSpreadSheet(SpreadSheetDoc):
self.f.write('fo:padding-left="%.3fcm" ' % style.get_padding())
self.f.write('style:text-outline="false" ')
self.f.write('style:text-crossing-out="none" ')
if font.get_type_face() == BaseDoc.FONT_SERIF:
if font.get_type_face() == FONT_SERIF:
self.f.write('style:font-name="Times New Roman" ')
else:
self.f.write('style:font-name="Arial" ')

View File

@ -18,7 +18,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle, TableStyle,\
TableCellStyle
from gen.plug.docgen.basedoc import PAPER_PORTRAIT
#------------------------------------------------------------------------
#
@ -26,9 +28,9 @@ import BaseDoc
#
#------------------------------------------------------------------------
class SpreadSheetDoc(object):
def __init__(self,type, orientation=BaseDoc.PAPER_PORTRAIT):
def __init__(self,type, orientation=PAPER_PORTRAIT):
self.orientation = orientation
if orientation == BaseDoc.PAPER_PORTRAIT:
if orientation == PAPER_PORTRAIT:
self.width = type.get_width()
self.height = type.get_height()
else:
@ -39,7 +41,7 @@ class SpreadSheetDoc(object):
self.lmargin = 2.54
self.rmargin = 2.54
self.font = BaseDoc.FontStyle()
self.font = FontStyle()
self.actfont = self.font
self.style_list = {}
self.table_styles = {}
@ -56,16 +58,16 @@ class SpreadSheetDoc(object):
self.name = name
def add_style(self, name,style):
self.style_list[name] = BaseDoc.ParagraphStyle(style)
self.style_list[name] = ParagraphStyle(style)
def add_table_style(self, name,style):
self.table_styles[name] = BaseDoc.TableStyle(style)
self.table_styles[name] = TableStyle(style)
def add_cell_style(self, name,style):
self.cell_styles[name] = BaseDoc.TableCellStyle(style)
self.cell_styles[name] = TableCellStyle(style)
def change_font(self,font):
self.actfont = BaseDoc.FontStyle(font)
self.actfont = FontStyle(font)
def restore_font(self):
self.actfont = self.font

View File

@ -35,7 +35,10 @@ import pango
# Gramps modules
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import BaseDoc, TextDoc
from gen.plug.docgen.basedoc import (FONT_SERIF, PARA_ALIGN_RIGHT,
FONT_SANS_SERIF, FONT_MONOSPACE, PARA_ALIGN_CENTER,
PARA_ALIGN_LEFT)
import ManagedWindow
try:
@ -93,7 +96,7 @@ class DocumentManager(object):
# TextBuf
#
#------------------------------------------------------------------------
class TextBufDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc):
class TextBufDoc(BaseDoc, TextDoc):
#--------------------------------------------------------------------
#
@ -111,21 +114,21 @@ class TextBufDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc):
style = sheet.get_paragraph_style(name)
font = style.get_font()
if font.get_type_face() == BaseDoc.FONT_SERIF:
if font.get_type_face() == FONT_SERIF:
tag.set_property("family", "Serif")
elif font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
elif font.get_type_face() == FONT_SANS_SERIF:
tag.set_property("family", "Sans")
elif font.get_type_face() == BaseDoc.FONT_MONOSPACE:
elif font.get_type_face() == FONT_MONOSPACE:
tag.set_property("family", "MonoSpace")
tag.set_property("size-points", float(font.get_size()))
if font.get_bold():
tag.set_property("weight", pango.WEIGHT_BOLD)
if style.get_alignment() == BaseDoc.PARA_ALIGN_RIGHT:
if style.get_alignment() == PARA_ALIGN_RIGHT:
tag.set_property("justification", gtk.JUSTIFY_RIGHT)
elif style.get_alignment() == BaseDoc.PARA_ALIGN_LEFT:
elif style.get_alignment() == PARA_ALIGN_LEFT:
tag.set_property("justification", gtk.JUSTIFY_LEFT)
elif style.get_alignment() == BaseDoc.PARA_ALIGN_CENTER:
elif style.get_alignment() == PARA_ALIGN_CENTER:
tag.set_property("justification", gtk.JUSTIFY_CENTER)
else:
tag.set_property("justification", gtk.JUSTIFY_FILL)

View File

@ -25,7 +25,7 @@ from _plugin import Plugin
from _manager import PluginManager
from _import import ImportPlugin
from _export import ExportPlugin
from _docgen import DocGenPlugin
from _docgenplugin import DocGenPlugin
__all__ = [ "menu", Plugin, PluginManager, ImportPlugin, ExportPlugin, \
DocGenPlugin ]
__all__ = [ "docgen", "menu", Plugin, PluginManager, ImportPlugin,
ExportPlugin, DocGenPlugin ]

View File

@ -1,109 +1,109 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2008 Brian G. Matherly
#
# 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
#
# $Id: $
"""
This module provides the Plugin class for document generator plugins.
"""
from gen.plug import Plugin
import BaseDoc
class DocGenPlugin(Plugin):
"""
This class represents a plugin for generating documents from Gramps
"""
def __init__(self, name, description, basedoc, paper, style, extension):
"""
@param name: A friendly name to call this plugin.
Example: "Plain Text"
@type name: string
@param description: A short description of the plugin.
Example: "This plugin will generate text documents in plain text."
@type description: string
@param basedoc: A class that implements the BaseDoc.BaseDoc
interface.
@type basedoc: BaseDoc.BaseDoc
@param paper: Indicates whether the plugin uses paper or not.
True = use paper; False = do not use paper
@type paper: bool
@param style: Indicates whether the plugin uses styles or not.
True = use styles; False = do not use styles
@type style: bool
@param extension: The extension for the output file.
Example: "txt"
@type extension: str
@return: nothing
"""
Plugin.__init__(self, name, description, basedoc.__module__)
self.__basedoc = basedoc
self.__paper = paper
self.__style = style
self.__extension = extension
def get_basedoc(self):
"""
Get the BaseDoc class for this plugin.
@return: the BaseDoc.BaseDoc class passed into __init__
"""
return self.__basedoc
def get_paper_used(self):
"""
Get the paper flag for this plugin.
@return: bool - True = use paper; False = do not use paper
"""
return self.__paper
def get_style_support(self):
"""
Get the style flag for this plugin.
@return: bool - True = use styles; False = do not use styles
"""
return self.__style
def get_extension(self):
"""
Get the file extension for the output file.
@return: str
"""
return self.__extension
def get_text_support(self):
"""
Check if the plugin supports the BaseDoc.TextDoc interface.
@return: bool: True if TextDoc is supported; False if TextDoc is not
supported.
"""
return bool(issubclass(self.__basedoc, BaseDoc.TextDoc))
def get_draw_support(self):
"""
Check if the plugin supports the BaseDoc.DrawDoc interface.
@return: bool: True if DrawDoc is supported; False if DrawDoc is not
supported.
"""
return bool(issubclass(self.__basedoc, BaseDoc.DrawDoc))
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2008 Brian G. Matherly
#
# 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
#
# $Id: $
"""
This module provides the Plugin class for document generator plugins.
"""
from gen.plug import Plugin
from gen.plug.docgen import TextDoc, DrawDoc
class DocGenPlugin(Plugin):
"""
This class represents a plugin for generating documents from Gramps
"""
def __init__(self, name, description, basedoc, paper, style, extension):
"""
@param name: A friendly name to call this plugin.
Example: "Plain Text"
@type name: string
@param description: A short description of the plugin.
Example: "This plugin will generate text documents in plain text."
@type description: string
@param basedoc: A class that implements the BaseDoc
interface.
@type basedoc: BaseDoc
@param paper: Indicates whether the plugin uses paper or not.
True = use paper; False = do not use paper
@type paper: bool
@param style: Indicates whether the plugin uses styles or not.
True = use styles; False = do not use styles
@type style: bool
@param extension: The extension for the output file.
Example: "txt"
@type extension: str
@return: nothing
"""
Plugin.__init__(self, name, description, basedoc.__module__)
self.__basedoc = basedoc
self.__paper = paper
self.__style = style
self.__extension = extension
def get_basedoc(self):
"""
Get the BaseDoc class for this plugin.
@return: the BaseDoc class passed into __init__
"""
return self.__basedoc
def get_paper_used(self):
"""
Get the paper flag for this plugin.
@return: bool - True = use paper; False = do not use paper
"""
return self.__paper
def get_style_support(self):
"""
Get the style flag for this plugin.
@return: bool - True = use styles; False = do not use styles
"""
return self.__style
def get_extension(self):
"""
Get the file extension for the output file.
@return: str
"""
return self.__extension
def get_text_support(self):
"""
Check if the plugin supports the TextDoc interface.
@return: bool: True if TextDoc is supported; False if TextDoc is not
supported.
"""
return bool(issubclass(self.__basedoc, TextDoc))
def get_draw_support(self):
"""
Check if the plugin supports the DrawDoc interface.
@return: bool: True if DrawDoc is supported; False if DrawDoc is not
supported.
"""
return bool(issubclass(self.__basedoc, DrawDoc))

View File

@ -0,0 +1,33 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 B. Malengier
#
# 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
#
# $Id: __init__.py 10055 2008-02-18 20:07:09Z acraphae $
"""
The docbackend package for managing the specific files an implementation of the
docgen API writes on. It provides common functionality, and translates between
gen data specific for output (eg markup in gen/lib) and output where needed
"""
from docbackend import DocBackendError, DocBackend
from cairobackend import CairoBackend
from latexbackend import LateXBackend, latexescape, latexescapeverbatim
#__all__ = [ DocBackend, CairoBackend, LateXBackend ]

View File

@ -0,0 +1,105 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Benny Malengier
#
# 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
#
# $Id: docbackend.py 12437 2009-04-13 02:11:49Z pez4brian $
"""File and File format management for the different reports
"""
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from xml.sax.saxutils import escape
#-------------------------------------------------------------------------
#
# GTK modules
#
#-------------------------------------------------------------------------
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from docbackend import DocBackend
#------------------------------------------------------------------------
#
# Set up logging
#
#------------------------------------------------------------------------
import logging
log = logging.getLogger(".cairobackend.py")
#------------------------------------------------------------------------
#
# Document Backend class for cairo docs
#
#------------------------------------------------------------------------
class CairoBackend(DocBackend):
"""
Implementation for cairo docs
"""
STYLETAG_TO_PROPERTY = {
DocBackend.FONTCOLOR : 'foreground',
DocBackend.HIGHLIGHT : 'background',
DocBackend.FONTFACE : 'face',
DocBackend.FONTSIZE : 'size',
}
# overwrite base class attributes, they become static var of CairoDoc
SUPPORTED_MARKUP = [
DocBackend.BOLD,
DocBackend.ITALIC,
DocBackend.UNDERLINE,
DocBackend.FONTFACE,
DocBackend.FONTSIZE,
DocBackend.FONTCOLOR,
DocBackend.HIGHLIGHT,
DocBackend.SUPERSCRIPT ]
STYLETAG_MARKUP = {
DocBackend.BOLD : ("<b>", "</b>"),
DocBackend.ITALIC : ("<i>", "</i>"),
DocBackend.UNDERLINE : ("<u>", "</u>"),
DocBackend.SUPERSCRIPT : ("<sup>", "</sup>"),
}
ESCAPE_FUNC = lambda x: escape
def _create_xmltag(self, type, value):
"""
overwrites the method in DocBackend
creates the pango xml tags needed for non bool style types
"""
if type not in self.SUPPORTED_MARKUP:
return None
if type == DocBackend.FONTSIZE:
#size is in thousandths of a point in pango
value = str(1000 * value)
return ('<span %s="%s">' % (self.STYLETAG_TO_PROPERTY[type],
self.ESCAPE_FUNC()(value)),
'</span>')

View File

@ -0,0 +1,409 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Benny Malengier
#
# 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
#
# $Id: docbackend.py 12437 2009-04-13 02:11:49Z pez4brian $
"""File and File format management for the different reports
"""
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GTK modules
#
#-------------------------------------------------------------------------
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
#------------------------------------------------------------------------
#
# Set up logging
#
#------------------------------------------------------------------------
import logging
log = logging.getLogger(".docbackend.py")
#------------------------------------------------------------------------
#
# Functions
#
#------------------------------------------------------------------------
def noescape(text):
return text
#-------------------------------------------------------------------------
#
# DocBackend exception
#
#-------------------------------------------------------------------------
class DocBackendError(Exception):
"""Error used to report docbackend errors."""
def __init__(self, value=""):
Exception.__init__(self)
self.value = value
def __str__(self):
return self.value
#------------------------------------------------------------------------
#
# Document Backend class
#
#------------------------------------------------------------------------
class DocBackend(object):
"""
Base class for text document backends.
The DocBackend manages a file to which it writes. It further knowns
enough of the file format to be able to translate between the BaseDoc API
and the file format.
Specifically for text reports a translation of styled notes to the file
format usage is done.
"""
BOLD = 0
ITALIC = 1
UNDERLINE = 2
FONTFACE = 3
FONTSIZE = 4
FONTCOLOR = 5
HIGHLIGHT = 6
SUPERSCRIPT = 7
SUPPORTED_MARKUP = []
ESCAPE_FUNC = lambda x: noescape
#Map between styletypes and internally used values. This map is needed
# to make TextDoc officially independant of gen.lib.styledtexttag
STYLETYPE_MAP = {
}
CLASSMAP = None
#STYLETAGTABLE to store markup for write_markup associated with style tags
STYLETAG_MARKUP = {
BOLD : ("", ""),
ITALIC : ("", ""),
UNDERLINE : ("", ""),
SUPERSCRIPT : ("", ""),
}
def __init__(self, filename=None):
"""
@param filename: path name of the file the backend works on
"""
self.__file = None
self._filename = filename
def getf(self):
return self._filename
def setf(self, value):
if self.__file is not None:
raise ValueError, _('Close file first')
self._filename = value
filename = property(getf, setf, None, "The filename the backend works on")
def open(self):
"""
Opens the document.
"""
if self.filename is None:
raise DocBackendError(_('No filename given'))
if self.__file is not None :
raise DocBackendError(_('File %s already open, close it first.')
% self.filename)
self._checkfilename()
try:
self.__file = open(self.filename, "w")
except IOError, msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
raise DocBackendError(errmsg)
except:
raise DocBackendError(_("Could not create %s") % self.filename)
def _checkfilename(self):
"""
Check to make sure filename satisfies the standards for this filetype
"""
pass
def close(self):
if self.__file is None:
raise IOError, 'No file open'
self.__file.close()
self.__file = None
def write(self, str):
"""Write a string to the file. There is no return value.
Due to buffering, the string may not actually show up untill the
close() method is called.
"""
self.__file.write(str)
def writelines(self, sequence):
"""Write a sequence of strings to the file. The sequence can be any
iterable object producing strings, typically a list of strings.
"""
self.__file.writelines(sequence)
def escape(self, preformatted=False):
"""
The escape func on text for this file format.
@param preformatted: bool: some formats can have different escape
function for normal text and preformatted text
"""
return self.ESCAPE_FUNC()
def find_tag_by_stag(self, s_tag):
"""
@param s_tag: object: assumed styledtexttag
@param s_tagvalue: None/int/str: value associated with the tag
A styled tag is type with a value.
Every styled tag must be converted to the tags used in the corresponding
markup for the backend, eg <b>text</b> for bold in html.
These markups are stored in STYLETAG_MARKUP. They are tuples for begin
and end tag
If a markup is not present yet, it is created, using the
_create_xmltag method you can overwrite
"""
type = s_tag.name
if not self.STYLETYPE_MAP or \
self.CLASSMAP <> type.__class__.__name__ :
self.CLASSMAP == type.__class__.__name__
self.STYLETYPE_MAP[type.__class__.BOLD] = self.BOLD
self.STYLETYPE_MAP[type.ITALIC] = self.ITALIC
self.STYLETYPE_MAP[type.UNDERLINE] = self.UNDERLINE
self.STYLETYPE_MAP[type.FONTFACE] = self.FONTFACE
self.STYLETYPE_MAP[type.FONTSIZE] = self.FONTSIZE
self.STYLETYPE_MAP[type.FONTCOLOR] = self.FONTCOLOR
self.STYLETYPE_MAP[type.HIGHLIGHT] = self.HIGHLIGHT
self.STYLETYPE_MAP[type.SUPERSCRIPT] = self.SUPERSCRIPT
typeval = int(s_tag.name)
s_tagvalue = s_tag.value
tag_name = None
if type.STYLE_TYPE[typeval] == bool:
return self.STYLETAG_MARKUP[self.STYLETYPE_MAP[typeval]]
elif type.STYLE_TYPE[typeval] == str:
tag_name = "%d %s" % (typeval, s_tagvalue)
elif type.STYLE_TYPE[typeval] == int:
tag_name = "%d %d" % (typeval, s_tagvalue)
if not tag_name:
return None
tags = self.STYLETAG_MARKUP.get(tag_name)
if tags is not None:
return tags
#no tag known yet, create the markup, add to lookup, and return
tags = self._create_xmltag(self.STYLETYPE_MAP[typeval], s_tagvalue)
self.STYLETAG_MARKUP[tag_name] = tags
return tags
def _create_xmltag(self, type, value):
"""
Create the xmltags for the backend.
Overwrite this method to create functionality with a backend
"""
if type not in self.SUPPORTED_MARKUP:
return None
return ('', '')
def add_markup_from_styled(self, text, s_tags, split=''):
"""
Input is plain text, output is text with markup added according to the
s_tags which are assumed to be styledtexttags.
When split is given the text will be split over the value given, and
tags applied in such a way that it the text can be safely splitted in
pieces along split
@param text : str, a piece of text
@param s_tags : styledtexttags that must be applied to the text
@param split : str, optional. A string along which the output can
be safely split without breaking the styling.
As adding markup means original text must be escaped, ESCAPE_FUNC is
used
This can be used to convert the text of a styledtext to the format
needed for a document backend
Do not call this method in a report, use the write_markup method
@note: the algorithm is complex as it assumes mixing of tags is not
allowed: eg <b>text<i> here</b> not</i> is assumed invalid
as markup. If the s_tags require such a setup, what is returned
is <b>text</b><i><b> here</b> not</i>
overwrite this method if this complexity is not needed.
"""
FIRST = 0
LAST = 1
tagspos = {}
for s_tag in s_tags:
tag = self.find_tag_by_stag(s_tag)
if tag is not None:
for (start, end) in s_tag.ranges:
if start in tagspos:
tagspos[start] += [(tag, FIRST)]
else:
tagspos[start] = [(tag, FIRST)]
if end in tagspos:
tagspos[end] = [(tag, LAST)] + tagspos[end]
else:
tagspos[end] = [(tag, LAST)]
start = 0
end = len(text)
keylist = tagspos.keys()
keylist.sort()
keylist = [x for x in keylist if x<=len(text)]
opentags = []
otext = u"" #the output, text with markup
lensplit = len(split)
for pos in keylist:
#write text up to tag
if pos > start:
if split:
#make sure text can split
splitpos = text[start:pos].find(split)
while splitpos <> -1:
otext += self.ESCAPE_FUNC()(text[start:start+splitpos])
#close open tags
for opentag in reversed(opentags):
otext += opentag[1]
#add split text
otext += self.ESCAPE_FUNC()(split)
#open the tags again
for opentag in opentags:
otext += opentag[0]
#obtain new values
start = start + splitpos + lensplit
splitpos = text[start:pos].find(split)
otext += self.ESCAPE_FUNC()(text[start:pos])
#write out tags
for tag in tagspos[pos]:
#close open tags starting from last open
for opentag in reversed(opentags):
otext += opentag[1]
#if start, add to opentag in beginning as first to open
if tag[1] == FIRST:
opentags = [tag[0]] + opentags
else:
#end tag, is closed already, remove from opentag
opentags = [x for x in opentags if not x == tag[0] ]
#now all tags are closed, open the ones that should open
for opentag in opentags:
otext += opentag[0]
start = pos
#add remainder of text, no markup present there
otext += self.ESCAPE_FUNC()(text[start:end])
#opentags should be empty. If not, user gave tags on positions that
# are over the end of the text. Just close the tags still open
if opentags:
print 'WARNING: DocBackend : More style tags in text than length '\
'of text allows.\n', opentags
for opentag in reversed(opentags):
otext += opentag[1]
return otext
def _add_markup_from_styled(self, text, s_tags, split=''):
"""
Input is plain text, output is text with markup added according to the
s_tags which are assumed to be styledtexttags.
When split is given the text will be split over the value given, and
tags applied in such a way that it the text can be safely splitted in
pieces along split
@param text : str, a piece of text
@param s_tags : styledtexttags that must be applied to the text
@param split : str, optional. A string along which the output can
be safely split without breaking the styling.
As adding markup means original text must be escaped, ESCAPE_FUNC is
used
This can be used to convert the text of a styledtext to the format
needed for a document backend
Do not call this method in a report, use the write_markup method
@note: the algorithm is complex as it assumes mixing of tags is not
allowed: eg <b>text<i> here</b> not</i> is assumed invalid
as markup. If the s_tags require such a setup, what is returned
is <b>text</b><i><b> here</b> not</i>
overwrite this method if this complexity is not needed.
"""
FIRST = 0
LAST = 1
tagspos = {}
for s_tag in s_tags:
tag = self.find_tag_by_stag(s_tag)
if tag is not None:
for (start, end) in s_tag.ranges:
if start in tagspos:
tagspos[start] += [(tag, FIRST)]
else:
tagspos[start] = [(tag, FIRST)]
if end in tagspos:
tagspos[end] += [(tag, LAST)]
else:
tagspos[end] = [(tag, LAST)]
start = 0
end = len(text)
keylist = tagspos.keys()
keylist.sort()
keylist = [x for x in keylist if x<=len(text)]
opentags = []
otext = u"" #the output, text with markup
lensplit = len(split)
for pos in keylist:
#write text up to tag
if pos > start:
if split:
#make sure text can split
splitpos = text[start:pos].find(split)
while splitpos <> -1:
otext += self.ESCAPE_FUNC()(text[start:start+splitpos])
#close open tags
for opentag in reversed(opentags):
otext += opentag[1]
#add split text
otext += self.ESCAPE_FUNC()(split)
#open the tags again
for opentag in opentags:
otext += opentag[0]
#obtain new values
start = start + splitpos + lensplit
splitpos = text[start:pos].find(split)
otext += self.ESCAPE_FUNC()(text[start:pos])

View File

@ -0,0 +1,173 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Benny Malengier
#
# 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
#
# $Id: docbackend.py 12437 2009-04-13 02:11:49Z pez4brian $
"""File and File format management for latex docs
"""
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
#-------------------------------------------------------------------------
#
# GTK modules
#
#-------------------------------------------------------------------------
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from docbackend import DocBackend
#------------------------------------------------------------------------
#
# Set up logging
#
#------------------------------------------------------------------------
import logging
log = logging.getLogger(".latexbackend.py")
#------------------------------------------------------------------------
#
# Functions
#
#------------------------------------------------------------------------
def latexescape(text):
"""
change text in text that latex shows correctly
special characters: \& \$ \% \# \_ \{ \}
"""
text = text.replace('&','\\&')
text = text.replace('$','\\$')
text = text.replace('%','\\%')
text = text.replace('#','\\#')
text = text.replace('_','\\_')
text = text.replace('{','\\{')
text = text.replace('}','\\}')
return text
def latexescapeverbatim(text):
"""
change text in text that latex shows correctly respecting whitespace
special characters: \& \$ \% \# \_ \{ \}
Now also make sure space and newline is respected
"""
text = text.replace('&', '\\&')
text = text.replace('$', '\\$')
text = text.replace('%', '\\%')
text = text.replace('#', '\\#')
text = text.replace('_', '\\_')
text = text.replace('{', '\\{')
text = text.replace('}', '\\}')
text = text.replace(' ', '\\ ')
text = text.replace('\n', '\\newline\n')
#spaces at begin are normally ignored, make sure they are not.
#due to above a space at begin is now \newline\n\
text = text.replace('\\newline\n\\ ', '\\newline\n\\hspace*{0.1cm}\\ ')
return text
#------------------------------------------------------------------------
#
# Document Backend class for cairo docs
#
#------------------------------------------------------------------------
class LateXBackend(DocBackend):
"""
Implementation of docbackend for latex docs.
"""
# overwrite base class attributes, they become static var of LaTeXDoc
SUPPORTED_MARKUP = [
DocBackend.BOLD,
DocBackend.ITALIC,
DocBackend.UNDERLINE,
DocBackend.FONTSIZE,
DocBackend.FONTFACE,
DocBackend.SUPERSCRIPT ]
STYLETAG_MARKUP = {
DocBackend.BOLD : ("\\textbf{", "}"),
DocBackend.ITALIC : ("\\textit{", "}"),
DocBackend.UNDERLINE : ("\\underline{", "}"),
DocBackend.SUPERSCRIPT : ("\\textsuperscript{", "}"),
}
ESCAPE_FUNC = lambda x: latexescape
def setescape(self, preformatted=False):
"""
Latex needs two different escape functions depending on the type.
This function allows to switch the escape function
"""
if not preformatted:
LateXBackend.ESCAPE_FUNC = lambda x: latexescape
else:
LateXBackend.ESCAPE_FUNC = lambda x: latexescapeverbatim
def _create_xmltag(self, type, value):
"""
overwrites the method in DocBackend.
creates the latex tags needed for non bool style types we support:
FONTSIZE : use different \large denomination based
on size
: very basic, in mono in the font face
then we use {\ttfamily }
"""
if type not in self.SUPPORTED_MARKUP:
return None
elif type == DocBackend.FONTSIZE:
#translate size in point to something LaTeX can work with
if value >= 22:
return ("{\\Huge ", "}")
elif value >= 20:
return ("{\\huge ", "}")
elif value >= 18:
return ("{\\LARGE ", "}")
elif value >= 16:
return ("{\\Large ", "}")
elif value >= 14:
return ("{\\large ", "}")
elif value < 8:
return ("{\\scriptsize ", "}")
elif value < 10:
return ("{\\footnotesize ", "}")
elif value < 12:
return ("{\\small ", "}")
else:
return ("", "")
elif type == DocBackend.FONTFACE:
if 'MONO' in value.upper():
return ("{\\ttfamily ", "}")
elif 'ROMAN' in value.upper():
return ("{\\rmfamily ", "}")
return None
def _checkfilename(self):
"""
Check to make sure filename satisfies the standards for this filetype
"""
if self._filename[-4:] != ".tex":
self._filename = self._filename + ".tex"

View File

@ -30,7 +30,7 @@ Option class representing a document style.
#
#-------------------------------------------------------------------------
from gen.plug.menu import EnumeratedListOption
import BaseDoc
from gen.plug.docgen import StyleSheetList
#-------------------------------------------------------------------------
#
@ -47,9 +47,9 @@ class StyleOption(EnumeratedListOption):
@param label: A friendly label to be applied to this option.
Example: "Style"
@type label: string
@param default_style: A BaseDoc.StyleSheet instance which provides the
@param default_style: A docgen StyleSheet instance which provides the
default styles.
@type default_style: BaseDoc.StyleSheet
@type default_style: docgen StyleSheet
@param module_name: The name of the module the style sheets belong to.
Example: "web_cal"
@type module_name: string
@ -60,7 +60,7 @@ class StyleOption(EnumeratedListOption):
self.__default_style = default_style
self.__default_style.set_name("default")
self.__style_file = "%s_style.xml" % module_name
style_list = BaseDoc.StyleSheetList(self.__style_file,
style_list = StyleSheetList(self.__style_file,
self.__default_style)
for style_name in style_list.get_style_names():
self.add_item(style_name, style_name)
@ -75,6 +75,6 @@ class StyleOption(EnumeratedListOption):
def get_style(self):
""" Get the selected style """
style_list = BaseDoc.StyleSheetList(self.__style_file,
style_list = StyleSheetList(self.__style_file,
self.__default_style)
return style_list.get_style_sheet(self.get_value())

View File

@ -69,7 +69,7 @@ import const
import Utils
import ListModel
import Errors
import BaseDoc
from gen.plug.docgen import StyleSheet, StyleSheetList
from QuestionDialog import WarningDialog, ErrorDialog
from gen.plug import PluginManager
from gen.plug.menu import PersonOption, FilterOption, FamilyOption
@ -1093,17 +1093,17 @@ class BookReportDialog(DocReportDialog):
'book', _("Book Report"))
self.book = book
self.database = dbstate.db
self.selected_style = BaseDoc.StyleSheet()
self.selected_style = StyleSheet()
for item in self.book.get_item_list():
# Set up default style
default_style = BaseDoc.StyleSheet()
default_style = StyleSheet()
make_default_style = item.option_class.make_default_style
make_default_style(default_style)
# Read all style sheets available for this item
style_file = item.option_class.handler.get_stylesheet_savefile()
style_list = BaseDoc.StyleSheetList(style_file, default_style)
style_list = StyleSheetList(style_file, default_style)
# Get the selected stylesheet
style_name = item.option_class.handler.get_default_stylesheet_name()
@ -1205,17 +1205,17 @@ def cl_report(database, name, category, options_str_dict):
book_list = BookList('books.xml', database)
book_name = clr.options_dict['bookname']
book = book_list.get_book(book_name)
selected_style = BaseDoc.StyleSheet()
selected_style = StyleSheet()
for item in book.get_item_list():
# Set up default style
default_style = BaseDoc.StyleSheet()
default_style = StyleSheet()
make_default_style = item.option_class.make_default_style
make_default_style(default_style)
# Read all style sheets available for this item
style_file = item.option_class.handler.get_stylesheet_savefile()
style_list = BaseDoc.StyleSheetList(style_file, default_style)
style_list = StyleSheetList(style_file, default_style)
# Get the selected stylesheet
style_name = item.option_class.handler.get_default_stylesheet_name()

View File

@ -35,7 +35,8 @@ from TransUtils import sgettext as _
#
#------------------------------------------------------------------------
from gen.lib import ChildRefType, Date, EventType, Name
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import FONT_SANS_SERIF
from BasicUtils import name_displayer
from DataViews import register, Gramplet
from gen.plug.menu import (BooleanOption, EnumeratedListOption,
@ -500,29 +501,29 @@ class RecordsReportOptions(MenuReportOptions):
def make_default_style(self, default_style):
#Paragraph Styles
font = BaseDoc.FontStyle()
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font = FontStyle()
font.set_type_face(FONT_SANS_SERIF)
font.set_size(10)
font.set_bold(0)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_font(font)
para.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style('REC-Normal', para)
font = BaseDoc.FontStyle()
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font = FontStyle()
font.set_type_face(FONT_SANS_SERIF)
font.set_size(10)
font.set_bold(1)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_font(font)
para.set_description(_('The style used for headings.'))
default_style.add_paragraph_style('REC-Heading', para)
font = BaseDoc.FontStyle()
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font = FontStyle()
font.set_type_face(FONT_SANS_SERIF)
font.set_size(12)
font.set_bold(1)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_font(font)
para.set_description(_("The style used for the report title"))
default_style.add_paragraph_style('REC-Title', para)

View File

@ -34,7 +34,8 @@ from gettext import gettext as _
# Gramps modules
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import BaseDoc, TextDoc
from gen.plug.docgen.basedoc import (PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER)
from gen.plug import PluginManager, DocGenPlugin
import Errors
import Utils
@ -120,7 +121,7 @@ def reformat_para(para='',left=0,right=72,just=LEFT,right_pad=0,first=0):
# Ascii
#
#------------------------------------------------------------------------
class AsciiDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
class AsciiDoc(BaseDoc,TextDoc):
#--------------------------------------------------------------------
#
@ -196,9 +197,9 @@ class AsciiDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
#
#--------------------------------------------------------------------
def end_paragraph(self):
if self.p.get_alignment() == BaseDoc.PARA_ALIGN_RIGHT:
if self.p.get_alignment() == PARA_ALIGN_RIGHT:
fmt = RIGHT
elif self.p.get_alignment() == BaseDoc.PARA_ALIGN_CENTER:
elif self.p.get_alignment() == PARA_ALIGN_CENTER:
fmt = CENTER
else:
fmt = LEFT

View File

@ -42,7 +42,7 @@ from math import radians
# Gramps modules
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen.basedoc import PAPER_PORTRAIT
import libcairodoc
from gen.plug import PluginManager, DocGenPlugin
import Errors
@ -95,10 +95,10 @@ MARGIN = 6
#------------------------------------------------------------------------
def paperstyle_to_pagesetup(paper_style):
"""Convert a BaseDoc.PaperStyle instance into a gtk.PageSetup instance.
"""Convert a PaperStyle instance into a gtk.PageSetup instance.
@param paper_style: Gramps paper style object to convert
@param type: BaseDoc.PaperStyle
@param type: PaperStyle
@return: page_setup
@rtype: gtk.PageSetup
"""
@ -149,7 +149,7 @@ def paperstyle_to_pagesetup(paper_style):
page_setup.set_paper_size(paper_size)
# Set paper orientation
if paper_style.get_orientation() == BaseDoc.PAPER_PORTRAIT:
if paper_style.get_orientation() == PAPER_PORTRAIT:
page_setup.set_orientation(gtk.PAGE_ORIENTATION_PORTRAIT)
else:
page_setup.set_orientation(gtk.PAGE_ORIENTATION_LANDSCAPE)

View File

@ -42,7 +42,8 @@ import ImgManip
import tarfile
import const
import Errors
import BaseDoc
from gen.plug.docgen import BaseDoc, TextDoc
from gen.plug.docgen.basedoc import FONT_SANS_SERIF
from QuestionDialog import ErrorDialog, WarningDialog
import Utils
@ -94,10 +95,10 @@ _bottom = [
# HtmlDoc
#
#------------------------------------------------------------------------
class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
class HtmlDoc(BaseDoc,TextDoc):
def __init__(self,styles,type,template):
BaseDoc.BaseDoc.__init__(self,styles,None,template)
BaseDoc.__init__(self,styles,None,template)
self.year = time.localtime(time.time())[0]
self.ext = '.html'
self.meta = ""
@ -306,7 +307,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
italic = 'font-style:italic; '
if font.get_bold():
bold = 'font-weight:bold; '
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
if font.get_type_face() == FONT_SANS_SERIF:
family = '"Helvetica","Arial","sans-serif"'
else:
family = '"Times New Roman","Times","serif"'

View File

@ -39,9 +39,11 @@ from gettext import gettext as _
# gramps modules
#
#------------------------------------------------------------------------
import BaseDoc
from docbackend.latexbackend import LateXBackend, latexescape
from gen.plug import PluginManager, DocGenPlugin
from gen.plug.docgen import BaseDoc, TextDoc
from gen.plug.docgen.basedoc import PAPER_LANDSCAPE, FONT_SANS_SERIF
from gen.plug.docbackend import LateXBackend, latexescape
import ImgManip
import Errors
import Utils
@ -129,7 +131,7 @@ class TexFont(object):
#
#------------------------------------------------------------------------
class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
class LaTeXDoc(BaseDoc, TextDoc):
"""LaTeX document interface class. Derived from BaseDoc"""
def page_break(self):
@ -147,7 +149,7 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
options = "12pt"
if self.paper.get_orientation() == BaseDoc.PAPER_LANDSCAPE:
if self.paper.get_orientation() == PAPER_LANDSCAPE:
options = options + ",landscape"
# Paper selections are somewhat limited on a stock installation.
@ -235,7 +237,7 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
thisstyle.font_beg = thisstyle.font_beg + "\\hfill"
# Establish font face and shape
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
if font.get_type_face() == FONT_SANS_SERIF:
thisstyle.font_beg = thisstyle.font_beg + "\\sffamily"
thisstyle.font_end = "\\rmfamily" + thisstyle.font_end
if font.get_bold():

View File

@ -44,7 +44,10 @@ from xml.sax.saxutils import escape
# Gramps modules
#
#-------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import BaseDoc, TextDoc, DrawDoc
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, DASHED, PAPER_PORTRAIT,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT,
INDEX_TYPE_ALP, PARA_ALIGN_RIGHT)
import const
from gen.plug import PluginManager, DocGenPlugin
from ReportBase import ReportUtils
@ -74,10 +77,10 @@ _esc_map = {
# ODFDoc
#
#-------------------------------------------------------------------------
class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
class ODFDoc(BaseDoc, TextDoc, DrawDoc):
def __init__(self, styles, type, template):
BaseDoc.BaseDoc.__init__(self, styles, type, template)
BaseDoc.__init__(self, styles, type, template)
self.media_list = []
self.cntnt = None
self.filename = None
@ -180,7 +183,7 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
self.cntnt.write('draw:stroke="none" ')
self.cntnt.write('draw:stroke-color="#000000" ')
if style.get_line_style() == BaseDoc.DASHED:
if style.get_line_style() == DASHED:
self.cntnt.write('svg:fill-color="#cccccc" ')
else:
self.cntnt.write('svg:fill-color="#%02x%02x%02x" ' % style.get_color())
@ -249,18 +252,18 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
self.cntnt.write('fo:keep-with-next="true" ')
align = style.get_alignment()
if align == BaseDoc.PARA_ALIGN_LEFT:
if align == PARA_ALIGN_LEFT:
self.cntnt.write('fo:text-align="start" ')
elif align == BaseDoc.PARA_ALIGN_RIGHT:
elif align == PARA_ALIGN_RIGHT:
self.cntnt.write('fo:text-align="end" ')
elif align == BaseDoc.PARA_ALIGN_CENTER:
elif align == PARA_ALIGN_CENTER:
self.cntnt.write('fo:text-align="center" ')
self.cntnt.write('style:justify-single-word="false" ')
else:
self.cntnt.write('fo:text-align="justify" ')
self.cntnt.write('style:justify-single-word="false" ')
font = style.get_font()
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
if font.get_type_face() == FONT_SANS_SERIF:
self.cntnt.write('style:font-name="Arial" ')
else:
self.cntnt.write('style:font-name="Times New Roman" ')
@ -287,15 +290,15 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
self.cntnt.write('style:family="text">\n')
self.cntnt.write('<style:text-properties ')
align = style.get_alignment()
if align == BaseDoc.PARA_ALIGN_LEFT:
if align == PARA_ALIGN_LEFT:
self.cntnt.write('fo:text-align="start" ')
elif align == BaseDoc.PARA_ALIGN_RIGHT:
elif align == PARA_ALIGN_RIGHT:
self.cntnt.write('fo:text-align="end" ')
elif align == BaseDoc.PARA_ALIGN_CENTER:
elif align == PARA_ALIGN_CENTER:
self.cntnt.write('fo:text-align="center" ')
self.cntnt.write('style:justify-single-word="false" ')
font = style.get_font()
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
if font.get_type_face() == FONT_SANS_SERIF:
self.cntnt.write('style:font-name="Arial" ')
else:
self.cntnt.write('style:font-name="Times New Roman" ')
@ -687,12 +690,12 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
self.sfile.write('fo:keep-with-next="always" ')
align = style.get_alignment()
if align == BaseDoc.PARA_ALIGN_LEFT:
if align == PARA_ALIGN_LEFT:
self.sfile.write('fo:text-align="start" ')
self.sfile.write('style:justify-single-word="false" ')
elif align == BaseDoc.PARA_ALIGN_RIGHT:
elif align == PARA_ALIGN_RIGHT:
self.sfile.write('fo:text-align="end" ')
elif align == BaseDoc.PARA_ALIGN_CENTER:
elif align == PARA_ALIGN_CENTER:
self.sfile.write('fo:text-align="center" ')
self.sfile.write('style:justify-single-word="false" ')
else:
@ -704,7 +707,7 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
font = style.get_font()
color = font.get_color()
self.sfile.write('fo:color="#%02x%02x%02x" ' % color)
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
if font.get_type_face() == FONT_SANS_SERIF:
self.sfile.write('style:font-name="Arial" ')
else:
self.sfile.write('style:font-name="Times New Roman" ')
@ -771,7 +774,7 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
self.sfile.write('<style:page-layout-properties fo:page-width="%.2fcm" ' % self.paper.get_size().get_width())
self.sfile.write('fo:page-height="%.2fcm" ' % self.paper.get_size().get_height())
self.sfile.write('style:num-format="1" ')
if self.paper.get_orientation() == BaseDoc.PAPER_PORTRAIT:
if self.paper.get_orientation() == PAPER_PORTRAIT:
self.sfile.write('style:print-orientation="portrait" ')
else:
self.sfile.write('style:print-orientation="landscape" ')
@ -887,10 +890,10 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
if mark:
key = escape(mark.key, _esc_map)
key = key.replace('"', '&quot;')
if mark.type == BaseDoc.INDEX_TYPE_ALP:
if mark.type == INDEX_TYPE_ALP:
self.cntnt.write('<text:alphabetical-index-mark ')
self.cntnt.write('text:string-value="%s" />' % key)
elif mark.type == BaseDoc.INDEX_TYPE_TOC:
elif mark.type == INDEX_TYPE_TOC:
self.cntnt.write('<text:toc-mark ')
self.cntnt.write('text:string-value="%s" ' % key)
self.cntnt.write('text:outline-level="%d" />' % mark.level)

View File

@ -33,7 +33,8 @@ from gettext import gettext as _
#-------------------------------------------------------------------------
from ReportBase import ReportUtils
from gen.plug import PluginManager, DocGenPlugin
import BaseDoc
from gen.plug.docgen import BaseDoc, DrawDoc
from gen.plug.docgen.basedoc import FONT_SERIF, PAPER_PORTRAIT, SOLID
import Errors
from Utils import gformat
@ -51,10 +52,10 @@ def coords(grp):
# PSDrawDoc
#
#-------------------------------------------------------------------------
class PSDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
class PSDrawDoc(BaseDoc,DrawDoc):
def __init__(self,styles,type,template):
BaseDoc.BaseDoc.__init__(self,styles,type,template)
BaseDoc.__init__(self,styles,type,template)
self.f = None
self.filename = None
self.level = 0
@ -62,7 +63,7 @@ class PSDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
def fontdef(self,para):
font = para.get_font()
if font.get_type_face() == BaseDoc.FONT_SERIF:
if font.get_type_face() == FONT_SERIF:
if font.get_bold():
if font.get_italic():
font_name = "/Times-BoldItalic"
@ -108,7 +109,7 @@ class PSDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
self.f.write('%%LanguageLevel: 2\n')
self.f.write('%%Pages: (atend)\n')
self.f.write('%%PageOrder: Ascend\n')
if self.paper.get_orientation() != BaseDoc.PAPER_PORTRAIT:
if self.paper.get_orientation() != PAPER_PORTRAIT:
self.f.write('%%Orientation: Landscape\n')
else:
self.f.write('%%Orientation: Portrait\n')
@ -145,7 +146,7 @@ class PSDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
self.page = self.page + 1
self.f.write("%%Page:")
self.f.write("%d %d\n" % (self.page,self.page))
if self.paper.get_orientation() != BaseDoc.PAPER_PORTRAIT:
if self.paper.get_orientation() != PAPER_PORTRAIT:
self.f.write('90 rotate %s cm %s cm translate\n' % (
gformat(0),gformat(-1*self.paper.get_size().get_height())))
@ -242,7 +243,7 @@ class PSDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
self.f.write('gsave\n')
self.f.write('newpath\n')
self.f.write('%s setlinewidth\n' % gformat(stype.get_line_width()))
if stype.get_line_style() == BaseDoc.SOLID:
if stype.get_line_style() == SOLID:
self.f.write('[] 0 setdash\n')
else:
self.f.write('[2 4] 0 setdash\n')
@ -274,7 +275,7 @@ class PSDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
self.f.write('%s cm %s cm moveto\n' % coords(self.translate(x1,y1)))
self.f.write('%s cm %s cm lineto\n' % coords(self.translate(x2,y2)))
self.f.write('%s setlinewidth\n' % gformat(stype.get_line_width()))
if stype.get_line_style() == BaseDoc.SOLID:
if stype.get_line_style() == SOLID:
self.f.write('[] 0 setdash\n')
else:
self.f.write('[2 4] 0 setdash\n')

View File

@ -34,7 +34,9 @@ from gettext import gettext as _
# Load the base BaseDoc class
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import BaseDoc, TextDoc
from gen.plug.docgen.basedoc import (FONT_SERIF, PARA_ALIGN_RIGHT
, PARA_ALIGN_CENTER, PARA_ALIGN_JUSTIFY)
from gen.plug import PluginManager, DocGenPlugin
import ImgManip
import Errors
@ -58,7 +60,7 @@ def twips(cm):
# use style sheets. Instead it writes raw formatting.
#
#------------------------------------------------------------------------
class RTFDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
class RTFDoc(BaseDoc,TextDoc):
#--------------------------------------------------------------------
#
@ -156,7 +158,7 @@ class RTFDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
size = f.get_size()*2
bgindex = self.color_map[p.get_background_color()]
fgindex = self.color_map[f.get_color()]
if f.get_type_face() == BaseDoc.FONT_SERIF:
if f.get_type_face() == FONT_SERIF:
self.font_type = '\\f0\\fs%d\\cf%d\\cb%d' % (size,fgindex,bgindex)
else:
self.font_type = '\\f1\\fs%d\\cf%d\\cb%d' % (size,fgindex,bgindex)
@ -171,14 +173,14 @@ class RTFDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc):
if not self.in_table:
self.f.write('\\pard')
if p.get_alignment() == BaseDoc.PARA_ALIGN_RIGHT:
if p.get_alignment() == PARA_ALIGN_RIGHT:
self.f.write('\\qr')
elif p.get_alignment() == BaseDoc.PARA_ALIGN_CENTER:
elif p.get_alignment() == PARA_ALIGN_CENTER:
self.f.write('\\qc')
self.f.write('\\ri%d' % twips(p.get_right_margin()))
self.f.write('\\li%d' % twips(p.get_left_margin()))
self.f.write('\\fi%d' % twips(p.get_first_indent()))
if p.get_alignment() == BaseDoc.PARA_ALIGN_JUSTIFY:
if p.get_alignment() == PARA_ALIGN_JUSTIFY:
self.f.write('\\qj')
if p.get_padding():
self.f.write('\\sa%d' % twips(p.get_padding()/2.0))

View File

@ -35,7 +35,8 @@ import StringIO
#
#-------------------------------------------------------------------------
from gen.plug import PluginManager, DocGenPlugin
import BaseDoc
from gen.plug.docgen import BaseDoc, DrawDoc
from gen.plug.docgen.basedoc import FONT_SANS_SERIF
import Errors
#-------------------------------------------------------------------------
@ -43,10 +44,10 @@ import Errors
# SvgDrawDoc
#
#-------------------------------------------------------------------------
class SvgDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
class SvgDrawDoc(BaseDoc, DrawDoc):
def __init__(self,styles,type,template):
BaseDoc.BaseDoc.__init__(self,styles,type,template)
BaseDoc.__init__(self,styles,type,template)
self.f = None
self.filename = None
self.level = 0
@ -112,7 +113,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
if font.get_italic():
self.t.write('font-style:italic;')
self.t.write('font-size:%d; ' % size)
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
if font.get_type_face() == FONT_SANS_SERIF:
self.t.write('font-family:sans-serif;')
else:
self.t.write('font-family:serif;')
@ -206,7 +207,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
if font.get_italic():
self.t.write(' font-style:italic;')
self.t.write(' font-size:%d;' % font_size)
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
if font.get_type_face() == FONT_SANS_SERIF:
self.t.write(' font-family:sans-serif;')
else:
self.t.write(' font-family:serif;')
@ -235,7 +236,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc):
if font.get_italic():
self.t.write('font-style:italic;')
self.t.write('font-size:%d; ' % font_size)
if font.get_type_face() == BaseDoc.FONT_SANS_SERIF:
if font.get_type_face() == FONT_SANS_SERIF:
self.t.write('font-family:sans-serif;')
else:
self.t.write('font-family:serif;')

View File

@ -35,7 +35,8 @@ from TransUtils import sgettext as _
# GRAMPS modules
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle, GraphicsStyle
from gen.plug.docgen.basedoc import FONT_SANS_SERIF, PARA_ALIGN_CENTER
from SubstKeywords import SubstKeywords
from gen.plug import PluginManager
from gen.plug.menu import BooleanOption, NumberOption, TextOption, PersonOption
@ -488,38 +489,38 @@ class AncestorTreeOptions(MenuReportOptions):
"""Make the default output style for the Ancestor Tree."""
## Paragraph Styles:
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(9)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("AC2-Normal", p)
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(16)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_('The basic style used for the title display.'))
default_style.add_paragraph_style("AC2-Title", p)
## Draw styles
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("AC2-Normal")
g.set_shadow(1, 0.2)
g.set_fill_color((255, 255, 255))
default_style.add_draw_style("AC2-box", g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("AC2-Title")
g.set_color((0, 0, 0))
g.set_fill_color((255, 255, 255))
g.set_line_width(0)
default_style.add_draw_style("AC2-title", g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
default_style.add_draw_style("AC2-line", g)
#------------------------------------------------------------------------

View File

@ -34,7 +34,9 @@ import time
# GRAMPS modules
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle, GraphicsStyle
from gen.plug.docgen.basedoc import (FONT_SERIF, PARA_ALIGN_CENTER
, PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT)
from BasicUtils import name_displayer
from gen.plug import PluginManager
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_DRAW
@ -461,17 +463,17 @@ class CalendarOptions(MenuReportOptions):
self.__filter.set_filters(filter_list)
def make_my_style(self, default_style, name, description,
size=9, font=BaseDoc.FONT_SERIF, justified ="left",
color=None, align=BaseDoc.PARA_ALIGN_CENTER,
size=9, font=FONT_SERIF, justified ="left",
color=None, align=PARA_ALIGN_CENTER,
shadow = None, italic=0, bold=0, borders=0, indent=None):
""" Create paragraph and graphic styles of the same name """
# Paragraph:
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(size)
f.set_type_face(font)
f.set_italic(italic)
f.set_bold(bold)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(align)
p.set_description(description)
@ -482,14 +484,14 @@ class CalendarOptions(MenuReportOptions):
if indent:
p.set(first_indent=indent)
if justified == "left":
p.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
p.set_alignment(PARA_ALIGN_LEFT)
elif justified == "right":
p.set_alignment(BaseDoc.PARA_ALIGN_RIGHT)
p.set_alignment(PARA_ALIGN_RIGHT)
elif justified == "center":
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
default_style.add_paragraph_style(name, p)
# Graphics:
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style(name)
if shadow:
g.set_shadow(*shadow)

View File

@ -35,7 +35,8 @@ from gen.plug.menu import TextOption, NumberOption, BooleanOption, PersonOption
from ReportBase import Report, MenuReportOptions, ReportUtils, CATEGORY_DRAW
from SubstKeywords import SubstKeywords
from TransUtils import sgettext as _
import BaseDoc
from gen.plug.docgen import GraphicsStyle, FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import FONT_SANS_SERIF, PARA_ALIGN_CENTER
#------------------------------------------------------------------------
#
@ -487,38 +488,38 @@ class DescendTreeOptions(MenuReportOptions):
def make_default_style(self,default_style):
"""Make the default output style for the Ancestor Tree."""
## Paragraph Styles:
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(9)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("DC2-Normal", p)
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(16)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_('The basic style used for the title display.'))
default_style.add_paragraph_style("DC2-Title", p)
## Draw styles
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("DC2-Normal")
g.set_shadow(1, 0.2)
g.set_fill_color((255, 255, 255))
default_style.add_draw_style("DC2-box", g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("DC2-Title")
g.set_color((0, 0, 0))
g.set_fill_color((255, 255, 255))
g.set_line_width(0)
default_style.add_draw_style("DC2-title", g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
default_style.add_draw_style("DC2-line", g)
#------------------------------------------------------------------------

View File

@ -33,7 +33,8 @@ from gettext import gettext as _
# gramps modules
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle, GraphicsStyle
from gen.plug.docgen.basedoc import FONT_SANS_SERIF, PARA_ALIGN_CENTER
from gen.plug import PluginManager
from gen.plug.menu import EnumeratedListOption, NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_DRAW
@ -383,46 +384,46 @@ class FanChartOptions(MenuReportOptions):
]
#Paragraph Styles
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(20)
f.set_bold(1)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_('The style used for the title.'))
default_style.add_paragraph_style("FC-Title",p)
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(9)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("text_style", p)
# GraphicsStyles
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('FC-Title')
g.set_line_width(0)
default_style.add_draw_style("t",g)
for i in range (0, self.MAX_GENERATIONS):
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_fill_color(BACKGROUND_COLORS[i])
g.set_paragraph_style('FC-Normal')
background_style_name = 'background_style' + '%d' % i
default_style.add_draw_style(background_style_name,g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_fill_color(BACKGROUND_COLORS[i])
g.set_paragraph_style('text_style')
g.set_line_width(0)
text_style_name = 'text_style' + '%d' % i
default_style.add_draw_style(text_style_name,g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_fill_color((255,255,255))
g.set_paragraph_style('FC-Normal')
default_style.add_draw_style('background_style_white',g)

View File

@ -43,7 +43,9 @@ from TransUtils import sgettext as _
# Person and relation types
from gen.lib import Person, FamilyRelType, EventType
# gender and report type names
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle, GraphicsStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, FONT_SERIF,
PARA_ALIGN_CENTER, PARA_ALIGN_LEFT)
from gen.plug import PluginManager
from gen.plug.menu import BooleanOption, NumberOption, EnumeratedListOption, \
FilterOption, PersonOption
@ -775,21 +777,21 @@ class StatisticsChartOptions(MenuReportOptions):
def make_default_style(self, default_style):
"""Make the default output style for the Statistics report."""
# Paragraph Styles
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(10)
f.set_type_face(BaseDoc.FONT_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
p.set_alignment(PARA_ALIGN_LEFT)
p.set_description(_("The style used for the items and values."))
default_style.add_paragraph_style("SC-Text",p)
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(14)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("SC-Title",p)
@ -802,14 +804,14 @@ class StatisticsChartOptions(MenuReportOptions):
SC-color-N - The colors for drawing pies.
SC-bar - A red bar with 0.5pt black line.
"""
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("SC-Title")
g.set_color((0,0,0))
g.set_fill_color((255,255,255))
g.set_line_width(0)
default_style.add_draw_style("SC-title",g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("SC-Text")
g.set_color((0,0,0))
g.set_fill_color((255,255,255))
@ -818,63 +820,63 @@ class StatisticsChartOptions(MenuReportOptions):
width = 0.8
# red
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('SC-Text')
g.set_color((0,0,0))
g.set_fill_color((255,0,0))
g.set_line_width(width)
default_style.add_draw_style("SC-color-0",g)
# orange
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('SC-Text')
g.set_color((0,0,0))
g.set_fill_color((255,158,33))
g.set_line_width(width)
default_style.add_draw_style("SC-color-1",g)
# green
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('SC-Text')
g.set_color((0,0,0))
g.set_fill_color((0,178,0))
g.set_line_width(width)
default_style.add_draw_style("SC-color-2",g)
# violet
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('SC-Text')
g.set_color((0,0,0))
g.set_fill_color((123,0,123))
g.set_line_width(width)
default_style.add_draw_style("SC-color-3",g)
# yellow
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('SC-Text')
g.set_color((0,0,0))
g.set_fill_color((255,255,0))
g.set_line_width(width)
default_style.add_draw_style("SC-color-4",g)
# blue
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('SC-Text')
g.set_color((0,0,0))
g.set_fill_color((0,105,214))
g.set_line_width(width)
default_style.add_draw_style("SC-color-5",g)
# gray
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('SC-Text')
g.set_color((0,0,0))
g.set_fill_color((210,204,210))
g.set_line_width(width)
default_style.add_draw_style("SC-color-6",g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_color((0,0,0))
g.set_fill_color((255,0,0))
g.set_line_width(width)
default_style.add_draw_style("SC-bar",g)
# legend
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style('SC-Text')
g.set_color((0,0,0))
g.set_fill_color((255,255,255))

View File

@ -41,7 +41,9 @@ from gen.plug import PluginManager
from gen.plug.menu import PersonOption, FilterOption, EnumeratedListOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_DRAW
pt2cm = ReportUtils.pt2cm
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle, GraphicsStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF,
DASHED, PARA_ALIGN_CENTER)
import Sort
from QuestionDialog import ErrorDialog
from BasicUtils import name_displayer
@ -363,29 +365,29 @@ class TimeLineOptions(MenuReportOptions):
def make_default_style(self,default_style):
"""Make the default output style for the Timeline report."""
# Paragraph Styles
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(10)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_description(_("The style used for the person's name."))
default_style.add_paragraph_style("TLG-Name",p)
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(8)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_("The style used for the year labels."))
default_style.add_paragraph_style("TLG-Label",p)
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(14)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
p = BaseDoc.ParagraphStyle()
f.set_type_face(FONT_SANS_SERIF)
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("TLG-Title",p)
@ -404,44 +406,44 @@ class TimeLineOptions(MenuReportOptions):
TLG-label - Contains the TLG-Label paragraph style used for the year
label's in the document.
"""
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_line_width(0.5)
g.set_color((0,0,0))
default_style.add_draw_style("TLG-line",g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_line_width(0.5)
g.set_color((0,0,0))
g.set_fill_color((0,0,0))
default_style.add_draw_style("TLG-solid",g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_line_width(0.5)
g.set_color((0,0,0))
g.set_fill_color((255,255,255))
default_style.add_draw_style("open",g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_line_width(0.5)
g.set_line_style(BaseDoc.DASHED)
g.set_line_style(DASHED)
g.set_color((0,0,0))
default_style.add_draw_style("TLG-grid",g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("TLG-Name")
g.set_color((0,0,0))
g.set_fill_color((255,255,255))
g.set_line_width(0)
default_style.add_draw_style("TLG-text",g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("TLG-Title")
g.set_color((0,0,0))
g.set_fill_color((255,255,255))
g.set_line_width(0)
default_style.add_draw_style("TLG-title",g)
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style("TLG-Label")
g.set_color((0,0,0))
g.set_fill_color((255,255,255))

View File

@ -38,11 +38,14 @@ from math import radians
# Gramps modules
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import BaseDoc, TextDoc, DrawDoc, ParagraphStyle,\
TableCellStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, FONT_SERIF,
FONT_MONOSPACE, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT)
from ReportBase import ReportUtils
from Errors import PluginError
from gen.plug import PluginManager, Plugin
from docbackend import CairoBackend
from gen.plug.docbackend import CairoBackend
#------------------------------------------------------------------------
#
@ -77,21 +80,21 @@ DEBUG = False
#------------------------------------------------------------------------
_TTF_FREEFONT = {
BaseDoc.FONT_SERIF: 'FreeSerif',
BaseDoc.FONT_SANS_SERIF: 'FreeSans',
BaseDoc.FONT_MONOSPACE: 'FreeMono',
FONT_SERIF: 'FreeSerif',
FONT_SANS_SERIF: 'FreeSans',
FONT_MONOSPACE: 'FreeMono',
}
_MS_TTFONT = {
BaseDoc.FONT_SERIF: 'Times New Roman',
BaseDoc.FONT_SANS_SERIF: 'Arial',
BaseDoc.FONT_MONOSPACE: 'Courier New',
FONT_SERIF: 'Times New Roman',
FONT_SANS_SERIF: 'Arial',
FONT_MONOSPACE: 'Courier New',
}
_GNOME_FONT = {
BaseDoc.FONT_SERIF: 'Serif',
BaseDoc.FONT_SANS_SERIF: 'Sans',
BaseDoc.FONT_MONOSPACE: 'Monospace',
FONT_SERIF: 'Serif',
FONT_SANS_SERIF: 'Sans',
FONT_MONOSPACE: 'Monospace',
}
font_families = _GNOME_FONT
@ -136,7 +139,7 @@ set_font_families()
#------------------------------------------------------------------------
def fontstyle_to_fontdescription(font_style):
"""Convert a BaseDoc.FontStyle instance to a pango.FontDescription one.
"""Convert a FontStyle instance to a pango.FontDescription one.
Font color and underline are not implemented in pango.FontDescription,
and have to be set with pango.Layout.set_attributes(attrlist) method.
@ -179,7 +182,7 @@ def tabstops_to_tabarray(tab_stops, dpi):
##class RowStyle(list):
##"""Specifies the format of a table row.
##RowStyle extents the available styles in BaseDoc.
##RowStyle extents the available styles in
##The RowStyle contains the width of each column as a percentage of the
##width of the full row. Note! The width of the row is not known until
@ -390,7 +393,7 @@ class GtkDocParagraph(GtkDocBaseElement):
_type = 'PARAGRAPH'
_allowed_children = []
# line spacing is not defined in BaseDoc.ParagraphStyle
# line spacing is not defined in ParagraphStyle
spacing = 2
def __init__(self, style, leader=None):
@ -529,7 +532,7 @@ class GtkDocParagraph(GtkDocBaseElement):
layout_line = layout.get_line(splitline)
index = layout_line.start_index
# and divide the text, first create the second part
new_style = BaseDoc.ParagraphStyle(self._style)
new_style = ParagraphStyle(self._style)
new_style.set_top_margin(0)
#we split a paragraph, text should begin in correct position: no indent
#as if the paragraph just continues from normal text
@ -809,7 +812,7 @@ class GtkDocTableCell(GtkDocBaseElement):
available_height -= child_height
if e2 is not None:
#divide the cell
new_style = BaseDoc.TableCellStyle(self._style)
new_style = TableCellStyle(self._style)
if e1 is not None:
new_style.set_top_border(False)
new_cell = GtkDocTableCell(new_style, self._span)
@ -1114,7 +1117,7 @@ class GtkDocText(GtkDocBaseElement):
_type = 'TEXT'
_allowed_children = []
# line spacing is not defined in BaseDoc.ParagraphStyle
# line spacing is not defined in ParagraphStyle
spacing = 0
def __init__(self, style, vertical_alignment, text, x, y, angle=0):
@ -1189,7 +1192,7 @@ class GtkDocText(GtkDocBaseElement):
# CairoDoc class
#
#------------------------------------------------------------------------
class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
class CairoDoc(BaseDoc, TextDoc, DrawDoc):
"""Act as an abstract document that can render onto a cairo context.
Maintains an abstract model of the document. The root of this abstract
@ -1421,7 +1424,7 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
paragraph_style_name = style.get_paragraph_style()
if paragraph_style_name:
paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name)
paragraph_style.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
paragraph_style.set_alignment(PARA_ALIGN_LEFT)
# horizontal position of the text is not included in the style,
# we assume that it is the size of the shadow, or 0.2mm
@ -1439,7 +1442,7 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
style = style_sheet.get_draw_style(style_name)
paragraph_style_name = style.get_paragraph_style()
paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name)
paragraph_style.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
paragraph_style.set_alignment(PARA_ALIGN_LEFT)
new_text = GtkDocText(paragraph_style, 'top', text, x, y, angle=0)
self._active_element.add_child(new_text)
@ -1449,7 +1452,7 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
style = style_sheet.get_draw_style(style_name)
paragraph_style_name = style.get_paragraph_style()
paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name)
paragraph_style.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
paragraph_style.set_alignment(PARA_ALIGN_CENTER)
new_text = GtkDocText(paragraph_style, 'top', text, x, y, angle=0)
self._active_element.add_child(new_text)
@ -1459,7 +1462,7 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc):
style = style_sheet.get_draw_style(style_name)
paragraph_style_name = style.get_paragraph_style()
paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name)
paragraph_style.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
paragraph_style.set_alignment(PARA_ALIGN_CENTER)
new_text = GtkDocText(paragraph_style, 'center', '\n'.join(text),
x, y, angle)

View File

@ -39,7 +39,9 @@ from gettext import gettext as _
from gen.plug import PluginManager
from gen.plug.menu import BooleanOption, NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
from BasicUtils import name_displayer
from gen.lib import ChildRefType
@ -159,7 +161,7 @@ class AncestorReport(Report):
name = name_displayer.display_formal(self.center_person)
title = _("Ahnentafel Report for %s") % name
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.start_paragraph("AHN-Title")
self.doc.write_text(title, mark)
self.doc.end_paragraph()
@ -179,7 +181,7 @@ class AncestorReport(Report):
generation += 1
# Create the Generation title, set an index marker
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 2)
mark = IndexMark(title, INDEX_TYPE_TOC, 2)
self.doc.start_paragraph("AHN-Generation")
self.doc.write_text(_("Generation %d") % generation, mark)
self.doc.end_paragraph()
@ -294,23 +296,23 @@ class AncestorOptions(MenuReportOptions):
#
# AHN-Title
#
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=16, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=16, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_('The style used for the title of the page.'))
default_style.add_paragraph_style("AHN-Title", para)
#
# AHN-Generation
#
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=14, italic=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=14, italic=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set_top_margin(0.125)
@ -321,7 +323,7 @@ class AncestorOptions(MenuReportOptions):
#
# AHN-Entry
#
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set(first_indent=-1.0, lmargin=1.0)
para.set_top_margin(0.125)
para.set_bottom_margin(0.125)

View File

@ -35,7 +35,9 @@ import datetime, time
# GRAMPS modules
#
#------------------------------------------------------------------------
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle, GraphicsStyle
from gen.plug.docgen.basedoc import (FONT_SERIF, PARA_ALIGN_RIGHT,
PARA_ALIGN_LEFT, PARA_ALIGN_CENTER)
from BasicUtils import name_displayer as _nd
from gen.plug import PluginManager
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
@ -426,17 +428,17 @@ class CalendarOptions(MenuReportOptions):
self.__filter.set_filters(filter_list)
def make_my_style(self, default_style, name, description,
size=9, font=BaseDoc.FONT_SERIF, justified ="left",
color=None, align=BaseDoc.PARA_ALIGN_CENTER,
size=9, font=FONT_SERIF, justified ="left",
color=None, align=PARA_ALIGN_CENTER,
shadow = None, italic=0, bold=0, borders=0, indent=None):
""" Create paragraph and graphic styles of the same name """
# Paragraph:
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(size)
f.set_type_face(font)
f.set_italic(italic)
f.set_bold(bold)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_font(f)
p.set_alignment(align)
p.set_description(description)
@ -447,14 +449,14 @@ class CalendarOptions(MenuReportOptions):
if indent:
p.set(first_indent=indent)
if justified == "left":
p.set_alignment(BaseDoc.PARA_ALIGN_LEFT)
p.set_alignment(PARA_ALIGN_LEFT)
elif justified == "right":
p.set_alignment(BaseDoc.PARA_ALIGN_RIGHT)
p.set_alignment(PARA_ALIGN_RIGHT)
elif justified == "center":
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
default_style.add_paragraph_style(name, p)
# Graphics:
g = BaseDoc.GraphicsStyle()
g = GraphicsStyle()
g.set_paragraph_style(name)
if shadow:
g.set_shadow(*shadow)

View File

@ -44,7 +44,8 @@ from gettext import gettext as _
from gen.plug import PluginManager
from gen.plug.menu import TextOption
from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, PARA_ALIGN_CENTER)
#------------------------------------------------------------------------
#

View File

@ -39,7 +39,9 @@ from gettext import gettext as _
from gen.plug import PluginManager
from gen.plug.menu import NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
import Sort
from BasicUtils import name_displayer
import DateHandler

View File

@ -43,7 +43,9 @@ from gen.plug import PluginManager
from gen.plug.menu import BooleanOption, NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
from ReportBase import Bibliography, Endnotes
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, FONT_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
import DateHandler
from BasicUtils import name_displayer as _nd
import Utils
@ -150,7 +152,7 @@ class DetAncestorReport(Report):
name = _nd.display_name(self.center_person.get_primary_name())
self.doc.start_paragraph("DAR-Title")
title = _("Ancestral Report for %s") % name
mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1)
mark = IndexMark(title,INDEX_TYPE_TOC,1)
self.doc.write_text(title,mark)
self.doc.end_paragraph()
@ -163,7 +165,7 @@ class DetAncestorReport(Report):
self.doc.page_break()
self.doc.start_paragraph("DAR-Generation")
text = _("Generation %d") % (generation+1)
mark = BaseDoc.IndexMark(text, BaseDoc.INDEX_TYPE_TOC, 2)
mark = IndexMark(text, INDEX_TYPE_TOC, 2)
self.doc.write_text(text, mark)
self.doc.end_paragraph()
generation = generation + 1
@ -798,20 +800,20 @@ class DetAncestorOptions(MenuReportOptions):
def make_default_style(self,default_style):
"""Make the default output style for the Detailed Ancestral Report"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=16,bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF,size=16,bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_('The style used for the title of the page.'))
default_style.add_paragraph_style("DAR-Title",para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF,size=14,italic=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set_top_margin(0.25)
@ -819,9 +821,9 @@ class DetAncestorOptions(MenuReportOptions):
para.set_description(_('The style used for the generation header.'))
default_style.add_paragraph_style("DAR-Generation",para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF,size=10,italic=0, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set_left_margin(1.0) # in centimeters
para.set_top_margin(0.25)
@ -829,9 +831,9 @@ class DetAncestorOptions(MenuReportOptions):
para.set_description(_('The style used for the children list title.'))
default_style.add_paragraph_style("DAR-ChildTitle",para)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set(size=10)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=-0.75,lmargin=1.75)
para.set_top_margin(0.25)
@ -839,32 +841,32 @@ class DetAncestorOptions(MenuReportOptions):
para.set_description(_('The style used for the children list.'))
default_style.add_paragraph_style("DAR-ChildList",para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10,italic=0, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF,size=10,italic=0, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0,lmargin=1.0)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
default_style.add_paragraph_style("DAR-NoteHeader",para)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set(lmargin=1.0)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("DAR-Entry",para)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set(first_indent=-1.0,lmargin=1.0)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_description(_('The style used for the first personal entry.'))
default_style.add_paragraph_style("DAR-First-Entry",para)
font = BaseDoc.FontStyle()
font.set(size=10,face=BaseDoc.FONT_SANS_SERIF,bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(size=10,face=FONT_SANS_SERIF,bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0,lmargin=1.0)
para.set_top_margin(0.25)
@ -872,9 +874,9 @@ class DetAncestorOptions(MenuReportOptions):
para.set_description(_('The style used for the More About header.'))
default_style.add_paragraph_style("DAR-MoreHeader",para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SERIF,size=10)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SERIF,size=10)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0,lmargin=1.0)
para.set_top_margin(0.25)

View File

@ -44,7 +44,9 @@ from gen.plug import PluginManager
from gen.plug.menu import BooleanOption, NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
from ReportBase import Bibliography, Endnotes
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, FONT_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
import DateHandler
from BasicUtils import name_displayer as _nd
import Utils
@ -205,7 +207,7 @@ class DetDescendantReport(Report):
title = _("Descendant Report for %(person_name)s") % {
'person_name' : name }
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.write_text(title, mark)
self.doc.end_paragraph()
@ -217,7 +219,7 @@ class DetDescendantReport(Report):
self.doc.page_break()
self.doc.start_paragraph("DDR-Generation")
text = _("Generation %d") % (generation+1)
mark = BaseDoc.IndexMark(text, BaseDoc.INDEX_TYPE_TOC, 2)
mark = IndexMark(text, INDEX_TYPE_TOC, 2)
self.doc.write_text(text, mark)
self.doc.end_paragraph()
if self.childref:
@ -833,20 +835,20 @@ class DetDescendantOptions(MenuReportOptions):
def make_default_style(self, default_style):
"""Make the default output style for the Detailed Ancestral Report"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=16, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=16, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_('The style used for the title of the page.'))
default_style.add_paragraph_style("DDR-Title", para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=14, italic=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=14, italic=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set_top_margin(0.25)
@ -854,9 +856,9 @@ class DetDescendantOptions(MenuReportOptions):
para.set_description(_('The style used for the generation header.'))
default_style.add_paragraph_style("DDR-Generation", para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=10, italic=0, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=10, italic=0, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set_left_margin(1.5) # in centimeters
para.set_top_margin(0.25)
@ -864,9 +866,9 @@ class DetDescendantOptions(MenuReportOptions):
para.set_description(_('The style used for the children list title.'))
default_style.add_paragraph_style("DDR-ChildTitle", para)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set(size=10)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=-0.75, lmargin=2.25)
para.set_top_margin(0.125)
@ -874,32 +876,32 @@ class DetDescendantOptions(MenuReportOptions):
para.set_description(_('The style used for the children list.'))
default_style.add_paragraph_style("DDR-ChildList", para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=10, italic=0, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=10, italic=0, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0, lmargin=1.5)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
default_style.add_paragraph_style("DDR-NoteHeader", para)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set(lmargin=1.5)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("DDR-Entry", para)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set(first_indent=-1.5, lmargin=1.5)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_description(_('The style used for the first personal entry.'))
default_style.add_paragraph_style("DDR-First-Entry", para)
font = BaseDoc.FontStyle()
font.set(size=10, face=BaseDoc.FONT_SANS_SERIF, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(size=10, face=FONT_SANS_SERIF, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0, lmargin=1.5)
para.set_top_margin(0.25)
@ -907,9 +909,9 @@ class DetDescendantOptions(MenuReportOptions):
para.set_description(_('The style used for the More About header.'))
default_style.add_paragraph_style("DDR-MoreHeader", para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SERIF, size=10)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SERIF, size=10)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0, lmargin=1.5)
para.set_top_margin(0.25)

View File

@ -37,7 +37,10 @@ from gettext import gettext as _
from gen.plug import PluginManager
from gen.plug.menu import PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle, TableStyle,\
TableCellStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, INDEX_TYPE_TOC,
PARA_ALIGN_CENTER)
from BasicUtils import name_displayer
import DateHandler

View File

@ -32,7 +32,10 @@ import gen.lib
from gen.plug import PluginManager
from gen.plug.menu import BooleanOption, FamilyOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle, TableStyle,\
TableCellStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, FONT_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
import DateHandler
from TransUtils import sgettext as _
from BasicUtils import name_displayer as _nd

View File

@ -35,7 +35,10 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
import gen.lib
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle, TableStyle,\
TableCellStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, INDEX_TYPE_TOC,
PARA_ALIGN_CENTER)
import DateHandler
from gen.plug import PluginManager
from gen.plug.menu import BooleanOption, FilterOption, PersonOption
@ -398,7 +401,7 @@ class IndivCompleteReport(Report):
media_list = self.person.get_media_list()
name = _nd.display(self.person)
title = _("Summary of %s") % name
mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1)
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.start_paragraph("IDS-Title")
self.doc.write_text(title,mark)
self.doc.end_paragraph()
@ -555,44 +558,44 @@ class IndivCompleteOptions(MenuReportOptions):
def make_default_style(self,default_style):
"""Make the default output style for the Individual Complete Report."""
# Paragraph Styles
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_bold(1)
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font.set_type_face(FONT_SANS_SERIF)
font.set_size(16)
p = BaseDoc.ParagraphStyle()
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p = ParagraphStyle()
p.set_alignment(PARA_ALIGN_CENTER)
p.set_top_margin(ReportUtils.pt2cm(8))
p.set_bottom_margin(ReportUtils.pt2cm(8))
p.set_font(font)
p.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("IDS-Title",p)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_bold(1)
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font.set_type_face(FONT_SANS_SERIF)
font.set_size(12)
font.set_italic(1)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(3))
p.set_bottom_margin(ReportUtils.pt2cm(3))
p.set_description(_("The style used for category labels."))
default_style.add_paragraph_style("IDS-TableTitle",p)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_bold(1)
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font.set_type_face(FONT_SANS_SERIF)
font.set_size(12)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(3))
p.set_bottom_margin(ReportUtils.pt2cm(3))
p.set_description(_("The style used for the spouse's name."))
default_style.add_paragraph_style("IDS-Spouse",p)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(12)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(3))
p.set_bottom_margin(ReportUtils.pt2cm(3))
@ -600,29 +603,29 @@ class IndivCompleteOptions(MenuReportOptions):
default_style.add_paragraph_style("IDS-Normal",p)
# Table Styles
tbl = BaseDoc.TableStyle()
tbl = TableStyle()
tbl.set_width(100)
tbl.set_columns(2)
tbl.set_column_width(0,20)
tbl.set_column_width(1,80)
default_style.add_table_style("IDS-IndTable",tbl)
tbl = BaseDoc.TableStyle()
tbl = TableStyle()
tbl.set_width(100)
tbl.set_columns(2)
tbl.set_column_width(0,50)
tbl.set_column_width(1,50)
default_style.add_table_style("IDS-ParentsTable",tbl)
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
cell.set_top_border(1)
cell.set_bottom_border(1)
default_style.add_cell_style("IDS-TableHead",cell)
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
default_style.add_cell_style("IDS-NormalCell",cell)
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
cell.set_longlist(1)
default_style.add_cell_style("IDS-ListCell",cell)

View File

@ -39,7 +39,9 @@ from string import capitalize
from gen.plug import PluginManager
from gen.plug.menu import NumberOption, BooleanOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
from BasicUtils import name_displayer
import DateHandler
@ -97,7 +99,7 @@ class KinshipReport(Report):
self.doc.start_paragraph("KIN-Title")
title = _("Kinship Report for %s") % pname
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.write_text(title, mark)
self.doc.end_paragraph()
@ -282,7 +284,7 @@ class KinshipReport(Report):
cap_title = capitalize(title)
subtitle = "%s (%d)" % (cap_title, len(people_handles))
self.doc.start_paragraph("KIN-Subtitle")
mark = BaseDoc.IndexMark(cap_title, BaseDoc.INDEX_TYPE_TOC, 2)
mark = IndexMark(cap_title, INDEX_TYPE_TOC, 2)
self.doc.write_text(subtitle, mark)
self.doc.end_paragraph()
for person_handle in people_handles:
@ -360,31 +362,31 @@ class KinshipOptions(MenuReportOptions):
def make_default_style(self,default_style):
"""Make the default output style for the Kinship Report."""
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(16)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
f.set_type_face(FONT_SANS_SERIF)
f.set_bold(1)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_header_level(1)
p.set_bottom_border(1)
p.set_bottom_margin(ReportUtils.pt2cm(8))
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("KIN-Title",p)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(12)
font.set_bold(True)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(6))
p.set_description(_('The basic style used for sub-headings.'))
default_style.add_paragraph_style("KIN-Subtitle",p)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(10)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_font(font)
p.set_left_margin(0.5)
p.set_description(_('The basic style used for the text display.'))

View File

@ -38,7 +38,10 @@ from gettext import gettext as _
from gen.plug import PluginManager
from gen.plug.menu import EnumeratedListOption
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle,\
TableStyle, TableCellStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
from gen.lib import MarkerType
from Filters import GenericFilterFactory, Rules
from BasicUtils import name_displayer
@ -79,7 +82,7 @@ class MarkerReport(Report):
self.doc.start_paragraph("MR-Title")
title = _("Marker Report for %s Items") % markerstr
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.write_text(title, mark)
self.doc.end_paragraph()
@ -100,7 +103,7 @@ class MarkerReport(Report):
self.doc.start_paragraph("MR-Heading")
header = _("People")
mark = BaseDoc.IndexMark(header, BaseDoc.INDEX_TYPE_TOC, 2)
mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header, mark)
self.doc.end_paragraph()
@ -187,7 +190,7 @@ class MarkerReport(Report):
self.doc.start_paragraph("MR-Heading")
header = _("Families")
mark = BaseDoc.IndexMark(header,BaseDoc.INDEX_TYPE_TOC, 2)
mark = IndexMark(header,INDEX_TYPE_TOC, 2)
self.doc.write_text(header, mark)
self.doc.end_paragraph()
@ -277,7 +280,7 @@ class MarkerReport(Report):
self.doc.start_paragraph("MR-Heading")
header = _("Events")
mark = BaseDoc.IndexMark(header, BaseDoc.INDEX_TYPE_TOC, 2)
mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header, mark)
self.doc.end_paragraph()
@ -363,7 +366,7 @@ class MarkerReport(Report):
self.doc.start_paragraph("MR-Heading")
header = _("Notes")
mark = BaseDoc.IndexMark(header, BaseDoc.INDEX_TYPE_TOC, 2)
mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header ,mark)
self.doc.end_paragraph()
@ -452,23 +455,23 @@ class MarkerOptions(MenuReportOptions):
def make_default_style(self,default_style):
"""Make the default output style for the Marker Report."""
# Paragraph Styles
f = BaseDoc.FontStyle()
f = FontStyle()
f.set_size(16)
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
f.set_type_face(FONT_SANS_SERIF)
f.set_bold(1)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set_header_level(1)
p.set_bottom_border(1)
p.set_top_margin(ReportUtils.pt2cm(3))
p.set_bottom_margin(ReportUtils.pt2cm(3))
p.set_font(f)
p.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
p.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("MR-Title", p)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=14, italic=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=14, italic=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set_top_margin(0.25)
@ -476,9 +479,9 @@ class MarkerOptions(MenuReportOptions):
para.set_description(_('The style used for the section headers.'))
default_style.add_paragraph_style("MR-Heading", para)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(12)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set(first_indent=-0.75, lmargin=.75)
p.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(3))
@ -486,10 +489,10 @@ class MarkerOptions(MenuReportOptions):
p.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("MR-Normal", p)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(12)
font.set_bold(True)
p = BaseDoc.ParagraphStyle()
p = ParagraphStyle()
p.set(first_indent=-0.75, lmargin=.75)
p.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(3))
@ -497,7 +500,7 @@ class MarkerOptions(MenuReportOptions):
p.set_description(_('The basic style used for table headings.'))
default_style.add_paragraph_style("MR-Normal-Bold", p)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
p.set(first_indent=-0.75, lmargin=.75)
para.set_top_margin(ReportUtils.pt2cm(3))
para.set_bottom_margin(ReportUtils.pt2cm(3))
@ -505,10 +508,10 @@ class MarkerOptions(MenuReportOptions):
default_style.add_paragraph_style("MR-Note",para)
#Table Styles
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
default_style.add_cell_style('MR-TableCell', cell)
table = BaseDoc.TableStyle()
table = TableStyle()
table.set_width(100)
table.set_columns(4)
table.set_column_width(0, 10)

View File

@ -44,7 +44,9 @@ from gen.plug import PluginManager
from gen.plug.menu import PersonOption
from ReportBase import Report, MenuReportOptions, ReportUtils, CATEGORY_TEXT
from BasicUtils import name_displayer
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, PARA_ALIGN_CENTER,
INDEX_TYPE_TOC)
#------------------------------------------------------------------------
#
@ -83,7 +85,7 @@ class NumberOfAncestorsReport(Report):
self.doc.start_paragraph("NOA-Title")
name = name_displayer.display(self.__person)
title = _("Number of Ancestors for %s") % name
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.write_text(title, mark)
self.doc.end_paragraph()
@ -175,22 +177,22 @@ class NumberOfAncestorsOptions(MenuReportOptions):
def make_default_style(self, default_style):
"""Make the default output style for the Number of Ancestors Report."""
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(16)
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font.set_type_face(FONT_SANS_SERIF)
font.set_bold(1)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_header_level(1)
para.set_bottom_border(1)
para.set_bottom_margin(ReportUtils.pt2cm(8))
para.set_font(font)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("NOA-Title", para)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(12)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_font(font)
para.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("NOA-Normal", para)

View File

@ -37,7 +37,10 @@ from gettext import gettext as _
from gen.plug import PluginManager
from gen.plug.menu import FilterOption, PlaceListOption
from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle, TableStyle,\
TableCellStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, FONT_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
import DateHandler
import Sort
from BasicUtils import name_displayer as _nd
@ -91,7 +94,7 @@ class PlaceReport(Report):
# identified as a major category if this is included in a Book report.
title = _("Place Report")
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.start_paragraph("PLC-ReportTitle")
self.doc.write_text(title, mark)
self.doc.end_paragraph()
@ -284,14 +287,14 @@ class PlaceOptions(MenuReportOptions):
"""
Define the style used for the report title
"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=16, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=16, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set_top_margin(0.25)
para.set_bottom_margin(0.25)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_('The style used for the title of the report.'))
self.default_style.add_paragraph_style("PLC-ReportTitle", para)
@ -299,9 +302,9 @@ class PlaceOptions(MenuReportOptions):
"""
Define the style used for the place title
"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SERIF, size=12, italic=0, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SERIF, size=12, italic=0, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=-1.5, lmargin=1.5)
para.set_top_margin(0.75)
@ -313,9 +316,9 @@ class PlaceOptions(MenuReportOptions):
"""
Define the style used for the place details
"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SERIF, size=10)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SERIF, size=10)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=0.0, lmargin=1.5)
para.set_description(_('The style used for place details.'))
@ -325,9 +328,9 @@ class PlaceOptions(MenuReportOptions):
"""
Define the style used for the event table column title
"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SERIF, size=10, bold=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SERIF, size=10, bold=1)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=-1.5, lmargin=1.5)
para.set_description(_('The style used for a column title.'))
@ -337,9 +340,9 @@ class PlaceOptions(MenuReportOptions):
"""
Define the style used for each section
"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SERIF, size=10, italic=0, bold=0)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SERIF, size=10, italic=0, bold=0)
para = ParagraphStyle()
para.set_font(font)
para.set(first_indent=-1.5, lmargin=1.5)
para.set_top_margin(0.5)
@ -351,7 +354,7 @@ class PlaceOptions(MenuReportOptions):
"""
Define the style used for event table
"""
table = BaseDoc.TableStyle()
table = TableStyle()
table.set_width(80)
table.set_columns(3)
table.set_column_width(0, 20)
@ -363,9 +366,9 @@ class PlaceOptions(MenuReportOptions):
"""
Define the style used for person and event details
"""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SERIF, size=10)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SERIF, size=10)
para = ParagraphStyle()
para.set_font(font)
para.set_description(_('The style used for event and person details.'))
self.default_style.add_paragraph_style("PLC-Details", para)
@ -374,14 +377,14 @@ class PlaceOptions(MenuReportOptions):
"""
Define the style used for cells in the event table
"""
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
self.default_style.add_cell_style("PLC-Cell", cell)
def __table_column_style(self):
"""
Define the style used for event table columns
"""
cell = BaseDoc.TableCellStyle()
cell = TableCellStyle()
cell.set_bottom_border(1)
self.default_style.add_cell_style('PLC-TableColumn', cell)

View File

@ -37,7 +37,8 @@ from gen.plug import PluginManager
from gen.plug.menu import StringOption, MediaOption, NumberOption
from Utils import media_path_full
from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF, PARA_ALIGN_CENTER)
#------------------------------------------------------------------------
#
@ -143,33 +144,33 @@ class SimpleBookTitleOptions(MenuReportOptions):
def make_default_style(self, default_style):
"""Make the default output style for the Simple Boot Title report."""
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=16, bold=1, italic=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=16, bold=1, italic=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set(pad=0.5)
para.set_description(_('The style used for the title of the page.'))
default_style.add_paragraph_style("SBT-Title", para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=14, italic=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=14, italic=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set(pad=0.5)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_('The style used for the subtitle.'))
default_style.add_paragraph_style("SBT-Subtitle", para)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF, size=10, italic=1)
para = BaseDoc.ParagraphStyle()
font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=10, italic=1)
para = ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set(pad=0.5)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_('The style used for the footer.'))
default_style.add_paragraph_style("SBT-Footer", para)

View File

@ -39,7 +39,9 @@ from gettext import gettext as _
import gen.lib
from gen.plug import PluginManager
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
import BaseDoc
from gen.plug.docgen import IndexMark, FontStyle, ParagraphStyle
from gen.plug.docgen.basedoc import (FONT_SANS_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
from Utils import media_path_full
import DateHandler
@ -73,7 +75,7 @@ class SummaryReport(Report):
"""
self.doc.start_paragraph("SR-Title")
title = _("Database Summary Report")
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC, 1)
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.write_text(title, mark)
self.doc.end_paragraph()
@ -252,32 +254,32 @@ class SummaryOptions(MenuReportOptions):
def make_default_style(self, default_style):
"""Make the default output style for the Summary Report."""
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(16)
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
font.set_type_face(FONT_SANS_SERIF)
font.set_bold(1)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_header_level(1)
para.set_bottom_border(1)
para.set_top_margin(ReportUtils.pt2cm(3))
para.set_bottom_margin(ReportUtils.pt2cm(3))
para.set_font(font)
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("SR-Title", para)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(12)
font.set_bold(True)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set_font(font)
para.set_top_margin(0)
para.set_description(_('The basic style used for sub-headings.'))
default_style.add_paragraph_style("SR-Heading", para)
font = BaseDoc.FontStyle()
font = FontStyle()
font.set_size(12)
para = BaseDoc.ParagraphStyle()
para = ParagraphStyle()
para.set(first_indent=-0.75, lmargin=.75)
para.set_font(font)
para.set_top_margin(ReportUtils.pt2cm(3))