Michael Gerz wrote:
What about the latexaccent and caption inset stuff? I think we should make both changes before 1.5.0beta is released, because they require a file format change and should be tested thouroughly in the beta period.
Here is an updated patch for the caption inset. The former one didn't really work because it failed to find caption inset properly. This patch search for float or wrap insets instead. In practice, this is fine as we won't allow multiple caption in the same float inset anyway.
It works fine except for decoration issues (the red rectangles around insets). Also, sometimes the numbering is not properly updated.
Abdel.
Index: buffer_funcs.C =================================================================== --- buffer_funcs.C (revision 16761) +++ buffer_funcs.C (working copy) @@ -38,6 +38,7 @@ #include "frontends/Alert.h" #include "insets/insetbibitem.h" +#include "insets/insetcaption.h" #include "insets/insetinclude.h" #include "support/filetools.h" @@ -477,34 +478,31 @@ par.params().labelString( par.translateIfPossible(layout->labelstring(), buf.params())); // In biblio shouldn't be following counters but... - } else if (layout->labeltype == LABEL_SENSITIVE) { - // Search for the first float or wrap inset in the iterator - size_t i = it.depth(); - InsetBase * in; - while (i > 0) { - --i; - in = &it[i].inset(); - if (in->lyxCode() == InsetBase::FLOAT_CODE - || in->lyxCode() == InsetBase::WRAP_CODE) - break; + } else if (!par.insetlist.empty()) { + InsetBase * it = par.insetlist.begin()->inset; + if (it->lyxCode() == InsetBase::FLOAT_CODE + || it->lyxCode() == InsetBase::WRAP_CODE) { + docstring const & type = it->getInsetName(); + if (!type.empty()) { + Floating const & fl = textclass.floats().getType(to_ascii(type)); + // FIXME UNICODE + docstring const counter(from_ascii(fl.type())); + counters.step(counter); + ParagraphList & pars = it->getText(0)->paragraphs(); + ParagraphList::const_iterator p = pars.begin(); + for (; p != pars.end(); ++p) { + if (p->insetlist.empty()) + continue; + InsetBase * icap = p->insetlist.begin()->inset; + if (icap->lyxCode() != InsetBase::CAPTION_CODE) + continue; + static_cast<InsetCaption *>(icap)->setCount(counters.value(counter)); + break; + } + } } - docstring const & type = in->getInsetName(); + par.params().labelString(docstring()); - if (!type.empty()) { - Floating const & fl = textclass.floats().getType(to_ascii(type)); - // FIXME UNICODE - counters.step(from_ascii(fl.type())); - - // Doesn't work... yet. - par.params().labelString(par.translateIfPossible( - bformat(from_ascii("%1$s #:"), from_utf8(fl.name())), - buf.params())); - } else { - // par->SetLayout(0); - par.params().labelString(par.translateIfPossible( - layout->labelstring(), buf.params())); - } - } else if (layout->labeltype == LABEL_NO_LABEL) par.params().labelString(docstring()); else Index: text3.C =================================================================== --- text3.C (revision 16761) +++ text3.C (working copy) @@ -1127,8 +1127,8 @@ #if 0 case LFUN_LIST_INSERT: case LFUN_THEOREM_INSERT: - case LFUN_CAPTION_INSERT: #endif + case LFUN_CAPTION_INSERT: case LFUN_NOTE_INSERT: case LFUN_CHARSTYLE_INSERT: case LFUN_BOX_INSERT: @@ -1159,9 +1159,8 @@ case LFUN_WRAP_INSERT: doInsertInset(cur, this, cmd, true, true); cur.posRight(); - // FIXME: the "Caption" name should not be hardcoded, - // but given by the float definition. - cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption")); + cur.dispatch(FuncRequest(LFUN_CAPTION_INSERT)); + updateLabels(cur.buffer()); break; case LFUN_INDEX_INSERT: