change tracking:

* src/insets/insetbase.h: replace markErased(...) by
        setChange(...)
        * src/insets/insettext.h: replace markErased(...) and
        markNew(...) by setChange(...)
        * src/insets/insettabular.h: replace markErased(...) by
        setChange(...)
        * src/insets/insettabular.C:
        * src/insets/insetbase.C:
        * src/insets/insettext.C:
        * src/paragraph_pimpl.C:
        * src/tabular.C: adjust properly


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15392 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Michael Schmitt 2006-10-20 09:29:19 +00:00
parent 2a887391ff
commit c3a9c54632
8 changed files with 33 additions and 53 deletions

View File

@ -268,10 +268,6 @@ std::string const & InsetBase::getInsetName() const
}
void InsetBase::markErased(bool)
{}
void InsetBase::cursorPos(BufferView const & /*bv*/, CursorSlice const &,
bool, int & x, int & y) const
{

View File

@ -17,6 +17,8 @@
#include <memory>
#include <vector>
#include "changes.h"
class Buffer;
class BufferView;
class CursorSlice;
@ -393,8 +395,8 @@ public:
*/
virtual bool noFontChange() const { return false; }
/// mark the inset as erased or not
virtual void markErased(bool erased);
/// set the change for the entire inset
virtual void setChange(Change const & change) {}
/// pretty arbitrary
virtual int width() const { return 10; }

View File

@ -1829,7 +1829,9 @@ bool InsetTabular::pasteSelection(LCursor & cur)
shared_ptr<InsetText> inset(
new InsetText(*paste_tabular->getCellInset(r1, c1)));
tabular.setCellInset(r2, c2, inset);
inset->markNew();
// FIXME: change tracking (MG)
inset->setChange(Change(cur.buffer().params().trackChanges ?
Change::INSERTED : Change::UNCHANGED));
cur.pos() = 0;
}
}
@ -1851,7 +1853,7 @@ void InsetTabular::cutSelection(LCursor & cur)
= cell(tabular.getCellNumber(i, j));
if (cur.buffer().params().trackChanges)
// FIXME: Change tracking (MG)
t->markErased(true);
t->setChange(Change(Change::DELETED));
else
t->clear();
}
@ -1903,10 +1905,10 @@ LyXText * InsetTabular::getText(int idx) const
}
void InsetTabular::markErased(bool erased)
void InsetTabular::setChange(Change const & change)
{
for (idx_type idx = 0; idx < nargs(); ++idx)
cell(idx)->markErased(erased);
cell(idx)->setChange(change);
}

View File

@ -117,8 +117,8 @@ public:
///
LyXText * getText(int) const;
///
void markErased(bool);
/// set the change for the entire inset
void setChange(Change const & change);
// this should return true if we have a "normal" cell, otherwise false.
// "normal" means without width set!

View File

@ -115,15 +115,6 @@ void InsetText::init()
}
void InsetText::markErased(bool erased)
{
// FIXME: change tracking (MG)
ParagraphList & pars = paragraphs();
for_each(pars.begin(), pars.end(),
bind(&Paragraph::setChange, _1, Change(erased ? Change::DELETED : Change::UNCHANGED)));
}
void InsetText::clear()
{
ParagraphList & pars = paragraphs();
@ -272,6 +263,16 @@ bool InsetText::getStatus(LCursor & cur, FuncRequest const & cmd,
}
void InsetText::setChange(Change const & change)
{
ParagraphList::iterator pit = paragraphs().begin();
ParagraphList::iterator end = paragraphs().end();
for (; pit != end; ++pit) {
pit->setChange(change);
}
}
int InsetText::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
@ -328,20 +329,6 @@ bool InsetText::showInsetDialog(BufferView *) const
}
void InsetText::markNew(bool /*track_changes*/)
{
ParagraphList::iterator pit = paragraphs().begin();
ParagraphList::iterator end = paragraphs().end();
for (; pit != end; ++pit) {
// FIXME: change tracking (MG)
// if (track_changes)
// set pit's text to UNCHANGED
// else
// set pit's text to INSERTED in CT mode; reset CT info otherwise
}
}
void InsetText::setText(docstring const & data, LyXFont const & font)
{
clear();

View File

@ -102,17 +102,8 @@ public:
///
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
/// mark as erased for change tracking
void markErased(bool erased);
/**
* Mark as new. Used when pasting in tabular, and adding rows
* or columns. Note that pasting will ensure that tracking already
* happens, and this just resets the changes for the copied text,
* whereas for row/col add, we need to start tracking changes
* for the (empty) paragraph contained.
*/
void markNew(bool track_changes = false);
/// set the change for the entire inset
void setChange(Change const & change);
/// append text onto the existing text
void appendParagraphs(Buffer * bp, ParagraphList &);

View File

@ -203,7 +203,8 @@ void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end)
changes_->set(Change::UNCHANGED, i);
// No real char at position size():
if (i < size() && owner_->isInset(i))
owner_->getInset(i)->markErased(false);
// FIXME: change tracking (MG)
owner_->getInset(i)->setChange(Change(Change::UNCHANGED));
break;
}
}
@ -325,7 +326,8 @@ bool Paragraph::Pimpl::erase(pos_type pos, bool trackChanges)
if (changetype != Change::INSERTED) {
changes_->record(Change(Change::DELETED), pos);
if (pos < size() && owner_->isInset(pos))
owner_->getInset(pos)->markErased(true);
// FIXME: change tracking (MG)
owner_->getInset(pos)->setChange(Change(Change::DELETED));
return false;
}
}

View File

@ -500,7 +500,7 @@ void LyXTabular::appendRow(BufferParams const & bp, idx_type const cell)
if (bp.trackChanges)
// FIXME: Change Tracking (MG)
for (col_type j = 0; j < columns_; ++j)
cell_info[row + 1][j].inset->markNew(true);
cell_info[row + 1][j].inset->setChange(Change(Change::INSERTED));
set_row_column_number_info();
}
@ -529,7 +529,7 @@ void LyXTabular::copyRow(BufferParams const & bp, row_type const row)
if (bp.trackChanges)
// FIXME: Change Tracking (MG)
for (col_type j = 0; j < columns_; ++j)
cell_info[row + 1][j].inset->markNew(true);
cell_info[row + 1][j].inset->setChange(Change(Change::INSERTED));
set_row_column_number_info();
}
@ -559,9 +559,9 @@ void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell)
//++column;
for (row_type i = 0; i < rows_; ++i) {
cell_info[i][column + 1].inset->clear();
if (bp.trackChanges)
// FIXME: Change Tracking (MG)
cell_info[i][column + 1].inset->markNew(true);
if (bp.trackChanges)
cell_info[i][column + 1].inset->setChange(Change(Change::INSERTED));
}
fixCellNums();
}
@ -593,7 +593,7 @@ void LyXTabular::copyColumn(BufferParams const & bp, col_type const column)
if (bp.trackChanges)
// FIXME: Change Tracking (MG)
for (row_type i = 0; i < rows_; ++i)
cell_info[i][column + 1].inset->markNew(true);
cell_info[i][column + 1].inset->setChange(Change(Change::INSERTED));
fixCellNums();
}