Replace ugly getParFromID() code with ParIterator-based stuff. I think

we can do the same for getInsetFromID() but Juergen didn't answer my query.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6145 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-02-14 02:21:01 +00:00
parent 69cf3b6204
commit d2b70ea0e6
14 changed files with 33 additions and 81 deletions

View File

@ -1,3 +1,12 @@
2003-02-14 John Levon <levon@movementarian.org>
* buffer.C: use ParIterator for getParFromID()
* paragraph.h:
* paragraph.C:
* paragraph_pimpl.h:
* paragraph_pimpl.C: remove unused getParFromID()
2003-02-14 John Levon <levon@movementarian.org>
* buffer.C: remove some very old #if 0'd parse code

View File

@ -3413,18 +3413,21 @@ Paragraph * Buffer::getParFromID(int id) const
{
if (id < 0)
return 0;
// why should we allow < 0 ??
//lyx::Assert(id >= 0);
ParConstIterator it(par_iterator_begin());
ParConstIterator end(par_iterator_end());
ParagraphList::iterator it = paragraphs.begin();
ParagraphList::iterator end = paragraphs.end();
for (; it != end; ++it) {
if (it->id() == id) {
return &*it;
}
Paragraph * tmp = it->getParFromID(id);
if (tmp) {
return tmp;
// go on then, show me how to remove
// the cast
if ((*it)->id() == id) {
return const_cast<Paragraph*>(*it);
}
}
return 0;
}

View File

@ -1,3 +1,14 @@
2003-02-14 John Levon <levon@movementarian.org>
* inset.h:
* inset.C:
* insetcollapsable.h:
* insetcollapsable.C:
* insettabular.h:
* insettabular.C:
* insettext.h:
* insettext.C: remove unused getParFromID()
2003-02-13 John Levon <levon@movementarian.org>
* insettext.h:

View File

@ -201,7 +201,7 @@ public:
virtual bool isTextInset() const { return false; }
///
virtual bool doClearArea() const { return true; }
///
/// return true if the inset should be removed automatically
virtual bool autoDelete() const;
/// returns true the inset can hold an inset of given type
virtual bool insetAllowed(Inset::Code) const { return false; }
@ -288,11 +288,7 @@ public:
return scx;
return 0;
}
/// try to get a paragraph pointer from it's id if we have a
/// paragraph to give back!
virtual Paragraph * getParFromID(int /* id */) const {
return 0;
}
/// try to get a inset pointer from it's id if we have
/// an inset to give back!
virtual Inset * getInsetFromID(int /* id */) const {

View File

@ -608,13 +608,6 @@ int InsetCollapsable::scroll(bool recursive) const
}
Paragraph * InsetCollapsable::getParFromID(int id) const
{
lyxerr[Debug::INFO] << "Looking for paragraph " << id << endl;
return inset.getParFromID(id);
}
Paragraph * InsetCollapsable::firstParagraph() const
{
return inset.firstParagraph();

View File

@ -150,8 +150,6 @@ public:
UpdatableInset::scroll(bv, offset);
}
///
Paragraph * getParFromID(int id) const;
///
Inset * getInsetFromID(int id) const;
///
Paragraph * firstParagraph() const;

View File

@ -2664,19 +2664,6 @@ void InsetTabular::getSelection(int & srow, int & erow,
}
Paragraph * InsetTabular::getParFromID(int id) const
{
Paragraph * result;
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;
}
}
return 0;
}
Paragraph * InsetTabular::firstParagraph() const
{
if (the_locking_inset)

View File

@ -196,8 +196,6 @@ public:
UpdatableInset::scroll(bv, offset);
}
///
Paragraph * getParFromID(int id) const;
///
Inset * getInsetFromID(int id) const;
///
Paragraph * firstParagraph() const;

View File

@ -2515,23 +2515,6 @@ void InsetText::clearInset(BufferView * bv, int baseline, bool & cleared) const
}
Paragraph * InsetText::getParFromID(int id) const
{
ParagraphList::iterator it = paragraphs.begin();
ParagraphList::iterator end = paragraphs.end();
for (; it != end; ++it) {
if (it->id() == id) {
return &*(it);
}
Paragraph * tmp2 = it->getParFromID(id);
if (tmp2 != 0) {
return tmp2;
}
}
return 0;
}
Paragraph * InsetText::firstParagraph() const
{
Paragraph * result;

View File

@ -203,8 +203,6 @@ public:
///
void clearSelection(BufferView * bv);
///
Paragraph * getParFromID(int id) const;
///
Inset * getInsetFromID(int id) const;
///
Paragraph * firstParagraph() const;

View File

@ -1978,12 +1978,6 @@ ParagraphParameters const & Paragraph::params() const
}
Paragraph * Paragraph::getParFromID(int id) const
{
return pimpl_->getParFromID(id);
}
bool Paragraph::isFreeSpacing() const
{
// for now we just need this, later should we need this in some

View File

@ -307,9 +307,6 @@ public:
/// returns -1 if inset not found
int getPositionOfInset(Inset const * inset) const;
/// some good comment here John?
Paragraph * getParFromID(int id) const;
///
int stripLeadingSpaces();

View File

@ -849,19 +849,6 @@ void Paragraph::Pimpl::validate(LaTeXFeatures & features,
}
Paragraph * Paragraph::Pimpl::getParFromID(int id) const
{
InsetList::iterator cit = owner_->insetlist.begin();
InsetList::iterator lend = owner_->insetlist.end();
Paragraph * result;
for (; cit != lend; ++cit) {
if ((result = cit.getInset()->getParFromID(id)))
return result;
}
return 0;
}
LyXFont const Paragraph::Pimpl::realizeFont(LyXFont const & font,
BufferParams const & bparams) const
{

View File

@ -171,8 +171,6 @@ struct Paragraph::Pimpl {
void validate(LaTeXFeatures & features,
LyXLayout const & layout) const;
///
Paragraph * getParFromID(int id) const;
///
unsigned int id_;
///