diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index 4a7cfc308f..8fafff8caf 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -4,7 +4,7 @@ # # Detailed format description is available in the customization manual -Format 100 +Format 101 Provides stdinsets 1 @@ -19,6 +19,7 @@ InsetLayout Marginal LabelString Margin LatexType command LatexName marginpar + InheritFont false Font Size Small EndFont @@ -52,6 +53,7 @@ InsetLayout Foot LatexType Command LatexName footnote Counter footnote + InheritFont false Font Size Small EndFont @@ -138,6 +140,7 @@ InsetLayout Note:Comment LatexName comment Requires verbatim BgColor commentbg + InheritFont false LabelFont Color comment Size Small @@ -179,6 +182,7 @@ InsetLayout Note:Greyedout LatexName lyxgreyedout Requires color,lyxgreyedout BgColor greyedoutbg + InheritFont false Font Size Normal Color greyedouttext @@ -351,6 +355,7 @@ InsetLayout Listings LabelString Listings[[inset]] LatexType none Decoration minimalistic + InheritFont false Font Color foreground Family typewriter @@ -462,6 +467,7 @@ InsetLayout IndexMacro:subentry End InsetLayout Box + InheritFont false LabelFont Color foreground Size Small @@ -572,6 +578,7 @@ End InsetLayout Float LaTeXType environment + InheritFont false LabelFont Color collapsible Size Small @@ -800,6 +807,7 @@ InsetLayout PrintNomencl End InsetLayout Tabular + InheritFont false HTMLStyle table { border-collapse: collapse; diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 46a433cc22..54f705910b 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -478,8 +478,9 @@ def convert(lines, end_format): re_trimLabelStringAppendix = re.compile(b'^(\\s*LabelStringAppendix\\s+)"\\s*(.*?)\\s*"\\s*$') re_trimEndLabelString = re.compile(b'^(\\s*EndLabelString\\s+)"\\s*(.*?)\\s*"\\s*$') re_trimLabelCounter = re.compile(b'^(\\s*LabelCounter\\s+)"\\s*(.*?)\\s*"\\s*$') - - + # for format 100 + re_InsetLayout100 = re.compile(b'^\\s*InsetLayout\\s+\\"?(Box|Float|Foot|Marginal|Listings|Note:Comment|Note:Greyedout|Tabular)(:\\S*)?\\"?\\s*$', re.IGNORECASE) + re_InheritFont = re.compile(b'^(\\s*)InheritFont(\\s+)(\\S+)$', re.IGNORECASE) # counters for sectioning styles (hardcoded in 1.3) counters = {b"part" : b"\\Roman{part}", b"chapter" : b"\\arabic{chapter}", @@ -586,7 +587,36 @@ def convert(lines, end_format): i += 1 continue - if 87 <= format <= 101: + if format == 100: + # InheritFont has been introduced and defaults to true. Some insets had + # an hardcoded inheritFont') method returning true. We removed them, so + # we want to introduce the correct tag if it is not already there. + match = re_InsetLayout100.match(lines[i]) + if not match: + i += 1 + continue + + inheritfont_found = False + inherited = False + while i < len(lines): + match = re_InheritFont.match(lines[i]) + if match: + inheritfont_found = True + else: + match = re_CopyStyle.match(lines[i]) + if match: + inherited = True + else: + match = re_End.match(lines[i]) + if match: + break + i += 1 + if not inheritfont_found and not inherited: + lines.insert(i, b"\tInheritFont false") + + continue + + if 87 <= format <= 99: # nothing to do. i += 1 continue diff --git a/src/TextClass.cpp b/src/TextClass.cpp index b4b1ce99df..4dd9ae091c 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -59,7 +59,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 = 100; // forenr: add inset label color +int const LAYOUT_FORMAT = 101; // lasgouttes: add InheritFont tag // Layout format for the current lyx file format. Controls which format is diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h index cc80da3ecd..f15896cb33 100644 --- a/src/insets/InsetBox.h +++ b/src/insets/InsetBox.h @@ -127,8 +127,6 @@ public: /// bool neverIndent() const override { return true; } /// - bool inheritFont() const override { return false; } - /// void latex(otexstream &, OutputParams const &) const override; /// int plaintext(odocstringstream & ods, OutputParams const & op, diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index 20ee6452e8..50c698a43e 100644 --- a/src/insets/InsetFloat.h +++ b/src/insets/InsetFloat.h @@ -105,8 +105,6 @@ private: /// bool insetAllowed(InsetCode) const override; /// - bool inheritFont() const override { return false; } - /// bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override; /// bool hasSubCaptions(ParIterator const & it) const override; diff --git a/src/insets/InsetFootlike.h b/src/insets/InsetFootlike.h index e0a3fd31d0..a2f9939d7f 100644 --- a/src/insets/InsetFootlike.h +++ b/src/insets/InsetFootlike.h @@ -31,10 +31,6 @@ private: void write(std::ostream & os) const override; /// bool insetAllowed(InsetCode) const override; - /** returns false if, when outputting LaTeX, font changes should - be closed before generating this inset. This is needed for - insets that may contain several paragraphs */ - bool inheritFont() const override { return false; } }; diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index d75f96851e..c72865cd90 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -43,8 +43,6 @@ public: private: /// bool isLabeled() const override { return true; } - /// false is needed since listings do their own font handling. - bool inheritFont() const override { return false; } /// InsetCode lyxCode() const override { return LISTINGS_CODE; } /// lstinline is inlined, normal listing is displayed diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index 32bb26bbf6..94a07906e5 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -61,8 +61,6 @@ private: InsetCode lyxCode() const override { return NOTE_CODE; } /// docstring layoutName() const override; - /// - bool inheritFont() const override { return params_.type == InsetNoteParams::Note; } /// Is the content of this inset part of the output document? bool producesOutput() const override { return params_.type == InsetNoteParams::Greyedout; } diff --git a/src/insets/InsetScript.h b/src/insets/InsetScript.h index 9eb80dbbd5..1a008a9888 100644 --- a/src/insets/InsetScript.h +++ b/src/insets/InsetScript.h @@ -95,8 +95,6 @@ public: /// bool neverIndent() const override { return true; } /// - bool inheritFont() const override { return true; } - /// int plaintext(odocstringstream & ods, OutputParams const & op, size_t max_length = INT_MAX) const override; /// diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 5602984b33..84b9ae4222 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -62,6 +62,8 @@ public: /// InsetCode lyxCode() const override { return CELL_CODE; } /// + docstring layoutName() const override { return from_ascii("Tabular:Cell"); } + /// Inset * clone() const override { return new InsetTableCell(*this); } /// bool getStatus(Cursor & cur, FuncRequest const & cmd, @@ -88,8 +90,6 @@ public: UpdateType utype, TocBackend & backend) const override; /// void metrics(MetricsInfo &, Dimension &) const override; - /// Needs to be same as InsetTabular - bool inheritFont() const override { return false; } /// Can the cell contain several paragraphs? bool allowMultiPar() const override { return !isMultiRow && (!isMultiColumn || isFixedWidth); } /// @@ -1039,8 +1039,6 @@ public: /// bool canPaintChange(BufferView const &) const override { return true; } /// - bool inheritFont() const override { return false; } - /// bool allowMultiPar() const override; /// bool allowsCaptionVariation(std::string const &) const override;