]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_2_2.py
Rename Caption:LongTableNoNumber to Caption:Unnumbered
[lyx.git] / lib / lyx2lyx / lyx_2_2.py
index d3f836a8407ea7d8480270fd3d3f32eb1dfd694a..04c32ce7aa6d6d2b813445b5b5640a4de0c0e53c 100644 (file)
@@ -104,6 +104,36 @@ def revert_Argument_to_TeX_brace(document, line, endline, n, nmax, environment,
 ###
 ###############################################################################
 
+def convert_longtable_label_internal(document, forward):
+    """
+    Convert reference to "LongTableNoNumber" into "Unnumbered" if forward is True
+    else revert it.
+    """
+    old_reference = "\\begin_inset Caption LongTableNoNumber"
+    new_reference = "\\begin_inset Caption Unnumbered"
+
+    # if the purpose is to revert swap the strings roles
+    if not forward:
+        old_reference, new_reference = new_reference, old_reference
+
+    i = 0
+    while True:
+        i = find_token(document.body, old_reference, i)
+
+        if i == -1:
+            return
+
+        document.body[i] = new_reference
+
+
+def convert_longtable_label(document):
+    convert_longtable_label_internal(document, True)
+
+
+def revert_longtable_label(document):
+    convert_longtable_label_internal(document, False)
+
+
 def convert_separator(document):
     """
     Convert layout separators to separator insets and add (LaTeX) paragraph
@@ -2201,110 +2231,6 @@ def revert_save_props(document):
     del document.header[i]
 
 
-def delete_TOG_project_URL(document):
-    i = 0
-    j = 0
-    while True:
-        # delete the TOG project URL
-        i = find_token(document.body, "\\begin_layout TOG project URL", i)
-        if i != -1:
-            j = find_end_of_layout(document.body, i + 1)
-        else:
-            return
-        if j != -1:
-            del(document.body[i : j + 1])
-        else:
-            document.warning("Malformed LyX document: Can't find end of layout TOG project URL")
-            return
-        i += 1
-
-
-def delete_TOG_video_URL(document):
-    i = 0
-    j = 0
-    while True:
-        # delete the TOG video URL
-        i = find_token(document.body, "\\begin_layout TOG video URL", i)
-        if i != -1:
-            j = find_end_of_layout(document.body, i)
-        else:
-            return
-        if j != -1:
-            del(document.body[i : j + 1])
-        else:
-            document.warning("Malformed LyX document: Can't find end of layout TOG video URL")
-            return
-        i += 1
-
-
-def delete_TOG_data_URL(document):
-    i = 0
-    j = 0
-    while True:
-        # delete the TOG video URL
-        i = find_token(document.body, "\\begin_layout TOG data URL", i)
-        if i != -1:
-            j = find_end_of_layout(document.body, i)
-        else:
-            return
-        if j != -1:
-            del(document.body[i : j + 1])
-        else:
-            document.warning("Malformed LyX document: Can't find end of layout TOG data URL")
-            return
-        i += 1
-
-
-def delete_TOG_code_URL(document):
-    i = 0
-    j = 0
-    while True:
-        # delete the TOG video URL
-        i = find_token(document.body, "\\begin_layout TOG code URL", i)
-        if i != -1:
-            j = find_end_of_layout(document.body, i)
-        else:
-            return
-        if j != -1:
-            del(document.body[i : j + 1])
-        else:
-            document.warning("Malformed LyX document: Can't find end of layout TOG code URL")
-            return
-        i += 1
-
-
-def convert_ACM_siggraph(document):
-    " Convert to version 0.92 of acmsiggraph. "
-    if document.textclass != "acmsiggraph":
-        return
-    # at first delete the now nonexistent styles since their info is now
-    # not needed and even unwanted
-    delete_TOG_project_URL(document)
-    delete_TOG_video_URL(document)
-    delete_TOG_data_URL(document)
-    delete_TOG_code_URL(document)
-    # now add a note that the user knows that he still has work to do
-    note = ["\\begin_layout Standard", "\\begin_inset Note Note", "status open", "",
-              "\\begin_layout Plain Layout", "", "\\series bold",
-              "\\color red", "Important note:", "\series default",
-              " This file was converted by \\SpecialChar LyX  to the format of acmsigplan 0.92.",
-              " This conversion is incomplete because you must add new information about",
-              " your article.",
-              " To see what is required, open the \\SpecialChar LyX  template file ",
-              "\\family sans",
-              "ACM-siggraph.lyx",
-              "\\family default",
-              ".",
-              "\\end_layout",
-              "",
-              "\\end_inset",
-              "",
-              "",
-              "\\end_layout",
-              ""]
-    document.body[1:1] = note
-
-
 def convert_info_tabular_feature(document):
     def f(arg):
         return arg.replace("inset-modify tabular", "tabular-feature")
@@ -2356,13 +2282,15 @@ convert = [
            [502, []],
            [503, []],
            [504, [convert_save_props]],
-           [505, [convert_ACM_siggraph]],
-           [506, [convert_info_tabular_feature]]
+           [505, []],
+           [506, [convert_info_tabular_feature]],
+           [507, [convert_longtable_label]]
           ]
 
 revert =  [
+           [506, [revert_longtable_label]],
            [505, [revert_info_tabular_feature]],
-           [504, [revert_save_props]],
+           [504, []],
            [503, [revert_save_props]],
            [502, [revert_verbatim_star]],
            [501, [revert_solution]],