* src/Utils.py (roman, pt2cm, cm2pt): Remove functions.

* src/ReportUtils.py (roman): Add function.
* src/docgen/OpenOfficeDoc.py (pt2cm): Remove function.
* src/docgen/PSDrawDoc.py (pt2cm): Remove function.
* src/plugins/AncestorChart2.py: Use ReportUtils.
* src/plugins/AncestorChart.py: Use ReportUtils.
* src/plugins/DesGraph.py: Use ReportUtils.
* src/plugins/FanChart.py: Use ReportUtils.
* src/plugins/StatisticsChart.py: Use ReportUtils.
* src/plugins/TimeLine.py: Use ReportUtils.


svn: r3937
This commit is contained in:
Alex Roitman 2005-01-19 04:47:36 +00:00
parent 0d96ab6776
commit ff42dac0d1
11 changed files with 69 additions and 77 deletions

View File

@ -32,6 +32,17 @@
* src/RelLib.py (Event.are_equal): Only compare place handles if
at least one if them is non-empty.
* src/Utils.py (roman, pt2cm, cm2pt): Remove functions.
* src/ReportUtils.py (roman): Add function.
* src/docgen/OpenOfficeDoc.py (pt2cm): Remove function.
* src/docgen/PSDrawDoc.py (pt2cm): Remove function.
* src/plugins/AncestorChart2.py: Use ReportUtils.
* src/plugins/AncestorChart.py: Use ReportUtils.
* src/plugins/DesGraph.py: Use ReportUtils.
* src/plugins/FanChart.py: Use ReportUtils.
* src/plugins/StatisticsChart.py: Use ReportUtils.
* src/plugins/TimeLine.py: Use ReportUtils.
2005-01-17 Don Allingham <dallingham@users.sourceforge.net>
* src/ReportUtils.py: Added
* src/BaseDoc.py: support for graphs

View File

