#
# 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
#
# $Id$
"""
Provides a BaseDoc based interface to the AbiWord document format.
"""
#-------------------------------------------------------------------------
#
# Imported Modules
#
#-------------------------------------------------------------------------
import base64
import string
import BaseDoc
import Errors
import Plugins
import ImgManip
from latin_utf8 import latin_to_utf8
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# Class Definitions
#
#-------------------------------------------------------------------------
class AbiWordDoc(BaseDoc.BaseDoc):
"""AbiWord document generator. Inherits from the BaseDoc generic
document interface class."""
def __init__(self,styles,type,template,orientation):
"""Initializes the AbiWordDoc class, calling the __init__ routine
of the parent BaseDoc class"""
BaseDoc.BaseDoc.__init__(self,styles,type,template,orientation)
self.f = None
self.level = 0
self.new_page = 0
self.in_table = 0
self.icount = 0;
self.imap = {}
def open(self,filename):
"""Opens the document, writing the necessary header information.
AbiWord uses an XML format, so the document format is pretty easy
to understand"""
if filename[-4:] != ".abw":
self.filename = "%s.abw" % filename
else:
self.filename = filename
try:
self.f = open(self.filename,"w")
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
raise Errors.ReportError(errmsg)
except:
raise Errors.ReportError(_("Could not create %s") % self.filename)
# doctype
self.f.write('\n')
self.f.write('\n')
self.f.write('\n')
self.f.write('
' % style_name)
if self.new_page == 1:
self.new_page = 0
self.f.write('