From c130d5dbfd3f4d4a2721c9be786b7fa45b806aca Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 30 Nov 2001 16:10:24 +0000 Subject: [PATCH] Hopefully fixed the redo problems with insets! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3127 a592a061-630c-0410-9148-cb99ea01b6c8 --- Makefile.am | 2 +- src/ChangeLog | 5 +++++ src/insets/ChangeLog | 8 ++++++++ src/insets/insettabular.C | 2 +- src/insets/insettext.C | 9 ++++----- src/insets/insettext.h | 2 +- src/tabular.C | 18 +++++++++++++++--- src/tabular.h | 4 ++-- src/undo_funcs.C | 7 +------ 9 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Makefile.am b/Makefile.am index 74c3db4fde..5f849c4c3f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,7 @@ EXTRA_DIST = ANNOUNCE INSTALL.OS2 INSTALL.autoconf README.OS2 \ UPGRADING lyx.man acconfig.h autogen.sh \ config development forms images sourcedoc -ETAGS_ARGS = --lang=c++ +#ETAGS_ARGS = --language-force=c++ man_MANS = lyx.1 ## Needed by bindist diff --git a/src/ChangeLog b/src/ChangeLog index 902bf4919b..d07fb1c5ae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-11-30 Juergen Vigna + + * tabular.C (LyXTabular): add a same_id to set the same id's in the + insets for undo reasons. + 2001-11-28 André Pönitz * vspace.[Ch]: cosmetical changes diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index a1f43772a2..89aa982082 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ +2001-11-30 Juergen Vigna + + * insettabular.C (InsetTabular): use the save_id flag to create also + the tabular with the same id's. + + * insettext.C (setParagraphData): added a same_id function for undo + to set the same paragraph id's as of the paragraph we are setting. + 2001-11-30 José Matos * inseturl.[Ch]: diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 1b4f42bd10..703c29742d 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -148,7 +148,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf, bool same_id) : UpdatableInset(tab, same_id), buffer(&buf) { - tabular.reset(new LyXTabular(this, *(tab.tabular))); + tabular.reset(new LyXTabular(this, *(tab.tabular), same_id)); the_locking_inset = 0; locked = no_selection = false; oldcell = -1; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index d313c0daa2..c05b94713f 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -161,7 +161,7 @@ InsetText & InsetText::operator=(InsetText const & it) void InsetText::init(InsetText const * ins, bool same_id) { if (ins) { - setParagraphData(ins->par); + setParagraphData(ins->par, same_id); autoBreakRows = ins->autoBreakRows; drawFrame_ = ins->drawFrame_; frame_color = ins->frame_color; @@ -1923,7 +1923,7 @@ int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const } -void InsetText::setParagraphData(Paragraph * p) +void InsetText::setParagraphData(Paragraph * p, bool same_id) { // we have to unlock any locked inset otherwise we're in troubles the_locking_inset = 0; @@ -1933,12 +1933,12 @@ void InsetText::setParagraphData(Paragraph * p) par = tmp; } - par = new Paragraph(*p, false); + par = new Paragraph(*p, same_id); par->setInsetOwner(this); Paragraph * np = par; while (p->next()) { p = p->next(); - np->next(new Paragraph(*p, false)); + np->next(new Paragraph(*p, same_id)); np->next()->previous(np); np = np->next(); np->setInsetOwner(this); @@ -2288,7 +2288,6 @@ Paragraph * InsetText::getParFromID(int id) const Paragraph * tmp = par; while (tmp) { int tmp_id = tmp->id(); - lyxerr << "Looking at paragraph: " << tmp_id << endl; if (tmp->id() == id) { return tmp; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index e96360f2a9..0938e43e87 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -176,7 +176,7 @@ public: /// void writeParagraphData(Buffer const *, std::ostream &) const; /// - void setParagraphData(Paragraph *); + void setParagraphData(Paragraph *, bool same_id = false); /// void setText(string const &); /// diff --git a/src/tabular.C b/src/tabular.C index 1445ad1818..5213651290 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -110,11 +110,23 @@ LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg) } -LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt) +LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt, + bool same_id) { owner_ = inset; cur_cell = -1; Init(lt.rows_, lt.columns_, <); + // we really should change again to have InsetText as a pointer + // and allocate it then we would not have to do this stuff all + // double! + if (same_id) { + for (int i = 0; i < rows_; ++i) { + for (int j = 0; j < columns_; ++j) { + cell_info[i][j].inset.id(lt.cell_info[i][j].inset.id()); + cell_info[i][j].inset.setParagraphData(lt.cell_info[i][j].inset.paragraph(),true); + } + } + } #if 0 #ifdef WITH_WARNINGS #warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb) @@ -164,9 +176,9 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt) } -LyXTabular * LyXTabular::clone(InsetTabular * inset) +LyXTabular * LyXTabular::clone(InsetTabular * inset, bool same_id) { - LyXTabular * result = new LyXTabular(inset, *this); + LyXTabular * result = new LyXTabular(inset, *this, same_id); #if 0 // don't know if this is good but I need to Clone also // the text-insets here, this is for the Undo-facility! diff --git a/src/tabular.h b/src/tabular.h index e660ba2f57..d48e8eaa84 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -174,14 +174,14 @@ public: /// LyXTabular(InsetTabular *, int columns_arg, int rows_arg); /// - LyXTabular(InsetTabular *, LyXTabular const &); + LyXTabular(InsetTabular *, LyXTabular const &, bool same_id = false); /// explicit LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex); /// LyXTabular & operator=(LyXTabular const &); /// - LyXTabular * clone(InsetTabular *); + LyXTabular * clone(InsetTabular *, bool same_id = false); /// Returns true if there is a topline, returns false if not bool TopLine(int cell, bool onlycolumn = false) const; diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 56b53ec745..e010d5773d 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -226,6 +226,7 @@ void setRedo(BufferView * bv, Undo::undo_kind kind, bv->buffer()->redostack.push(createUndo(bv, kind, first, behind)); } +using lyx::pos_type; Undo * createUndo(BufferView * bv, Undo::undo_kind kind, Paragraph const * first, Paragraph const * behind) @@ -266,12 +267,6 @@ Undo * createUndo(BufferView * bv, Undo::undo_kind kind, Paragraph * start = const_cast(first); Paragraph * end = 0; -#if 0 - if (first) - start = const_cast(before->next()); - else - start = firstUndoParagraph(bv); -#endif if (behind) end = const_cast(behind->previous()); else { -- 2.39.2