parlist-a-1.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6683 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-04-02 17:11:38 +00:00
parent 9bfcf348c8
commit 6ce86e2bfe
14 changed files with 130 additions and 79 deletions

View File

@ -472,7 +472,7 @@ bool BufferView::removeAutoInsets()
// 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();
@ -515,7 +515,7 @@ void BufferView::insertErrors(TeXErrors & terr)
Paragraph * texrowpar = 0;
if (tmpid == -1) {
texrowpar = text->ownerParagraph();
texrowpar = &*text->ownerParagraphs().begin();
tmppos = 0;
} else {
texrowpar = buffer()->getParFromID(tmpid);
@ -546,7 +546,7 @@ void BufferView::setCursorFromRow(int row)
Paragraph * texrowpar;
if (tmpid == -1) {
texrowpar = text->ownerParagraph();
texrowpar = &*text->ownerParagraphs().begin();
tmppos = 0;
} else {
texrowpar = buffer()->getParFromID(tmpid);

View File

@ -1,3 +1,26 @@
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
@ -20,7 +43,7 @@
* text.C: adjust
* text2.C: adjust
* text3.C: adjust
* lyxrow_funcs. [Ch]: new files
* lyxrow.[Ch]: remove next and previous pointers

View File

@ -1,8 +1,30 @@
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
@ -12,7 +34,7 @@
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

View File

@ -95,7 +95,7 @@ InsetERT::InsetERT(BufferParams const & bp,
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).
@ -200,8 +200,9 @@ void InsetERT::write(Buffer const * buf, ostream & os) const
//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) {
@ -224,7 +225,6 @@ void InsetERT::write(Buffer const * buf, ostream & os) const
break;
}
}
par = par->next();
}
}
@ -349,9 +349,11 @@ void InsetERT::lfunMouseMotion(FuncRequest const & cmd)
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
@ -365,8 +367,8 @@ int InsetERT::latex(Buffer const *, ostream & os, bool /*fragile*/,
os << par->getChar(i);
}
}
par = par->next();
if (par) {
++par;
if (par != end) {
os << "\n\n";
lines += 2;
}
@ -384,9 +386,11 @@ int InsetERT::ascii(Buffer const *, ostream &, int /*linelen*/) const
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)) {
@ -396,8 +400,8 @@ int InsetERT::linuxdoc(Buffer const *, ostream & os) const
os << par->getChar(i);
}
}
par = par->next();
if (par) {
++par;
if (par != end) {
os << "\n";
lines ++;
}
@ -409,9 +413,11 @@ int InsetERT::linuxdoc(Buffer const *, ostream & os) const
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)) {
@ -421,8 +427,8 @@ int InsetERT::docbook(Buffer const *, ostream & os, bool) const
os << par->getChar(i);
}
}
par = par->next();
if (par) {
++par;
if (par != end) {
os << "\n";
lines ++;
}
@ -437,7 +443,7 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd)
Inset::RESULT result = UNDISPATCHED;
BufferView * bv = cmd.view();
if (inset.paragraph()->empty()) {
if (inset.paragraphs.begin()->empty()) {
set_latex_font(bv);
}
@ -480,7 +486,7 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd)
break;
case LFUN_LAYOUT:
bv->owner()->setLayout(inset.paragraph()->layout()->name());
bv->owner()->setLayout(inset.paragraphs.begin()->layout()->name());
result = DISPATCHED_NOUPDATE;
break;
@ -511,17 +517,18 @@ string const InsetERT::get_new_label() const
{
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()) {

View File

@ -137,7 +137,7 @@ InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
setInsetName(type);
LyXTextClass const & tclass = bp.getLyXTextClass();
if (tclass.hasLayout(caplayout))
inset.paragraph()->layout(tclass[caplayout]);
inset.paragraphs.begin()->layout(tclass[caplayout]);
}
@ -364,7 +364,7 @@ void InsetFloat::wide(bool w, BufferParams const & bp)
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

View File

@ -1631,7 +1631,7 @@ bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
++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);
}
@ -1660,7 +1660,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
--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);
}
@ -2852,8 +2852,8 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
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;
}
@ -2863,8 +2863,8 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
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;
@ -2879,8 +2879,8 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
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;

View File

@ -2428,12 +2428,6 @@ LyXCursor const & InsetText::cursor(BufferView * bv) const
}
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

View File

@ -208,8 +208,6 @@ public:
///
LyXCursor const & cursor(BufferView *) const;
///
Paragraph * paragraph() const;
///
void paragraph(Paragraph *);
///
bool allowSpellcheck() const { return true; }

View File

@ -67,7 +67,7 @@ InsetWrap::InsetWrap(BufferParams const & bp, string const & type)
setInsetName(type);
LyXTextClass const & tclass = bp.getLyXTextClass();
if (tclass.hasLayout(caplayout))
inset.paragraph()->layout(tclass[caplayout]);
inset.paragraphs.begin()->layout(tclass[caplayout]);
}
@ -269,8 +269,10 @@ void InsetWrap::addToToc(toc::TocList & toclist, Buffer const * buf) const
// 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 =
@ -279,7 +281,7 @@ void InsetWrap::addToToc(toc::TocList & toclist, Buffer const * buf) const
toc::TocItem const item(tmp->id(), 0 , str);
toclist[name].push_back(item);
}
tmp = tmp->next();
++tmp;
}
}

View File

@ -626,7 +626,7 @@ public:
//
// 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

View File

@ -129,7 +129,7 @@ LyXTabular::LyXTabular(BufferParams const & bp,
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);
}
}
}
@ -1338,7 +1338,7 @@ void LyXTabular::SetMultiColumn(Buffer * buffer, int cell, int number)
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
@ -1983,8 +1983,8 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf,
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{";

View File

@ -88,12 +88,13 @@ void LyXText::init(BufferView * bview, bool reinit)
} 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;
@ -694,7 +695,7 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
// 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 {
@ -1646,15 +1647,17 @@ bool LyXText::updateInset(Inset * inset)
// 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;
}
@ -2283,8 +2286,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
// 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();
@ -2319,8 +2322,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
// 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();
@ -2357,12 +2360,12 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
}
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;
}

View File

@ -214,9 +214,9 @@ void LyXText::gotoInset(vector<Inset::Code> const & codes,
}
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;
@ -411,13 +411,15 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
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;
}
}

View File

@ -53,7 +53,7 @@ Paragraph * firstUndoParagraph(BufferView * bv, int inset_id)
if (result)
return result;
}
return bv->text->ownerParagraph();
return &*bv->text->ownerParagraphs().begin();
}