4370: Reports in ODT format are corrupted
svn: r16210
This commit is contained in:
parent
df18b2427d
commit
a5122b4d1d
@ -344,17 +344,37 @@ class DocBackend(object):
|
|||||||
for opentag in opentags:
|
for opentag in opentags:
|
||||||
otext += opentag[0]
|
otext += opentag[0]
|
||||||
start = pos
|
start = pos
|
||||||
#add remainder of text, no markup present there
|
#add remainder of text, no markup present there if all is correct
|
||||||
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
|
|
||||||
if opentags:
|
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 '\
|
print 'WARNING: DocBackend : More style tags in text than length '\
|
||||||
'of text allows.\n', opentags
|
'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):
|
for opentag in reversed(opentags):
|
||||||
otext += opentag[1]
|
otext += opentag[1]
|
||||||
|
else:
|
||||||
|
otext += self.ESCAPE_FUNC()(text[start:end])
|
||||||
|
|
||||||
return otext
|
return otext
|
||||||
|
|
||||||
def format_link(self, value):
|
def format_link(self, value):
|
||||||
|
@ -1390,9 +1390,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
|
|||||||
"""
|
"""
|
||||||
text = str(styledtext)
|
text = str(styledtext)
|
||||||
s_tags = styledtext.get_tags()
|
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')
|
markuptext = self._backend.add_markup_from_styled(text, s_tags, '\n')
|
||||||
# we need to know if we have new styles to add.
|
# we need to know if we have new styles to add.
|
||||||
# if markuptext contains : FontColor, FontFace, FontSize ...
|
# if markuptext contains : FontColor, FontFace, FontSize ...
|
||||||
@ -1411,9 +1408,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
|
|||||||
start = m.end()
|
start = m.end()
|
||||||
linenb = 1
|
linenb = 1
|
||||||
self.start_paragraph(style_name)
|
self.start_paragraph(style_name)
|
||||||
markuptext = markuptext.replace('\1', '&') # must be the first
|
|
||||||
markuptext = markuptext.replace('\2', '<')
|
|
||||||
markuptext = markuptext.replace('\3', '>')
|
|
||||||
for line in markuptext.split('\n'):
|
for line in markuptext.split('\n'):
|
||||||
[line, sigcount] = process_spaces(line, format)
|
[line, sigcount] = process_spaces(line, format)
|
||||||
if sigcount == 0:
|
if sigcount == 0:
|
||||||
|
@ -61,7 +61,13 @@ LOG = logging.getLogger(".odfbackend.py")
|
|||||||
|
|
||||||
def _escape(string):
|
def _escape(string):
|
||||||
""" a write to the file
|
""" a write to the file
|
||||||
|
""""""
|
||||||
|
change text in text that latex shows correctly
|
||||||
|
special characters: & < and >
|
||||||
"""
|
"""
|
||||||
|
string = string.replace('&', '&') # must be the first
|
||||||
|
string = string.replace('<', '<')
|
||||||
|
string = string.replace('>', '>')
|
||||||
return string
|
return string
|
||||||
|
|
||||||
class OdfBackend(DocBackend):
|
class OdfBackend(DocBackend):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user