* 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 <benny.malengier@gramps-project.org> 


svn: r9039
This commit is contained in:
Benny Malengier 2007-09-29 14:56:45 +00:00
parent 38a312e4a4
commit bb231a73f1
4 changed files with 37 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* 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 <benny.malengier@gramps-project.org>
* 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!

View File

@ -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)

View File

@ -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'])

View File

@ -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<region corner1_x="%d" corner1_y="%d" '
'corner2_x="%d" corner2_y="%d"/>\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)