move getParFromID to Buffer

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2207 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-07-09 09:16:00 +00:00
parent 8f9acf64a9
commit f6c9132899
13 changed files with 60 additions and 34 deletions

View File

@ -156,7 +156,7 @@ void BufferView::insertErrors(TeXErrors & terr)
texrowpar = text->firstParagraph();
tmppos = 0;
} else {
texrowpar = text->getParFromID(tmpid);
texrowpar = buffer()->getParFromID(tmpid);
}
if (texrowpar == 0)
@ -185,7 +185,7 @@ void BufferView::setCursorFromRow(int row)
texrowpar = text->firstParagraph();
tmppos = 0;
} else {
texrowpar = text->getParFromID(tmpid);
texrowpar = buffer()->getParFromID(tmpid);
}
text->setCursor(this, texrowpar, tmppos);
}

View File

@ -1149,7 +1149,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
if (b != 0 ) buffer(b);
}
Paragraph * par = bv_->text->getParFromID(saved_positions[i].par_id);
Paragraph * par = buffer_->getParFromID(saved_positions[i].par_id);
if (!par)
return;

View File

@ -1,3 +1,17 @@
2001-07-09 Lars Gullik Bjønnes <larsbj@birdstep.com>
* text2.C (getParFromID): removed
* buffer.C (getParFromID): new method moved form lyxtext.
* BufferView2.C (insertErrors): adjust
(setCursorFromRow): adjust
* BufferView_pimpl.C (restorePosition): adjust
* lyxfunc.C (Dispatch): adjust
* undo_funcs.C (textUndo): adjust
(textRedo): adjust
(textHandleUndo): adjust
(textHandleUndo): adjust
2001-07-08 Lars Gullik Bjønnes <larsbj@birdstep.com>
* buffer.C: up' the LYX_FORMAT

View File

@ -3689,3 +3689,21 @@ Inset * Buffer::getInsetFromID(int id_arg) const
}
return 0;
}
Paragraph * Buffer::getParFromID(int id) const
{
if (id < 0) return 0;
Paragraph * par = paragraph;
while (par) {
if (par->id() == id) {
return par;
}
Paragraph * tmp = par->getParFromID(id);
if (tmp) {
return tmp;
}
par = par->next();
}
return 0;
}

View File

@ -128,6 +128,8 @@ public:
void insertErtContents(Paragraph * par, int & pos,
LyXFont const & font,
bool set_inactive = true);
///
Paragraph * getParFromID(int id) const;
private:
/// Parse a single inset.
void readInset(LyXLex &, Paragraph *& par, int & pos, LyXFont &);

View File

