diff --git a/gramps/src/AbiWordDoc.py b/gramps/src/AbiWordDoc.py
index e4d3ac846..ee027e36b 100644
--- a/gramps/src/AbiWordDoc.py
+++ b/gramps/src/AbiWordDoc.py
@@ -103,15 +103,15 @@ class AbiWordDoc(TextDoc):
self.f.write('\n')
self.f.close()
- def add_photo(self,name,x,y):
+ def add_photo(self,pos,name,x_cm,y_cm):
import GdkImlib
image = GdkImlib.Image(name)
scale = float(image.rgb_width)/float(image.rgb_height)
- act_width = x * scale
- act_height = y * scale
+ act_width = int(((x_cm * scale)*2.54)*72)
+ act_height = int(((y_cm * scale)*2.54)*72)
- self.photo_list.append((name,act_width*40,act_height*40))
+ self.photo_list.append((name,act_width,act_height))
base = "/tmp/%s.png" % os.path.basename(name)
tag = string.replace(base,'.','_')
diff --git a/gramps/src/GrampsParser.py b/gramps/src/GrampsParser.py
index d26a448bf..d2da91e10 100644
--- a/gramps/src/GrampsParser.py
+++ b/gramps/src/GrampsParser.py
@@ -22,20 +22,7 @@ from RelLib import *
import string
import utils
-
-#-------------------------------------------------------------------------
-#
-# Find a parser. xml.sax should be available, but it is possible that
-# someone has removed it in favor of the PyXML distribution, which
-# defined a _xmlplux.sax
-#
-#-------------------------------------------------------------------------
-try:
- from xml.sax import handler
- from xml.sax import make_parser
-except:
- from _xmlplus.sax import handler
- from _xmlplus.sax import make_parser
+import xml.parsers.expat
#-------------------------------------------------------------------------
#
@@ -62,7 +49,7 @@ def fix_spaces(text_list):
# Gramps database parsing class. Derived from SAX XML parser
#
#-------------------------------------------------------------------------
-class GrampsParser(handler.ContentHandler):
+class GrampsParser:
#---------------------------------------------------------------------
#
@@ -122,22 +109,12 @@ class GrampsParser(handler.ContentHandler):
self.func_index = 0
self.func = None
- handler.ContentHandler.__init__(self)
-
- #---------------------------------------------------------------------
- #
- #
- #
- #---------------------------------------------------------------------
- def setDocumentLocator(self,locator):
- self.locator = locator
-
- #---------------------------------------------------------------------
- #
- #
- #
- #---------------------------------------------------------------------
- def endDocument(self):
+ def parse(self,file):
+ p = xml.parsers.expat.ParserCreate()
+ p.StartElementHandler = self.startElement
+ p.EndElementHandler = self.endElement
+ p.CharacterDataHandler = self.characters
+ p.ParseFile(file)
self.db.setResearcher(self.owner)
if self.tempDefault != None:
id = self.tempDefault
@@ -145,32 +122,17 @@ class GrampsParser(handler.ContentHandler):
person = self.db.personMap[id]
self.db.setDefaultPerson(person)
- #---------------------------------------------------------------------
- #
- #
- #
- #---------------------------------------------------------------------
def start_place(self,attrs):
if attrs.has_key('ref'):
self.placeobj = self.db.findPlaceNoMap(u2l(attrs['ref']))
else:
self.placeobj = None
- #---------------------------------------------------------------------
- #
- #
- #
- #---------------------------------------------------------------------
def start_placeobj(self,attrs):
self.placeobj = self.db.findPlaceNoMap(u2l(attrs['id']))
self.placeobj.set_title(u2l(attrs['title']))
self.locations = 0
- #---------------------------------------------------------------------
- #
- #
- #
- #---------------------------------------------------------------------
def start_location(self,attrs):
loc = Location()
if attrs.has_key('city'):
diff --git a/gramps/src/HtmlDoc.py b/gramps/src/HtmlDoc.py
index 35418dd08..99a0f6c1a 100644
--- a/gramps/src/HtmlDoc.py
+++ b/gramps/src/HtmlDoc.py
@@ -258,7 +258,7 @@ class HtmlDoc(TextDoc):
self.f.write(line)
self.f.close()
- def add_photo(self,name,x,y):
+ def add_photo(self,name,pos,x,y):
if no_pil:
return
@@ -293,8 +293,15 @@ class HtmlDoc(TextDoc):
except:
return
- self.f.write('\n' % \
- (refname,pixx,pixy))
+ if pos == "right":
+ xtra = ' align="right"'
+ elif pos == "left" :
+ xtra = ' align="left"'
+ else:
+ xtra = ''
+
+ self.f.write('\n' % \
+ (refname,pixx,pixy,xtra))
def start_table(self,name,style):
self.tbl = self.table_styles[style]
diff --git a/gramps/src/KwordDoc.py b/gramps/src/KwordDoc.py
index a446b7df8..c0e33a60a 100644
--- a/gramps/src/KwordDoc.py
+++ b/gramps/src/KwordDoc.py
@@ -352,7 +352,7 @@ class KwordDoc(TextDoc):
def end_cell(self):
pass
- def add_photo(self,name,x,y):
+ def add_photo(self,name,pos,x,y):
if no_pil:
return
diff --git a/gramps/src/LaTeXDoc.py b/gramps/src/LaTeXDoc.py
index 734b441ca..f07b878c1 100644
--- a/gramps/src/LaTeXDoc.py
+++ b/gramps/src/LaTeXDoc.py
@@ -121,7 +121,7 @@ class LaTeXDoc(TextDoc):
def end_cell(self):
pass
- def add_photo(self,name,x,y):
+ def add_photo(self,name,pos,x,y):
pass
def horizontal_line(self):
diff --git a/gramps/src/OpenOfficeDoc.py b/gramps/src/OpenOfficeDoc.py
index 1a53a6a80..b55d54f71 100644
--- a/gramps/src/OpenOfficeDoc.py
+++ b/gramps/src/OpenOfficeDoc.py
@@ -158,6 +158,64 @@ class OpenOfficeDoc(TextDoc):
self.f.write('\n')
self.f.write('\n')
self.f.write('\n')
+
+ #Begin photo style
+ self.f.write('')
+ self.f.write('')
+ self.f.write('\n')
+
+ self.f.write('')
+ self.f.write('')
+ self.f.write('\n')
+
+ self.f.write('')
+ self.f.write('')
+ self.f.write('\n')
+
+ self.f.write('')
+ self.f.write('')
+ self.f.write('\n')
+
+ #end of Photo style edits
+
self.f.write('\n')
self.f.write('\n')
@@ -171,25 +229,33 @@ class OpenOfficeDoc(TextDoc):
self._write_photos()
self._write_zip()
- def add_photo(self,name,x,y):
+ def add_photo(self,name,pos,x_cm,y_cm):
import GdkImlib
image = GdkImlib.Image(name)
scale = float(image.rgb_width)/float(image.rgb_height)
- act_width = x * scale
- act_height = y * scale
+ act_width = int(((x_cm * scale)*2.54)*72)
+ act_height = int(((y_cm * scale)*2.54)*72)
- self.photo_list.append((name,int(act_width)*40,int(act_height)*40))
+ self.photo_list.append((name,act_width,act_height))
base = os.path.basename(name)
tag = string.replace(base,'.','_')
- self.f.write(' 1:
scale = 1.0/scale
- act_width = twips(x * scale)
- act_height = twips(y * scale)
+ act_width = twips(x_cm * scale)
+ act_height = twips(y_cm * scale)
im.thumbnail((int(act_width*40),int(act_height*40)))
- self.f.write('{\*\shppict{\\pict\\jpegblip\\picwgoal%d\\pichgoal%d\n' % (x,y))
+ self.f.write('{\*\shppict{\\pict\\jpegblip')
+ self.f.write('\\picwgoal%d\\pichgoal%d\n' % (act_width,act_height))
index = 1
for i in buf:
self.f.write('%02x' % ord(i))
diff --git a/gramps/src/ReadXML.py b/gramps/src/ReadXML.py
index 98e3430d9..a8847062c 100644
--- a/gramps/src/ReadXML.py
+++ b/gramps/src/ReadXML.py
@@ -54,17 +54,6 @@ try:
except:
gzip_ok = 0
-#-------------------------------------------------------------------------
-#
-# Try to abstract SAX1 from SAX2
-#
-#-------------------------------------------------------------------------
-
-try:
- from xml.sax import make_parser, SAXParseException, SAXReaderNotAvailable
-except:
- from _xmlplus.sax import make_parser, SAXParseException, SAXReaderNotAvailable
-
#-------------------------------------------------------------------------
#
# Initialization function for the module. Called to start the reading
@@ -78,15 +67,7 @@ def importData(database, filename, callback):
database.pmap = {}
database.fmap = {}
- try:
- parser = make_parser()
- except SAXReaderNotAvailable:
- msg1 = _("GRAMPS is not able to find an XML parser on your system.")
- msg2 = _("This is probably due to an incomplete python or PyXML installation")
- GnomeErrorDialog("%s\n%s" % (msg1,msg2))
- return
-
- parser.setContentHandler(GrampsImportParser(database,callback,basefile))
+ parser = GrampsImportParser(database,callback,basefile)
if gzip_ok:
use_gzip = 1
@@ -114,11 +95,6 @@ def importData(database, filename, callback):
try:
parser.parse(xml_file)
- except SAXParseException:
- GnomeErrorDialog(_("%s is a corrupt file") % filename)
- import traceback
- traceback.print_exc()
- return 0
except IOError,msg:
GnomeErrorDialog(_("Error reading %s") % filename + "\n" + str(msg))
import traceback
@@ -147,8 +123,7 @@ def loadData(database, filename, callback=None):
filename = os.path.normpath(filename)
- parser = make_parser()
- parser.setContentHandler(GrampsParser(database,callback,basefile))
+ parser = GrampsParser(database,callback,basefile)
if gzip_ok:
use_gzip = 1
@@ -177,13 +152,6 @@ def loadData(database, filename, callback=None):
try:
parser.parse(xml_file)
- except SAXParseException,msg:
- line = string.split(str(msg),':')
- filemsg = _("%s is a corrupt file.") % filename
- errtype = string.strip(line[3])
- errmsg = _('A "%s" error on line %s was detected.') % (errtype,line[1])
- GnomeErrorDialog("%s\n%s" % (filemsg,errmsg))
- return 0
except IOError,msg:
errmsg = "%s\n%s" % (_("Error reading %s") % filename,str(msg))
GnomeErrorDialog(errmsg)
@@ -212,20 +180,12 @@ def loadRevision(database, file, filename, revision, callback=None):
database.pmap = {}
database.fmap = {}
- parser = make_parser()
- parser.setContentHandler(GrampsParser(database,callback,basefile))
+ parser = GrampsParser(database,callback,basefile)
filename = _("%s (revision %s)") % (filename,revision)
try:
parser.parse(file)
- except SAXParseException,msg:
- line = string.split(str(msg),':')
- filemsg = _("%s is a corrupt file.") % filename
- errtype = string.strip(line[3])
- errmsg = _('A "%s" error on line %s was detected.') % (errtype,line[1])
- GnomeErrorDialog("%s\n%s" % (filemsg,errmsg))
- return 0
except IOError,msg:
errmsg = "%s\n%s" % (_("Error reading %s") % filename, str(msg))
GnomeErrorDialog(errmsg)
diff --git a/gramps/src/TextDoc.py b/gramps/src/TextDoc.py
index e3f307a47..32da0a1b3 100644
--- a/gramps/src/TextDoc.py
+++ b/gramps/src/TextDoc.py
@@ -576,7 +576,8 @@ class TextDoc:
self.name = ""
self.photo_list = []
- def add_photo(self,name,x,y):
+ def add_photo(self,name,align,w_cm,h_cm):
+ """adds a photo of the specified width (in centimeters)"""
pass
def get_usable_width(self):
diff --git a/gramps/src/plugins/IndivSummary.py b/gramps/src/plugins/IndivSummary.py
index 0289c99b6..fc66d5b26 100644
--- a/gramps/src/plugins/IndivSummary.py
+++ b/gramps/src/plugins/IndivSummary.py
@@ -222,7 +222,7 @@ class IndivSummary:
if object.getMimeType()[0:5] == "image":
file = object.getPath()
self.d.start_paragraph("Normal")
- self.d.add_photo(file,4.0,4.0)
+ self.d.add_photo(file,"row",4.0,4.0)
self.d.end_paragraph()
self.d.start_table("one","IndTable")
diff --git a/gramps/src/plugins/WebPage.py b/gramps/src/plugins/WebPage.py
index a777a9b05..97aa8e220 100644
--- a/gramps/src/plugins/WebPage.py
+++ b/gramps/src/plugins/WebPage.py
@@ -257,7 +257,7 @@ class IndividualPage:
if object.getMimeType()[0:5] == "image":
file = object.getPath()
self.doc.start_paragraph("Data")
- self.doc.add_photo(file,4.0,4.0)
+ self.doc.add_photo(file,"row",4.0,4.0)
self.doc.end_paragraph()
# Start the first table, which consists of basic information, including
@@ -346,7 +346,7 @@ class IndividualPage:
src = obj.getReference().getPath()
base = os.path.basename(src)
self.doc.start_link("images/%s" % base)
- self.doc.add_photo(src,1.5,1.5)
+ self.doc.add_photo(src,"row",1.5,1.5)
shutil.copy(src,"%s/images/%s" % (self.dir,base))
self.doc.end_link()