texrowpar = text->ownerParagraphs().begin();
tmppos = 0;
} else {
- texrowpar = *buffer()->getParFromID(tmpid);
+ texrowpar = buffer()->getParFromID(tmpid).pit();
}
text->setCursor(texrowpar, tmppos);
}
// The test it.size()==1 was needed to prevent crashes.
// How to set the cursor corretly when it.size()>1 ??
if (it.size() == 1) {
- text->setCursorIntern(*it, 0);
+ text->setCursorIntern(it.pit(), 0);
text->redoParagraphs(text->cursor,
boost::next(text->cursor.par()));
text->fullRebreak();
if (par == buffer_->par_iterator_end())
return;
- bv_->text->setCursor(*par,
- min((*par)->size(), saved_positions[i].par_pos));
+ bv_->text->setCursor(par.pit(),
+ min(par->size(), saved_positions[i].par_pos));
update(BufferView::SELECT);
if (i > 0)
if (!tracking) {
ParIterator const end = buf->par_iterator_end();
- for (ParIterator it = buf->par_iterator_begin(); it != end; ++it) {
- (*it)->trackChanges();
- }
+ for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
+ it->trackChanges();
buf->params.tracking_changes = true;
// we cannot allow undos beyond the freeze point
}
ParIterator const end = buf->par_iterator_end();
- for (ParIterator it = buf->par_iterator_begin(); it != end; ++it) {
- (*it)->untrackChanges();
- }
+ for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
+ it->untrackChanges();
buf->params.tracking_changes = false;
}
+
+2003-06-12 André Pönitz <poenitz@gmx.net>
+
+ * BufferView.C:
+ * BufferView_pimpl.C:
+ * CutAndPaste.C:
+ * buffer.C:
+ * iterators.[Ch]:
+ * lyxfunc.C:
+ * text.C:
+ * toc.C: Return a Paragraph & for ParIterator::operator*()
+
2003-06-11 John Levon <levon@movementarian.org>
* lyx_main.C:
LyXTextClass const & tclass2 = textclasslist[c2];
ParIterator end = ParIterator(pars.end(), pars);
for (ParIterator it = ParIterator(pars.begin(), pars); it != end; ++it) {
- Paragraph * par = &*(*it);
- string const name = par->layout()->name();
+ string const name = it->layout()->name();
bool hasLayout = tclass2.hasLayout(name);
if (hasLayout)
- par->layout(tclass2[name]);
+ it->layout(tclass2[name]);
else
- par->layout(tclass2.defaultLayout());
+ it->layout(tclass2.defaultLayout());
if (!hasLayout && name != tclass1.defaultLayoutName()) {
++ret;
string const s = bformat(
_("Layout had to be changed from\n%1$s to %2$s\n"
"because of class conversion from\n%3$s to %4$s"),
- name, par->layout()->name(), tclass1.name(), tclass2.name());
+ name, it->layout()->name(), tclass1.name(), tclass2.name());
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem("Changed Layout", s,
- par->id(), 0,
- par->size()));
+ it->id(), 0,
+ it->size()));
}
}
return ret;
ParIterator end = par_iterator_end();
for (ParIterator it = par_iterator_begin(); it != end; ++it)
- (*it)->changeLanguage(params, from, to);
+ it->changeLanguage(params, from, to);
}
{
ParIterator end = par_iterator_end();
for (ParIterator it = par_iterator_begin(); it != end; ++it)
- if ((*it)->isMultiLingual(params))
+ if (it->isMultiLingual(params))
return true;
return false;
}
for (; it != end; ++it)
- if ((*it)->id() == id)
+ if (it->id() == id)
return it;
return end;
bool Buffer::hasParWithID(int id) const
{
- ParIterator it(const_cast<Buffer*>(this)->par_iterator_begin());
- ParIterator end(const_cast<Buffer*>(this)->par_iterator_end());
+ ParConstIterator it = par_iterator_begin();
+ ParConstIterator end = par_iterator_end();
if (id < 0) {
// John says this is called with id == -1 from undo
}
for (; it != end; ++it)
- if ((*it)->id() == id)
+ if (it->id() == id)
return true;
return false;
void ControlErrorList::goTo(int item)
{
- BufferView * const bv = kernel().bufferview();
- Buffer * const buf = kernel().buffer();
-
ErrorItem const & err = errorlist_[item];
-
if (err.par_id == -1)
return;
+ Buffer * const buf = kernel().buffer();
ParIterator pit = buf->getParFromID(err.par_id);
if (pit == buf->par_iterator_end()) {
int range = err.pos_end - err.pos_start;
- if (err.pos_end > (*pit)->size() || range <= 0)
- range = (*pit)->size() - err.pos_start;
+ if (err.pos_end > pit->size() || range <= 0)
+ range = pit->size() - err.pos_start;
// Now make the selection.
+ BufferView * const bv = kernel().bufferview();
bv->insetUnlock();
bv->toggleSelection();
bv->text->clearSelection();
- bv->text->setCursor(*pit, err.pos_start);
+ bv->text->setCursor(pit.pit(), err.pos_start);
bv->text->setSelectionRange(range);
bv->toggleSelection(false);
bv->fitCursor();
ParPosition::ParPosition(ParagraphList::iterator p, ParagraphList const & pl)
: pit(p), plist(&pl)
{
- if (p != const_cast<ParagraphList&>(pl).end()) {
+ if (p != pl.end()) {
it.reset(p->insetlist.begin());
}
}
}
// Try to go to the next paragarph
- if (next(p.pit) != const_cast<ParagraphList*>(p.plist)->end()
+ if (next(p.pit) != p.plist->end()
|| pimpl_->positions.size() == 1) {
++p.pit;
p.index.reset();
}
-ParagraphList::iterator ParIterator::operator*() const
+Paragraph & ParIterator::operator*() const
+{
+ return *pimpl_->positions.back().pit;
+}
+
+
+ParagraphList::iterator ParIterator::pit() const
{
return pimpl_->positions.back().pit;
}
}
// Try to go to the next paragarph
- if (next(p.pit) != const_cast<ParagraphList*>(p.plist)->end()
+ if (next(p.pit) != p.plist->end()
|| pimpl_->positions.size() == 1) {
++p.pit;
p.index.reset();
}
-ParagraphList::iterator ParConstIterator::operator*() const
+Paragraph const & ParConstIterator::operator*() const
+{
+ return *pimpl_->positions.back().pit;
+}
+
+
+ParagraphList::const_iterator ParConstIterator::pit() const
{
return pimpl_->positions.back().pit;
}
-ParagraphList::iterator ParConstIterator::operator->() const
+ParagraphList::const_iterator ParConstIterator::operator->() const
{
return pimpl_->positions.back().pit;
}
///
ParIterator & operator++();
///
- ParagraphList::iterator operator*() const;
+ Paragraph & operator*() const;
///
ParagraphList::iterator operator->() const;
///
ParagraphList::iterator outerPar() const;
///
+ ParagraphList::iterator pit() const;
+ ///
ParagraphList & plist() const;
///
size_t size() const;
///
ParConstIterator & operator++();
///
- ParagraphList::iterator operator*() const;
+ ParagraphList::const_iterator pit() const;
///
- ParagraphList::iterator operator->() const;
-
+ Paragraph const & operator*() const;
///
+ ParagraphList::const_iterator operator->() const;
+
+ /// depth of nesting
size_t size() const;
///
friend
<< id << ']' << endl;
break;
} else {
- lyxerr[Debug::INFO] << "Paragraph " << (*par)->id()
+ lyxerr[Debug::INFO] << "Paragraph " << par->id()
<< " found." << endl;
}
if (view()->theLockingInset())
view()->unlockInset(view()->theLockingInset());
- if ((*par)->inInset()) {
+ if (par->inInset()) {
FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
- (*par)->inInset()->localDispatch(cmd);
+ par->inInset()->localDispatch(cmd);
}
// Set the cursor
- view()->getLyXText()->setCursor(*par, 0);
+ view()->getLyXText()->setCursor(par.pit(), 0);
view()->switchKeyMap();
owner->view_state_changed();
};
-pos_type
-LyXText::rowBreakPoint(Row const & row) const
+pos_type LyXText::rowBreakPoint(Row const & row) const
{
ParagraphList::iterator pit = row.par();
// or the end of the par, then choose the possible break
// nearest that.
- int const left = leftMargin(const_cast<Row&>(row));
+ int const left = leftMargin(row);
int x = left;
// pixel width since last breakpoint
// For each paragraph, traverse its insets and look for
// FLOAT_CODE or WRAP_CODE
- InsetList::iterator it = pit->insetlist.begin();
- InsetList::iterator end = pit->insetlist.end();
+ InsetList::const_iterator it = pit->insetlist.begin();
+ InsetList::const_iterator end = pit->insetlist.end();
for (; it != end; ++it) {
if (it->inset->lyxCode() == Inset::FLOAT_CODE) {
InsetFloat * il =