support for multirows in tables:

- fileformat change (lyx2lyx code follows the next days)
- the patch is a joint work of Edwin and me

The patch is huge but the major parts work already. I put it in now as the minor known issues can be solved step by step the next days. I think this is the best solution because collaborating with such large patches already lead to copy/paste bugs.

The known issues are listed here:
http://wiki.lyx.org/Devel/Multirow

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33414 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2010-02-11 01:07:54 +00:00
parent 4c9f0eb5e6
commit 8bb69f24b6
15 changed files with 535 additions and 272 deletions

View File

@ -1,6 +1,10 @@
LyX file-format changes
-----------------------
2010-02-11 Uwe Stöhr <uwestoehr@web.de> and Edwin Leuven <e.leuven@uva.nl>
* Format incremented to 377: support for multirow cells in
tables
2010-01-10 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 376: new buffer param
\maintain_unincluded_children. If true, the aux files of

View File

@ -1517,6 +1517,7 @@ lib_images_files = Split('''
tabular-feature_delete-column.png
tabular-feature_delete-row.png
tabular-feature_multicolumn.png
tabular-feature_multirow.png
tabular-feature_set-all-lines.png
tabular-feature_set-border-lines.png
tabular-feature_set-longtabular.png

View File

@ -415,6 +415,7 @@ dist_images_DATA = \
images/tabular-feature_delete-column.png \
images/tabular-feature_delete-row.png \
images/tabular-feature_multicolumn.png \
images/tabular-feature_multirow.png \
images/tabular-feature_set-all-lines.png \
images/tabular-feature_set-longtabular.png \
images/tabular-feature_set-rotate-cell.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

View File

@ -1197,10 +1197,12 @@ convert = [[346, []],
[373, [merge_gbrief]],
[374, []],
[375, []],
[376, []]
[376, []],
[377, []]
]
revert = [[375, [revert_includeall]],
revert = [[376, []],
[375, [revert_includeall]],
[374, [revert_includeonly]],
[373, [revert_html_options]],
[372, [revert_gbrief]],

View File

@ -161,6 +161,7 @@ ToolbarSet
Item "Rotate cell" "tabular-feature toggle-rotate-cell"
Item "Rotate table" "tabular-feature toggle-rotate-tabular"
Item "Set multi-column" "tabular-feature multicolumn"
Item "Set multi-row" "tabular-feature multirow"
End
Toolbar "math" "Math"

View File

@ -126,7 +126,7 @@ namespace {
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
int const LYX_FORMAT = 376; // jspitzm: support for unincluded file maintenance
int const LYX_FORMAT = 377; // uwestoehr: support for multirows
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;

View File

@ -546,7 +546,8 @@ char const * simplefeatures[] = {
"bm",
"pdfpages",
"amscd",
"slashed"
"slashed",
"multirow"
};
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);

View File

@ -2069,9 +2069,10 @@ void LyXAction::init()
set-rotate-cell|unset-rotate-cell|toggle-rotate-cell|set-usebox|set-lthead|
unset-lthead|set-ltfirsthead|unset-ltfirsthead|set-ltfoot|unset-ltfoot|
set-ltlastfoot|unset-ltlastfoot|set-ltnewpage|toggle-ltcaption|
set-special-column|set-special-multi|set-booktabs|unset-booktabs|
set-top-space|set-bottom-space|set-interline-space|set-border-lines|
tabular-valign-top|tabular-valign-middle|tabular-valign-bottom \n
set-special-column|set-special-multicolumn|set-special-multirow|
set-booktabs|unset-booktabs|set-top-space|set-bottom-space|
set-interline-space|set-border-lines|tabular-valign-top|
tabular-valign-middle|tabular-valign-bottom \n
<ARG>: additional argument for some commands, use debug mode to explore its values.
* \li Origin: Jug, 28 Jul 2000
* \endvar

View File

@ -2805,7 +2805,8 @@ void PrefShortcuts::shortcutOkPressed()
// make sure this key isn't already bound---and, if so, not unbound
FuncCode const unbind = user_unbind_.getBinding(k).action;
if (oldBinding.action != LFUN_UNKNOWN_ACTION && unbind == LFUN_UNKNOWN_ACTION)
if (oldBinding.action != LFUN_UNKNOWN_ACTION && unbind == LFUN_UNKNOWN_ACTION
&& toqstr(makeCmdString(oldBinding)) != save_lfun_)
{
// FIXME Perhaps we should offer to over-write the old shortcut?
// If so, we'll need to remove it from our list, etc.
@ -2817,7 +2818,7 @@ void PrefShortcuts::shortcutOkPressed()
return;
}
if (!save_lfun_.isEmpty() && new_lfun == save_lfun_)
if (!save_lfun_.isEmpty())
// real modification of the lfun's shortcut,
// so remove the previous one
removeShortcut();

View File

@ -96,6 +96,8 @@ GuiTabular::GuiTabular(GuiView & lv)
this, SLOT(vAlign_changed(int)));
connect(multicolumnCB, SIGNAL(clicked()),
this, SLOT(multicolumn_clicked()));
connect(multirowCB, SIGNAL(clicked()),
this, SLOT(multirow_clicked()));
connect(newpageCB, SIGNAL(clicked()),
this, SLOT(ltNewpage_clicked()));
connect(headerStatusCB, SIGNAL(clicked()),
@ -172,6 +174,7 @@ GuiTabular::GuiTabular(GuiView & lv)
bc().addReadOnly(booktabsRB);
bc().addReadOnly(multicolumnCB);
bc().addReadOnly(multirowCB);
bc().addReadOnly(rotateCellCB);
bc().addReadOnly(rotateTabularCB);
bc().addReadOnly(specialAlignmentED);
@ -396,6 +399,12 @@ void GuiTabular::multicolumn_clicked()
changed();
}
void GuiTabular::multirow_clicked()
{
toggleMultiRow();
changed();
}
void GuiTabular::rotateTabular()
{
@ -654,7 +663,7 @@ Length getColumnPWidth(Tabular const & t, size_t cell)
Length getMColumnPWidth(Tabular const & t, size_t cell)
{
if (t.isMultiColumn(cell))
if (t.isMultiColumn(cell) || t.isMultiRow(cell))
return t.cellInfo(cell).p_width;
return Length();
}
@ -662,7 +671,8 @@ Length getMColumnPWidth(Tabular const & t, size_t cell)
docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
{
if (what == Tabular::SET_SPECIAL_MULTI)
if (what == Tabular::SET_SPECIAL_MULTICOLUMN
|| what == Tabular::SET_SPECIAL_MULTIROW)
return t.cellInfo(cell).align_special;
return t.column_info[t.cellColumn(cell)].align_special;
}
@ -670,7 +680,6 @@ docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
}
void GuiTabular::updateContents()
{
initialiseParams(string());
@ -684,9 +693,11 @@ void GuiTabular::updateContents()
tabularColumnED->setText(QString::number(col + 1));
bool const multicol(tabular_.isMultiColumn(cell));
multicolumnCB->setChecked(multicol);
bool const multirow(tabular_.isMultiRow(cell));
multirowCB->setChecked(multirow);
rotateCellCB->setChecked(tabular_.getRotateCell(cell));
rotateTabularCB->setChecked(tabular_.rotate);
@ -699,7 +710,11 @@ void GuiTabular::updateContents()
if (multicol) {
special = getAlignSpecial(tabular_, cell,
Tabular::SET_SPECIAL_MULTI);
Tabular::SET_SPECIAL_MULTICOLUMN);
pwidth = getMColumnPWidth(tabular_, cell);
} else if (multirow) {
special = getAlignSpecial(tabular_, cell,
Tabular::SET_SPECIAL_MULTIROW);
pwidth = getMColumnPWidth(tabular_, cell);
} else {
special = getAlignSpecial(tabular_, cell,
@ -832,7 +847,8 @@ void GuiTabular::updateContents()
vAlignCB->setCurrentIndex(valign);
hAlignCB->setEnabled(true);
vAlignCB->setEnabled(!pwidth.zero());
if (!multirow && !pwidth.zero())
vAlignCB->setEnabled(true);
int tableValign = 1;
switch (tabular_.tabular_valignment) {
@ -927,6 +943,7 @@ void GuiTabular::updateContents()
// When a row is set as longtable caption, it must not be allowed
// to unset that this row is a multicolumn.
multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN));
multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW));
Tabular::ltType ltt;
bool use_empty;
@ -1021,15 +1038,16 @@ void GuiTabular::closeGUI()
// apply the fixed width values
size_t const cell = getActiveCell();
bool const multicol = tabular_.isMultiColumn(cell);
bool const multirow = tabular_.isMultiRow(cell);
string width = widgetsToLength(widthED, widthUnitCB);
string width2;
Length llen = getColumnPWidth(tabular_, cell);
Length llenMulti = getMColumnPWidth(tabular_, cell);
if (multicol && !llenMulti.zero())
if (multicol && multirow && !llenMulti.zero())
width2 = llenMulti.asString();
else if (!multicol && !llen.zero())
else if (!multicol && !multirow && !llen.zero())
width2 = llen.asString();
// apply the special alignment
@ -1038,14 +1056,19 @@ void GuiTabular::closeGUI()
if (multicol)
sa2 = getAlignSpecial(tabular_, cell,
Tabular::SET_SPECIAL_MULTI);
Tabular::SET_SPECIAL_MULTICOLUMN);
else if (multirow)
sa2 = getAlignSpecial(tabular_, cell,
Tabular::SET_SPECIAL_MULTIROW);
else
sa2 = getAlignSpecial(tabular_, cell,
Tabular::SET_SPECIAL_COLUMN);
if (sa1 != sa2) {
if (multicol)
set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
set(Tabular::SET_SPECIAL_MULTICOLUMN, to_utf8(sa1));
if (multirow)
set(Tabular::SET_SPECIAL_MULTIROW, to_utf8(sa1));
else
set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
}
@ -1162,7 +1185,9 @@ void GuiTabular::set(Tabular::Feature f, string const & arg)
void GuiTabular::setSpecial(string const & special)
{
if (tabular_.isMultiColumn(getActiveCell()))
set(Tabular::SET_SPECIAL_MULTI, special);
set(Tabular::SET_SPECIAL_MULTICOLUMN, special);
else if (tabular_.isMultiRow(getActiveCell()))
set(Tabular::SET_SPECIAL_MULTIROW, special);
else
set(Tabular::SET_SPECIAL_COLUMN, special);
}
@ -1186,6 +1211,13 @@ void GuiTabular::toggleMultiColumn()
}
void GuiTabular::toggleMultiRow()
{
set(Tabular::MULTIROW);
updateView();
}
void GuiTabular::rotateTabular(bool yes)
{
if (yes)
@ -1255,7 +1287,8 @@ void GuiTabular::valign(GuiTabular::VALIGN v)
break;
}
if (tabular_.isMultiColumn(getActiveCell()))
if (tabular_.isMultiColumn(getActiveCell())
|| tabular_.isMultiRow(getActiveCell()))
set(multi_num);
else
set(num);

View File

@ -45,6 +45,7 @@ private Q_SLOTS:
void topBorder_changed();
void bottomBorder_changed();
void multicolumn_clicked();
void multirow_clicked();
void rotateTabular();
void rotateCell();
void hAlign_changed(int align);
@ -101,6 +102,7 @@ private:
void setWidth(std::string const & width);
void toggleMultiColumn();
void toggleMultiRow();
void rotateTabular(bool yes);
void rotateCell(bool yes);

View File

@ -130,8 +130,8 @@
<attribute name="title">
<string>&amp;Table Settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="GroupBox12">
<property name="title">
<string>Column settings</string>
@ -283,7 +283,7 @@
<item row="3" column="0">
<widget class="QCheckBox" name="multicolumnCB">
<property name="toolTip">
<string>Merge cells</string>
<string>Merge cells of different columns</string>
</property>
<property name="text">
<string>&amp;Multicolumn</string>
@ -296,9 +296,28 @@
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Cell setting</string>
<string>Row setting</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="multirowCB">
<property name="toolTip">
<string>Merge cells of different rows</string>
</property>
<property name="text">
<string>M&amp;ultirow</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Cell setting</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QCheckBox" name="rotateCellCB">
<property name="toolTip">
@ -312,7 +331,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="tabAlignmentGB">
<property name="enabled">
<bool>true</bool>
@ -388,7 +407,7 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="specialAlignmentLA">
@ -409,15 +428,15 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item row="4" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>68</height>
<width>17</width>
<height>0</height>
</size>
</property>
</spacer>
@ -1497,6 +1516,7 @@
<tabstop>vAlignCB</tabstop>
<tabstop>multicolumnCB</tabstop>
<tabstop>rotateTabularCB</tabstop>
<tabstop>multirowCB</tabstop>
<tabstop>rotateCellCB</tabstop>
<tabstop>specialAlignmentED</tabstop>
<tabstop>closePB</tabstop>

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,6 @@
* Full author contact details are available in file CREDITS.
*/
// This is Juergen's rewrite of the tabular (table) support.
// Things to think of when designing the new tabular support:
@ -24,14 +23,6 @@
// - multirow
// - column styles
// This is what I have written about tabular support in the LyX3-Tasks file:
//
// o rewrite of table code. Should probably be written as some
// kind of an inset. [Done]
// o enhance longtable support
// Lgb
#ifndef INSET_TABULAR_H
#define INSET_TABULAR_H
@ -120,6 +111,8 @@ public:
///
MULTICOLUMN,
///
MULTIROW,
///
SET_ALL_LINES,
///
UNSET_ALL_LINES,
@ -164,7 +157,9 @@ public:
///
SET_SPECIAL_COLUMN,
///
SET_SPECIAL_MULTI,
SET_SPECIAL_MULTICOLUMN,
///
SET_SPECIAL_MULTIROW,
///
SET_BOOKTABS,
///
@ -199,7 +194,11 @@ public:
///
CELL_BEGIN_OF_MULTICOLUMN,
///
CELL_PART_OF_MULTICOLUMN
CELL_PART_OF_MULTICOLUMN,
///
CELL_BEGIN_OF_MULTIROW,
///
CELL_PART_OF_MULTIROW
};
///
@ -277,14 +276,16 @@ public:
/// return space occupied by the second horizontal line and
/// interline space above row \p row in pixels
int getAdditionalHeight(row_type row) const;
int interRowSpace(row_type row) const;
///
int getAdditionalWidth(idx_type cell) const;
int interColumnSpace(idx_type cell) const;
/* returns the maximum over all rows */
///
int columnWidth(idx_type cell) const;
///
int rowHeight(idx_type cell) const;
///
int width() const;
///
int height() const;
@ -340,7 +341,9 @@ public:
///
int cellWidth(idx_type cell) const;
///
int getBeginningOfTextInCell(idx_type cell) const;
int textHOffset(idx_type cell) const;
///
int textVOffset(idx_type cell) const;
///
void appendRow(idx_type cell);
///
@ -354,8 +357,6 @@ public:
///
void copyColumn(col_type);
///
bool isFirstCellInRow(idx_type cell) const;
///
idx_type getFirstCellInRow(row_type row) const;
///
bool isLastCellInRow(idx_type cell) const;
@ -384,10 +385,18 @@ public:
///
void setMultiColumn(idx_type cell, idx_type number);
///
idx_type unsetMultiColumn(idx_type cell); // returns number of new cells
void unsetMultiColumn(idx_type cell);
///
bool isPartOfMultiColumn(row_type row, col_type column) const;
///
bool isPartOfMultiRow(row_type row, col_type column) const;
///
bool isMultiRow(idx_type cell) const;
///
void setMultiRow(idx_type cell, idx_type number);
///
void unsetMultiRow(idx_type cell);
///
row_type cellRow(idx_type cell) const;
///
col_type cellColumn(idx_type cell) const;
@ -482,6 +491,8 @@ public:
///
int multicolumn;
///
int multirow;
///
LyXAlignment alignment;
///
VAlignment valignment;
@ -614,6 +625,8 @@ public:
///
idx_type columnSpan(idx_type cell) const;
///
idx_type rowSpan(idx_type cell) const;
///
BoxType useParbox(idx_type cell) const;
///
// helper function for Latex returns number of newlines
@ -622,9 +635,9 @@ public:
///
int TeXBottomHLine(odocstream &, row_type row, std::string const lang) const;
///
int TeXCellPreamble(odocstream &, idx_type cell, bool & ismulticol) const;
int TeXCellPreamble(odocstream &, idx_type cell, bool & ismulticol, bool & ismultirow) const;
///
int TeXCellPostamble(odocstream &, idx_type cell, bool ismulticol) const;
int TeXCellPostamble(odocstream &, idx_type cell, bool ismulticol, bool ismultirow) const;
///
int TeXLongtableHeaderFooter(odocstream &, OutputParams const &) const;
///