parlist-21-a.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7054 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-05-27 17:29:03 +00:00
parent a8e8e755fc
commit 4882d49f88
13 changed files with 98 additions and 42 deletions

View File

@ -260,9 +260,9 @@ int BufferView::Pimpl::resizeCurrentBuffer()
{
lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
Paragraph * par = 0;
Paragraph * selstartpar = 0;
Paragraph * selendpar = 0;
ParagraphList::iterator par;
ParagraphList::iterator selstartpar;
ParagraphList::iterator selendpar;
UpdatableInset * the_locking_inset = 0;
pos_type pos = 0;
@ -276,11 +276,11 @@ int BufferView::Pimpl::resizeCurrentBuffer()
owner_->message(_("Formatting document..."));
if (bv_->text) {
par = &*bv_->text->cursor.par();
par = bv_->text->cursor.par();
pos = bv_->text->cursor.pos();
selstartpar = &*bv_->text->selection.start.par();
selstartpar = bv_->text->selection.start.par();
selstartpos = bv_->text->selection.start.pos();
selendpar = &*bv_->text->selection.end.par();
selendpar = bv_->text->selection.end.par();
selendpos = bv_->text->selection.end.pos();
selection = bv_->text->selection.set();
mark_set = bv_->text->selection.mark();
@ -311,9 +311,13 @@ int BufferView::Pimpl::resizeCurrentBuffer()
bv_->text->init(bv_);
//buffer_->resizeInsets(bv_);
}
par = bv_->text->ownerParagraphs().end();
selstartpar = bv_->text->ownerParagraphs().end();
selendpar = bv_->text->ownerParagraphs().end();
}
if (par) {
if (par != bv_->text->ownerParagraphs().end()) {
bv_->text->selection.set(true);
// At this point just to avoid the Delete-Empty-Paragraph-
// Mechanism when setting the cursor.

View File

@ -1,3 +1,22 @@
2003-05-27 Lars Gullik Bjønnes <larsbj@gullik.net>
* text3.C: adjust
* text2.C (cursorBottom): adjust
(setCounter): use ParagraphList::find, adjust
* text.C (workWidth): use ParagraphList::find, adjust
* lyxcursor.C (LyXCursor): adjust
* buffer.C (inset_iterator): adjust
* ParagraphList.h: make iterator(value_type) private, make
ParagraphList a friend of iterator.
* ParagraphList.C (find): new function
* BufferView_pimpl.C (resizeCurrentBuffer): adjust
2003-05-27 André Pönitz <poenitz@gmx.net>

View File

@ -315,4 +315,17 @@ bool ParagraphList::empty() const
return parlist == 0;
}
ParagraphList::iterator ParagraphList::find(Paragraph const & p)
{
iterator it = begin();
iterator last = end();
for (;it != last; ++it) {
if (&*it == &p)
break;
}
return it;
}
#endif

View File

@ -26,6 +26,7 @@ public:
///
class iterator {
public:
friend class ParagraphList;
///
typedef std::bidirectional_iterator_tag iterator_category;
///
@ -39,8 +40,6 @@ public:
///
iterator();
///
iterator(value_type);
///
reference operator*();
///
pointer operator->();
@ -53,6 +52,8 @@ public:
///
iterator operator--(int);
private:
///
iterator(value_type);
///
Paragraph * ptr;
};
@ -98,6 +99,8 @@ public:
int size() const;
///
bool empty() const;
///
iterator find(Paragraph const &);
private:
///
Paragraph * parlist;

View File

@ -2383,7 +2383,7 @@ void Buffer::setParentName(string const & name)
Buffer::inset_iterator::inset_iterator()
: pit(0), pend(0)
: pit(), pend()
{}

View File

@ -1,3 +1,14 @@
2003-05-27 Lars Gullik Bjønnes <larsbj@gullik.net>
* insettext.C (saveLyXTextState): adjust
(restoreLyXTextState): adjust
(init): adjust
(lockInset): adjust
(unlockInsetInInset): adjust
(localDispatch): adjust
(getLyXText): adjust
* insettabular.C (insertAsciiString): adjust
2003-05-27 André Pönitz <poenitz@gmx.net>

View File

@ -2811,7 +2811,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
if (cols < columns) {
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
ti->setText(buf.substr(op, p - op), font);
++cols;
++cell;
@ -2822,7 +2822,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
if (cols < columns) {
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
ti->setText(buf.substr(op, p - op), font);
}
cols = ocol;
@ -2838,7 +2838,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
if ((cell < cells) && (op < len)) {
InsetText * ti = loctab->GetCellInset(cell);
LyXFont const font = ti->getLyXText(bv)->
getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
ti->setText(buf.substr(op, len - op), font);
}

View File

@ -82,31 +82,31 @@ void InsetText::saveLyXTextState(LyXText * t) const
ParagraphList::iterator it = paragraphs.begin();
ParagraphList::iterator end = paragraphs.end();
for (; it != end; ++it) {
if (&*it == t->cursor.par())
if (it == t->cursor.par())
break;
}
if (it != end && t->cursor.pos() <= it->size()) {
sstate.lpar = &*t->cursor.par();
sstate.lpar = t->cursor.par();
sstate.pos = t->cursor.pos();
sstate.boundary = t->cursor.boundary();
sstate.selstartpar = &*t->selection.start.par();
sstate.selstartpar = t->selection.start.par();
sstate.selstartpos = t->selection.start.pos();
sstate.selstartboundary = t->selection.start.boundary();
sstate.selendpar = &*t->selection.end.par();
sstate.selendpar = t->selection.end.par();
sstate.selendpos = t->selection.end.pos();
sstate.selendboundary = t->selection.end.boundary();
sstate.selection = t->selection.set();
sstate.mark_set = t->selection.mark();
} else {
sstate.lpar = 0;
sstate.lpar = paragraphs.end();
}
}
void InsetText::restoreLyXTextState(LyXText * t) const
{
if (!sstate.lpar)
if (sstate.lpar == paragraphs.end())
return;
t->selection.set(true);
@ -193,10 +193,10 @@ void InsetText::init(InsetText const * ins)
drawTextXOffset = 0;
drawTextYOffset = 0;
locked = false;
old_par = 0;
old_par = paragraphs.end();
last_drawn_width = -1;
cached_bview = 0;
sstate.lpar = 0;
sstate.lpar = paragraphs.end();
in_insetAllowed = false;
}
@ -671,8 +671,8 @@ void InsetText::lockInset(BufferView * bv)
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
inset_boundary = false;
inset_par = 0;
old_par = 0;
inset_par = paragraphs.end();
old_par = paragraphs.end();
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
@ -774,7 +774,7 @@ bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
the_locking_inset = 0;
if (lr)
moveRightIntern(bv, true, false);
old_par = 0; // force layout setting
old_par = paragraphs.end(); // force layout setting
if (scroll())
scroll(bv, 0.0F);
else
@ -1029,8 +1029,8 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
inset_boundary = false;
inset_par = 0;
old_par = 0;
inset_par = paragraphs.end();
old_par = paragraphs.end();
bool clear = false;
if (!lt) {
@ -2204,7 +2204,7 @@ LyXText * InsetText::getLyXText(BufferView const * lbv,
if (locked) {
saveLyXTextState(it->second.text.get());
} else {
sstate.lpar = 0;
sstate.lpar = paragraphs.end();
}
}
//

View File

@ -386,9 +386,9 @@ private:
mutable boost::shared_ptr<LyXText> cached_text;
///
struct save_state {
Paragraph * lpar;
Paragraph * selstartpar;
Paragraph * selendpar;
ParagraphList::iterator lpar;
ParagraphList::iterator selstartpar;
ParagraphList::iterator selendpar;
lyx::pos_type pos;
lyx::pos_type selstartpos;
lyx::pos_type selendpos;

View File

@ -12,7 +12,7 @@
LyXCursor::LyXCursor()
: par_(0), pos_(0), boundary_(false),
: par_(), pos_(0), boundary_(false),
x_(0), ix_(0), x_fix_(0), y_(0), iy_(0), row_(0)
{}

View File

@ -147,8 +147,8 @@ int LyXText::workWidth() const
int LyXText::workWidth(Inset const * inset) const
{
Paragraph * par = inset->parOwner();
lyx::Assert(par);
ParagraphList::iterator par = ownerParagraphs().find(*inset->parOwner());
//lyx::Assert(par);
pos_type pos = par->getPositionOfInset(inset);
lyx::Assert(pos != -1);

View File

@ -885,8 +885,14 @@ void LyXText::cursorBottom()
{
#warning FIXME
// This is how it should be:
// ParagraphList::iterator lastpit = boost::prior(ownerParagraphs().end());
ParagraphList::iterator lastpit = &ownerParagraphs().back();
#ifndef NO_STD_LIST
ParagraphList::iterator lastpit = boost::prior(ownerParagraphs().end());
#else
ParagraphList::iterator lastpit = ownerParagraphs().begin();
ParagraphList::iterator end = ownerParagraphs().end();
while (boost::next(lastpit) != end)
++lastpit;
#endif
int pos = lastpit->size();
setCursor(lastpit, pos);
}
@ -1191,7 +1197,7 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
isOK = true;
break;
} else {
tmppit = in->parOwner();
tmppit = ownerParagraphs().find(*in->parOwner());
}
}

View File

@ -95,20 +95,20 @@ namespace {
LyXCursor const & cur, int & x, int & y)
{
lyx::pos_type const pos = cur.pos();
Paragraph /*const*/ & par = *cur.par();
ParagraphList::iterator par = cur.par();
if (pos >= par.size() || !par.isInset(pos))
if (pos >= par->size() || !par->isInset(pos))
return 0;
Inset /*const*/ * inset = par.getInset(pos);
Inset /*const*/ * inset = par->getInset(pos);
if (!isEditableInset(inset))
return 0;
// get inset dimensions
lyx::Assert(par.getInset(pos));
lyx::Assert(par->getInset(pos));
LyXFont const & font = text.getFont(bv->buffer(), &par, pos);
LyXFont const & font = text.getFont(bv->buffer(), par, pos);
int const width = inset->width(bv, font);
int const inset_x = font.isVisibleRightToLeft()
@ -128,7 +128,7 @@ namespace {
return 0;
}
text.setCursor(&par, pos, true);
text.setCursor(par, pos, true);
x -= b.x1;
// The origin of an inset is on the baseline