Le 25/03/2016 20:08, Kornel Benko a écrit :
Am Freitag, 25. März 2016 um 19:51:53, schrieb Jean-Marc Lasgouttes 
<lasgout...@lyx.org>
...
---
  development/FORMAT                                 |     4 +
  lib/doc/de/EmbeddedObjects.lyx                     | 45901 -------------------

What is this? 45901 deleted lines?

This is what happens when one runs updatedocs.py and the lyx2lyx crashes. A deleted file :( The same holds for updatelayouts.py, but I caught this one at the time.

The following patch is more reasonable.

JMarc

>From f3288353659c2aa3f020c5c9a0f5c865ac2ca529 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Fri, 25 Mar 2016 19:22:57 +0100
Subject: [PATCH] Rename Caption:LongTableNoNumber to Caption:Unnumbered

The term LongTable has been deprecated and moreover the renaming makes the interface easier to the eye.

File format updated to 507. (conversion based on jamatos patch)
Layout format updated to 60.
tex2ylx tests updated.
---
 development/FORMAT                                 |  4 +++
 lib/lyx2lyx/LyX.py                                 |  2 +-
 lib/lyx2lyx/lyx_2_2.py                             | 34 +++++++++++++++++++++-
 lib/scripts/layout2layout.py                       | 17 ++++++++++-
 src/Text3.cpp                                      |  2 +-
 src/TextClass.cpp                                  |  2 +-
 src/insets/InsetCaption.cpp                        |  2 +-
 src/insets/InsetFloat.cpp                          |  2 +-
 src/insets/InsetTabular.cpp                        |  2 +-
 src/tex2lyx/test/CJK.lyx.lyx                       |  2 +-
 src/tex2lyx/test/CJKutf8.lyx.lyx                   |  2 +-
 src/tex2lyx/test/DummyDocument.lyx.lyx             |  2 +-
 src/tex2lyx/test/Dummy~Document.lyx.lyx            |  2 +-
 src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx         |  2 +-
 src/tex2lyx/test/algo2e.lyx.lyx                    |  2 +-
 .../test/box-color-size-space-align.lyx.lyx        |  2 +-
 src/tex2lyx/test/test-insets-basic.lyx.lyx         |  6 ++--
 src/tex2lyx/test/test-insets.lyx.lyx               |  6 ++--
 src/tex2lyx/test/test-memoir.lyx.lyx               |  2 +-
 src/tex2lyx/test/test-modules.lyx.lyx              |  2 +-
 src/tex2lyx/test/test-refstyle-theorems.lyx.lyx    |  2 +-
 src/tex2lyx/test/test-scr.lyx.lyx                  |  2 +-
 src/tex2lyx/test/test-structure.lyx.lyx            |  2 +-
 src/tex2lyx/test/test.lyx.lyx                      |  2 +-
 src/tex2lyx/test/verbatim.lyx.lyx                  |  2 +-
 src/version.h                                      |  4 +--
 26 files changed, 81 insertions(+), 30 deletions(-)

diff --git a/development/FORMAT b/development/FORMAT
index 1d24d92..9384409 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -11,6 +11,10 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
 
 -----------------------
 
+2016-03-25 Jean-Marc Lasgouttes <lasgout...@lyx.org>
+	* Format incremented to 507
+	  Convert caption subtype LongTableNoNumber to Unnumbered
+
 2016-01-26 Guillaume Munch <g...@lyx.org>
 	* Format incremented to 506
 	  No new parameters.
diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py
index b2b5731..e7078f1 100644
--- a/lib/lyx2lyx/LyX.py
+++ b/lib/lyx2lyx/LyX.py
@@ -86,7 +86,7 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
                    ("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
                    ("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
-                   ("2_2", list(range(475,507)), minor_versions("2.2" , 0))
+                   ("2_2", list(range(475,508)), minor_versions("2.2" , 0))
                   ]
 
 ####################################################################
diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py
index a1f3005..04c32ce 100644
--- a/lib/lyx2lyx/lyx_2_2.py
+++ b/lib/lyx2lyx/lyx_2_2.py
@@ -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
@@ -2253,10 +2283,12 @@ convert = [
            [503, []],
            [504, [convert_save_props]],
            [505, []],
-           [506, [convert_info_tabular_feature]]
+           [506, [convert_info_tabular_feature]],
+           [507, [convert_longtable_label]]
           ]
 
 revert =  [
+           [506, [revert_longtable_label]],
            [505, [revert_info_tabular_feature]],
            [504, []],
            [503, [revert_save_props]],
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index a87c300..7de844b 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -198,6 +198,9 @@ import os, re, string, sys
 # New Layout tags "AddToToc", "IsTocCaption"
 # New Layout argument tag "IsTocCaption"
 
+# Incremented to format 60, 25 March 2016 by lasgouttes
+# Rename caption subtype LongTableNoNumber to Unnumbered
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -205,7 +208,7 @@ import os, re, string, sys
 # development/tools/updatelayouts.py script to update all
 # layout files to the new format.
 
-currentFormat = 59
+currentFormat = 60
 
 
 def usage(prog_name):
@@ -319,6 +322,7 @@ def convert(lines):
     re_TopEnvironment = re.compile(r'^(\s*)LabelType(\s+)Top_Environment\s*$', re.IGNORECASE)
     re_CenteredEnvironment = re.compile(r'^(\s*)LabelType(\s+)Centered_Top_Environment\s*$', re.IGNORECASE)
     re_ChapterStyle = re.compile(r'^\s*Style\s+Chapter\s*$', re.IGNORECASE)
+    re_InsetLayout_CaptionLTNN = re.compile(r'^(\s*InsetLayout\s+)(Caption:LongTableNonumber)', re.IGNORECASE)
 
 
     # counters for sectioning styles (hardcoded in 1.3)
@@ -430,6 +434,17 @@ def convert(lines):
                 i += 1
             continue
 
+        if format == 59:
+            match = re_InsetLayout_CaptionLTNN.match(lines[i])
+            if not match:
+                i += 1
+                continue
+            # '^(\s*InsetLayout\s+)(Caption:LongTableNonumber)'
+            lead  = match.group(1)
+            lines[i] = lead + "Caption:Unnumbered"
+            i += 1
+            continue
+
         if format == 58:
             # nothing to do.
             i += 1
diff --git a/src/Text3.cpp b/src/Text3.cpp
index fbcd9b7..15ffb28 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -2718,7 +2718,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
 	case LFUN_CAPTION_INSERT: {
 		code = CAPTION_CODE;
 		string arg = cmd.getArg(0);
-		bool varia = arg != "LongTableNoNumber"
+		bool varia = arg != "Unnumbered"
 			&& cur.inset().allowsCaptionVariation(arg);
 		// not allowed in description items,
 		// and in specific insets
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index c6f3ee0..b6b76fd 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -61,7 +61,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 59; //gm: OutlinerName, AddToToc, IsTocCaption
+int const LAYOUT_FORMAT = 60; //lasgouttes LongTableNoNumber => Unnumbered
 
 namespace {
 
diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp
index 21b834a..b69d1ba 100644
--- a/src/insets/InsetCaption.cpp
+++ b/src/insets/InsetCaption.cpp
@@ -224,7 +224,7 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd,
 		if (first_arg == "changetype") {
 			string const type = cmd.getArg(1);
 			status.setOnOff(type == type_);
-			bool varia = type != "LongTableNoNumber";
+			bool varia = type != "Unnumbered";
 			// check if the immediate parent inset allows caption variation
 			if (cur.depth() > 1) {
 				varia = cur[cur.depth() - 2].inset().allowsCaptionVariation(type);
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index cfd4002..ae1bf63 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -487,7 +487,7 @@ void InsetFloat::setNewLabel()
 
 bool InsetFloat::allowsCaptionVariation(std::string const & newtype) const
 {
-	return !params_.subfloat && newtype != "LongTableNoNumber";
+	return !params_.subfloat && newtype != "Unnumbered";
 }
 
 
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 6d8f7d0..4f94c83 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3521,7 +3521,7 @@ bool InsetTabular::insetAllowed(InsetCode code) const
 bool InsetTabular::allowsCaptionVariation(std::string const & newtype) const
 {
 	return tabular.is_long_tabular &&
-		(newtype == "Standard" || newtype == "LongTableNoNumber");
+		(newtype == "Standard" || newtype == "Unnumbered");
 }
 
 
diff --git a/src/tex2lyx/test/CJK.lyx.lyx b/src/tex2lyx/test/CJK.lyx.lyx
index 7bc5896..eaee089 100644
--- a/src/tex2lyx/test/CJK.lyx.lyx
+++ b/src/tex2lyx/test/CJK.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/CJKutf8.lyx.lyx b/src/tex2lyx/test/CJKutf8.lyx.lyx
index 1b23ea1..d065946 100644
--- a/src/tex2lyx/test/CJKutf8.lyx.lyx
+++ b/src/tex2lyx/test/CJKutf8.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/DummyDocument.lyx.lyx b/src/tex2lyx/test/DummyDocument.lyx.lyx
index 8be454e..583c8e4 100644
--- a/src/tex2lyx/test/DummyDocument.lyx.lyx
+++ b/src/tex2lyx/test/DummyDocument.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/Dummy~Document.lyx.lyx b/src/tex2lyx/test/Dummy~Document.lyx.lyx
index db40c8b..5f1ac1f 100644
--- a/src/tex2lyx/test/Dummy~Document.lyx.lyx
+++ b/src/tex2lyx/test/Dummy~Document.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
index 1c34977..eb50ffe 100644
--- a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
+++ b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/algo2e.lyx.lyx b/src/tex2lyx/test/algo2e.lyx.lyx
index 4615e90..7f1de8a 100644
--- a/src/tex2lyx/test/algo2e.lyx.lyx
+++ b/src/tex2lyx/test/algo2e.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
index 762f3bf..4a572e0 100644
--- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
+++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-insets-basic.lyx.lyx b/src/tex2lyx/test/test-insets-basic.lyx.lyx
index dfd4042..369a479 100644
--- a/src/tex2lyx/test/test-insets-basic.lyx.lyx
+++ b/src/tex2lyx/test/test-insets-basic.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -1539,7 +1539,7 @@ Second
 
 \begin_layout Standard
 
-\begin_inset Caption LongTableNoNumber
+\begin_inset Caption Unnumbered
 
 \begin_layout Plain Layout
 standard foot
@@ -1584,7 +1584,7 @@ bottom.
 
 \begin_layout Standard
 
-\begin_inset Caption LongTableNoNumber
+\begin_inset Caption Unnumbered
 
 \begin_layout Plain Layout
 (last foot)
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx b/src/tex2lyx/test/test-insets.lyx.lyx
index 33e83f6..e22b2da 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -1596,7 +1596,7 @@ Second
 
 \begin_layout Standard
 
-\begin_inset Caption LongTableNoNumber
+\begin_inset Caption Unnumbered
 
 \begin_layout Plain Layout
 standard foot
@@ -1641,7 +1641,7 @@ bottom.
 
 \begin_layout Standard
 
-\begin_inset Caption LongTableNoNumber
+\begin_inset Caption Unnumbered
 
 \begin_layout Plain Layout
 (last foot)
diff --git a/src/tex2lyx/test/test-memoir.lyx.lyx b/src/tex2lyx/test/test-memoir.lyx.lyx
index 41e382f..73bc66a 100644
--- a/src/tex2lyx/test/test-memoir.lyx.lyx
+++ b/src/tex2lyx/test/test-memoir.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-modules.lyx.lyx b/src/tex2lyx/test/test-modules.lyx.lyx
index a248d6a..3de6556 100644
--- a/src/tex2lyx/test/test-modules.lyx.lyx
+++ b/src/tex2lyx/test/test-modules.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
index a51c546..eeae6ff 100644
--- a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
+++ b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-scr.lyx.lyx b/src/tex2lyx/test/test-scr.lyx.lyx
index 8d0ebff..6e6688e 100644
--- a/src/tex2lyx/test/test-scr.lyx.lyx
+++ b/src/tex2lyx/test/test-scr.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-structure.lyx.lyx b/src/tex2lyx/test/test-structure.lyx.lyx
index f4bba82..db2763c 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test.lyx.lyx b/src/tex2lyx/test/test.lyx.lyx
index 407f802..dfc628c 100644
--- a/src/tex2lyx/test/test.lyx.lyx
+++ b/src/tex2lyx/test/test.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/verbatim.lyx.lyx b/src/tex2lyx/test/verbatim.lyx.lyx
index d552d16..6438247 100644
--- a/src/tex2lyx/test/verbatim.lyx.lyx
+++ b/src/tex2lyx/test/verbatim.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 506
+\lyxformat 507
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/version.h b/src/version.h
index 9a37739..a87b5bc 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 506 // guillaume munch: convert "inset-modify tabular"
-#define LYX_FORMAT_TEX2LYX 506
+#define LYX_FORMAT_LYX 507 // lasgouttes: rename LongTableNoNumber to Unnumbered
+#define LYX_FORMAT_TEX2LYX 507
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER
-- 
2.5.0

Reply via email to