@ -498,21 +498,25 @@ int InsetCollapsable::scroll(bool recursive) const
return sx;
}
Paragraph * InsetCollapsable::getParFromID(int id) const
{
return inset.getParFromID(id);
}
Paragraph * InsetCollapsable::firstParagraph() const
{
return inset.firstParagraph();
}
LyXCursor const & InsetCollapsable::cursor(BufferView * bv) const
{
return inset.cursor(bv);
}
Inset * InsetCollapsable::getInsetFromID(int id_arg) const
{
if (id_arg == id())

View File

@ -2392,8 +2392,8 @@ void InsetTabular::getSelection(int & srow, int & erow, int & scol, int & ecol)
Paragraph * InsetTabular::getParFromID(int id) const
{
Paragraph * result;
for(int i=0; i < tabular->rows(); ++i) {
for(int j=0; j < tabular->columns(); ++j) {
for(int i = 0; i < tabular->rows(); ++i) {
for(int j = 0; j < tabular->columns(); ++j) {
if ((result = tabular->GetCellInset(i, j)->getParFromID(id)))
return result;
}

View File

@ -1826,6 +1826,7 @@ void InsetText::clearInset(Painter & pain, int baseline, bool & cleared) const
need_update = FULL;
}
Paragraph * InsetText::getParFromID(int id) const
{
Paragraph * result = par;
@ -1838,6 +1839,7 @@ Paragraph * InsetText::getParFromID(int id) const
return result;
}
Paragraph * InsetText::firstParagraph() const
{
Paragraph * result;
@ -1847,6 +1849,7 @@ Paragraph * InsetText::firstParagraph() const
return par;
}
LyXCursor const & InsetText::cursor(BufferView * bv) const
{
if (the_locking_inset)
@ -1854,11 +1857,13 @@ LyXCursor const & InsetText::cursor(BufferView * bv) const
return getLyXText(bv)->cursor;
}
Paragraph * InsetText::paragraph() const
{
return par;
}
void InsetText::paragraph(Paragraph * p)
{
par = p;
@ -1873,6 +1878,7 @@ void InsetText::paragraph(Paragraph * p)
need_update |= INIT;
}
Inset * InsetText::getInsetFromID(int id_arg) const
{
if (id_arg == id())

View File

@ -1326,7 +1326,7 @@ string const LyXFunc::Dispatch(int ac,
int id;
istr >> id;
Paragraph * par = TEXT()->getParFromID(id);
Paragraph * par = owner->buffer()->getParFromID(id);
if (par == 0) {
lyxerr[Debug::INFO] << "No matching paragraph found! ["
<< id << "]" << std::endl;

View File

@ -442,9 +442,6 @@ public:
///
int numberOfCell(Paragraph * par,
Paragraph::size_type pos) const;
///
Paragraph * getParFromID(int id) const;
///
void removeTableRow(LyXCursor & cursor) const;
///

View File

@ -546,11 +546,10 @@ Paragraph * Paragraph::Pimpl::TeXDeeper(Buffer const * buf,
Paragraph * Paragraph::Pimpl::getParFromID(int id) const
{
InsetList::const_iterator cit = owner_->insetlist.begin();
InsetList::const_iterator lend = owner_->insetlist.end();
Paragraph * result;
for (InsetList::const_iterator cit = owner_->insetlist.begin();
cit != lend; ++cit)
{
for (; cit != lend; ++cit) {
if ((result = cit->inset->getParFromID(id)))
return result;
}

View File

@ -2402,20 +2402,6 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
}
Paragraph * LyXText::getParFromID(int id) const
{
if (id < 0)
return 0;
Paragraph * result = firstParagraph();
Paragraph * ires = 0;
while (result && result->id() != id) {
if ((ires = result->getParFromID(id)))
return ires;
result = result->next();
}
return result;
}
void LyXText::toggleAppendix(BufferView * bview)
{
Paragraph * par = cursor.par();
@ -2459,7 +2445,7 @@ Paragraph * LyXText::ownerParagraph(Paragraph * p) const
Paragraph * LyXText::ownerParagraph(int id, Paragraph * p) const
{
Paragraph * op = getParFromID(id);
Paragraph * op = bv_owner->buffer()->getParFromID(id);
if (op && op->InInset()) {
static_cast<InsetText *>(op->InInset())->paragraph(p);
} else {

View File

@ -32,13 +32,13 @@ bool textUndo(BufferView * bv)
if (undo) {
finishUndo();
if (!undo_frozen) {
Paragraph * first = bv->text->getParFromID(undo->number_of_before_par);
Paragraph * first = bv->buffer()->getParFromID(undo->number_of_before_par);
if (!first)
first = firstUndoParagraph(bv, undo->number_of_inset_id);
if (first) {
bv->buffer()->redostack.push(
createUndo(bv, undo->kind, first,
bv->text->getParFromID(undo->number_of_behind_par)));
bv->buffer()->getParFromID(undo->number_of_behind_par)));
}
}
}
@ -53,13 +53,13 @@ bool textRedo(BufferView * bv)
if (undo) {
finishUndo();
if (!undo_frozen) {
Paragraph * first = bv->text->getParFromID(undo->number_of_before_par);
Paragraph * first = bv->buffer()->getParFromID(undo->number_of_before_par);
if (!first)
first = firstUndoParagraph(bv, undo->number_of_inset_id);
if (first) {
bv->buffer()->undostack.push(
createUndo(bv, undo->kind, first,
bv->text->getParFromID(undo->number_of_behind_par)));
bv->buffer()->getParFromID(undo->number_of_behind_par)));
}
}
}
@ -73,9 +73,9 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
bool result = false;
if (undo) {
Paragraph * before =
bv->text->getParFromID(undo->number_of_before_par);
bv->buffer()->getParFromID(undo->number_of_before_par);
Paragraph * behind =
bv->text->getParFromID(undo->number_of_behind_par);
bv->buffer()->getParFromID(undo->number_of_behind_par);
Paragraph * tmppar;
Paragraph * tmppar2;
Paragraph * endpar;
@ -158,7 +158,7 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
} else
endpar = behind;
tmppar = bv->text->getParFromID(undo->number_of_cursor_par);
tmppar = bv->buffer()->getParFromID(undo->number_of_cursor_par);
UpdatableInset* it = static_cast<UpdatableInset*>(tmppar3->InInset());
if (it) {
it->getLyXText(bv)->redoParagraphs(bv, it->getLyXText(bv)->cursor,