Add TableStyle layout tag

Fixes: #8360
This commit is contained in:
Juergen Spitzmueller 2019-03-26 17:42:56 +01:00
parent 9e684f3a16
commit 4b3aacd13b
7 changed files with 272 additions and 19 deletions

View 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

View 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

View 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

View 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();

View 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);
break;
}
// 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 (doInsertInset(cur, this, cmd, false, true))
cur.posForward();
else
bv->showDialog("tabularcreate");
break;
}

View 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
}

View 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_; }