#include "author.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "bufferparams.h"
#include "BufferView.h"
#include "cursor.h"
&& align == LYX_ALIGN_BLOCK
&& !par.params().noindent()
// in charstyles, tabulars and ert paragraphs are never indented!
- && (par.ownerCode() != InsetBase::TEXT_CODE
+ && ((par.ownerCode() != InsetBase::TEXT_CODE || isMainText())
&& par.ownerCode() != InsetBase::ERT_CODE
&& par.ownerCode() != InsetBase::CHARSTYLE_CODE)
&& (par.layout() != tclass.defaultLayout()
maxasc += bufparams.getDefSkip().inPixels(*bv());
}
- if (pars_[pit].params().startOfAppendix())
+ if (par.params().startOfAppendix())
maxasc += int(3 * dh);
// This is special code for the chapter, since the label of this
// layout is printed in an extra row
- if (layout->counter == "chapter" && bufparams.secnumdepth >= 0) {
+ if (layout->counter == "chapter"
+ && !par.params().labelString().empty()) {
labeladdon = int(font_metrics::maxHeight(labelfont)
* layout->spacing.getValue()
* spacing(par));
while (!pars_[next_par].empty() && pars_[next_par].isNewline(0))
pars_[next_par].erase(0);
- updateCounters();
+ updateCounters(cur.buffer());
// This check is necessary. Otherwise the new empty paragraph will
// be deleted automatically. And it is more friendly for the user!
--cur.pos();
// the counters may have changed
- updateCounters();
+ updateCounters(cur.buffer());
setCursor(cur, cur.pit(), cur.pos(), false);
}
} else {
}
-void LyXText::redoParagraph(pit_type const pit)
+bool LyXText::redoParagraph(pit_type const pit)
{
// remove rows of paragraph, keep track of height changes
Paragraph & par = pars_[pit];
+ // Add bibitem insets if necessary
+ if (par.layout()->labeltype == LABEL_BIBLIO) {
+ bool hasbibitem(false);
+ if (!par.insetlist.empty()
+ // Insist on it being in pos 0
+ && par.getChar(0) == Paragraph::META_INSET) {
+ InsetBase * inset = par.insetlist.begin()->inset;
+ if (inset->lyxCode() == InsetBase::BIBITEM_CODE)
+ hasbibitem = true;
+ }
+ if (!hasbibitem) {
+ InsetBibitem * inset(new
+ InsetBibitem(InsetCommandParams("bibitem")));
+ par.insertInset(0, static_cast<InsetBase *>(inset));
+ bv()->cursor().posRight();
+ }
+ }
+
// redo insets
InsetList::iterator ii = par.insetlist.begin();
InsetList::iterator iend = par.insetlist.end();
dim.asc += par.rows()[0].ascent();
dim.des -= par.rows()[0].ascent();
+
+ bool const same = dim == par.dim();
+
par.dim() = dim;
//lyxerr << "redoParagraph: " << par.rows().size() << " rows\n";
+
+ return !same;
}
maxwidth_ = mi.base.textwidth;
//lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
// << " maxWidth: " << maxwidth_ << "\nfont: " << mi.base.font << endl;
+ // save the caller's font locally:
+ font_ = mi.base.font;
unsigned int h = 0;
unsigned int w = 0;
pos_type LyXText::x2pos(pit_type pit, int row, int x) const
{
+ BOOST_ASSERT(row < pars_[pit].rows().size());
bool bound = false;
Row const & r = pars_[pit].rows()[row];
return r.pos() + getColumnNearX(pit, r, x, bound);