lyx_2_0.py: fix revert_tabularvalign

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30476 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2009-07-11 13:01:16 +00:00
parent 48dd95812d
commit fa76010250

View File

@ -207,38 +207,48 @@ def revert_tabularvalign(document):
document.warning("Malformed LyX document: Could not find end of tabular.") document.warning("Malformed LyX document: Could not find end of tabular.")
i = j i = j
continue continue
# don't set a box for longtables, only delete tabularvalignment
p = find_token(document.body, "<features islongtable=", i)
if p > -1:
q = document.body[p].find("tabularvalignment")
if q > -1:
document.body[p] = document.body[p][:q-1]
document.body[p] = document.body[p] + '>'
i = i + 1
k = find_token(document.body, "<features tabularvalignment=", i) # when no longtable
if k == -1: if p == -1:
i = j k = find_token(document.body, "<features tabularvalignment=", i)
continue if k == -1:
i = j
continue
# which valignment is specified? # which valignment is specified?
tabularvalignment_re = re.compile(r'<features tabularvalignment="(top|bottom)">') tabularvalignment_re = re.compile(r'<features tabularvalignment="(top|bottom)">')
m = tabularvalignment_re.match(document.body[k]) m = tabularvalignment_re.match(document.body[k])
if not m: if not m:
i = j i = j
continue continue
tabularvalignment = m.group(1) tabularvalignment = m.group(1)
subst = ['\\end_layout', '\\end_inset'] subst = ['\\end_layout', '\\end_inset']
document.body[j+1:j+1] = subst # just inserts those lines document.body[j+1:j+1] = subst # just inserts those lines
subst = ['\\begin_inset Box Frameless', subst = ['\\begin_inset Box Frameless',
'position "' + tabularvalignment[0] +'"', 'position "' + tabularvalignment[0] +'"',
'hor_pos "c"', 'hor_pos "c"',
'has_inner_box 1', 'has_inner_box 1',
'inner_pos "c"', 'inner_pos "c"',
'use_parbox 0', 'use_parbox 0',
'width "0col%"', 'width "0col%"',
'special "none"', 'special "none"',
'height "1in"', 'height "1in"',
'height_special "totalheight"', 'height_special "totalheight"',
'status open', 'status open',
'', '',
'\\begin_layout Plain Layout'] '\\begin_layout Plain Layout']
document.body[i:i] = subst # this just inserts the array at i document.body[i:i] = subst # this just inserts the array at i
i += len(subst) + 2 # adjust i to save a few cycles i += len(subst) + 2 # adjust i to save a few cycles
def revert_phantom(document): def revert_phantom(document):