#endif
} else if (token == "\\begin_layout") {
lex.eatLine();
- string layoutname = lex.getString();
+ docstring layoutname = lex.getDocString();
font = Font(Font::ALL_INHERIT, bp.language);
change = Change(Change::UNCHANGED);
if (!hasLayout) {
errorList.push_back(ErrorItem(_("Unknown layout"),
bformat(_("Layout '%1$s' does not exist in textclass '%2$s'\nTrying to use the default instead.\n"),
- from_utf8(layoutname), from_utf8(tclass.name())), par.id(), 0, par.size()));
+ layoutname, from_utf8(tclass.name())), par.id(), 0, par.size()));
layoutname = tclass.defaultLayoutName();
}
} // namespace anon
+bool Text::empty() const
+{
+ return pars_.empty() || (pars_.size() == 1 && pars_[0].empty()
+ // FIXME: Should we consider the labeled type as empty too?
+ && pars_[0].layout()->labeltype == LABEL_NO_LABEL);
+}
+
double Text::spacing(Buffer const & buffer,
Paragraph const & par) const
}
-int Text::singleWidth(Buffer const & buffer, Paragraph const & par,
- pos_type pos) const
-{
- return singleWidth(par, pos, par.getChar(pos),
- getFont(buffer, par, pos));
-}
-
-
-int Text::singleWidth(Paragraph const & par,
- pos_type pos, char_type c, Font const & font) const
-{
- // The most common case is handled first (Asger)
- if (isPrintable(c)) {
- Language const * language = font.language();
- if (language->rightToLeft()) {
- if (language->lang() == "arabic_arabtex" ||
- language->lang() == "arabic_arabi" ||
- language->lang() == "farsi") {
- if (Encodings::isComposeChar_arabic(c))
- return 0;
- c = par.transformChar(c, pos);
- } else if (language->lang() == "hebrew" &&
- Encodings::isComposeChar_hebrew(c))
- return 0;
- }
- return theFontMetrics(font).width(c);
- }
-
- if (c == Paragraph::META_INSET)
- return par.getInset(pos)->width();
-
- return theFontMetrics(font).width(c);
-}
-
-
int Text::leftMargin(Buffer const & buffer, int max_width, pit_type pit) const
{
BOOST_ASSERT(pit >= 0);
TextClass const & tclass = buffer.params().getTextClass();
Layout_ptr const & layout = par.layout();
- string parindent = layout->parindent;
+ docstring parindent = layout->parindent;
int l_margin = 0;
if (isMainText(buffer))
l_margin += changebarMargin();
- // FIXME UNICODE
- docstring leftm = from_utf8(tclass.leftmargin());
- l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(leftm);
+ l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
+ tclass.leftmargin());
if (par.getDepth() != 0) {
// find the next level paragraph
switch (layout->margintype) {
case MARGIN_DYNAMIC:
if (!layout->leftmargin.empty()) {
- // FIXME UNICODE
- docstring leftm = from_utf8(layout->leftmargin);
- l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(leftm);
+ l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
+ layout->leftmargin);
}
if (!par.getLabelstring().empty()) {
- // FIXME UNICODE
- docstring labin = from_utf8(layout->labelindent);
- l_margin += labelfont_metrics.signedWidth(labin);
- docstring labstr = par.getLabelstring();
- l_margin += labelfont_metrics.width(labstr);
- docstring labsep = from_utf8(layout->labelsep);
- l_margin += labelfont_metrics.width(labsep);
+ l_margin += labelfont_metrics.signedWidth(layout->labelindent);
+ l_margin += labelfont_metrics.width(par.getLabelstring());
+ l_margin += labelfont_metrics.width(layout->labelsep);
}
break;
case MARGIN_MANUAL: {
- // FIXME UNICODE
- docstring labin = from_utf8(layout->labelindent);
- l_margin += labelfont_metrics.signedWidth(labin);
+ l_margin += labelfont_metrics.signedWidth(layout->labelindent);
// The width of an empty par, even with manual label, should be 0
if (!par.empty() && pos >= par.beginOfBody()) {
if (!par.getLabelWidthString().empty()) {
docstring labstr = par.getLabelWidthString();
l_margin += labelfont_metrics.width(labstr);
- docstring labsep = from_utf8(layout->labelsep);
- l_margin += labelfont_metrics.width(labsep);
+ l_margin += labelfont_metrics.width(layout->labelsep);
}
}
break;
}
case MARGIN_STATIC: {
- // FIXME UNICODE
- docstring leftm = from_utf8(layout->leftmargin);
- l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(leftm)
- * 4 / (par.getDepth() + 4);
+ l_margin += theFontMetrics(buffer.params().getFont()).
+ signedWidth(layout->leftmargin) * 4 / (par.getDepth() + 4);
break;
}
case MARGIN_FIRST_DYNAMIC:
if (layout->labeltype == LABEL_MANUAL) {
if (pos >= par.beginOfBody()) {
- // FIXME UNICODE
- l_margin += labelfont_metrics.signedWidth(
- from_utf8(layout->leftmargin));
+ l_margin += labelfont_metrics.signedWidth(layout->leftmargin);
} else {
- // FIXME UNICODE
- l_margin += labelfont_metrics.signedWidth(
- from_utf8(layout->labelindent));
+ l_margin += labelfont_metrics.signedWidth(layout->labelindent);
}
} else if (pos != 0
// Special case to fix problems with
|| (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, pars_))) {
- // FIXME UNICODE
- l_margin += labelfont_metrics.signedWidth(from_utf8(layout->leftmargin));
+ l_margin += labelfont_metrics.signedWidth(layout->leftmargin);
} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
&& layout->labeltype != LABEL_BIBLIO
&& layout->labeltype !=
LABEL_CENTERED_TOP_ENVIRONMENT) {
- l_margin += labelfont_metrics.signedWidth(from_utf8(layout->labelindent));
- l_margin += labelfont_metrics.width(from_utf8(layout->labelsep));
+ l_margin += labelfont_metrics.signedWidth(layout->labelindent);
+ l_margin += labelfont_metrics.width(layout->labelsep);
l_margin += labelfont_metrics.width(par.getLabelstring());
}
break;
// row in this paragraph.
RowList::iterator rit = par.rows().begin();
RowList::iterator end = par.rows().end();
-#ifdef WITH_WARNINGS
-#warning This is wrong.
-#endif
+ // FIXME: This is wrong.
int minfill = max_width;
for ( ; rit != end; ++rit)
if (rit->fill() < minfill)
|| buffer.params().paragraph_separation ==
BufferParams::PARSEP_INDENT))
{
- docstring din = from_utf8(parindent);
- l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(din);
+ l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
+ parindent);
}
return l_margin;
recordUndo(cur, Undo::DELETE);
if(!par.eraseChar(cur.pos(), cur.buffer().params().trackChanges)) {
// the character has been logically deleted only => skip it
- cur.forwardPosNoDescend();
+ cur.top().forwardPos();
}
checkBufferStructure(cur.buffer(), cur);
needsUpdate = true;
bool Text::dissolveInset(Cursor & cur) {
BOOST_ASSERT(this == cur.text());
- if (isMainText(*cur.bv().buffer()) || cur.inset().nargs() != 1)
+ if (isMainText(cur.bv().buffer()) || cur.inset().nargs() != 1)
return false;
recordUndoInset(cur);
bool drawOnBegMargin, bool drawOnEndMargin) const
{
BufferView & bv = *pi.base.bv;
- Buffer & buffer = *bv.buffer();
+ Buffer & buffer = bv.buffer();
TextMetrics const & tm = bv.textMetrics(this);
DocIterator cur = beg;
int x1 = cursorX(bv, beg.top(), beg.boundary());
depth_type dth = 0;
for (; pit != end; ++pit)
pit->write(buf, os, buf.params(), dth);
+
+ // Close begin_deeper
+ for(; dth > 0; --dth)
+ os << "\n\\end_deeper";
}
pos_type cursor_vpos = 0;
- Buffer const & buffer = *bv.buffer();
+ Buffer const & buffer = bv.buffer();
RowMetrics const m = tm.computeRowMetrics(pit, row);
double x = m.x;
Bidi bidi;
// Use font span to speed things up, see below
FontSpan font_span;
Font font;
- FontMetrics const & labelfm = theFontMetrics(
- getLabelFont(buffer, par));
// If the last logical character is a separator, skip it, unless
// it's in the last row of a paragraph; see skipped_sep_vpos declaration
continue;
pos_type pos = bidi.vis2log(vpos);
if (body_pos > 0 && pos == body_pos - 1) {
- // FIXME UNICODE
- docstring const lsep = from_utf8(par.layout()->labelsep);
- x += m.label_hfill + labelfm.width(lsep);
+ FontMetrics const & labelfm = theFontMetrics(
+ getLabelFont(buffer, par));
+ x += m.label_hfill + labelfm.width(par.layout()->labelsep);
if (par.isLineSeparator(body_pos - 1))
- x -= singleWidth(buffer, par, body_pos - 1);
+ x -= tm.singleWidth(pit, body_pos - 1);
}
// Use font span to speed things up, see above
font = getFont(buffer, par, pos);
}
- x += singleWidth(par, pos, par.getChar(pos), font);
+ x += pm.singleWidth(pos, font);
if (par.hfillExpansion(row, pos))
x += (pos >= body_pos) ? m.hfill : m.label_hfill;
// see correction above
if (boundary_correction) {
if (isRTL(buffer, sl, boundary))
- x -= singleWidth(buffer, par, ppos);
+ x -= tm.singleWidth(pit, ppos);
else
- x += singleWidth(buffer, par, ppos);
+ x += tm.singleWidth(pit, ppos);
}
return int(x);