From fd1ee3b424786db6428bd9e39cad9a79071f9482 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes 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. Document EmbeddedObjects.lyx has been updated. --- development/FORMAT | 4 +++ lib/doc/EmbeddedObjects.lyx | 8 ++--- .../Changelog-EmbeddedObjects-LyX_22x.txt | 3 ++ 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 +- .../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 +-- 28 files changed, 88 insertions(+), 34 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 1d24d92937..9384409b53 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 + * Format incremented to 507 + Convert caption subtype LongTableNoNumber to Unnumbered + 2016-01-26 Guillaume Munch * Format incremented to 506 No new parameters. diff --git a/lib/doc/EmbeddedObjects.lyx b/lib/doc/EmbeddedObjects.lyx index ad7ed8b793..63f8e170c5 100644 --- a/lib/doc/EmbeddedObjects.lyx +++ b/lib/doc/EmbeddedObjects.lyx @@ -1,5 +1,5 @@ #LyX 2.2 created this file. For more info see http://www.lyx.org/ -\lyxformat 506 +\lyxformat 507 \begin_document \begin_header \save_transient_properties true @@ -7689,7 +7689,7 @@ Caption \begin_inset space ~ \end_inset -(LongTableNoNumber) +(Unnumbered) \family default . Table @@ -7842,7 +7842,7 @@ TEL. \begin_inset Text \begin_layout Plain Layout -\begin_inset Caption LongTableNoNumber +\begin_inset Caption Unnumbered \begin_layout Plain Layout Continued Example Phone List @@ -10017,7 +10017,7 @@ TEL. \begin_inset Text \begin_layout Plain Layout -\begin_inset Caption LongTableNoNumber +\begin_inset Caption Unnumbered \begin_layout Plain Layout Continued Example Phone List diff --git a/lib/doc/attic/Changelog-EmbeddedObjects-LyX_22x.txt b/lib/doc/attic/Changelog-EmbeddedObjects-LyX_22x.txt index 722ed35e3f..8e02ad7f2c 100644 --- a/lib/doc/attic/Changelog-EmbeddedObjects-LyX_22x.txt +++ b/lib/doc/attic/Changelog-EmbeddedObjects-LyX_22x.txt @@ -16,3 +16,6 @@ second step: entries)of longtable accordingly occurrences: sec. 2.2, 2.6, 2.7, 4.2 - sec. 7.1: new template "vector graphics" + +second step (cont'd by lasgouttes) +- sec. 2.6.3.3: caption type LongTableNoNumber has been renamed to Unumbered. diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index b2b57313ce..e7078f148c 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 a1f3005d7e..04c32ce7aa 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 a87c300a88..7de844b87f 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 fbcd9b7206..15ffb2881f 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 c9655df6dc..e1e40272ea 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 21b834aac5..b69d1ba71a 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 cfd4002677..ae1bf63816 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 6d8f7d0737..4f94c8333f 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 7bc5896ff1..eaee0894f6 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 1b23ea107a..d065946b7b 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 8be454e868..583c8e414a 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 db40c8bd93..5f1ac1f4df 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 1c34977234..eb50ffe2cf 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 4615e903ff..7f1de8a1c9 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 762f3bfcec..4a572e0d7f 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 dfd4042a27..369a4798fc 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 33e83f665c..e22b2da361 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 41e382f836..73bc66a3df 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 a248d6a166..3de6556083 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 a51c5460e1..eeae6ffba1 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 8d0ebffc0c..6e6688ef4f 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 f4bba823cf..db2763ca2b 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 407f802362..dfc628cfcf 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 d552d1698e..6438247dd8 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 9a377391d2..a87b5bcd44 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