]> git.lyx.org Git - features.git/commitdiff
Fix alignment rendering of multirow in LyX (#8976)
authorScott Kostyshak <skostysh@princeton.edu>
Fri, 14 Feb 2014 02:17:20 +0000 (21:17 -0500)
committerScott Kostyshak <skostysh@lyx.org>
Sat, 27 Sep 2014 02:38:13 +0000 (22:38 -0400)
Multirow cells now have the same alignment rendering in LyX
as in the output. The alignment of a multirow can change as
long as the column is not of fixed width. If the column is
of fixed width, the multirow is left-aligned.

When setting a multirow, the alignment is copied from
the last cell in the selection.

src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
status.21x

index 39fa2f9fc018e86fcc93b9ca52be0a7f065da9bb..3f1235809253dddbe75219963b254e641a4aed77 100644 (file)
@@ -1154,7 +1154,7 @@ void Tabular::setColumnPWidth(Cursor & cur, idx_type cell,
        col_type const c = cellColumn(cell);
 
        column_info[c].p_width = width;
-       // reset the vertical alignment to top if the fixed with
+       // reset the vertical alignment to top if the fixed width
        // is removed or zero because only fixed width columns can
        // have a vertical alignment
        if (column_info[c].p_width.zero())
@@ -1164,6 +1164,8 @@ void Tabular::setColumnPWidth(Cursor & cur, idx_type cell,
                // because of multicolumns
                toggleFixedWidth(cur, cellInset(cell).get(),
                                 !getPWidth(cell).zero());
+               if (isMultiRow(cell))
+                       setAlignment(cell, LYX_ALIGN_LEFT, false);
        }
        // cur paragraph can become invalid after paragraphs were merged
        if (cur.pit() > cur.lastpit())
@@ -1718,7 +1720,8 @@ bool Tabular::hasMultiRow(row_type r) const
 }
 
 Tabular::idx_type Tabular::setMultiRow(idx_type cell, idx_type number,
-                                      bool const bottom_border)
+                                      bool const bottom_border,
+                                      LyXAlignment const halign)
 {
        idx_type const col = cellColumn(cell);
        idx_type const row = cellRow(cell);
@@ -1734,10 +1737,10 @@ Tabular::idx_type Tabular::setMultiRow(idx_type cell, idx_type number,
        // be changed for the whole table row,
        // support changing this only for the multirow cell can be done via
        // \multirowsetup
-       // this feature would be a fileformat change
-       // until LyX supports this, use the deault alignment of multirow
-       // cells: left
-       cs.alignment = LYX_ALIGN_LEFT;
+       if (getPWidth(cell).zero())
+               cs.alignment = halign;
+       else
+               cs.alignment = LYX_ALIGN_LEFT;
 
        // set the bottom line of the last selected cell
        setBottomLine(cell, bottom_border);
@@ -5707,7 +5710,8 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                        // check whether we are completely in a multirow
                        if (!tabular.isMultiRow(cur.idx()))
                                tabular.setMultiRow(cur.idx(), 1,
-                                                   tabular.bottomLine(cur.idx()));
+                                                   tabular.bottomLine(cur.idx()),
+                                                   tabular.getAlignment(cur.idx()));
                        break;
                }
                // we have a selection so this means we just add all this
@@ -5716,7 +5720,8 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                row_type const row_start = tabular.cellRow(s_start);
                row_type const row_end = tabular.cellRow(cur.selEnd().idx());
                cur.idx() = tabular.setMultiRow(s_start, row_end - row_start + 1,
-                                               tabular.bottomLine(cur.selEnd().idx()));
+                                               tabular.bottomLine(cur.selEnd().idx()),
+                                               tabular.getAlignment(cur.selEnd().idx()));
                cur.pit() = 0;
                cur.pos() = 0;
                cur.setSelection(false);
index 565d5f6719ef4b669e584c6a41d9acbd26860ca5..8ef3709ff898537a1a5aba2b0f8e40d5bc1805fc 100644 (file)
@@ -525,7 +525,8 @@ public:
        bool hasMultiRow(row_type r) const;
        ///
        idx_type setMultiRow(idx_type cell, idx_type number,
-                            bool const bottom_border);
+                            bool const bottom_border,
+                            LyXAlignment const halign);
        ///
        void unsetMultiRow(idx_type cell);
        ///
index 10841f2fadd59ac021034b47f40e7ba623093d3a..de54c0326551d04eecdbb1e1b1ebbe90f9a374ff 100644 (file)
@@ -60,6 +60,7 @@ What's new
 
 * USER INTERFACE
 
+- Fix alignment rendering of multirow in LyX (#8976)
 
 
 * INTERNALS