diff --git a/ChangeLog b/ChangeLog index d945a0dff..b520c0dd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-09-29 Benny Malengier + * src/GrampsDb/_ReadXML.py: read region tag in xml + * src/GrampsDb/_WriteXML.py: output region tag in xml (=subsection of picture) + * src/Editors/_EditMediaRef.py: make sure rectangle is none if nothing given + 2007-09-29 Benny Malengier * src/GrampsDb/_ReadXML.py: remove bug: no more creation of objects if bookmark is found with handle that is not in database. This causes corruption of database! diff --git a/src/Editors/_EditMediaRef.py b/src/Editors/_EditMediaRef.py index 0bcda671e..5ed4c27e1 100644 --- a/src/Editors/_EditMediaRef.py +++ b/src/Editors/_EditMediaRef.py @@ -206,7 +206,10 @@ class EditMediaRef(EditReference): ) if (coord[0] == None and coord[1] == None - and coord[2] == None and coord[3] == None): + and coord[2] == None and coord[3] == None) or ( + coord[0] == 0 and coord[1] == 0 + and coord[2] == 0 and coord[3] == 0 + ): coord = None self.source_ref.set_rectangle(coord) diff --git a/src/GrampsDb/_ReadXML.py b/src/GrampsDb/_ReadXML.py index fb9ae6785..4112bcb34 100644 --- a/src/GrampsDb/_ReadXML.py +++ b/src/GrampsDb/_ReadXML.py @@ -386,6 +386,7 @@ class GrampsParser(UpdateCallback): "families" : (None, self.stop_families), "family" : (self.start_family, self.stop_family), "rel" : (self.start_rel, None), + "region" : (self.start_region, None), "father" : (self.start_father, None), "first" : (None, self.stop_first), "call" : (None, self.stop_call), @@ -1189,6 +1190,13 @@ class GrampsParser(UpdateCallback): self.person.add_media_reference(self.objref) elif self.placeobj: self.placeobj.add_media_reference(self.objref) + + def start_region(self,attrs): + rect = (int(attrs.get('corner1_x')), + int(attrs.get('corner1_y')), + int(attrs.get('corner2_x')), + int(attrs.get('corner2_y')) ) + self.objref.set_rectangle(rect) def start_object(self,attrs): gramps_id = self.map_oid(attrs['id']) diff --git a/src/GrampsDb/_WriteXML.py b/src/GrampsDb/_WriteXML.py index e58f52925..bb99ed2c6 100644 --- a/src/GrampsDb/_WriteXML.py +++ b/src/GrampsDb/_WriteXML.py @@ -911,11 +911,30 @@ class XmlWriter(UpdateCallback): self.g.write(' priv="1"') proplist = photo.get_attribute_list() refslist = photo.get_source_references() + rect = photo.get_rectangle() + if rect is not None : + corner1_x = rect[0] + corner1_y = rect[1] + corner2_x = rect[2] + corner2_y = rect[3] + if corner1_x==None : corner1_x = 0 + if corner1_y==None : corner1_y = 0 + if corner2_x==None : corner2_x = 0 + if corner2_y==None : corner2_y = 0 + #don't output not set rectangle + if (corner1_x == 0 and corner1_y == 0 + and corner2_x == 0 and corner2_y == 0 + ): + rect = None if len(proplist) == 0 and len(refslist) == 0 \ - and photo.get_note() == "": + and photo.get_note() == "" and rect is None: self.g.write("/>\n") else: self.g.write(">\n") + if rect is not None : + self.g.write(' %s\n' % + (sp,corner1_x,corner1_y,corner2_x,corner2_y)) self.write_attribute_list(proplist,indent+1) for ref in refslist: self.dump_source_ref(ref,indent+1)