@ -21,6 +21,11 @@
# $Id$
#-------------------------------------------------------------------------
#
# Convert points to cm and back
#
#-------------------------------------------------------------------------
def pt2cm(pt):
"""
Converts points to centimeters. Fonts are typically specified in points,
@ -134,6 +139,31 @@ def draw_vertical_bar_graph(doc, format, start_x, start_y, height, width, data):
def age_of(person):
pass
#-------------------------------------------------------------------------
#
# Roman numbers
#
#-------------------------------------------------------------------------
def roman(num):
""" Integer to Roman numeral converter for 0 < num < 4000 """
if type(num) != type(0):
return "?"
if not 0 < num < 4000:
return "?"
vals = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
nums = ( 'M','CM', 'D','CD', 'C','XC', 'L','XL', 'X','IX', 'V','IV', 'I')
retval = ""
for i in range(len(vals)):
amount = int(num / vals[i])
retval += nums[i] * amount
num -= vals[i] * amount
return retval
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
if __name__ == "__main__":
import BaseDoc
import OpenOfficeDoc

View File

@ -414,37 +414,6 @@ def search_for(name):
return 1
return 0
#-------------------------------------------------------------------------
#
# Roman numbers
#
#-------------------------------------------------------------------------
def roman(num):
""" Integer to Roman numeral converter for 0 < num < 4000 """
if type(num) != type(0):
return "?"
if not 0 < num < 4000:
return "?"
vals = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
nums = ( 'M','CM', 'D','CD', 'C','XC', 'L','XL', 'X','IX', 'V','IV', 'I')
retval = ""
for i in range(len(vals)):
amount = int(num / vals[i])
retval += nums[i] * amount
num -= vals[i] * amount
return retval
#-------------------------------------------------------------------------
#
# Convert points to cm and back
#
#-------------------------------------------------------------------------
def pt2cm(pt):
return (float(pt)/28.3465)
def cm2pt(cm):
return (float(cm)/2.54)*72
#-------------------------------------------------------------------------
#
# Change label apperance

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2003 Donald N. Allingham
# Copyright (C) 2000-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -26,7 +26,6 @@
#
#-------------------------------------------------------------------------
import os
import string
import zipfile
import time
import locale
@ -45,6 +44,7 @@ import PluginMgr
import ImgManip
import FontScale
import GrampsMime
from ReportUtils import pt2cm
#-------------------------------------------------------------------------
#
@ -703,7 +703,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
for line in text.split('\n\n'):
self.start_paragraph(style_name)
line = line.replace('\n',' ')
line = string.join(line.split())
line = ' '.join(line.split())
self.write_text(line)
self.end_paragraph()
@ -810,7 +810,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
self.cntnt.write('<text:p text:style-name="X%s">' % pname)
self.cntnt.write('<text:span text:style-name="F%s">\n' % pname)
self.write_text(string.join(text,'\n'))
self.write_text('\n'.join(text))
self.cntnt.write('</text:span>\n</text:p>\n</draw:text-box>\n')
def draw_path(self,style,path):
@ -972,14 +972,6 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
self.cntnt.write('</text:p>\n')
self.cntnt.write('</draw:text-box>\n')
#------------------------------------------------------------------------
#
# point to centimeter convertion
#
#------------------------------------------------------------------------
def pt2cm(val):
return (float(val)/28.3465)
#--------------------------------------------------------------------------
#
# Register plugins

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 Donald N. Allingham
# Copyright (C) 2000-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -23,8 +23,8 @@
# python modules
#
#-------------------------------------------------------------------------
import string
from math import pi, cos, sin
from gettext import gettext as _
#-------------------------------------------------------------------------
#
@ -35,17 +35,7 @@ import PluginMgr
import Errors
import BaseDoc
from Report import run_print_dialog
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# pt2cm - points to cm conversion
#
#-------------------------------------------------------------------------
def pt2cm(val):
return (float(val)/72.0)*2.54
from ReportUtils import pt2cm
#-------------------------------------------------------------------------
#
@ -59,7 +49,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f = None
self.filename = None
self.level = 0
self.page = 0
self.page = 0
def fontdef(self,para):
font = para.get_font()
@ -143,7 +133,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
pass
def start_page(self):
self.page = self.page + 1
self.page = self.page + 1
self.f.write("%%Page:")
self.f.write("%d %d\n" % (self.page,self.page))
if self.orientation != BaseDoc.PAPER_PORTRAIT:
@ -182,8 +172,8 @@ class PSDrawDoc(BaseDoc.BaseDoc):
def draw_text(self,style,text,x1,y1):
stype = self.draw_styles[style]
para_name = stype.get_paragraph_style()
p = self.style_list[para_name]
para_name = stype.get_paragraph_style()
p = self.style_list[para_name]
x1 = x1 + self.lmargin
y1 = y1 + self.tmargin + pt2cm(p.get_font().get_size())
@ -252,7 +242,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
stype = self.draw_styles[style]
pname = stype.get_paragraph_style()
p = self.style_list[pname]
font = p.get_font()
font = p.get_font()
size = font.get_size()
@ -344,9 +334,9 @@ class PSDrawDoc(BaseDoc.BaseDoc):
x = x + self.lmargin
y = y + self.tmargin
box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style()
p = self.style_list[para_name]
box_style = self.draw_styles[style]
para_name = box_style.get_paragraph_style()
p = self.style_list[para_name]
(junk,fdef) = self.encode_text(p,text)
bh = box_style.get_height()
@ -379,10 +369,10 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('closepath\n')
self.f.write('%.4f setlinewidth\n' % box_style.get_line_width())
self.f.write('%.4f %.4f %.4f setrgbcolor stroke\n' % rgb_color(box_style.get_color()))
if text != "":
if text != "":
(text,fdef) = self.encode_text(p,text)
self.f.write(fdef)
lines = string.split(text,'\n')
lines = '\n'.split(text)
nlines = len(lines)
mar = 10/28.35
f_in_cm = p.get_font().get_size()/28.35

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2004 Donald N. Allingham
# Copyright (C) 2000-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -44,7 +44,7 @@ import gtk
import BaseDoc
import Report
from SubstKeywords import SubstKeywords
from Utils import pt2cm
from ReportUtils import pt2cm
import const
import ReportOptions

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2004 Donald N. Allingham
# Copyright (C) 2000-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -45,7 +45,7 @@ import gtk
import BaseDoc
import Report
from SubstKeywords import SubstKeywords
from Utils import pt2cm, cm2pt
from ReportUtils import pt2cm, cm2pt
import const
import ReportOptions

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2004 Donald N. Allingham
# Copyright (C) 2000-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -45,7 +45,7 @@ import GraphLayout
import Report
import BaseDoc
from SubstKeywords import SubstKeywords
from Utils import pt2cm
from ReportUtils import pt2cm
import const
import ReportOptions

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2004 Donald N. Allingham
# Copyright (C) 2003-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -44,7 +44,7 @@ import Report
import ReportOptions
import const
from SubstKeywords import SubstKeywords
from Utils import pt2cm
from ReportUtils import pt2cm
#------------------------------------------------------------------------
#

View File

@ -46,7 +46,7 @@ import gtk
# GRAMPS modules
#
#------------------------------------------------------------------------
from Utils import pt2cm
from ReportUtils import pt2cm
import const # gender and report type names
from RelLib import Person # need Person internals for getting gender / gender name
import Utils

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2004 Donald N. Allingham
# Copyright (C) 2003-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -43,7 +43,7 @@ import gtk
# GRAMPS modules
#
#------------------------------------------------------------------------
from Utils import pt2cm
from ReportUtils import pt2cm
import Report
import BaseDoc
import GenericFilter