mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Switch font for multipar insets
Use font switches for insets that allow paragraph breaks rather than insets that do not inherit outer font settings. No change of behavior is intended with respect to the current status, but this will allow a simple and effective fix for #10263.
This commit is contained in:
parent
f348e0edc5
commit
f5672a4843
@ -1039,7 +1039,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
|
||||
// ArabTeX, though, cannot handle this special behavior, it seems.
|
||||
bool arabtex = basefont.language()->lang() == "arabic_arabtex"
|
||||
|| running_font.language()->lang() == "arabic_arabtex";
|
||||
if (open_font && !inset->inheritFont()) {
|
||||
if (open_font && (!inset->inheritFont() || inset->allowMultiPar())) {
|
||||
bool closeLanguage = arabtex
|
||||
|| basefont.isRightToLeft() == running_font.isRightToLeft();
|
||||
unsigned int count = running_font.latexWriteStartChanges(os, bparams,
|
||||
@ -2563,14 +2563,14 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
&& runningChange == change
|
||||
&& change.type == Change::DELETED
|
||||
&& !os.afterParbreak());
|
||||
bool const non_inherit_inset =
|
||||
(c == META_INSET && getInset(i) && !getInset(i)->inheritFont());
|
||||
bool const multipar_inset =
|
||||
(c == META_INSET && getInset(i) && getInset(i)->allowMultiPar());
|
||||
|
||||
// Do we need to close the previous font?
|
||||
if (open_font &&
|
||||
((current_font != running_font
|
||||
|| current_font.language() != running_font.language())
|
||||
|| (non_inherit_inset
|
||||
|| (multipar_inset
|
||||
&& (current_font == prev_font
|
||||
|| current_font.language() == prev_font.language()))))
|
||||
{
|
||||
@ -2658,7 +2658,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
column += 1;
|
||||
}
|
||||
otexstringstream ots;
|
||||
if (!non_inherit_inset) {
|
||||
if (!multipar_inset) {
|
||||
column += current_font.latexWriteStartChanges(ots, bparams,
|
||||
runparams, basefont, last_font, false,
|
||||
needsCProtection(runparams.moving_arg));
|
||||
@ -2754,13 +2754,13 @@ void Paragraph::latex(BufferParams const & bparams,
|
||||
}
|
||||
}
|
||||
// We need to restore these after insets with
|
||||
// inheritFont() false
|
||||
// allowMultiPar() true
|
||||
Font const save_running_font = running_font;
|
||||
Font const save_basefont = basefont;
|
||||
d->latexInset(bparams, os, rp, running_font,
|
||||
basefont, real_outerfont, open_font,
|
||||
runningChange, style, i, column);
|
||||
if (non_inherit_inset) {
|
||||
if (multipar_inset) {
|
||||
running_font = save_running_font;
|
||||
basefont = save_basefont;
|
||||
}
|
||||
|
@ -592,6 +592,8 @@ public:
|
||||
virtual bool asciiOnly() const { return false; }
|
||||
/// returns whether this inset is allowed in other insets of given mode
|
||||
virtual bool allowedIn(mode_type) const { return true; }
|
||||
/// returns whether paragraph breaks can occur inside this inset
|
||||
virtual bool allowMultiPar() const { return false; }
|
||||
/**
|
||||
* The font is inherited from the parent for LaTeX export if this
|
||||
* method returns true. No open font changes are closed in front of
|
||||
|
@ -4366,6 +4366,18 @@ bool InsetTabular::insetAllowed(InsetCode code) const
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::allowMultiPar() const
|
||||
{
|
||||
for (Tabular::col_type c = 0; c < tabular.ncols(); ++c) {
|
||||
for (Tabular::row_type r = 0; r < tabular.nrows(); ++r) {
|
||||
if (tabular.cellInset(r,c)->allowMultiPar())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::allowsCaptionVariation(std::string const & newtype) const
|
||||
{
|
||||
return tabular.is_long_tabular &&
|
||||
|
@ -83,6 +83,8 @@ public:
|
||||
void metrics(MetricsInfo &, Dimension &) const;
|
||||
/// Needs to be same as InsetTabular
|
||||
bool inheritFont() const { return false; }
|
||||
/// Can the cell contain several paragraphs?
|
||||
bool allowMultiPar() const { return !isMultiRow && (!isMultiColumn || isFixedWidth); }
|
||||
private:
|
||||
/// unimplemented
|
||||
InsetTableCell();
|
||||
@ -135,8 +137,6 @@ private:
|
||||
virtual bool forceLocalFontSwitch() const;
|
||||
/// Is the width forced to some value?
|
||||
bool hasFixedWidth() const { return isFixedWidth; }
|
||||
/// Can the cell contain several paragraphs?
|
||||
bool allowMultiPar() const { return !isMultiRow && (!isMultiColumn || isFixedWidth); }
|
||||
};
|
||||
|
||||
|
||||
@ -979,6 +979,8 @@ public:
|
||||
insets that may contain several paragraphs */
|
||||
bool inheritFont() const { return false; }
|
||||
///
|
||||
bool allowMultiPar() const;
|
||||
///
|
||||
bool allowsCaptionVariation(std::string const &) const;
|
||||
//
|
||||
bool isTable() const { return true; }
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
///
|
||||
virtual bool isMacroScope() const { return false; }
|
||||
///
|
||||
virtual bool allowMultiPar() const { return getLayout().isMultiPar(); }
|
||||
bool allowMultiPar() const { return getLayout().isMultiPar(); }
|
||||
///
|
||||
bool isInTitle() const { return intitle_context_; }
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user