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 &, void InsetBase::cursorPos(BufferView const & /*bv*/, CursorSlice const &,
bool, int & x, int & y) const bool, int & x, int & y) const
{ {

View File

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

View File

@ -1829,7 +1829,9 @@ bool InsetTabular::pasteSelection(LCursor & cur)
shared_ptr<InsetText> inset( shared_ptr<InsetText> inset(
new InsetText(*paste_tabular->getCellInset(r1, c1))); new InsetText(*paste_tabular->getCellInset(r1, c1)));
tabular.setCellInset(r2, c2, inset); 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; cur.pos() = 0;
} }
} }
@ -1851,7 +1853,7 @@ void InsetTabular::cutSelection(LCursor & cur)
= cell(tabular.getCellNumber(i, j)); = cell(tabular.getCellNumber(i, j));
if (cur.buffer().params().trackChanges) if (cur.buffer().params().trackChanges)
// FIXME: Change tracking (MG) // FIXME: Change tracking (MG)
t->markErased(true); t->setChange(Change(Change::DELETED));
else else
t->clear(); 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) 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; LyXText * getText(int) const;
/// /// set the change for the entire inset
void markErased(bool); void setChange(Change const & change);
// this should return true if we have a "normal" cell, otherwise false. // this should return true if we have a "normal" cell, otherwise false.
// "normal" means without width set! // "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() void InsetText::clear()
{ {
ParagraphList & pars = paragraphs(); 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, int InsetText::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const 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) void InsetText::setText(docstring const & data, LyXFont const & font)
{ {
clear(); clear();

View File

@ -102,17 +102,8 @@ public:
/// ///
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const; bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
/// mark as erased for change tracking /// set the change for the entire inset
void markErased(bool erased); void setChange(Change const & change);
/**
* 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);
/// append text onto the existing text /// append text onto the existing text
void appendParagraphs(Buffer * bp, ParagraphList &); 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); changes_->set(Change::UNCHANGED, i);
// No real char at position size(): // No real char at position size():
if (i < size() && owner_->isInset(i)) if (i < size() && owner_->isInset(i))
owner_->getInset(i)->markErased(false); // FIXME: change tracking (MG)
owner_->getInset(i)->setChange(Change(Change::UNCHANGED));
break; break;
} }
} }
@ -325,7 +326,8 @@ bool Paragraph::Pimpl::erase(pos_type pos, bool trackChanges)
if (changetype != Change::INSERTED) { if (changetype != Change::INSERTED) {
changes_->record(Change(Change::DELETED), pos); changes_->record(Change(Change::DELETED), pos);
if (pos < size() && owner_->isInset(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; return false;
} }
} }

View File

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