]> git.lyx.org Git - features.git/commitdiff
Add TableStyle layout tag
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 26 Mar 2019 16:42:56 +0000 (17:42 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:21 +0000 (15:48 +0200)
Fixes: #8360
lib/doc/Customization.lyx
lib/doc/de/Customization.lyx
lib/scripts/layout2layout.py
src/BufferParams.cpp
src/Text3.cpp
src/TextClass.cpp
src/TextClass.h

index 89f97ab1537a1c1d3f7d0ee51ab397cb250d5a2f..50388eb215da65d8e22f1c863d4955e919c33616 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 567
+\lyxformat 569
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -124,6 +124,7 @@ logicalmkup
 \papercolumns 1
 \papersides 2
 \paperpagestyle headings
+\tablestyle default
 \tracking_changes true
 \output_changes false
 \html_math_output 0
@@ -10951,8 +10952,136 @@ reference "subsec:Paragraph-Styles"
 \end_inset
 
  for details on paragraph styles.
+\change_inserted -712698321 1553617804
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1553617862
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1553617809
+TableStyle
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1553617805
+<name>
+\end_layout
+
+\end_inset
+
+] defines the default table style that is used when inserting a table.
+ The following styles are available:
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+
+\change_inserted -712698321 1553617929
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1553617920
+Formal
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+: formal (
+\begin_inset Quotes eld
+\end_inset
+
+booktabs
+\begin_inset Quotes erd
+\end_inset
+
+) style with horizontal lines only and a bold top and bottom line.
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted -712698321 1553618031
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1553618006
+Simple_Grid
+\end_layout
+
+\end_inset
+
+: Simple table lines.
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted -712698321 1553618309
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1553618031
+Grid_with_Head
+\end_layout
+
+\end_inset
+
+: Like 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1553618043
+Simple_Grid
 \end_layout
 
+\end_inset
+
+, but with the header column offset with a second horizontal line.
+ This is also the default style of \SpecialChar LyX
+.
+\end_layout
+
+\begin_layout Itemize
+
+\change_inserted -712698321 1553618280
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1553618261
+No_Borders
+\end_layout
+
+\end_inset
+
+: Table without lines.
+\change_unchanged
+
+\end_layout
+
+\end_deeper
 \begin_layout Description
 \begin_inset Flex Code
 status collapsed
index 15cecf6c19ae09b1c4015c814d725884746b022f..79f354bcbc21efa5ae2603c00b47a6befdfeb3d0 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 564
+\lyxformat 569
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -132,6 +132,7 @@ logicalmkup
 \papercolumns 1
 \papersides 2
 \paperpagestyle headings
+\tablestyle default
 \tracking_changes false
 \output_changes false
 \html_math_output 0
@@ -9218,6 +9219,104 @@ reference "subsec:Einzelne-Absatz-Layouts"
 \begin_inset Flex Code
 status collapsed
 
+\begin_layout Plain Layout
+TableStyle
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+<name>
+\end_layout
+
+\end_inset
+
+] legt den Standardstil fest, der für eingefügte Tabellen verwendet wird.
+ Die folgenden Stile stehen zur Verfügung:
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+Formal
+\end_layout
+
+\end_inset
+
+: formaler Stil (
+\begin_inset Quotes eld
+\end_inset
+
+booktabs
+\begin_inset Quotes erd
+\end_inset
+
+) nur mit horizontalen Linien und fetter Linie am Kopf und Fuß der Tabelle.
+\end_layout
+
+\begin_layout Itemize
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+Simple_Grid
+\end_layout
+
+\end_inset
+
+: Einfache Tabellenlinien.
+\end_layout
+
+\begin_layout Itemize
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+Grid_with_Head
+\end_layout
+
+\end_inset
+
+: Wie 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+Simple_Grid
+\end_layout
+
+\end_inset
+
+, aber mit einer zusätzlichen horizontalen Linie unter der Kopfzeile.
+ Das ist auch der Standard-Tabellenstil von \SpecialChar LyX
+.
+\end_layout
+
+\begin_layout Itemize
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+No_Borders
+\end_layout
+
+\end_inset
+
+: Tabelle ohne Rahmenlinien.
+\end_layout
+
+\end_deeper
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
 \begin_layout Plain Layout
 TitleLatexName
 \end_layout
index 5d6c7ad0dc1eed84cb0eedf175607c50ecae910c..331a51f1be3a0f973545c9c3dd663d63f997c793 100644 (file)
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 71
+currentFormat = 72
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -239,6 +239,9 @@ currentFormat = 71
 # Incremented to format 71, 12 March 2019 by spitz
 # New [Inset]Layout tag NeedMBoxProtect
 
+# Incremented to format 72, 26 March 2019 by spitz
+# New TextClass tag TableStyle
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -488,7 +491,7 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if format >= 65 and format <= 70:
+        if format >= 65 and format <= 71:
             # nothing to do.
             i += 1
             continue
index 887dfa3de944ab2118357cc80ca611dbc0ca89fa..de46966f2e29573fe9162d6a73ca4eb758280961 100644 (file)
@@ -2440,6 +2440,7 @@ void BufferParams::useClassDefaults()
        sides = tclass.sides();
        columns = tclass.columns();
        pagestyle = tclass.pagestyle();
