replace getFirstParagraph() by getParagraphs()

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6934 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-05-05 15:39:48 +00:00
parent b83cfa09ee
commit aee7213a76
10 changed files with 33 additions and 27 deletions

View File

@ -1,3 +1,9 @@
2003-05-05 André Pönitz <poenitz@gmx.net>
* iterator.C:
* undo_funcs.C: use getParagraphs() instead of getFirstParagraph()
2003-05-02 Michael Schmitt <michael.schmitt@teststep.org> 2003-05-02 Michael Schmitt <michael.schmitt@teststep.org>
* bufferparams.C: Output warning if a document with missing * bufferparams.C: Output warning if a document with missing

View File

@ -29,6 +29,7 @@ class Painter;
class LyXText; class LyXText;
class LyXLex; class LyXLex;
class Paragraph; class Paragraph;
class ParagraphList;
class LyXCursor; class LyXCursor;
class FuncRequest; class FuncRequest;
class WordLangTuple; class WordLangTuple;
@ -267,7 +268,7 @@ public:
virtual Inset * getInsetFromID(int /*id*/) const { return 0; } virtual Inset * getInsetFromID(int /*id*/) const { return 0; }
/// if this insets owns paragraphs (f.ex. InsetText) then it /// if this insets owns paragraphs (f.ex. InsetText) then it
/// should return it's very first one! /// should return it's very first one!
virtual Paragraph * getFirstParagraph(int /*num*/) const { return 0; } virtual ParagraphList * getParagraphs(int /*num*/) const { return 0; }
/// ///
virtual bool haveParagraphs() const { virtual bool haveParagraphs() const {
return false; return false;

View File

@ -571,9 +571,9 @@ int InsetCollapsable::scroll(bool recursive) const
} }
Paragraph * InsetCollapsable::getFirstParagraph(int i) const ParagraphList * InsetCollapsable::getParagraphs(int i) const
{ {
return inset.getFirstParagraph(i); return inset.getParagraphs(i);
} }

View File

@ -142,7 +142,7 @@ public:
/// ///
Inset * getInsetFromID(int id) const; Inset * getInsetFromID(int id) const;
/// ///
Paragraph * getFirstParagraph(int) const; ParagraphList * getParagraphs(int) const;
/// ///
LyXCursor const & cursor(BufferView *) const; LyXCursor const & cursor(BufferView *) const;
/// ///

View File

@ -2522,10 +2522,10 @@ void InsetTabular::getSelection(int & srow, int & erow,
} }
Paragraph * InsetTabular::getFirstParagraph(int i) const ParagraphList * InsetTabular::getParagraphs(int i) const
{ {
return (i < tabular->GetNumberOfCells()) return (i < tabular->GetNumberOfCells())
? tabular->GetCellInset(i)->getFirstParagraph(0) ? tabular->GetCellInset(i)->getParagraphs(0)
: 0; : 0;
} }

View File

@ -195,7 +195,7 @@ public:
/// ///
Inset * getInsetFromID(int id) const; Inset * getInsetFromID(int id) const;
/// ///
Paragraph * getFirstParagraph(int) const; ParagraphList * getParagraphs(int) const;
/// ///
LyXCursor const & cursor(BufferView *) const; LyXCursor const & cursor(BufferView *) const;
/// ///

View File

@ -2382,9 +2382,9 @@ void InsetText::clearInset(BufferView * bv, int start_x, int baseline) const
} }
Paragraph * InsetText::getFirstParagraph(int i) const ParagraphList * InsetText::getParagraphs(int i) const
{ {
return (i == 0) ? &*(paragraphs.begin()) : 0; return (i == 0) ? const_cast<ParagraphList*>(&paragraphs) : 0;
} }

View File

@ -198,7 +198,7 @@ public:
/// ///
Inset * getInsetFromID(int id) const; Inset * getInsetFromID(int id) const;
/// ///
Paragraph * getFirstParagraph(int) const; ParagraphList * getParagraphs(int) const;
/// ///
LyXCursor const & cursor(BufferView *) const; LyXCursor const & cursor(BufferView *) const;
/// ///

View File

@ -10,9 +10,9 @@ ParIterator & ParIterator::operator++()
// Does the current inset contain more "cells" ? // Does the current inset contain more "cells" ?
if (p.index >= 0) { if (p.index >= 0) {
++p.index; ++p.index;
Paragraph * par = p.it.getInset()->getFirstParagraph(p.index); ParagraphList * plist = p.it.getInset()->getParagraphs(p.index);
if (par) { if (plist && !plist->empty()) {
positions.push(ParPosition(par)); positions.push(ParPosition(&plist->front()));
return *this; return *this;
} }
++p.it; ++p.it;
@ -25,10 +25,10 @@ ParIterator & ParIterator::operator++()
// Try to find the next inset that contains paragraphs // Try to find the next inset that contains paragraphs
InsetList::iterator end = p.par->insetlist.end(); InsetList::iterator end = p.par->insetlist.end();
for (; p.it != end; ++p.it) { for (; p.it != end; ++p.it) {
Paragraph * par = p.it.getInset()->getFirstParagraph(0); ParagraphList * plist = p.it.getInset()->getParagraphs(0);
if (par) { if (plist && !plist->empty()) {
p.index = 0; p.index = 0;
positions.push(ParPosition(par)); positions.push(ParPosition(&plist->front()));
return *this; return *this;
} }
} }
@ -52,9 +52,9 @@ ParConstIterator & ParConstIterator::operator++()
// Does the current inset contain more "cells" ? // Does the current inset contain more "cells" ?
if (p.index >= 0) { if (p.index >= 0) {
++p.index; ++p.index;
Paragraph * par = p.it.getInset()->getFirstParagraph(p.index); ParagraphList * plist = p.it.getInset()->getParagraphs(p.index);
if (par) { if (plist && !plist->empty()) {
positions.push(ParPosition(par)); positions.push(ParPosition(&plist->front()));
return *this; return *this;
} }
++p.it; ++p.it;
@ -67,10 +67,10 @@ ParConstIterator & ParConstIterator::operator++()
// Try to find the next inset that contains paragraphs // Try to find the next inset that contains paragraphs
InsetList::iterator end = p.par->insetlist.end(); InsetList::iterator end = p.par->insetlist.end();
for (; p.it != end; ++p.it) { for (; p.it != end; ++p.it) {
Paragraph * par = p.it.getInset()->getFirstParagraph(0); ParagraphList * plist = p.it.getInset()->getParagraphs(0);
if (par) { if (plist && !plist->empty()) {
p.index = 0; p.index = 0;
positions.push(ParPosition(par)); positions.push(ParPosition(&plist->front()));
return *this; return *this;
} }
} }

View File

@ -17,7 +17,6 @@
#include "insets/insettext.h" #include "insets/insettext.h"
#include "debug.h" #include "debug.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "iterators.h" #include "iterators.h"
#include <vector> #include <vector>
@ -51,11 +50,11 @@ Paragraph * firstUndoParagraph(BufferView * bv, int inset_id)
{ {
Inset * inset = bv->buffer()->getInsetFromID(inset_id); Inset * inset = bv->buffer()->getInsetFromID(inset_id);
if (inset) { if (inset) {
Paragraph * result = inset->getFirstParagraph(0); ParagraphList * result = inset->getParagraphs(0);
if (result) if (result && !result->empty())
return result; return &result->front();
} }
return &*bv->text->ownerParagraphs().begin(); return &bv->text->ownerParagraphs().front();
} }