* src/Plugins.py, src/PluginMgr.py: Move to ReportUtils.

svn: r6133
This commit is contained in:
Alex Roitman
2006-03-11 01:12:06 +00:00
parent 9d086fd022
commit 6b9d4207ce
91 changed files with 321 additions and 375 deletions

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 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,21 +26,25 @@ Provides a BaseDoc based interface to the AbiWord document format.
#-------------------------------------------------------------------------
#
# Imported Modules
# Python Modules
#
#-------------------------------------------------------------------------
import base64
import os
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# Gramps Modules
#
#-------------------------------------------------------------------------
import BaseDoc
import Errors
import PluginMgr
from PluginUtils import register_text_doc
import ImgManip
import Mime
import Utils
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# Class Definitions
@@ -333,6 +337,6 @@ try:
print_label=_("Open in %s") % prog[1]
else:
print_label=None
PluginMgr.register_text_doc(mtype,AbiWordDoc,1,1,1,".abw", print_label)
register_text_doc(mtype,AbiWordDoc,1,1,1,".abw", print_label)
except:
PluginMgr.register_text_doc(_('AbiWord document'),AbiWordDoc,1,1,1,".abw", None)
register_text_doc(_('AbiWord document'),AbiWordDoc,1,1,1,".abw", None)

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 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
@@ -34,7 +34,7 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
import BaseDoc
import PluginMgr
from PluginUtils import register_text_doc
import Errors
import Mime
@@ -391,7 +391,7 @@ try:
else:
print_label=None
PluginMgr.register_text_doc(mtype,AsciiDoc,1,1,1,".txt", print_label)
register_text_doc(mtype,AsciiDoc,1,1,1,".txt", print_label)
except:
PluginMgr.register_text_doc(_("Plain Text"),AsciiDoc,1,1,1,".txt", None)
register_text_doc(_("Plain Text"),AsciiDoc,1,1,1,".txt", None)

View File

