mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Replace hardcoded inheritFont() with InheritFont InsetLayout tag
Each removed inheritFont method is replaced by a 'InheritFont false' line in the relevant InsetLayout entry. Add code to layout2layout that does this automatically when the entry is missing. The case of InsetScript is special, since the inheritFont() was not needed here: the default is indeed true. Fixes bug #12238.
This commit is contained in:
parent
747de78f9c
commit
81e35bc396
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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; }
|
||||
|
@ -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;
|
||||
///
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user