Fix a minor bug in the xymatrix lyx2lyx stuff and make it a bit more

pythonic.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33913 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-03-29 16:29:57 +00:00
parent e4b3e9b7bc
commit 7ba836548f

View File

@ -1268,7 +1268,8 @@ def revert_equalspacing_xymatrix(document):
" Revert a Formula with xymatrix@! to an ERT inset " " Revert a Formula with xymatrix@! to an ERT inset "
i = 0 i = 0
j = 0 j = 0
has_preamble = 0 has_preamble = False
has_equal_spacing = False
while True: while True:
found = -1 found = -1
i = find_token(document.body, "\\begin_inset Formula", i) i = find_token(document.body, "\\begin_inset Formula", i)
@ -1279,24 +1280,26 @@ def revert_equalspacing_xymatrix(document):
document.warning("Malformed LyX document: Could not find end of Formula inset.") document.warning("Malformed LyX document: Could not find end of Formula inset.")
break break
for curline in range(len(document.body[i:j])): for curline in range(i,j):
found = document.body[i+curline].find("\\xymatrix@!") found = document.body[curline].find("\\xymatrix@!")
if found != -1: if found != -1:
break break
if found != -1: if found != -1:
has_equal_spacing = True
content = document.body[i][21:] content = document.body[i][21:]
for curline in range(len(document.body[i+1:j])): content += '\n'.join(document.body[i+1:j])
content += document.body[i+1+curline]
subst = [put_cmd_in_ert(content)] subst = [put_cmd_in_ert(content)]
document.body[i:j+1] = subst document.body[i:j+1] = subst
else:
for curline in range(len(document.body[i:j])):
l = document.body[i+curline].find("\\xymatrix")
if l != -1:
has_preamble = 1;
i += 1 i += 1
if has_preamble == 0: else:
for curline in range(i,j):
l = document.body[curline].find("\\xymatrix")
if l != -1:
has_preamble = True;
break;
i = j + 1
if has_equal_spacing and not has_preamble:
add_to_preamble(document, ['\\usepackage[all]{xy}']) add_to_preamble(document, ['\\usepackage[all]{xy}'])
## ##