4370: Reports in ODT format are corrupted

svn: r16209
This commit is contained in:
Benny Malengier 2010-11-18 20:18:06 +00:00
parent 8dd881dc2f
commit 028e5caf03
3 changed files with 32 additions and 12 deletions

View File

@ -341,15 +341,35 @@ class DocBackend(object):
for opentag in opentags:
otext += opentag[0]
start = pos
#add remainder of text, no markup present there
otext += self.ESCAPE_FUNC()(text[start:end])
#opentags should be empty. If not, user gave tags on positions that
# are over the end of the text. Just close the tags still open
#add remainder of text, no markup present there if all is correct
if opentags:
# a problem, we don't have a closing tag left but there are open
# tags. Just keep them up to end of text
pos = len(text)
print 'WARNING: DocBackend : More style tags in text than length '\
'of text allows.\n', opentags
if pos > start:
if split:
#make sure text can split
splitpos = text[start:pos].find(split)
while splitpos != -1:
otext += self.ESCAPE_FUNC()(text[start:start+splitpos])
#close open tags
for opentag in reversed(opentags):
otext += opentag[1]
#add split text
otext += self.ESCAPE_FUNC()(split)
#open the tags again
for opentag in opentags:
otext += opentag[0]
#obtain new values
start = start + splitpos + lensplit
splitpos = text[start:pos].find(split)
otext += self.ESCAPE_FUNC()(text[start:pos])
for opentag in reversed(opentags):
otext += opentag[1]
else:
otext += self.ESCAPE_FUNC()(text[start:end])
return otext

View File

@ -1222,9 +1222,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
"""
text = str(styledtext)
s_tags = styledtext.get_tags()
text = text.replace('&', '\1') # must be the first
text = text.replace('<', '\2')
text = text.replace('>', '\3')
markuptext = self._backend.add_markup_from_styled(text, s_tags, '\n')
# we need to know if we have new styles to add.
# if markuptext contains : FontColor, FontFace, FontSize ...
@ -1243,9 +1240,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
start = m.end()
linenb = 1
self.start_paragraph(style_name)
markuptext = markuptext.replace('\1', '&amp;') # must be the first
markuptext = markuptext.replace('\2', '&lt;')
markuptext = markuptext.replace('\3', '&gt;')
for line in markuptext.split('\n'):
[line, sigcount] = process_spaces(line, format)
if sigcount == 0:

View File

@ -61,7 +61,13 @@ LOG = logging.getLogger(".odfbackend.py")
def _escape(string):
""" a write to the file
""""""
change text in text that latex shows correctly
special characters: & < and >
"""
string = string.replace('&', '&amp;') # must be the first
string = string.replace('<', '&lt;')
string = string.replace('>', '&gt;')
return string
class OdfBackend(DocBackend):