mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Prevent access to null local_font
This commit is contained in:
parent
1d00389bf8
commit
fc9684a130
@ -672,4 +672,12 @@ docstring Inset::completionPrefix(Cursor const &) const
|
||||
return docstring();
|
||||
}
|
||||
|
||||
|
||||
Language const * Inset::getLocalOrDefaultLang(const OutputParams & rp) const
|
||||
{
|
||||
return (rp.local_font != nullptr)
|
||||
? rp.local_font->language()
|
||||
: buffer().params().language;
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -54,6 +54,7 @@ class InsetList;
|
||||
class InsetMath;
|
||||
class InsetTabular;
|
||||
class InsetText;
|
||||
class Language;
|
||||
class LaTeXFeatures;
|
||||
class Lexer;
|
||||
class MathAtom;
|
||||
@ -618,6 +619,9 @@ public:
|
||||
/// Determine the action of backspace and delete: do we select instead of
|
||||
/// deleting if not already selected?
|
||||
virtual bool confirmDeletion() const { return false; }
|
||||
/// Return the local_font's language or the buffer's default language
|
||||
/// if local_font is null
|
||||
Language const * getLocalOrDefaultLang(const OutputParams &) const;
|
||||
|
||||
protected:
|
||||
/// Constructors
|
||||
|
@ -355,7 +355,8 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
|
||||
string maybeBeginL;
|
||||
string maybeEndL;
|
||||
bool needEndL = false;
|
||||
if (!runparams.isFullUnicode() && runparams.local_font->isRightToLeft()) {
|
||||
if (!runparams.isFullUnicode()
|
||||
&& runparams.local_font && runparams.local_font->isRightToLeft()) {
|
||||
maybeBeginL = "\\beginL";
|
||||
maybeEndL = "\\endL";
|
||||
}
|
||||
|
@ -195,11 +195,11 @@ docstring InsetFloatList::xhtml(XMLStream &, OutputParams const & op) const {
|
||||
if (type == "table") {
|
||||
toctype = "table";
|
||||
toclabel = translateIfPossible(from_ascii("List of Tables"),
|
||||
op.local_font->language()->lang());
|
||||
getLocalOrDefaultLang(op)->lang());
|
||||
} else if (type == "figure") {
|
||||
toctype = "figure";
|
||||
toclabel = translateIfPossible(from_ascii("List of Figures"),
|
||||
op.local_font->language()->lang());
|
||||
getLocalOrDefaultLang(op)->lang());
|
||||
} else {
|
||||
LYXERR0("Unknown Builtin Float!");
|
||||
return docstring();
|
||||
@ -207,7 +207,7 @@ docstring InsetFloatList::xhtml(XMLStream &, OutputParams const & op) const {
|
||||
} else {
|
||||
toctype = to_utf8(getParam("type"));
|
||||
toclabel = translateIfPossible(from_utf8(cit->second.listName()),
|
||||
op.local_font->language()->lang());
|
||||
getLocalOrDefaultLang(op)->lang());
|
||||
}
|
||||
|
||||
shared_ptr<Toc const> toc = buffer().tocBackend().toc(toctype);
|
||||
|
@ -1911,7 +1911,7 @@ docstring InsetPrintIndex::xhtml(XMLStream &, OutputParams const & op) const
|
||||
xs << xml::StartTag("div", tocattr);
|
||||
xs << xml::CR();
|
||||
xs << xml::StartTag(lay.htmltag(), lay.htmlGetAttrString());
|
||||
xs << translateIfPossible(indexName, op.local_font->language()->lang());
|
||||
xs << translateIfPossible(indexName, getLocalOrDefaultLang(op)->lang());
|
||||
xs << xml::EndTag(lay.htmltag());
|
||||
xs << xml::CR();
|
||||
xs << xml::StartTag("ul", "class='main'");
|
||||
|
@ -187,7 +187,8 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
||||
if (!basicstyle.empty())
|
||||
param_string = rtrim(param_string, ",") + ",basicstyle={" + basicstyle + "}";
|
||||
}
|
||||
if (runparams.use_polyglossia && runparams.local_font->isRightToLeft()) {
|
||||
if (runparams.use_polyglossia && runparams.local_font
|
||||
&& runparams.local_font->isRightToLeft()) {
|
||||
// We need to use the *latin switches (#11554)
|
||||
smatch sub;
|
||||
if (regex_match(param_string, sub, reg1))
|
||||
@ -248,9 +249,7 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
|
||||
Encoding const * const save_enc = runparams.encoding;
|
||||
|
||||
Encoding const * const outer_encoding =
|
||||
(runparams.local_font != 0) ?
|
||||
runparams.local_font->language()->encoding()
|
||||
: buffer().params().language->encoding();
|
||||
getLocalOrDefaultLang(runparams)->encoding();
|
||||
Encoding const * fixedlstenc = forcedEncoding(runparams.encoding, outer_encoding);
|
||||
if (fixedlstenc) {
|
||||
// We need to switch to a singlebyte encoding, due to
|
||||
|
@ -222,7 +222,7 @@ docstring InsetPrintNomencl::xhtml(XMLStream &, OutputParams const & op) const
|
||||
InsetLayout const & il = getLayout();
|
||||
string const & tag = il.htmltag();
|
||||
docstring toclabel = translateIfPossible(from_ascii("Nomenclature"),
|
||||
op.local_font->language()->lang());
|
||||
getLocalOrDefaultLang(op)->lang());
|
||||
|
||||
xs << xml::StartTag("div", "class='nomencl'")
|
||||
<< xml::StartTag(tag, "class='nomencl'")
|
||||
@ -333,7 +333,7 @@ void InsetPrintNomencl::docbook(XMLStream & xs, OutputParams const & runparams)
|
||||
// TODO: At least, that's what was done before...
|
||||
|
||||
docstring toclabel = translateIfPossible(from_ascii("Nomenclature"),
|
||||
runparams.local_font->language()->lang());
|
||||
getLocalOrDefaultLang(runparams)->lang());
|
||||
|
||||
xs << xml::StartTag("glossary");
|
||||
xs << xml::CR();
|
||||
|
@ -814,7 +814,7 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
|
||||
|| style == QuoteStyle::French
|
||||
|| style == QuoteStyle::FrenchIN)
|
||||
&& level_ == QuoteLevel::Primary
|
||||
&& prefixIs(runparams.local_font->language()->code(), "fr")) {
|
||||
&& prefixIs(getLocalOrDefaultLang(runparams)->code(), "fr")) {
|
||||
// Specific guillemets of French babel
|
||||
// including correct French spacing
|
||||
if (side_ == QuoteSide::Opening)
|
||||
@ -826,11 +826,11 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
|
||||
// (ligatures not featured in PDF strings)
|
||||
qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
|
||||
} else if (runparams.main_fontenc == "T1"
|
||||
&& !runparams.local_font->language()->internalFontEncoding()) {
|
||||
&& !getLocalOrDefaultLang(runparams)->internalFontEncoding()) {
|
||||
// Quotation marks for T1 font encoding
|
||||
// (using ligatures)
|
||||
qstr = quoteparams.getLaTeXQuote(quotechar, "t1");
|
||||
} else if (runparams.local_font->language()->internalFontEncoding()) {
|
||||
} else if (getLocalOrDefaultLang(runparams)->internalFontEncoding()) {
|
||||
// Quotation marks for internal font encodings
|
||||
// (ligatures not featured)
|
||||
qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
|
||||
|
@ -432,7 +432,7 @@ docstring InsetRef::xhtml(XMLStream & xs, OutputParams const & op) const
|
||||
// some sort of counter with the label, and we don't have that yet.
|
||||
docstring const attr = "href=\"#" + xml::cleanAttr(ref) + '"';
|
||||
xs << xml::StartTag("a", to_utf8(attr));
|
||||
xs << displayString(ref, cmd, op.local_font->language()->lang());;
|
||||
xs << displayString(ref, cmd, getLocalOrDefaultLang(op)->lang());
|
||||
xs << xml::EndTag("a");
|
||||
return docstring();
|
||||
}
|
||||
|
@ -588,8 +588,7 @@ void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
|
||||
case InsetSpaceParams::PROTECTED:
|
||||
if (runparams.find_effective())
|
||||
os.put(0xa0);
|
||||
else if (runparams.local_font
|
||||
&& runparams.local_font->language()->lang() == "polutonikogreek")
|
||||
else if (getLocalOrDefaultLang(runparams)->lang() == "polutonikogreek")
|
||||
// in babel's polutonikogreek, ~ is active
|
||||
os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
|
||||
else
|
||||
|
@ -421,15 +421,15 @@ void InsetSpecialChar::read(Lexer & lex)
|
||||
void InsetSpecialChar::latex(otexstream & os,
|
||||
OutputParams const & rp) const
|
||||
{
|
||||
bool const rtl = rp.local_font->isRightToLeft();
|
||||
bool const rtl = rp.local_font && rp.local_font->isRightToLeft();
|
||||
bool const utf8 = rp.encoding->iconvName() == "UTF-8";
|
||||
string lswitch = "";
|
||||
string lswitche = "";
|
||||
if (rtl && !rp.use_polyglossia) {
|
||||
lswitch = "\\L{";
|
||||
lswitche = "}";
|
||||
if (rp.local_font->language()->lang() == "arabic_arabi"
|
||||
|| rp.local_font->language()->lang() == "farsi")
|
||||
if (getLocalOrDefaultLang(rp)->lang() == "arabic_arabi"
|
||||
|| getLocalOrDefaultLang(rp)->lang() == "farsi")
|
||||
lswitch = "\\textLR{";
|
||||
}
|
||||
|
||||
|
@ -3179,7 +3179,8 @@ void Tabular::TeXRow(otexstream & os, row_type row,
|
||||
// The bidi package (loaded by polyglossia with XeTeX) reverses RTL table columns
|
||||
// Luabibdi (used by LuaTeX) behaves like classic
|
||||
bool const bidi_rtl =
|
||||
runparams.local_font->isRightToLeft()
|
||||
runparams.local_font
|
||||
&& runparams.local_font->isRightToLeft()
|
||||
&& buffer().params().useBidiPackage(runparams);
|
||||
bool const ct = !buffer().params().output_changes;
|
||||
idx_type lastcell =
|
||||
@ -3351,7 +3352,8 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const
|
||||
// The bidi package (loaded by polyglossia with XeTeX) swaps the column
|
||||
// order for RTL (#9686). Thus we use this list.
|
||||
bool const bidi_rtl =
|
||||
runparams.local_font->isRightToLeft()
|
||||
runparams.local_font
|
||||
&& runparams.local_font->isRightToLeft()
|
||||
&& buffer().params().useBidiPackage(runparams);
|
||||
list<col_type> columns;
|
||||
list<col_type> logical_columns;
|
||||
|
Loading…
Reference in New Issue
Block a user