Collapse the contents of multicolumn cells into one (fix #121).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3796 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2002-03-21 15:58:54 +00:00
parent 74e3712580
commit b15efeb111
7 changed files with 60 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2002-03-21 Juergen Vigna <jug@sad.it>
* tabular.C (SetMultiColumn): collapse also the contents of the
cells and set the last border right. Added a Buffer const * param.
2002-03-20 Lars Gullik Bjønnes <larsbj@birdstep.com>
* Makefile.am (LYX_CONV_LIBS): select libs depending on partial

View File

@ -1,3 +1,8 @@
2002-03-21 Juergen Vigna <jug@sad.it>
* insettext.C (appendParagraphs): new function added to append
the paragraphs to this insets paragraphs.
2002-03-20 Lars Gullik Bjønnes <larsbj@birdstep.com>
* Makefile.am: special rules if partial linking

View File

@ -2036,7 +2036,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
tabular->UnsetMultiColumn(actcell);
updateLocal(bv, INIT, true);
} else {
tabular->SetMultiColumn(actcell, 1);
tabular->SetMultiColumn(bv->buffer(), actcell, 1);
updateLocal(bv, CELL, true);
}
return;
@ -2053,7 +2053,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
s_start = sel_cell_start;
s_end = sel_cell_end;
}
tabular->SetMultiColumn(s_start, s_end - s_start + 1);
tabular->SetMultiColumn(bv->buffer(), s_start, s_end - s_start + 1);
actcell = s_start;
clearSelection();
updateLocal(bv, INIT, true);

View File

@ -2656,3 +2656,37 @@ void InsetText::getDrawFont(LyXFont & font) const
return;
owner()->getDrawFont(font);
}
void InsetText::appendParagraphs(BufferParams const & bparams,
Paragraph * newpar)
{
Paragraph * buf;
Paragraph * tmpbuf = newpar;
Paragraph * lastbuffer = buf = new Paragraph(*tmpbuf, false);
while (tmpbuf->next()) {
tmpbuf = tmpbuf->next();
lastbuffer->next(new Paragraph(*tmpbuf, false));
lastbuffer->next()->previous(lastbuffer);
lastbuffer = lastbuffer->next();
}
lastbuffer = par;
while (lastbuffer->next())
lastbuffer = lastbuffer->next();
if (newpar->size() && lastbuffer->size() &&
!lastbuffer->isSeparator(lastbuffer->size()-1))
{
lastbuffer->insertChar(lastbuffer->size(), ' ');
}
// make the buf exactly the same layout than our last paragraph
buf->makeSameLayout(lastbuffer);
// paste it!
lastbuffer->next(buf);
buf->previous(lastbuffer);
lastbuffer->pasteParagraph(bparams);
reinitLyXText();
}

View File

@ -249,6 +249,8 @@ public:
///
void getDrawFont(LyXFont &) const;
///
void appendParagraphs(BufferParams const & bparams, Paragraph *);
///
//
// Public structures and variables
///

View File

@ -1543,15 +1543,25 @@ LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
}
void LyXTabular::SetMultiColumn(int cell, int number)
void LyXTabular::SetMultiColumn(Buffer const * buffer, int cell, int number)
{
cellinfo_of_cell(cell)->multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
cellinfo_of_cell(cell)->right_line = column_info[column_of_cell(cell+number-1)].right_line;
#if 1
for (int i = 1; i < number; ++i) {
cellinfo_of_cell(cell+i)->multicolumn = CELL_PART_OF_MULTICOLUMN;
cellinfo_of_cell(cell)->inset.appendParagraphs(buffer->params,
cellinfo_of_cell(cell+i)->inset.paragraph());
cellinfo_of_cell(cell+i)->inset.clear();
}
#else
for (number--; number > 0; --number) {
cellinfo_of_cell(cell+number)->multicolumn = CELL_PART_OF_MULTICOLUMN;
}
#endif
set_row_column_number_info();
}

View File

@ -304,7 +304,7 @@ public:
///
bool IsMultiColumn(int cell, bool real = false) const;
///
void SetMultiColumn(int cell, int number);
void SetMultiColumn(Buffer const *, int cell, int number);
///
int UnsetMultiColumn(int cell); // returns number of new cells
///