mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +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.
|
// ArabTeX, though, cannot handle this special behavior, it seems.
|
||||||
bool arabtex = basefont.language()->lang() == "arabic_arabtex"
|
bool arabtex = basefont.language()->lang() == "arabic_arabtex"
|
||||||
|| running_font.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
|
bool closeLanguage = arabtex
|
||||||
|| basefont.isRightToLeft() == running_font.isRightToLeft();
|
|| basefont.isRightToLeft() == running_font.isRightToLeft();
|
||||||
unsigned int count = running_font.latexWriteStartChanges(os, bparams,
|
unsigned int count = running_font.latexWriteStartChanges(os, bparams,
|
||||||
@ -2563,14 +2563,14 @@ void Paragraph::latex(BufferParams const & bparams,
|
|||||||
&& runningChange == change
|
&& runningChange == change
|
||||||
&& change.type == Change::DELETED
|
&& change.type == Change::DELETED
|
||||||
&& !os.afterParbreak());
|
&& !os.afterParbreak());
|
||||||
bool const non_inherit_inset =
|
bool const multipar_inset =
|
||||||
(c == META_INSET && getInset(i) && !getInset(i)->inheritFont());
|
(c == META_INSET && getInset(i) && getInset(i)->allowMultiPar());
|
||||||
|
|
||||||
// Do we need to close the previous font?
|
// Do we need to close the previous font?
|
||||||
if (open_font &&
|
if (open_font &&
|
||||||
((current_font != running_font
|
((current_font != running_font
|
||||||
|| current_font.language() != running_font.language())
|
|| current_font.language() != running_font.language())
|
||||||
|| (non_inherit_inset
|
|| (multipar_inset
|
||||||
&& (current_font == prev_font
|
&& (current_font == prev_font
|
||||||
|| current_font.language() == prev_font.language()))))
|
|| current_font.language() == prev_font.language()))))
|
||||||
{
|
{
|
||||||
@ -2658,7 +2658,7 @@ void Paragraph::latex(BufferParams const & bparams,
|
|||||||
column += 1;
|
column += 1;
|
||||||
}
|
}
|
||||||
otexstringstream ots;
|
otexstringstream ots;
|
||||||
if (!non_inherit_inset) {
|
if (!multipar_inset) {
|
||||||
column += current_font.latexWriteStartChanges(ots, bparams,
|
column += current_font.latexWriteStartChanges(ots, bparams,
|
||||||
runparams, basefont, last_font, false,
|
runparams, basefont, last_font, false,
|
||||||
needsCProtection(runparams.moving_arg));
|
needsCProtection(runparams.moving_arg));
|
||||||
@ -2754,13 +2754,13 @@ void Paragraph::latex(BufferParams const & bparams,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We need to restore these after insets with
|
// We need to restore these after insets with
|
||||||
// inheritFont() false
|
// allowMultiPar() true
|
||||||
Font const save_running_font = running_font;
|
Font const save_running_font = running_font;
|
||||||
Font const save_basefont = basefont;
|
Font const save_basefont = basefont;
|
||||||
d->latexInset(bparams, os, rp, running_font,
|
d->latexInset(bparams, os, rp, running_font,
|
||||||
basefont, real_outerfont, open_font,
|
basefont, real_outerfont, open_font,
|
||||||
runningChange, style, i, column);
|
runningChange, style, i, column);
|
||||||
if (non_inherit_inset) {
|
if (multipar_inset) {
|
||||||
running_font = save_running_font;
|
running_font = save_running_font;
|
||||||
basefont = save_basefont;
|
basefont = save_basefont;
|
||||||
}
|
}
|
||||||
|
@ -592,6 +592,8 @@ public:
|
|||||||
virtual bool asciiOnly() const { return false; }
|
virtual bool asciiOnly() const { return false; }
|
||||||
/// returns whether this inset is allowed in other insets of given mode
|
/// returns whether this inset is allowed in other insets of given mode
|
||||||
virtual bool allowedIn(mode_type) const { return true; }
|
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
|
* The font is inherited from the parent for LaTeX export if this
|
||||||
* method returns true. No open font changes are closed in front of
|
* 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
|
bool InsetTabular::allowsCaptionVariation(std::string const & newtype) const
|
||||||
{
|
{
|
||||||
return tabular.is_long_tabular &&
|
return tabular.is_long_tabular &&
|
||||||
|
@ -83,6 +83,8 @@ public:
|
|||||||
void metrics(MetricsInfo &, Dimension &) const;
|
void metrics(MetricsInfo &, Dimension &) const;
|
||||||
/// Needs to be same as InsetTabular
|
/// Needs to be same as InsetTabular
|
||||||
bool inheritFont() const { return false; }
|
bool inheritFont() const { return false; }
|
||||||
|
/// Can the cell contain several paragraphs?
|
||||||
|
bool allowMultiPar() const { return !isMultiRow && (!isMultiColumn || isFixedWidth); }
|
||||||
private:
|
private:
|
||||||
/// unimplemented
|
/// unimplemented
|
||||||
InsetTableCell();
|
InsetTableCell();
|
||||||
@ -135,8 +137,6 @@ private:
|
|||||||
virtual bool forceLocalFontSwitch() const;
|
virtual bool forceLocalFontSwitch() const;
|
||||||
/// Is the width forced to some value?
|
/// Is the width forced to some value?
|
||||||
bool hasFixedWidth() const { return isFixedWidth; }
|
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 */
|
insets that may contain several paragraphs */
|
||||||
bool inheritFont() const { return false; }
|
bool inheritFont() const { return false; }
|
||||||
///
|
///
|
||||||
|
bool allowMultiPar() const;
|
||||||
|
///
|
||||||
bool allowsCaptionVariation(std::string const &) const;
|
bool allowsCaptionVariation(std::string const &) const;
|
||||||
//
|
//
|
||||||
bool isTable() const { return true; }
|
bool isTable() const { return true; }
|
||||||
|
@ -161,7 +161,7 @@ public:
|
|||||||
///
|
///
|
||||||
virtual bool isMacroScope() const { return false; }
|
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_; }
|
bool isInTitle() const { return intitle_context_; }
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user