]> git.lyx.org Git - features.git/commitdiff
lyx_2_0.py: fix revert_tabularvalign
authorUwe Stöhr <uwestoehr@web.de>
Sat, 11 Jul 2009 13:01:16 +0000 (13:01 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Sat, 11 Jul 2009 13:01:16 +0000 (13:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30476 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_2_0.py

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