@@ -35,7 +35,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#------------------------------------------------------------------------
import PluginMgr
from PluginUtils import register_text_doc
import ImgManip
import tarfile
import const
@@ -506,6 +506,6 @@ try:
print_label=_("Open in %s") % prog[1]
else:
print_label=None
PluginMgr.register_text_doc(mtype,HtmlDoc,1,0,1,".html", print_label)
register_text_doc(mtype,HtmlDoc,1,0,1,".html", print_label)
except:
PluginMgr.register_text_doc(_('HTML'),HtmlDoc,1,0,1,".html", None)
register_text_doc(_('HTML'),HtmlDoc,1,0,1,".html", None)

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 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
@@ -20,21 +20,34 @@
# $Id$
import BaseDoc
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
import time
import cStringIO
import gzip
import os
from gettext import gettext as _
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
import BaseDoc
import Errors
from TarFile import TarFile
import PluginMgr
from PluginUtils import register_text_doc
import ImgManip
import Mime
from gettext import gettext as _
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
def points(val):
inch = float(val)/2.54
return (int(inch*72))
@@ -495,6 +508,6 @@ try:
print_label=_("Open in %s") % prog[1]
else:
print_label=None
PluginMgr.register_text_doc(mtype, KwordDoc, 1, 1, 1, ".kwd", print_label)
register_text_doc(mtype, KwordDoc, 1, 1, 1, ".kwd", print_label)
except:
PluginMgr.register_text_doc(_('KWord'), KwordDoc, 1, 1, 1, ".kwd", print_label)
register_text_doc(_('KWord'), KwordDoc, 1, 1, 1, ".kwd", print_label)

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 Donald N. Allingham
#
# Modifications and feature additions:
# 2002 Donald A. Peterson
@@ -61,8 +61,9 @@ else:
#
#------------------------------------------------------------------------
import BaseDoc
import PluginMgr
from ReportUtils import rgb_color
from PluginUtils import ReportUtils, \
register_text_doc, register_draw_doc, register_book_doc
rgb_color = ReportUtils.rgb_color
#------------------------------------------------------------------------
#
@@ -1245,7 +1246,7 @@ class LPRDoc(BaseDoc.BaseDoc):
# Register the document generator with the system
#
#------------------------------------------------------------------------
PluginMgr.register_text_doc(
register_text_doc(
name=_("Print..."),
classref=LPRDoc,
table=1,
@@ -1255,7 +1256,7 @@ PluginMgr.register_text_doc(
print_report_label=None,
clname='print')
PluginMgr.register_book_doc(
register_book_doc(
_("Print..."),
LPRDoc,
1,
@@ -1264,7 +1265,7 @@ PluginMgr.register_book_doc(
"",
'print')
PluginMgr.register_draw_doc(
register_draw_doc(
_("Print..."),
LPRDoc,
1,

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 Donald N. Allingham
#
# Modifications and feature additions:
# 2002-2003 Donald A. Peterson
@@ -41,7 +41,7 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
import BaseDoc
import PluginMgr
from PluginUtils import register_text_doc
import ImgManip
import Errors
@@ -501,7 +501,7 @@ class LaTeXDoc(BaseDoc.BaseDoc):
# Register the document generator with the system
#
#------------------------------------------------------------------------
PluginMgr.register_text_doc(
register_text_doc(
name=_("LaTeX"),
classref=LaTeXDoc,
table=1,

View File

@@ -41,11 +41,12 @@ from math import pi, cos, sin, fabs
import Errors
import BaseDoc
import const
import PluginMgr
import PluginUtils import ReportUtils, \
register_text_doc, register_draw_doc, register_book_doc
pt2cm = ReportUtils.pt2cm
import ImgManip
import FontScale
import Mime
from ReportUtils import pt2cm
#-------------------------------------------------------------------------
#
@@ -1141,13 +1142,10 @@ try:
else:
print_label = None
PluginMgr.register_text_doc(mtype,ODFDoc,1,1,1,".odt",print_label)
PluginMgr.register_book_doc(mtype,ODFDoc,1,1,1,".odt")
PluginMgr.register_draw_doc(mtype,ODFDoc,1,1, ".odt",print_label);
register_text_doc(mtype,ODFDoc,1,1,1,".odt",print_label)
register_book_doc(mtype,ODFDoc,1,1,1,".odt")
register_draw_doc(mtype,ODFDoc,1,1, ".odt",print_label);
except:
PluginMgr.register_text_doc(_('Open Document Text'),
ODFDoc,1,1,1,".odt", None)
PluginMgr.register_book_doc(_("Open Document Text"),
ODFDoc,1,1,1,".odt")
PluginMgr.register_draw_doc(_("Open Document Text"),
ODFDoc,1,1,".odt",None);
register_text_doc(_('Open Document Text'),ODFDoc,1,1,1,".odt", None)
register_book_doc(_("Open Document Text"),ODFDoc,1,1,1,".odt")
register_draw_doc(_("Open Document Text"),ODFDoc,1,1,".odt",None);

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 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
@@ -31,6 +31,8 @@ import time
import locale
from cStringIO import StringIO
from math import pi, cos, sin, fabs
from gettext import gettext as _
from xml.sax.saxutils import escape
#-------------------------------------------------------------------------
#
@@ -40,21 +42,19 @@ from math import pi, cos, sin, fabs
import Errors
import BaseDoc
import const
import PluginMgr
from PluginUtils import ReportUtils, \
register_text_doc, register_draw_doc, register_book_doc
pt2cm = ReportUtils.pt2cm
import ImgManip
import FontScale
import Mime
import Utils
from ReportUtils import pt2cm
#-------------------------------------------------------------------------
#
# internationalization
# constants
#
#-------------------------------------------------------------------------
from gettext import gettext as _
from xml.sax.saxutils import escape
_apptype = 'application/vnd.sun.xml.writer'
_esc_map = {
@@ -1003,10 +1003,12 @@ try:
else:
print_label = None
PluginMgr.register_text_doc(mtype,OpenOfficeDoc,1,1,1,".sxw",print_label)
PluginMgr.register_book_doc(mtype,OpenOfficeDoc,1,1,1,".sxw")
PluginMgr.register_draw_doc(mtype,OpenOfficeDoc,1,1, ".sxw",print_label);
register_text_doc(mtype,OpenOfficeDoc,1,1,1,".sxw",print_label)
register_book_doc(mtype,OpenOfficeDoc,1,1,1,".sxw")
register_draw_doc(mtype,OpenOfficeDoc,1,1, ".sxw",print_label);
except:
PluginMgr.register_text_doc(_('OpenOffice.org Writer'), OpenOfficeDoc,1,1,1,".sxw", None)
PluginMgr.register_book_doc(_("OpenOffice.org Writer"), OpenOfficeDoc,1,1,1,".sxw")
PluginMgr.register_draw_doc(_("OpenOffice.org Writer"), OpenOfficeDoc,1,1,".sxw",None);
register_text_doc(_('OpenOffice.org Writer'),
OpenOfficeDoc,1,1,1,".sxw", None)
register_book_doc(_("OpenOffice.org Writer"), OpenOfficeDoc,1,1,1,".sxw")
register_draw_doc(_("OpenOffice.org Writer"),
OpenOfficeDoc,1,1,".sxw",None);

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 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
@@ -33,11 +33,10 @@ from gettext import gettext as _
# Gramps modules
#
#-------------------------------------------------------------------------
import PluginMgr
from PluginUtils import register_draw_doc, ReportUtils, Report
pt2cm, rgb_color = ReportUtils.pt2cm, ReportUtils.rgb_color
import Errors
import BaseDoc
from Report import run_print_dialog
from ReportUtils import pt2cm, rgb_color
from Utils import gformat
def lrgb(grp):
@@ -137,7 +136,7 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write('%%EOF\n')
self.f.close()
if self.print_req:
run_print_dialog (self.filename)
Report.run_print_dialog (self.filename)
def write_text(self,text):
pass
@@ -420,5 +419,5 @@ class PSDrawDoc(BaseDoc.BaseDoc):
self.f.write("(%s) show\n" % lines[i])
self.f.write('grestore\n')
PluginMgr.register_draw_doc(_("PostScript"),PSDrawDoc,1,1,".ps",
register_draw_doc(_("PostScript"),PSDrawDoc,1,1,".ps",
_("Print a copy"));

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 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
@@ -33,7 +33,7 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
import BaseDoc
import PluginMgr
from PluginUtils import register_text_doc, register_draw_doc, register_book_doc
import Errors
import ImgManip
import Mime
@@ -643,14 +643,12 @@ try:
print_label=_("Open in %s") % mprog[1]
else:
print_label=None
PluginMgr.register_text_doc(mtype, PdfDoc, 1, 1, 1, ".pdf", print_label)
PluginMgr.register_draw_doc(mtype, PdfDoc, 1, 1, ".pdf", print_label)
PluginMgr.register_book_doc(mtype,classref=PdfDoc,
table=1,paper=1,style=1,ext=".pdf")
register_text_doc(mtype, PdfDoc, 1, 1, 1, ".pdf", print_label)
register_draw_doc(mtype, PdfDoc, 1, 1, ".pdf", print_label)
register_book_doc(mtype,classref=PdfDoc,
table=1,paper=1,style=1,ext=".pdf")
except:
PluginMgr.register_text_doc(_('PDF document'), PdfDoc,
1, 1, 1,".pdf", None)
PluginMgr.register_draw_doc(_('PDF document'), PdfDoc,
1, 1, ".pdf", None)
PluginMgr.register_book_doc(name=_("PDF document"),classref=PdfDoc,
table=1,paper=1,style=1,ext=".pdf")
register_text_doc(_('PDF document'), PdfDoc,1, 1, 1,".pdf", None)
register_draw_doc(_('PDF document'), PdfDoc,1, 1, ".pdf", None)
register_book_doc(name=_("PDF document"),classref=PdfDoc,
table=1,paper=1,style=1,ext=".pdf")

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2005 Donald N. Allingham
# Copyright (C) 2000-2006 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
@@ -34,7 +34,7 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
import BaseDoc
import PluginMgr
from PluginUtils import register_text_doc
import ImgManip
import Errors
import Mime
@@ -427,6 +427,6 @@ try:
print_label=_("Open in %s") % mprog[1]
else:
print_label=None
PluginMgr.register_text_doc(mtype, RTFDoc, 1, 1, 1, ".rtf", print_label)
register_text_doc(mtype, RTFDoc, 1, 1, 1, ".rtf", print_label)
except:
PluginMgr.register_text_doc(_('RTF document'), RTFDoc, 1, 1, 1, ".rtf", None)
register_text_doc(_('RTF document'), RTFDoc, 1, 1, 1, ".rtf", None)

View File

@@ -0,0 +1,116 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2003 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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
#
import BaseDoc
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
class SpreadSheetDoc:
def __init__(self,type,orientation=BaseDoc.PAPER_PORTRAIT):
self.orientation = orientation
if orientation == BaseDoc.PAPER_PORTRAIT:
self.width = type.get_width()
self.height = type.get_height()
else:
self.width = type.get_height()
self.height = type.get_width()
self.tmargin = 2.54
self.bmargin = 2.54
self.lmargin = 2.54
self.rmargin = 2.54
self.font = BaseDoc.FontStyle()
self.actfont = self.font
self.style_list = {}
self.table_styles = {}
self.cell_styles = {}
self.name = ""
def get_usable_width(self):
return self.width - (self.rmargin + self.lmargin)
def get_usable_height(self):
return self.height - (self.tmargin + self.bmargin)
def creator(self,name):
self.name = name
def add_style(self,name,style):
self.style_list[name] = BaseDoc.ParagraphStyle(style)
def add_table_style(self,name,style):
self.table_styles[name] = BaseDoc.TableStyle(style)
def add_cell_style(self,name,style):
self.cell_styles[name] = BaseDoc.TableCellStyle(style)
def change_font(self,font):
self.actfont = BaseDoc.FontStyle(font)
def restore_font(self):
self.actfont = self.font
def get_default_font(self):
return self.font
def get_active_font(self):
return self.actfont
def open(self,filename):
pass
def close(self):
pass
def start_page(self,name,style_name):
pass
def end_page(self):
pass
def start_paragraph(self,style_name):
pass
def end_paragraph(self):
pass
def start_table(self,name,style_name):
pass
def end_table(self):
pass
def start_row(self):
pass
def end_row(self):
pass
def start_cell(self,style_name,span=1):
pass
def end_cell(self):
pass
def write_text(self,text):
pass

View File

@@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2004 Donald N. Allingham
# Copyright (C) 2000-2006 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
@@ -25,16 +25,15 @@
# python modules
#
#-------------------------------------------------------------------------
import string
from math import pi, cos, sin, fabs
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
import PluginMgr
from gettext import gettext as _
from PluginUtils import register_draw_doc
import BaseDoc
import Errors
@@ -200,7 +199,7 @@ class SvgDrawDoc(BaseDoc.BaseDoc):
if text != "":
font = p.get_font()
font_size = font.get_size()
lines = string.split(text,'\n')
lines = text.split('\n')
nlines = len(lines)
mar = 10/28.35
fs = (font_size/28.35) * 1.2
@@ -261,4 +260,4 @@ def units(val):
# Register document generator
#
#-------------------------------------------------------------------------
PluginMgr.register_draw_doc(_("SVG (Scalable Vector Graphics)"),SvgDrawDoc,1,1,".svg");
register_draw_doc(_("SVG (Scalable Vector Graphics)"),SvgDrawDoc,1,1,".svg");