]> git.lyx.org Git - features.git/commitdiff
Collapse the contents of multicolumn cells into one (fix #121).
authorJürgen Vigna <jug@sad.it>
Thu, 21 Mar 2002 15:58:54 +0000 (15:58 +0000)
committerJürgen Vigna <jug@sad.it>
Thu, 21 Mar 2002 15:58:54 +0000 (15:58 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3796 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettext.h
src/tabular.C
src/tabular.h

index eccb38fc79c37316f44a5e2378ce2d74ffff2a12..de39f86dd7bdf87192e8788104d12ce0f9d47922 100644 (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
index b306d002f9277bc0eede40cc9b5cc14a550af780..7adc6d06652152c371fffaaae242ba35e8b52837 100644 (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
index 3c10ce891bb9a3f4006991bc112d28319f9f02e3..5ed539c7899539b0d97a90b2ed91867c6d8c0813 100644 (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);
index 51430207881eebae391c3f7174b7b8fcdc3fb671..6b28eab05d150d23daad139eb1efb42a79d17274 100644 (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();
+}
index 91fe8da05baba4fe2d5e2dd1b6ea2cafcb2b2887..38c15266d8ce5b4f9c091842955e464ed43eaa10 100644 (file)
@@ -249,6 +249,8 @@ public:
        ///
        void getDrawFont(LyXFont &) const;
        ///
+       void appendParagraphs(BufferParams const & bparams, Paragraph *);
+       ///
        //
        // Public structures and variables
        ///
index e5f64586a42a204cfc1676edefc8d9714ac650b3..d80ed83234b4f9fd357d6805fe07ead3a95ddc05 100644 (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();
 }
 
index 7a03f8fd95262e1a059f00f83bc6d9a7dac6d0e8..50c2e51fa397efc7da1a83f6d6d61d42b92f5d08 100644 (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
        ///