Uwe Stöhr schrieb:
The attached patch fixes
http://bugzilla.lyx.org/show_bug.cgi?id=5752
It fixes the following problems:
- every row can only have one attribute - it cannot be a footer and
header at once
- when a row is already set as e.g. first header, no other row can be
the first header
The attached version of the patch also fixes now this problem:
- Only the first row can be the caption. When you define for example the second
row as caption and the first one as first header, then you get a broken table in
the output. The longtable docs also describe that the caption is designed to be
in the first row.
> The only thing this is now missing:
> - when the first header empty checkbox is checked, then haveLTFirstHead()
needs
> to be set true
> (I guess achieving this is simple, but I failed and it is now time for bed.)
>
> Please test the patch and simplify it if possible. I think that some part of
the checkbox logic
> can be done directly in the TabularUI.ui file, but my Qt designer is
currently crashing all the
> time, so I couldn't have a look.
regards Uwe
Index: src/frontends/qt4/GuiTabular.cpp
===================================================================
--- src/frontends/qt4/GuiTabular.cpp (revision 28399)
+++ src/frontends/qt4/GuiTabular.cpp (working copy)
@@ -23,6 +23,8 @@
#include "BufferView.h"
#include "Cursor.h"
#include "FuncRequest.h"
+#include "FuncStatus.h"
+#include "LyXFunc.h"
#include "LyXRC.h"
#include "insets/InsetTabular.h"
@@ -786,6 +788,38 @@
captionStatusCB->setChecked(tabular_.ltCaption(row));
captionStatusCB->blockSignals(false);
+ // FIXME: Some of them should be handled directly in TabularUI.ui
+ firstheaderBorderAboveCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTFIRSTHEAD))).enabled());
+ firstheaderBorderBelowCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTFIRSTHEAD))).enabled());
+ // first header can be suppressed when there is a header
+ firstheaderNoContentsCB->setEnabled(tabular_.haveLTHead() && !tabular_.haveLTFirstHead());
+ firstheaderStatusCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTFIRSTHEAD))).enabled());
+ headerBorderAboveCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTHEAD))).enabled());
+ headerBorderBelowCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTHEAD))).enabled());
+ headerStatusCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTHEAD))).enabled());
+ footerBorderAboveCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTFOOT))).enabled());
+ footerBorderBelowCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTFOOT))).enabled());
+ footerStatusCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTFOOT))).enabled());
+ lastfooterBorderAboveCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTLASTFOOT))).enabled());
+ lastfooterBorderBelowCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTLASTFOOT))).enabled());
+ // last footer can only be suppressed when there is a footer
+ lastfooterNoContentsCB->setEnabled(tabular_.haveLTFoot() && !tabular_.haveLTLastFoot());
+ lastfooterStatusCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::SET_LTLASTFOOT))).enabled());
+ captionStatusCB->setEnabled(getStatus(
+ FuncRequest(getLfun(), featureAsString(Tabular::TOGGLE_LTCAPTION))).enabled());
+
Tabular::ltType ltt;
bool use_empty;
bool row_set = tabular_.getRowOfLTHead(row, ltt);
@@ -838,7 +872,7 @@
}
row_set = tabular_.getRowOfLTLastFoot(row, ltt);
- lastfooterStatusCB->setChecked(row_set);
+ lastfooterStatusCB->setChecked(row_set);
if (ltt.set && (!ltt.empty || !use_empty)) {
lastfooterBorderAboveCB->setChecked(ltt.topDL);
lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
Index: src/insets/InsetTabular.cpp
===================================================================
--- src/insets/InsetTabular.cpp (revision 28399)
+++ src/insets/InsetTabular.cpp (working copy)
@@ -1759,6 +1759,15 @@
}
+bool Tabular::haveLTCaption() const
+{
+ for (row_type i = 0; i < row_info.size(); ++i)
+ if (row_info[i].caption)
+ return true;
+ return false;
+}
+
+
// end longtable support functions
void Tabular::setRowAscent(row_type row, int height)
@@ -3832,7 +3841,17 @@
status.setOnOff(convert<int>(argument) == tabular.getUsebox(cur.idx()));
break;
- case Tabular::SET_LTFIRSTHEAD:
+ // when a header/footer/caption is set, no other row can be the same
+ // furthermore, every row can only be one thing:
+ // either a footer or header or caption
+ case Tabular::SET_LTFIRSTHEAD:
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
+ && !tabular.ltCaption(sel_row_start)
+ && (!tabular.haveLTFirstHead()
+ || tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)));
status.setOnOff(tabular.getRowOfLTHead(sel_row_start, dummyltt));
break;
@@ -3841,6 +3860,13 @@
break;
case Tabular::SET_LTHEAD:
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
+ && !tabular.ltCaption(sel_row_start)
+ && (!tabular.haveLTHead()
+ || tabular.getRowOfLTHead(sel_row_start, dummyltt)));
status.setOnOff(tabular.getRowOfLTHead(sel_row_start, dummyltt));
break;
@@ -3849,6 +3875,13 @@
break;
case Tabular::SET_LTFOOT:
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
+ && !tabular.ltCaption(sel_row_start)
+ && (!tabular.haveLTFoot()
+ || tabular.getRowOfLTFoot(sel_row_start, dummyltt)));
status.setOnOff(tabular.getRowOfLTFoot(sel_row_start, dummyltt));
break;
@@ -3857,6 +3890,13 @@
break;
case Tabular::SET_LTLASTFOOT:
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
+ && !tabular.ltCaption(sel_row_start)
+ && (!tabular.haveLTLastFoot()
+ || tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)));
status.setOnOff(tabular.getRowOfLTFoot(sel_row_start, dummyltt));
break;
@@ -3869,7 +3909,15 @@
break;
case Tabular::TOGGLE_LTCAPTION:
- status.setEnabled(sel_row_start == sel_row_end);
+ status.setEnabled(sel_row_start == sel_row_end
+ && !tabular.getRowOfLTFirstHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTHead(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTFoot(sel_row_start, dummyltt)
+ && !tabular.getRowOfLTLastFoot(sel_row_start, dummyltt)
+ // Only the first row can be the caption.
+ && sel_row_start == 0
+ && (!tabular.haveLTCaption()
+ || tabular.ltCaption(sel_row_start)));
status.setOnOff(tabular.ltCaption(sel_row_start));
break;
Index: src/insets/InsetTabular.h
===================================================================
--- src/insets/InsetTabular.h (revision 28399)
+++ src/insets/InsetTabular.h (working copy)
@@ -420,6 +420,8 @@
///
bool haveLTLastFoot() const;
///
+ bool haveLTCaption() const;
+ ///
// end longtable support
///
boost::shared_ptr<InsetTableCell> cellInset(idx_type cell) const;