LyXLayout_ptr const & layout = par->layout();
- Paragraph::depth_type par_depth = par->getDepth();
// We specialize the 95% common case:
- if (!par_depth) {
+ if (!par->getDepth()) {
if (layout->labeltype == LABEL_MANUAL
&& pos < beginningOfMainBody(buf, par)) {
// 1% goes here
{
LyXLayout_ptr const & layout = par->layout();
- Paragraph::depth_type par_depth = par->getDepth();
-
- if (!par_depth) {
+ if (!par->getDepth()) {
return layout->resfont;
}
{
LyXLayout_ptr const & layout = par->layout();
- Paragraph::depth_type par_depth = par->getDepth();
-
- if (!par_depth) {
+ if (!par->getDepth()) {
return layout->reslabelfont;
}
selection.start.pos(), false);
selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos(), false);
- updateCounters(bview, cursor.row());
+ updateCounters(bview);
clearSelection();
setSelection(bview);
setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
setCursor(bview, selection.start.par(), selection.start.pos());
selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos());
- updateCounters(bview, cursor.row());
+ updateCounters(bview);
clearSelection();
setSelection(bview);
setCursor(bview, tmpcursor.par(), tmpcursor.pos());
selection.start.pos());
selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos());
- updateCounters(bview, cursor.row());
+ updateCounters(bview);
clearSelection();
setSelection(bview);
setCursor(bview, tmpcursor.par(), tmpcursor.pos());
if (tmprow && tmprow->next())
setHeightOfRow(bview, tmprow->next());
+ updateCounters(bview);
}
Paragraph * endpar(selection.end.par());
pos_type const startpos(selection.start.pos());
pos_type const endpos(selection.end.pos());
-
+
if (startpar == endpar) {
return startpar->asString(buffer, startpos, endpos, label);
}
|| cursor.row()->next()->par() != cursor.row()->par()) {
setCursor(bview, cursor.par(), rowLast(cursor.row()) + 1);
} else {
- if (cursor.par()->size() &&
+ if (!cursor.par()->empty() &&
(cursor.par()->getChar(rowLast(cursor.row())) == ' '
|| cursor.par()->isNewline(rowLast(cursor.row())))) {
setCursor(bview, cursor.par(), rowLast(cursor.row()));
LyXTextClass const & textclass = buf->params.getLyXTextClass();
LyXLayout_ptr const & layout = par->layout();
- // copy the prev-counters to this one,
- // unless this is the first paragraph
if (par->previous()) {
- par->ctrs.copy(par->previous()->ctrs, par->ctrs, "");
-
par->params().appendix(par->previous()->params().appendix());
if (!par->params().appendix() && par->params().startOfAppendix()) {
par->params().appendix(true);
- par->ctrs.reset("");
+ buf->counters().reset();
}
par->enumdepth = par->previous()->enumdepth;
par->itemdepth = par->previous()->itemdepth;
} else {
- par->ctrs.reset("");
par->params().appendix(par->params().startOfAppendix());
par->enumdepth = 0;
par->itemdepth = 0;
&& par->previous()->getDepth() > par->getDepth()
&& layout->labeltype != LABEL_BIBLIO) {
par->enumdepth = par->depthHook(par->getDepth())->enumdepth;
- par->ctrs.set(par->ctrs.enums[par->enumdepth],
- par->depthHook(par->getDepth())->ctrs.value(par->ctrs.enums[par->enumdepth]));
}
if (!par->params().labelString().empty()) {
} else {
par->setLabelWidthString(string());
}
-
+
// is it a layout that has an automatic label?
if (layout->labeltype >= LABEL_COUNTER_CHAPTER) {
int i = layout->labeltype - LABEL_COUNTER_CHAPTER;
- string numbertype, langtype;
+ string numbertype, langtype;
ostringstream s;
if (i >= 0 && i<= buf->params.secnumdepth) {
- par->ctrs.step(par->ctrs.sects[i]);
+ buf->counters().step(buf->counters().sects[i]);
// Is there a label? Useful for Chapter layout
if (!par->params().appendix()) {
else
langtype = "latin";
}
-
- s << par->ctrs.numberLabel(par->ctrs.sects[i],
+
+ s << buf->counters().numberLabel(buf->counters().sects[i],
numbertype, langtype, head);
- par->params().labelString(par->params().labelString() +s.str().c_str());
+ par->params().labelString(par->params().labelString() + s.str().c_str());
// We really want to remove the c_str as soon as
// possible...
// reset enum counters
- par->ctrs.reset("enum");
+ buf->counters().reset("enum");
} else if (layout->labeltype < LABEL_COUNTER_ENUMI) {
- par->ctrs.reset("enum");
+ buf->counters().reset("enum");
} else if (layout->labeltype == LABEL_COUNTER_ENUMI) {
- par->ctrs.step(par->ctrs.enums[par->enumdepth]);
+ buf->counters().step(buf->counters().enums[par->enumdepth]);
- s << par->ctrs.numberLabel(par->ctrs.enums[par->enumdepth],
+ s << buf->counters().numberLabel(buf->counters().enums[par->enumdepth],
"enumeration", langtype);
par->params().labelString(s.str().c_str());
}
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
- par->ctrs.step("bibitem");
- int number = par->ctrs.value("bibitem");
+ buf->counters().step("bibitem");
+ int number = buf->counters().value("bibitem");
if (!par->bibkey) {
InsetCommandParams p("bibitem" );
par->bibkey = new InsetBibKey(p);
// the caption hack:
if (layout->labeltype == LABEL_SENSITIVE) {
- bool isOK (par->inInset() && par->inInset()->owner() &&
- (par->inInset()->owner()->lyxCode() == Inset::FLOAT_CODE));
+ Paragraph * tmppar = par;
+ Inset * in = 0;
+ bool isOK = false;
+ while (tmppar && tmppar->inInset()
+ // the single '=' is intended below
+ && (in = tmppar->inInset()->owner())) {
+ if (in->lyxCode() == Inset::FLOAT_CODE) {
+ isOK = true;
+ break;
+ } else {
+ tmppar = in->parOwner();
+ }
+ }
if (isOK) {
- InsetFloat * tmp = static_cast<InsetFloat*>(par->inInset()->owner());
Floating const & fl
- = floatList.getType(tmp->type());
+ = floatList.getType(static_cast<InsetFloat*>(in)->type());
- // Why doesn't it work? -- MV
- par->ctrs.step(fl.name());
- // We should get the correct number here too.
+ buf->counters().step(fl.name());
+
+ // Doesn't work... yet.
ostringstream o;
- o << fl.name() << " " << par->ctrs.value(fl.name()) << ":";
+ //o << fl.name() << " " << buf->counters().value(fl.name()) << ":";
+ o << fl.name() << " #:";
s = o.str();
} else {
/* par->SetLayout(0);
/* reset the enumeration counter. They are always resetted
* when there is any other layout between */
for (int i = par->enumdepth + 1; i < 4; i++) {
- par->ctrs.set(par->ctrs.enums[i], 0);
+ buf->counters().set(buf->counters().enums[i], 0);
}
}
}
// Updates all counters BEHIND the row. Changed paragraphs
// with a dynamic left margin will be rebroken.
-void LyXText::updateCounters(BufferView * bview, Row * row) const
+void LyXText::updateCounters(BufferView * bview) const
{
Paragraph * par;
+
+ Row * row = firstrow;
+ par = row->par();
- if (!row) {
- row = firstrow;
- par = row->par();
- } else {
- par = row->par()->next();
- }
-
+ bview->buffer()->counters().reset();
while (par) {
while (row->par() != par)
row = row->next();
-
+
setCounter(bview->buffer(), par);
// now check for the headline layouts. remember that they
setCursor(bview, cursor.par(), cursor.pos());
selection.cursor = cursor;
- updateCounters(bview, cursor.row());
+ updateCounters(bview);
}
selection.cursor = cursor;
setCursor(bview, actpar, pos);
setSelection(bview);
- updateCounters(bview, cursor.row());
+ updateCounters(bview);
}
return false;
}
}
-
+
void LyXText::setCursorFromCoordinates(BufferView * bview, LyXCursor & cur,
int x, int y) const
cur.x(x);
cur.y(y + row->baseline());
cur.row(row);
-
+
if (beforeFullRowInset(*row, cur)) {
pos_type last = rowLastPrintable(row);
float x = getCursorX(bview, row->next(), cur.pos(), last, bound);
// we can't possibly have deleted a paragraph before this point
bool deleted = false;
- if ((old_cursor.par()->size() == 0
+ if ((old_cursor.par()->empty()
|| (old_cursor.par()->size() == 1
&& old_cursor.par()->isLineSeparator(0)))) {
// ok, we will delete anything
* there is another layout before */
if (refresh_row->next()) {
breakAgain(bview, refresh_row->next());
- updateCounters(bview, refresh_row);
+ updateCounters(bview);
}
setHeightOfRow(bview, refresh_row);
} else {
there is another layout before */
if (refresh_row) {
breakAgain(bview, refresh_row);
- updateCounters(bview, refresh_row->previous());
+ updateCounters(bview);
}
}
}
-void LyXText::toggleAppendix(BufferView * bview)
-{
- Paragraph * par = cursor.par();
- bool start = !par->params().startOfAppendix();
-
- // ensure that we have only one start_of_appendix in this document
- Paragraph * tmp = ownerParagraph();
- for (; tmp; tmp = tmp->next()) {
- tmp->params().startOfAppendix(false);
- }
-
- par->params().startOfAppendix(start);
-
- // we can set the refreshing parameters now
- status(bview, LyXText::NEED_MORE_REFRESH);
- refresh_y = 0;
- refresh_row = 0; // not needed for full update
- updateCounters(bview, 0);
- setCursor(bview, cursor.par(), cursor.pos());
-}
-
-
Paragraph * LyXText::ownerParagraph() const
{
if (inset_owner) {
return inset_owner->paragraph();
}
- return bv_owner->buffer()->paragraph;
+ return &*(bv_owner->buffer()->paragraphs.begin());
}
if (inset_owner) {
inset_owner->paragraph(p);
} else {
- bv_owner->buffer()->paragraph = p;
+ bv_owner->buffer()->paragraphs.set(p);
}
}
void LyXText::status(BufferView * bview, LyXText::text_status st) const
{
LyXText * t = bview->text;
-
+
// We should only go up with refreshing code so this means that if
// we have a MORE refresh we should never set it to LITTLE if we still
// didn't handle it (and then it will be UNCHANGED. Now as long as