// It is possible that the last line is empty if it was cursor_par
// and/or only had an error inset on it. So we set the cursor to the
// start of the doc to force its removal and ensure a valid saved cursor
- if (text->setCursor(text->ownerParagraph(), 0)
+ if (text->setCursor(&*text->ownerParagraphs().begin(), 0)
&& 0 == cursor_par_next) {
cursor_par = cursor_par_prev;
cursor_pos = cursor_par->size();
Paragraph * texrowpar = 0;
if (tmpid == -1) {
- texrowpar = text->ownerParagraph();
+ texrowpar = &*text->ownerParagraphs().begin();
tmppos = 0;
} else {
texrowpar = buffer()->getParFromID(tmpid);
Paragraph * texrowpar;
if (tmpid == -1) {
- texrowpar = text->ownerParagraph();
+ texrowpar = &*text->ownerParagraphs().begin();
tmppos = 0;
} else {
texrowpar = buffer()->getParFromID(tmpid);
+2003-04-02 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * undo_funcs.C (firstUndoParagraph): adjust
+
+ * text3.C (gotoInset): adjust
+ (dispatch): adjust, and rewrite loop.
+
+ * text2.C (init): adjust, and rewrite loop.
+ (redoParagraphs): adjust
+ (updateInset): adjust, and rewrite loop.
+ (deleteEmptyParagraphMechanism): adjust
+
+ * tabular.C (LyXTabular): adjust
+ (SetMultiColumn): adjust
+ (TeXRow): adjust
+
+ * lyxtext.[Ch] (ownerParagraph): delete function
+ (ownerParagraphs): new function returns a ParagraphList.
+
+ * BufferView.C (removeAutoInsets): adjust
+ (insertErrors): adjust
+ (setCursorFromRow): adjust
+
2003-04-01 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (buffer): ensure that the Layout is correct
* text.C: adjust
* text2.C: adjust
* text3.C: adjust
-
+
* lyxrow_funcs. [Ch]: new files
* lyxrow.[Ch]: remove next and previous pointers
+2003-04-02 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * insetwrap.C (InsetWrap): adjust
+ (addToToc): adjust and rewrite loop
+
+ * insettext.[Ch] (paragraph): delete function
+
+ * insettabular.C (moveNextCell): adjust
+ (movePrevCell): adjust
+ (insertAsciiString): adjust
+
+ * insetfloat.C (InsetFloat): adjust
+ (addToToc): adjust
+
+ * insetert.C (InsetERT): adjust
+ (write): adjust, and rewrite loop
+ (latex): adjust, and rewrite loop
+ (linuxdoc): adjust, and rewrite loop
+ (docbook): adjust, and rewrite loop
+ (localDispatch): adjust
+ (get_new_label): adjust
+
2003-04-01 John Levon <levon@movementarian.org>
From Alfredo Braunstein
- * insetbutton.h:
+ * insetbutton.h:
* insetbutton.C: add localDispatch()
* insetcommand.C: return DISPATCHED when edit() called
2003-04-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* insettext.C: adjust
-
+
2003-04-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* insettext.C (draw): adjust
string::const_iterator end = contents.end();
pos_type pos = 0;
for (; cit != end; ++cit) {
- inset.paragraph()->insertChar(pos++, *cit, font);
+ inset.paragraphs.begin()->insertChar(pos++, *cit, font);
}
// the init has to be after the initialization of the paragraph
// because of the label settings (draw_label for ert insets).
//inset.writeParagraphData(buf, os);
string const layout(buf->params.getLyXTextClass().defaultLayoutName());
- Paragraph * par = inset.paragraph();
- while (par) {
+ ParagraphList::iterator par = inset.paragraphs.begin();
+ ParagraphList::iterator end = inset.paragraphs.end();
+ for (; par != end; ++par) {
os << "\n\\layout " << layout << "\n";
pos_type siz = par->size();
for (pos_type i = 0; i < siz; ++i) {
break;
}
}
- par = par->next();
}
}
int InsetERT::latex(Buffer const *, ostream & os, bool /*fragile*/,
bool /*free_spc*/) const
{
- Paragraph * par = inset.paragraph();
+ ParagraphList::iterator par = inset.paragraphs.begin();
+ ParagraphList::iterator end = inset.paragraphs.end();
+
int lines = 0;
- while (par) {
+ while (par != end) {
pos_type siz = par->size();
for (pos_type i = 0; i < siz; ++i) {
// ignore all struck out text
os << par->getChar(i);
}
}
- par = par->next();
- if (par) {
+ ++par;
+ if (par != end) {
os << "\n\n";
lines += 2;
}
int InsetERT::linuxdoc(Buffer const *, ostream & os) const
{
- Paragraph * par = inset.paragraph();
+ ParagraphList::iterator par = inset.paragraphs.begin();
+ ParagraphList::iterator end = inset.paragraphs.end();
+
int lines = 0;
- while (par) {
+ while (par != end) {
pos_type siz = par->size();
for (pos_type i = 0; i < siz; ++i) {
if (par->isNewline(i)) {
os << par->getChar(i);
}
}
- par = par->next();
- if (par) {
+ ++par;
+ if (par != end) {
os << "\n";
lines ++;
}
int InsetERT::docbook(Buffer const *, ostream & os, bool) const
{
- Paragraph * par = inset.paragraph();
+ ParagraphList::iterator par = inset.paragraphs.begin();
+ ParagraphList::iterator end = inset.paragraphs.end();
+
int lines = 0;
- while (par) {
+ while (par != end) {
pos_type siz = par->size();
for (pos_type i = 0; i < siz; ++i) {
if (par->isNewline(i)) {
os << par->getChar(i);
}
}
- par = par->next();
- if (par) {
+ ++par;
+ if (par != end) {
os << "\n";
lines ++;
}
Inset::RESULT result = UNDISPATCHED;
BufferView * bv = cmd.view();
- if (inset.paragraph()->empty()) {
+ if (inset.paragraphs.begin()->empty()) {
set_latex_font(bv);
}
break;
case LFUN_LAYOUT:
- bv->owner()->setLayout(inset.paragraph()->layout()->name());
+ bv->owner()->setLayout(inset.paragraphs.begin()->layout()->name());
result = DISPATCHED_NOUPDATE;
break;
{
string la;
pos_type const max_length = 15;
- pos_type const p_siz = inset.paragraph()->size();
+ pos_type const p_siz = inset.paragraphs.begin()->size();
pos_type const n = min(max_length, p_siz);
pos_type i = 0;
pos_type j = 0;
for(; i < n && j < p_siz; ++j) {
- if (inset.paragraph()->isInset(j))
+ if (inset.paragraphs.begin()->isInset(j))
continue;
- la += inset.paragraph()->getChar(j);
+ la += inset.paragraphs.begin()->getChar(j);
++i;
}
- if (inset.paragraph()->next() || (i > 0 && j < p_siz)) {
+ if (boost::next(inset.paragraphs.begin()) != inset.paragraphs.end() ||
+ (i > 0 && j < p_siz)) {
la += "...";
}
if (la.empty()) {
setInsetName(type);
LyXTextClass const & tclass = bp.getLyXTextClass();
if (tclass.hasLayout(caplayout))
- inset.paragraph()->layout(tclass[caplayout]);
+ inset.paragraphs.begin()->layout(tclass[caplayout]);
}
void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const
{
- ParIterator pit(inset.paragraph());
+ ParIterator pit(&*inset.paragraphs.begin());
ParIterator end;
// Find a caption layout in one of the (child inset's) pars
++actcell;
}
if (lock) {
- bool rtl = tabular->GetCellInset(actcell)->paragraph()->
+ bool rtl = tabular->GetCellInset(actcell)->paragraphs.begin()->
isRightToLeftPar(bv->buffer()->params);
activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
}
--actcell;
}
if (lock) {
- bool rtl = tabular->GetCellInset(actcell)->paragraph()->
+ bool rtl = tabular->GetCellInset(actcell)->paragraphs.begin()->
isRightToLeftPar(bv->buffer()->params);
activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
}
if (cols < columns) {
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
- getFont(bv->buffer(), ti->paragraph(), 0);
- ti->setText(buf.substr(op, p-op), font);
+ getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
+ ti->setText(buf.substr(op, p - op), font);
++cols;
++cell;
}
if (cols < columns) {
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
- getFont(bv->buffer(), ti->paragraph(), 0);
- ti->setText(buf.substr(op, p-op), font);
+ getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
+ ti->setText(buf.substr(op, p - op), font);
}
cols = ocol;
++row;
if ((cell < cells) && (op < len)) {
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
- getFont(bv->buffer(), ti->paragraph(), 0);
- ti->setText(buf.substr(op, len-op), font);
+ getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
+ ti->setText(buf.substr(op, len - op), font);
}
return true;
}
-Paragraph * InsetText::paragraph() const
-{
- return &*(paragraphs.begin());
-}
-
-
void InsetText::paragraph(Paragraph * p)
{
// GENERAL COMMENT: We don't have to free the old paragraphs as the
///
LyXCursor const & cursor(BufferView *) const;
///
- Paragraph * paragraph() const;
- ///
void paragraph(Paragraph *);
///
bool allowSpellcheck() const { return true; }
setInsetName(type);
LyXTextClass const & tclass = bp.getLyXTextClass();
if (tclass.hasLayout(caplayout))
- inset.paragraph()->layout(tclass[caplayout]);
+ inset.paragraphs.begin()->layout(tclass[caplayout]);
}
// Now find the caption in the float...
// We now tranverse the paragraphs of
// the inset...
- Paragraph * tmp = inset.paragraph();
- while (tmp) {
+ ParagraphList::iterator tmp = inset.paragraphs.begin();
+ ParagraphList::iterator end = inset.paragraphs.end();
+
+ for (; tmp != end; ++tmp) {
if (tmp->layout()->name() == caplayout) {
string const name = floatname(params_.type, buf->params);
string const str =
toc::TocItem const item(tmp->id(), 0 , str);
toclist[name].push_back(item);
}
- tmp = tmp->next();
+ ++tmp;
}
}
//
// special owner functions
///
- Paragraph * ownerParagraph() const;
+ ParagraphList & ownerParagraphs() const;
//
void ownerParagraph(Paragraph *) const;
// set it searching first for the right owner using the paragraph id
for (int i = 0; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) {
cell_info[i][j].inset.id(lt.cell_info[i][j].inset.id());
- cell_info[i][j].inset.setParagraphData(lt.cell_info[i][j].inset.paragraph(),true);
+ cell_info[i][j].inset.setParagraphData(&*lt.cell_info[i][j].inset.paragraphs.begin(), true);
}
}
}
for (int i = 1; i < number; ++i) {
cellinfo_of_cell(cell+i)->multicolumn = CELL_PART_OF_MULTICOLUMN;
cellinfo_of_cell(cell)->inset.appendParagraphs(buffer,
- cellinfo_of_cell(cell+i)->inset.paragraph());
+ &*cellinfo_of_cell(cell+i)->inset.paragraphs.begin());
cellinfo_of_cell(cell+i)->inset.clear(false);
}
#else
ret += TeXCellPreamble(os, cell);
InsetText * inset = GetCellInset(cell);
- bool rtl = inset->paragraph()->isRightToLeftPar(buf->params) &&
- !inset->paragraph()->empty() && GetPWidth(cell).zero();
+ bool rtl = inset->paragraphs.begin()->isRightToLeftPar(buf->params) &&
+ !inset->paragraphs.begin()->empty() && GetPWidth(cell).zero();
if (rtl)
os << "\\R{";
} else if (!rowlist_.empty())
return;
- Paragraph * par = ownerParagraph();
- current_font = getFont(bview->buffer(), par, 0);
+ ParagraphList::iterator par = ownerParagraphs().begin();
+ ParagraphList::iterator end = ownerParagraphs().end();
- while (par) {
- insertParagraph(par, rowlist_.end());
- par = par->next();
+ current_font = getFont(bview->buffer(), &*par, 0);
+
+ for (; par != end; ++par) {
+ insertParagraph(&*par, rowlist_.end());
}
setCursorIntern(rowlist_.begin()->par(), 0);
selection.cursor = cursor;
// changed the ownerParagrah() so the paragraph inside
// the row is NOT my really first par anymore.
// Got it Lars ;) (Jug 20011206)
- first_phys_par = ownerParagraph();
+ first_phys_par = &*ownerParagraphs().begin();
#warning FIXME
// In here prevrit could be set to rows().end(). (Lgb)
} else {
// check every paragraph
- Paragraph * par = ownerParagraph();
+ ParagraphList::iterator par = ownerParagraphs().begin();
+ ParagraphList::iterator end = ownerParagraphs().end();
+
do {
pos = par->getPositionOfInset(inset);
if (pos != -1) {
- checkParagraph(par, pos);
+ checkParagraph(&*par, pos);
return true;
}
- par = par->next();
- } while (par);
+ ++par;
+ } while (par != end);
return false;
}
// delete old row
removeRow(old_cursor.row());
- if (ownerParagraph() == old_cursor.par()) {
- ownerParagraph(ownerParagraph()->next());
+ if (ownerParagraphs().begin() == old_cursor.par()) {
+ ownerParagraph(&*boost::next(ownerParagraphs().begin()));
}
// delete old par
delete old_cursor.par();
// delete old row
removeRow(old_cursor.row());
// delete old par
- if (ownerParagraph() == old_cursor.par()) {
- ownerParagraph(ownerParagraph()->next());
+ if (ownerParagraphs().begin() == old_cursor.par()) {
+ ownerParagraph(&*boost::next(ownerParagraphs().begin()));
}
delete old_cursor.par();
}
-Paragraph * LyXText::ownerParagraph() const
+ParagraphList & LyXText::ownerParagraphs() const
{
if (inset_owner) {
- return inset_owner->paragraph();
+ return inset_owner->paragraphs;
}
- return &*(bv_owner->buffer()->paragraphs.begin());
+ return bv_owner->buffer()->paragraphs;
}
}
if (!gotoNextInset(codes, contents)) {
- if (cursor.pos() || cursor.par() != ownerParagraph()) {
+ if (cursor.pos() || cursor.par() != ownerParagraphs().begin()) {
LyXCursor tmp = cursor;
- cursor.par(ownerParagraph());
+ cursor.par(&*ownerParagraphs().begin());
cursor.pos(0);
if (!gotoNextInset(codes, contents)) {
cursor = tmp;
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()) {
+ ParagraphList::iterator tmp = ownerParagraphs().begin();
+ ParagraphList::iterator end = ownerParagraphs().end();
+
+ for (; tmp != end; ++tmp) {
if (tmp->params().startOfAppendix()) {
- setUndo(bv, Undo::EDIT, tmp, tmp->next());
+ setUndo(bv, Undo::EDIT, &*tmp, &*boost::next(tmp));
tmp->params().startOfAppendix(false);
int tmpy;
- setHeightOfRow(getRow(tmp, 0, tmpy));
+ setHeightOfRow(getRow(&*tmp, 0, tmpy));
break;
}
}
if (result)
return result;
}
- return bv->text->ownerParagraph();
+ return &*bv->text->ownerParagraphs().begin();
}