lyx_2_0.py: fix reversion routine for \makebox support

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34807 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2010-07-08 02:24:13 +00:00
parent 8082dfd825
commit af6de17818

View File

@ -1849,6 +1849,8 @@ def revert_makebox(document):
# only revert frameless boxes without an inner box # only revert frameless boxes without an inner box
i = find_token(document.body, '\\begin_inset Box Frameless', i) i = find_token(document.body, '\\begin_inset Box Frameless', i)
if i == -1: if i == -1:
# remove the option use_makebox
revert_use_makebox(document)
return return
z = find_end_of_inset(document.body, i) z = find_end_of_inset(document.body, i)
if z == -1: if z == -1:
@ -1856,30 +1858,41 @@ def revert_makebox(document):
return return
j = find_token(document.body, 'use_makebox 1', i) j = find_token(document.body, 'use_makebox 1', i)
# assure we found the makebox of the current box # assure we found the makebox of the current box
if j > z or j == -1: if j < z and j != -1:
return y = find_token(document.body, "\\begin_layout", i)
y = find_token(document.body, "\\begin_layout", i) if y > z or y == -1:
if y > z or y == -1: document.warning("Malformed LyX document: Can't find layout in box.")
document.warning("Malformed LyX document: Can't find layout in box.") return
return # remove the \end_layout \end_inset pair
# remove the \end_layout \end_inset pair document.body[z - 2:z + 1] = put_cmd_in_ert("}")
document.body[z - 2:z + 1] = put_cmd_in_ert("}") # determine the alignment
# determine the alignment k = find_token(document.body, 'hor_pos', j - 4)
k = find_token(document.body, 'hor_pos', j - 4) align = document.body[k][9]
align = document.body[k][9] # determine the width
# determine the width l = find_token(document.body, 'width "', j + 1)
l = find_token(document.body, 'width "', j + 1) length = document.body[l][7:]
length = document.body[l][7:] # remove trailing '"'
# remove trailing '"' length = length[:-1]
length = length[:-1] # latex_length returns "bool,length"
# latex_length returns "bool,length" length = latex_length(length).split(",")[1]
length = latex_length(length).split(",")[1] subst = "\\makebox[" + length + "][" \
subst = "\\makebox[" + length + "][" \ + align + "]{"
+ align + "]{" document.body[i:y + 1] = put_cmd_in_ert(subst)
document.body[i:y + 1] = put_cmd_in_ert(subst)
i += 1 i += 1
def revert_use_makebox(document):
" Deletes use_makebox option of boxes "
h = 0
while 1:
# remove the option use_makebox
h = find_token(document.body, 'use_makebox', 0)
if h == -1:
return
del document.body[h]
h += 1
def revert_IEEEtran(document): def revert_IEEEtran(document):
" Convert IEEEtran layouts and styles to TeX code " " Convert IEEEtran layouts and styles to TeX code "
if document.textclass != "IEEEtran": if document.textclass != "IEEEtran":