mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Fix for #10624.
If we're in the first paragraph after a division (section, etc), use the prefix for it.
This commit is contained in:
parent
83356ab9fe
commit
dd2efe8d0d
71
src/Text.cpp
71
src/Text.cpp
@ -1974,12 +1974,44 @@ docstring Text::currentState(CursorData const & cur, bool devel_mode) const
|
||||
|
||||
docstring Text::getPossibleLabel(DocIterator const & cur) const
|
||||
{
|
||||
pit_type pit = cur.pit();
|
||||
pit_type textpit = cur.pit();
|
||||
Layout const * layout = &(pars_[textpit].layout());
|
||||
|
||||
Layout const * layout = &(pars_[pit].layout());
|
||||
// Will contain the label prefix.
|
||||
docstring name;
|
||||
|
||||
// For captions, we just take the caption type
|
||||
Inset * caption_inset = cur.innerInsetOfType(CAPTION_CODE);
|
||||
if (caption_inset) {
|
||||
string const & ftype = static_cast<InsetCaption *>(caption_inset)->floattype();
|
||||
FloatList const & fl = cur.buffer()->params().documentClass().floats();
|
||||
if (fl.typeExist(ftype)) {
|
||||
Floating const & flt = fl.getType(ftype);
|
||||
name = from_utf8(flt.refPrefix());
|
||||
}
|
||||
if (name.empty())
|
||||
name = from_utf8(ftype.substr(0,3));
|
||||
} else {
|
||||
// For section, subsection, etc...
|
||||
if (layout->latextype == LATEX_PARAGRAPH && textpit != 0) {
|
||||
Layout const * layout2 = &(pars_[textpit - 1].layout());
|
||||
if (layout2->latextype != LATEX_PARAGRAPH) {
|
||||
--textpit;
|
||||
layout = layout2;
|
||||
}
|
||||
}
|
||||
if (layout->latextype != LATEX_PARAGRAPH)
|
||||
name = layout->refprefix;
|
||||
|
||||
// If none of the above worked, see if the inset knows.
|
||||
if (name.empty()) {
|
||||
InsetLayout const & il = cur.inset().getLayout();
|
||||
name = il.refprefix();
|
||||
}
|
||||
}
|
||||
|
||||
docstring text;
|
||||
docstring par_text = pars_[pit].asString(AS_STR_SKIPDELETE);
|
||||
docstring par_text = pars_[textpit].asString(AS_STR_SKIPDELETE);
|
||||
|
||||
// The return string of math matrices might contain linebreaks
|
||||
par_text = subst(par_text, '\n', '-');
|
||||
@ -2000,39 +2032,6 @@ docstring Text::getPossibleLabel(DocIterator const & cur) const
|
||||
if (text.size() > max_label_length)
|
||||
text.resize(max_label_length);
|
||||
|
||||
// Will contain the label prefix.
|
||||
docstring name;
|
||||
|
||||
// For section, subsection, etc...
|
||||
if (layout->latextype == LATEX_PARAGRAPH && pit != 0) {
|
||||
Layout const * layout2 = &(pars_[pit - 1].layout());
|
||||
if (layout2->latextype != LATEX_PARAGRAPH) {
|
||||
--pit;
|
||||
layout = layout2;
|
||||
}
|
||||
}
|
||||
if (layout->latextype != LATEX_PARAGRAPH)
|
||||
name = layout->refprefix;
|
||||
|
||||
// For captions, we just take the caption type
|
||||
Inset * caption_inset = cur.innerInsetOfType(CAPTION_CODE);
|
||||
if (caption_inset) {
|
||||
string const & ftype = static_cast<InsetCaption *>(caption_inset)->floattype();
|
||||
FloatList const & fl = cur.buffer()->params().documentClass().floats();
|
||||
if (fl.typeExist(ftype)) {
|
||||
Floating const & flt = fl.getType(ftype);
|
||||
name = from_utf8(flt.refPrefix());
|
||||
}
|
||||
if (name.empty())
|
||||
name = from_utf8(ftype.substr(0,3));
|
||||
}
|
||||
|
||||
// If none of the above worked, see if the inset knows.
|
||||
if (name.empty()) {
|
||||
InsetLayout const & il = cur.inset().getLayout();
|
||||
name = il.refprefix();
|
||||
}
|
||||
|
||||
if (!name.empty())
|
||||
text = name + ':' + text;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user