mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
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:
parent
69cf3b6204
commit
d2b70ea0e6
@ -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
|
||||
|
19
src/buffer.C
19
src/buffer.C
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -150,8 +150,6 @@ public:
|
||||
UpdatableInset::scroll(bv, offset);
|
||||
}
|
||||
///
|
||||
Paragraph * getParFromID(int id) const;
|
||||
///
|
||||
Inset * getInsetFromID(int id) const;
|
||||
///
|
||||
Paragraph * firstParagraph() const;
|
||||
|
@ -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)
|
||||
|
@ -196,8 +196,6 @@ public:
|
||||
UpdatableInset::scroll(bv, offset);
|
||||
}
|
||||
///
|
||||
Paragraph * getParFromID(int id) const;
|
||||
///
|
||||
Inset * getInsetFromID(int id) const;
|
||||
///
|
||||
Paragraph * firstParagraph() const;
|
||||
|
@ -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;
|
||||
|
@ -203,8 +203,6 @@ public:
|
||||
///
|
||||
void clearSelection(BufferView * bv);
|
||||
///
|
||||
Paragraph * getParFromID(int id) const;
|
||||
///
|
||||
Inset * getInsetFromID(int id) const;
|
||||
///
|
||||
Paragraph * firstParagraph() const;
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -171,8 +171,6 @@ struct Paragraph::Pimpl {
|
||||
void validate(LaTeXFeatures & features,
|
||||
LyXLayout const & layout) const;
|
||||
|
||||
///
|
||||
Paragraph * getParFromID(int id) const;
|
||||
///
|
||||
unsigned int id_;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user