2007-07-18 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/MarkupText.py: improved xml generator * src/docgen/GtkPrint.py: fix svn proplist svn: r8740
This commit is contained in:
parent
a733ad271b
commit
7ce0cc4eef
@ -1,3 +1,7 @@
|
|||||||
|
2007-07-18 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
|
||||||
|
* src/MarkupText.py: improved xml generator
|
||||||
|
* src/docgen/GtkPrint.py: fix svn proplist
|
||||||
|
|
||||||
2007-07-18 Alex Roitman <shura@gramps-project.org>
|
2007-07-18 Alex Roitman <shura@gramps-project.org>
|
||||||
* configure.in: Revert checks for pycairo.
|
* configure.in: Revert checks for pycairo.
|
||||||
|
|
||||||
|
@ -184,31 +184,45 @@ class MarkupWriter:
|
|||||||
indices = eventdict.keys()
|
indices = eventdict.keys()
|
||||||
indices.sort()
|
indices.sort()
|
||||||
for index in indices:
|
for index in indices:
|
||||||
modified_tags = []
|
# separate the events by tag names
|
||||||
for (name, attrs, type, pair_idx) in eventdict[index]:
|
tagdict = {}
|
||||||
if attrs.getLength():
|
for event in eventdict[index]:
|
||||||
# remove this event, we will insert new ones instead
|
# we care only about tags having attributes
|
||||||
eventdict[index].remove((name, attrs, type, pair_idx))
|
if event[1].getLength():
|
||||||
|
if tagdict.has_key(event[0]):
|
||||||
# if the tag is already open first we need to close it
|
tagdict[event[0]].append(event)
|
||||||
if active_tags.has_key(name):
|
|
||||||
tmp_attrs = xmlreader.AttributesImpl({})
|
|
||||||
tmp_attrs._attrs.update(active_tags[name])
|
|
||||||
eventdict[index].insert(0, (name, tmp_attrs,
|
|
||||||
self.EVENT_END,
|
|
||||||
active_idx[name]))
|
|
||||||
# update pair index in tag opening event
|
|
||||||
# FIXME this is ugly
|
|
||||||
for event in eventdict[active_idx[name]]:
|
|
||||||
if (event[0] == name and
|
|
||||||
event[2] == self.EVENT_START):
|
|
||||||
new_event = (event[0], event[1], event[2], index)
|
|
||||||
eventdict[active_idx[name]].remove(event)
|
|
||||||
eventdict[active_idx[name]].append(new_event)
|
|
||||||
else:
|
else:
|
||||||
active_tags[name] = xmlreader.AttributesImpl({})
|
tagdict[event[0]] = [event]
|
||||||
|
|
||||||
|
# let's handle each tag
|
||||||
|
for tag_name in tagdict.keys():
|
||||||
|
|
||||||
|
# first we close the tag if it's already open
|
||||||
|
if active_tags.has_key(tag_name):
|
||||||
|
tmp_attrs = xmlreader.AttributesImpl({})
|
||||||
|
tmp_attrs._attrs.update(active_tags[tag_name])
|
||||||
|
eventdict[index].insert(0, (name, tmp_attrs,
|
||||||
|
self.EVENT_END,
|
||||||
|
active_idx[tag_name]))
|
||||||
|
# go back where the tag was opened and update the pair_idx,
|
||||||
|
# i.e. with the current index.
|
||||||
|
# FIXME this is ugly
|
||||||
|
for event in eventdict[active_idx[tag_name]]:
|
||||||
|
if (event[0] == tag_name and
|
||||||
|
event[2] == self.EVENT_START):
|
||||||
|
new_event = (event[0], event[1], event[2], index)
|
||||||
|
eventdict[active_idx[tag_name]].remove(event)
|
||||||
|
eventdict[active_idx[tag_name]].append(new_event)
|
||||||
|
else:
|
||||||
|
active_tags[tag_name] = xmlreader.AttributesImpl({})
|
||||||
|
|
||||||
|
# update
|
||||||
|
for event in tagdict[tag_name]:
|
||||||
|
# remove this event, we will insert new ones instead
|
||||||
|
eventdict[index].remove(event)
|
||||||
|
|
||||||
# update the active attribute object for the tag
|
# update the active attribute object for the tag
|
||||||
|
(name, attrs, type, pair_idx) = event
|
||||||
if type == self.EVENT_START:
|
if type == self.EVENT_START:
|
||||||
active_tags[name]._attrs.update(attrs)
|
active_tags[name]._attrs.update(attrs)
|
||||||
elif type == self.EVENT_END:
|
elif type == self.EVENT_END:
|
||||||
@ -220,25 +234,20 @@ class MarkupWriter:
|
|||||||
else:
|
else:
|
||||||
pass # error
|
pass # error
|
||||||
|
|
||||||
# if the tag's attr list is empty after the updates
|
# if the tag's attr list is empty after the updates
|
||||||
# delete the tag completely from the list of active tags
|
# delete the tag completely from the list of active tags
|
||||||
if not active_tags[name].getLength():
|
if not active_tags[name].getLength():
|
||||||
del active_tags[name]
|
del active_tags[name]
|
||||||
##del active_idx[name]
|
##del active_idx[name]
|
||||||
|
|
||||||
# remember this tag has changes
|
# re-open all tags with updated attrs
|
||||||
if name not in modified_tags:
|
if active_tags.has_key(tag_name):
|
||||||
modified_tags.append(name)
|
|
||||||
|
|
||||||
# re-open all tags with updated attrs
|
|
||||||
for name in modified_tags:
|
|
||||||
if active_tags.has_key(name):
|
|
||||||
tmp_attrs = xmlreader.AttributesImpl({})
|
tmp_attrs = xmlreader.AttributesImpl({})
|
||||||
tmp_attrs._attrs.update(active_tags[name])
|
tmp_attrs._attrs.update(active_tags[tag_name])
|
||||||
eventdict[index].append((name, tmp_attrs,
|
eventdict[index].append((tag_name, tmp_attrs,
|
||||||
self.EVENT_START, pair_idx))
|
self.EVENT_START, 0))
|
||||||
# also save the index of tag opening
|
# also save the index of tag opening
|
||||||
active_idx[name] = index
|
active_idx[tag_name] = index
|
||||||
|
|
||||||
# sort events at the same index
|
# sort events at the same index
|
||||||
indices = eventdict.keys()
|
indices = eventdict.keys()
|
||||||
|
@ -18,7 +18,11 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
# $Id: PdfDoc.py 7855 2006-12-29 03:58:26Z dallingham $
|
# $Id$
|
||||||
|
|
||||||
|
"Printing interface based on gtk.Print*"
|
||||||
|
|
||||||
|
__revision__ = "$Revision$"
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -29,7 +33,7 @@ from gettext import gettext as _
|
|||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# gramps modules
|
# Gramps modules
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
import BaseDoc
|
import BaseDoc
|
||||||
@ -44,22 +48,20 @@ import Errors
|
|||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(".GtkDoc")
|
log = logging.getLogger(".GtkDoc")
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GtkPrint
|
# GTK modules
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
##import pygtk
|
||||||
import pygtk
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
if not hasattr(gtk, "PrintOperation"):
|
|
||||||
raise Errors.UnavailableError(
|
|
||||||
_("Cannot be loaded because PyGtk 2.10 or later is not installed"))
|
|
||||||
|
|
||||||
import cairo
|
import cairo
|
||||||
import pango
|
import pango
|
||||||
|
|
||||||
|
##if not hasattr(gtk, "PrintOperation"):
|
||||||
|
if gtk.pygtk_version < (2,10,0):
|
||||||
|
raise Errors.UnavailableError(
|
||||||
|
_("Cannot be loaded because PyGtk 2.10 or later is not installed"))
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -445,7 +447,6 @@ class GtkDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc,BaseDoc.DrawDoc):
|
|||||||
# Register the document generator with the GRAMPS plugin system
|
# Register the document generator with the GRAMPS plugin system
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
register_text_doc(_('GtkPrint'), GtkDoc,1, 1, 1,"", None)
|
register_text_doc(_('GtkPrint'), GtkDoc, 1, 1, 1, "", None)
|
||||||
register_draw_doc(_('GtkPrint'), GtkDoc,1, 1, "", None)
|
register_draw_doc(_('GtkPrint'), GtkDoc, 1, 1, "", None)
|
||||||
register_book_doc(name=_("GtkPrint"),classref=GtkDoc,
|
register_book_doc(_("GtkPrint"), GtkDoc, 1, 1, 1, "", None)
|
||||||
table=1,paper=1,style=1,ext="")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user