mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
* lib/lyx2lyx/lyx_1_4.py:
* lib/lyx2lyx/lyx_1_6.py: - improve reversion method for floats. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22508 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fcf47395c5
commit
76c98826a2
@ -1832,7 +1832,13 @@ def revert_float(document):
|
|||||||
i = find_token_exact(document.body, '\\begin_inset Float', i)
|
i = find_token_exact(document.body, '\\begin_inset Float', i)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
return
|
return
|
||||||
floatline = document.body[i]
|
line = document.body[i]
|
||||||
|
r = re.compile(r'\\begin_inset Float (.*)$')
|
||||||
|
m = r.match(line)
|
||||||
|
floattype = m.group(1)
|
||||||
|
if floattype != "figure" and floattype != "table":
|
||||||
|
i = i + 1
|
||||||
|
continue
|
||||||
j = find_end_of_inset(document.body, i)
|
j = find_end_of_inset(document.body, i)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
document.warning("Malformed lyx document: Missing '\\end_inset'.")
|
document.warning("Malformed lyx document: Missing '\\end_inset'.")
|
||||||
@ -1843,9 +1849,6 @@ def revert_float(document):
|
|||||||
if l == -1:
|
if l == -1:
|
||||||
document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Float inset.")
|
document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Float inset.")
|
||||||
return
|
return
|
||||||
floattype = "table"
|
|
||||||
if floatline == "\\begin_inset Float figure":
|
|
||||||
floattype = "figure"
|
|
||||||
document.body[j] = '\\layout Standard\n\\begin_inset ERT\nstatus Collapsed\n\n' \
|
document.body[j] = '\\layout Standard\n\\begin_inset ERT\nstatus Collapsed\n\n' \
|
||||||
'\\layout Standard\n\n\n\\backslash\n' \
|
'\\layout Standard\n\n\n\\backslash\n' \
|
||||||
'end{sideways' + floattype + '}\n\n\\end_inset\n'
|
'end{sideways' + floattype + '}\n\n\\end_inset\n'
|
||||||
|
@ -1140,12 +1140,19 @@ def revert_serbianlatin(document):
|
|||||||
|
|
||||||
|
|
||||||
def revert_rotfloat(document):
|
def revert_rotfloat(document):
|
||||||
" Revert sidewaysalgorithm. "
|
" Revert sideways custom floats. "
|
||||||
i = 0
|
i = 0
|
||||||
while 1:
|
while 1:
|
||||||
i = find_token(document.body, '\\begin_inset Float algorithm', i)
|
i = find_token(document.body, "\\begin_inset Float", i)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
return
|
return
|
||||||
|
line = document.body[i]
|
||||||
|
r = re.compile(r'\\begin_inset Float (.*)$')
|
||||||
|
m = r.match(line)
|
||||||
|
floattype = m.group(1)
|
||||||
|
if floattype == "figure" or floattype == "table":
|
||||||
|
i = i + 1
|
||||||
|
continue
|
||||||
j = find_end_of_inset(document.body, i)
|
j = find_end_of_inset(document.body, i)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
document.warning("Malformed lyx document: Missing '\\end_inset'.")
|
document.warning("Malformed lyx document: Missing '\\end_inset'.")
|
||||||
@ -1158,17 +1165,20 @@ def revert_rotfloat(document):
|
|||||||
return
|
return
|
||||||
document.body[j] = '\\begin_layout Standard\n\\begin_inset ERT\nstatus collapsed\n\n' \
|
document.body[j] = '\\begin_layout Standard\n\\begin_inset ERT\nstatus collapsed\n\n' \
|
||||||
'\\begin_layout Standard\n\n\n\\backslash\n' \
|
'\\begin_layout Standard\n\n\n\\backslash\n' \
|
||||||
'end{sidewaysalgorithm}\n\\end_layout\n\n\\end_inset\n'
|
'end{sideways' + floattype + '}\n\\end_layout\n\n\\end_inset\n'
|
||||||
del document.body[i+1:l-1]
|
del document.body[i+1:l-1]
|
||||||
document.body[i] = '\\begin_inset ERT\nstatus collapsed\n\n' \
|
document.body[i] = '\\begin_inset ERT\nstatus collapsed\n\n' \
|
||||||
'\\begin_layout Standard\n\n\n\\backslash\n' \
|
'\\begin_layout Standard\n\n\n\\backslash\n' \
|
||||||
'begin{sidewaysalgorithm}\n\\end_layout\n\n\\end_inset\n\n\\end_layout\n\n'
|
'begin{sideways' + floattype + '}\n\\end_layout\n\n\\end_inset\n\n\\end_layout\n\n'
|
||||||
|
if floattype == "algorithm":
|
||||||
add_to_preamble(document,
|
add_to_preamble(document,
|
||||||
['% Commands inserted by lyx2lyx for sideways algorithm float',
|
['% Commands inserted by lyx2lyx for sideways algorithm float',
|
||||||
'\\usepackage{rotfloat}\n'
|
'\\usepackage{rotfloat}\n'
|
||||||
'\\floatstyle{ruled}\n'
|
'\\floatstyle{ruled}\n'
|
||||||
'\\newfloat{algorithm}{tbp}{loa}\n'
|
'\\newfloat{algorithm}{tbp}{loa}\n'
|
||||||
'\\floatname{algorithm}{Algorithm}\n'])
|
'\\floatname{algorithm}{Algorithm}\n'])
|
||||||
|
else:
|
||||||
|
document.warning("Cannot create preamble definition for custom float" + floattype + ".")
|
||||||
i = i + 1
|
i = i + 1
|
||||||
continue
|
continue
|
||||||
i = i + 1
|
i = i + 1
|
||||||
@ -1181,7 +1191,13 @@ def revert_widesideways(document):
|
|||||||
i = find_token(document.body, '\\begin_inset Float', i)
|
i = find_token(document.body, '\\begin_inset Float', i)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
return
|
return
|
||||||
floatline = document.body[i]
|
line = document.body[i]
|
||||||
|
r = re.compile(r'\\begin_inset Float (.*)$')
|
||||||
|
m = r.match(line)
|
||||||
|
floattype = m.group(1)
|
||||||
|
if floattype != "figure" and floattype != "table":
|
||||||
|
i = i + 1
|
||||||
|
continue
|
||||||
j = find_end_of_inset(document.body, i)
|
j = find_end_of_inset(document.body, i)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
document.warning("Malformed lyx document: Missing '\\end_inset'.")
|
document.warning("Malformed lyx document: Missing '\\end_inset'.")
|
||||||
@ -1193,9 +1209,6 @@ def revert_widesideways(document):
|
|||||||
if l == -1:
|
if l == -1:
|
||||||
document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Float inset.")
|
document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Float inset.")
|
||||||
return
|
return
|
||||||
floattype = "table"
|
|
||||||
if floatline == "\\begin_inset Float figure":
|
|
||||||
floattype = "figure"
|
|
||||||
document.body[j] = '\\begin_layout Standard\n\\begin_inset ERT\nstatus collapsed\n\n' \
|
document.body[j] = '\\begin_layout Standard\n\\begin_inset ERT\nstatus collapsed\n\n' \
|
||||||
'\\begin_layout Standard\n\n\n\\backslash\n' \
|
'\\begin_layout Standard\n\n\n\\backslash\n' \
|
||||||
'end{sideways' + floattype + '*}\n\\end_layout\n\n\\end_inset\n'
|
'end{sideways' + floattype + '*}\n\\end_layout\n\n\\end_inset\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user