mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
change tracking:
* src/paragraph.h: rename acceptChange() to acceptChanges() * src/insets/insetbase.h: * src/insets/insettext.h: * src/insets/insettabular.h: add acceptChanges() * src/*.C: fix acceptChanges() (& also accept changes in nested insets) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15520 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
048122515d
commit
00ffa3ca7c
@ -400,6 +400,8 @@ public:
|
||||
|
||||
/// set the change for the entire inset
|
||||
virtual void setChange(Change const &) {}
|
||||
/// accept the changes within the inset
|
||||
virtual void acceptChanges() {};
|
||||
|
||||
/// pretty arbitrary
|
||||
virtual int width() const { return 10; }
|
||||
|
@ -1914,6 +1914,13 @@ void InsetTabular::setChange(Change const & change)
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::acceptChanges()
|
||||
{
|
||||
for (idx_type idx = 0; idx < nargs(); ++idx)
|
||||
cell(idx)->acceptChanges();
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::forceDefaultParagraphs(idx_type cell) const
|
||||
{
|
||||
return tabular.getPWidth(cell).zero();
|
||||
|
@ -117,6 +117,8 @@ public:
|
||||
|
||||
/// set the change for the entire inset
|
||||
void setChange(Change const & change);
|
||||
/// accept the changes within the inset
|
||||
void acceptChanges();
|
||||
|
||||
// this should return true if we have a "normal" cell, otherwise false.
|
||||
// "normal" means without width set!
|
||||
|
@ -272,6 +272,18 @@ void InsetText::setChange(Change const & change)
|
||||
}
|
||||
|
||||
|
||||
void InsetText::acceptChanges()
|
||||
{
|
||||
ParagraphList::iterator pit = paragraphs().begin();
|
||||
ParagraphList::iterator end = paragraphs().end();
|
||||
for (; pit != end; ++pit) {
|
||||
// FIXME: change tracking (MG)
|
||||
// we must handle end-of-par chars!
|
||||
pit->acceptChanges(0, pit->size() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InsetText::latex(Buffer const & buf, odocstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
|
@ -104,6 +104,8 @@ public:
|
||||
|
||||
/// set the change for the entire inset
|
||||
void setChange(Change const & change);
|
||||
/// accept the changes within the inset
|
||||
void acceptChanges();
|
||||
|
||||
/// append text onto the existing text
|
||||
void appendParagraphs(Buffer * bp, ParagraphList &);
|
||||
|
@ -1441,9 +1441,9 @@ void Paragraph::setChange(pos_type pos, Change const & change)
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::acceptChange(pos_type start, pos_type end)
|
||||
void Paragraph::acceptChanges(pos_type start, pos_type end)
|
||||
{
|
||||
return pimpl_->acceptChange(start, end);
|
||||
return pimpl_->acceptChanges(start, end);
|
||||
}
|
||||
|
||||
|
||||
|
@ -217,8 +217,8 @@ public:
|
||||
/// set change at given pos
|
||||
void setChange(pos_type pos, Change const & change);
|
||||
|
||||
/// accept change
|
||||
void acceptChange(pos_type start, pos_type end);
|
||||
/// accept changes within the given range
|
||||
void acceptChanges(pos_type start, pos_type end);
|
||||
|
||||
/// reject change
|
||||
void rejectChange(pos_type start, pos_type end);
|
||||
|
@ -127,41 +127,33 @@ Change const Paragraph::Pimpl::lookupChange(pos_type pos) const
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end)
|
||||
void Paragraph::Pimpl::acceptChanges(pos_type start, pos_type end)
|
||||
{
|
||||
// FIXME: change tracking (MG)
|
||||
return;
|
||||
|
||||
// care for empty pars
|
||||
|
||||
lyxerr[Debug::CHANGES] << "acceptchange" << endl;
|
||||
pos_type i = start;
|
||||
|
||||
for (; i < end; ++i) {
|
||||
switch (lookupChange(i).type) {
|
||||
for (pos_type pos = start; pos < end; ++pos) {
|
||||
switch (lookupChange(pos).type) {
|
||||
case Change::UNCHANGED:
|
||||
break;
|
||||
|
||||
case Change::INSERTED:
|
||||
// FIXME: change tracking (MG)
|
||||
changes_.set(Change(Change::UNCHANGED), i);
|
||||
changes_.set(Change(Change::UNCHANGED), pos);
|
||||
break;
|
||||
|
||||
case Change::DELETED:
|
||||
// Suppress access to nonexistent
|
||||
// "end-of-paragraph char":
|
||||
if (i < size()) {
|
||||
eraseChar(i, false);
|
||||
if (pos < size()) {
|
||||
eraseChar(pos, false);
|
||||
--end;
|
||||
--i;
|
||||
--pos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lyxerr[Debug::CHANGES] << "endacceptchange" << endl;
|
||||
// FIXME: change tracking (MG)
|
||||
// changes_.reset(Change::UNCHANGED);
|
||||
// also accept changes in nested insets
|
||||
if (pos < size() && owner_->isInset(pos)) {
|
||||
owner_->getInset(pos)->acceptChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,8 +49,8 @@ public:
|
||||
void setChange(Change const & change);
|
||||
/// set change at given pos
|
||||
void setChange(pos_type pos, Change const & change);
|
||||
/// accept change
|
||||
void acceptChange(pos_type start, pos_type end);
|
||||
/// accept changes within the given range
|
||||
void acceptChanges(pos_type start, pos_type end);
|
||||
/// reject change
|
||||
void rejectChange(pos_type start, pos_type end);
|
||||
|
||||
|
@ -1464,7 +1464,7 @@ void LyXText::acceptChange(LCursor & cur)
|
||||
pos_type left = ( pit == it.pit() ? it.pos() : 0 );
|
||||
pos_type right =
|
||||
( pit == et.pit() ? et.pos() : pars_[pit].size() + 1 );
|
||||
pars_[pit].acceptChange(left, right);
|
||||
pars_[pit].acceptChanges(left, right);
|
||||
}
|
||||
if (isDeleted) {
|
||||
ParagraphList & plist = paragraphs();
|
||||
|
Loading…
Reference in New Issue
Block a user