* src/docgen/OpenOfficeDoc.org: remove ^L and ^Z from output, use

xml.sax.saxutils.escape to handle XML entities


svn: r4984
This commit is contained in:
Don Allingham 2005-07-31 04:43:06 +00:00
parent d768deae74
commit 2070dcba43
2 changed files with 17 additions and 12 deletions

View File

@ -1,5 +1,6 @@
2005-07-30 Don Allingham <don@gramps-project.org>
* src/docgen/OpenOfficeDoc.org: remove ^L and ^Z from output
* src/docgen/OpenOfficeDoc.org: remove ^L and ^Z from output, use
xml.sax.saxutils.escape to handle XML entities
2005-07-29 Don Allingham <don@gramps-project.org>
* src/GrampsBSDDB.py: issue complete redraw on name grouping change

View File

@ -52,10 +52,18 @@ from ReportUtils import pt2cm
#
#-------------------------------------------------------------------------
from gettext import gettext as _
from xml.sax.saxutils import escape
_apptype = 'application/vnd.sun.xml.writer'
_esc_map = {
'\x1a' : '',
'\x0c' : '',
'\n' : '<text:line-break/>',
'&lt;super&gt;' : '<text:span text:style-name="GSuper">',
'&lt;/super&gt;' : '</text:span>')
}
#-------------------------------------------------------------------------
#
# OpenOfficeDoc
@ -704,16 +712,12 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
self.end_paragraph()
def write_text(self,text):
text = text.replace('&','&amp;') # Must be first
text = text.replace('<','&lt;')
text = text.replace('>','&gt;')
text = text.replace('\x1a','')
text = text.replace('\x0c','')
text = text.replace('\n','<text:line-break/>')
text = text.replace('&lt;super&gt;',
'<text:span text:style-name="GSuper">')
text = text.replace('&lt;/super&gt;','</text:span>')
self.cntnt.write(text)
"""
Uses the xml.sax.saxutils.escape function to convert XML
entities. The _esc_map dictionary allows us to add our own
mappings.
"""
self.cntnt.write(escape(text,_esc_map))
def _write_manifest(self):
self.mfile = StringIO()