+       tablestyle = tclass.tablestyle();
        use_default_options = true;
        // Only if class has a ToC hierarchy
        if (tclass.hasTocLevels()) {
@@ -2456,6 +2457,7 @@ bool BufferParams::hasClassDefaults() const
        return sides == tclass.sides()
                && columns == tclass.columns()
                && pagestyle == tclass.pagestyle()
+               && tablestyle == tclass.tablestyle()
                && use_default_options
                && secnumdepth == tclass.secnumdepth()
                && tocdepth == tclass.tocdepth();
index e51d323e03733b9d17be95dd7c6bef4ee4b4b8f2..7baf9a8eba4fc0e0f22544a72c9458b4892870d7 100644 (file)
@@ -2078,19 +2078,28 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_TABULAR_INSERT: {
-               if (cur.buffer()->masterParams().tablestyle != "default") {
-                       FuncRequest fr(LFUN_TABULAR_STYLE_INSERT,
-                                      cur.buffer()->masterParams().tablestyle + " "
-                                      + to_ascii(cmd.argument()));
-                       lyx::dispatch(fr);
+               // if there were no arguments, just open the dialog
+               if (cmd.argument().empty()) {
+                       bv->showDialog("tabularcreate");
                        break;
+               } else if (cur.buffer()->masterParams().tablestyle != "default"
+                          || bv->buffer().params().documentClass().tablestyle() != "default") {
+                       string tabstyle = cur.buffer()->masterParams().tablestyle;
+                       if (tabstyle == "default")
+                               tabstyle = bv->buffer().params().documentClass().tablestyle();
+                       if (!libFileSearch("tabletemplates", tabstyle + ".lyx").empty()) {
+                               FuncRequest fr(LFUN_TABULAR_STYLE_INSERT,
+                                              tabstyle + " " + to_ascii(cmd.argument()));
+                               lyx::dispatch(fr);
+                               break;
+                       } else
+                               // Unknown style. Report and fall back to default.
+                               cur.errorMessage(from_utf8(N_("Table Style ")) + from_utf8(tabstyle) +
+                                                    from_utf8(N_(" not known")));
+                       
                }
-               // if there were no arguments, just open the dialog
                if (doInsertInset(cur, this, cmd, false, true))
                        cur.posForward();
-               else
-                       bv->showDialog("tabularcreate");
-
                break;
        }
 
index d1cf13b3bf852184db0b0b241e35e70bd6360bb1..566ac7a8e36ebee667a38836567d355fa2a9d701 100644 (file)
@@ -62,7 +62,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 = 71; // spitz: NeedMBoxProtect
+int const LAYOUT_FORMAT = 72; // spitz: TableStyle
 
 
 // Layout format for the current lyx file format. Controls which format is
@@ -151,9 +151,9 @@ TextClass::TextClass()
        : loaded_(false), tex_class_avail_(false),
          opt_enginetype_("authoryear|numerical"), opt_fontsize_("10|11|12"),
          opt_pagestyle_("empty|plain|headings|fancy"), pagestyle_("default"),
-         columns_(1), sides_(OneSide), secnumdepth_(3), tocdepth_(3),
-         outputType_(LATEX), outputFormat_("latex"), has_output_format_(false),
-         defaultfont_(sane_font),
+         tablestyle_("default"), columns_(1), sides_(OneSide), secnumdepth_(3),
+         tocdepth_(3), outputType_(LATEX), outputFormat_("latex"),
+         has_output_format_(false), defaultfont_(sane_font), 
          titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"),
          min_toclevel_(0), max_toclevel_(0), maxcitenames_(2),
          cite_full_author_list_(true)
@@ -226,7 +226,8 @@ enum TextClassTags {
        TC_MAXCITENAMES,
        TC_DEFAULTBIBLIO,
        TC_FULLAUTHORLIST,
-       TC_OUTLINERNAME
+       TC_OUTLINERNAME,
+       TC_TABLESTYLE
 };
 
 
@@ -279,6 +280,7 @@ LexerKeyword textClassTags[] = {
        { "secnumdepth",       TC_SECNUMDEPTH },
        { "sides",             TC_SIDES },
        { "style",             TC_STYLE },
+       { "tablestyle",        TC_TABLESTYLE },
        { "titlelatexname",    TC_TITLELATEXNAME },
        { "titlelatextype",    TC_TITLELATEXTYPE },
        { "tocdepth",          TC_TOCDEPTH }
@@ -863,6 +865,11 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                case TC_OUTLINERNAME:
                        error = !readOutlinerName(lexrc);
                        break;
+
+               case TC_TABLESTYLE:
+                       lexrc.next();
+                       tablestyle_ = rtrim(lexrc.getString());
+                       break;
                } // end of switch
        }
 
index b9ec227d4071c01f844274ffb48fed0d63753686..dc1b296475a1c9a8f7f3aeaa645c4a3bd3def913 100644 (file)
@@ -277,6 +277,8 @@ protected:
        ///
        std::string pagestyle_;
        ///
+       std::string tablestyle_;
+       ///
        std::string class_header_;
        ///
        docstring defaultlayout_;
@@ -453,6 +455,8 @@ public:
        ///
        std::string const & pagestyle() const { return pagestyle_; }
        ///
+       std::string const & tablestyle() const { return tablestyle_; }
+       ///
        docstring const & preamble() const { return preamble_; }
        ///
        docstring const & htmlpreamble() const { return htmlpreamble_; }