diff --git a/ChangeLog b/ChangeLog index cb0271186..ec4ce68a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * src/ReportUtils.py: Added * src/BaseDoc.py: support for graphs diff --git a/src/ReportUtils.py b/src/ReportUtils.py index 5d881b989..ab6e98c1e 100644 --- a/src/ReportUtils.py +++ b/src/ReportUtils.py @@ -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 diff --git a/src/Utils.py b/src/Utils.py index f8250e786..93c1ff0b6 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -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 diff --git a/src/docgen/OpenOfficeDoc.py b/src/docgen/OpenOfficeDoc.py index f3a888ff8..e32cb76d7 100644 --- a/src/docgen/OpenOfficeDoc.py +++ b/src/docgen/OpenOfficeDoc.py @@ -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('' % pname) self.cntnt.write('\n' % pname) - self.write_text(string.join(text,'\n')) + self.write_text('\n'.join(text)) self.cntnt.write('\n\n\n') def draw_path(self,style,path): @@ -972,14 +972,6 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self.cntnt.write('\n') self.cntnt.write('\n') -#------------------------------------------------------------------------ -# -# point to centimeter convertion -# -#------------------------------------------------------------------------ -def pt2cm(val): - return (float(val)/28.3465) - #-------------------------------------------------------------------------- # # Register plugins diff --git a/src/docgen/PSDrawDoc.py b/src/docgen/PSDrawDoc.py index bb978c9c3..07668a1e4 100644 --- a/src/docgen/PSDrawDoc.py +++ b/src/docgen/PSDrawDoc.py @@ -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 diff --git a/src/plugins/AncestorChart.py b/src/plugins/AncestorChart.py index 1c4987fcb..3437cc812 100644 --- a/src/plugins/AncestorChart.py +++ b/src/plugins/AncestorChart.py @@ -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 diff --git a/src/plugins/AncestorChart2.py b/src/plugins/AncestorChart2.py index 048d566e6..dca8c2302 100644 --- a/src/plugins/AncestorChart2.py +++ b/src/plugins/AncestorChart2.py @@ -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 diff --git a/src/plugins/DesGraph.py b/src/plugins/DesGraph.py index 48a700a5c..d32f246f4 100644 --- a/src/plugins/DesGraph.py +++ b/src/plugins/DesGraph.py @@ -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 diff --git a/src/plugins/FanChart.py b/src/plugins/FanChart.py index ba37c08d4..66c06e57f 100644 --- a/src/plugins/FanChart.py +++ b/src/plugins/FanChart.py @@ -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 #------------------------------------------------------------------------ # diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index 50ba48202..fc7d2377d 100755 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -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 diff --git a/src/plugins/TimeLine.py b/src/plugins/TimeLine.py index f2c9ba0f8..b78ce32d9 100644 --- a/src/plugins/TimeLine.py +++ b/src/plugins/TimeLine.py @@ -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