> I don't think this is the correct approach. The error you see is not bound to
> a specific LyX version, you can also produce it with LyX 1.5:
>
> - insert a table
> - make a cell of fixed width with some content
> - Edit->Paragraph->Center
> - remove fixed width from cell
> - view->dvi

This is a different bug. Bug 2995 is about that when you set the paragraph where the table is in to centered, it is correctly handled by LyX 1.3 but not by LyX 1.4 and later. So this is about the paragraph alignment outside the table, not inside.

A better patch is attached. I suggest to put it in and open a new one for the 
problem you described.

regards Uwe
Index: lyx_1_4.py
===================================================================
--- lyx_1_4.py	(revision 20455)
+++ lyx_1_4.py	(working copy)
@@ -2429,8 +2429,31 @@
 
         i = i + 10
 
+
+def convert_align_in_tables(document):
+    # removes \align settings from within tables (fixes bug 2995)
+    " Convert table alignment, remove '\align' settings from tables"
+    regexp = re.compile(r'^\\begin_inset\s+Tabular')
+    i = 0
+    while 1:
+        i = find_re(document.body, regexp, i)
+        if i == -1:
+            return
+        j = find_token(document.body, "</lyxtabular>", i + 1)
+        if j == -1:
+            #this should not happen
+            document.warning("Malformed lyx document: Missing '</lyxtabular>'")
+            return
+        for k in range(i, j):
+            m = find_tokens(document.body, ["\\align left", "\\align center",
+                                            "\\align right"], i + 1)
+            if m != -1:
+                del document.body[m]
+        i = j + 1
+
+
 ##
-# Convertion hub
+# Conversion hub
 #
 
 supported_versions = ["1.4.%d" % i for i in range(3)] + ["1.4"]
@@ -2459,7 +2482,8 @@
            [242, [convert_french]],
            [243, [remove_paperpackage]],
            [244, [rename_spaces]],
-           [245, [remove_quotestimes, convert_sgml_paragraphs]]]
+           [245, [remove_quotestimes, convert_sgml_paragraphs, convert_align_in_tables]]
+          ]
 
 revert =  [[244, []],
            [243, [revert_space_names]],

Reply via email to