git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28437 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2009-02-10 18:08:09 +00:00
parent 0c3109e2d3
commit e029b216b7
4 changed files with 101 additions and 5 deletions

View File

@ -23,6 +23,8 @@
#include "BufferView.h"
#include "Cursor.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LyXFunc.h"
#include "insets/InsetTabular.h"
@ -784,6 +786,37 @@ void GuiTabular::updateContents()
captionStatusCB->setChecked(tabular_.ltCaption(row));
captionStatusCB->blockSignals(false);
// FIXME: shouldn't this be handled by GuiDialog?
// FIXME: Some of them should be handled directly in TabularUI.ui
firstheaderBorderAboveCB->setEnabled(funcEnabled(Tabular::SET_LTFIRSTHEAD));
firstheaderBorderBelowCB->setEnabled(funcEnabled(Tabular::SET_LTFIRSTHEAD));
// first header can only be suppressed when there is a header
firstheaderNoContentsCB->setEnabled(tabular_.haveLTHead()
&& !tabular_.haveLTFirstHead());
// check if setting a first header is allowed
// additionally check firstheaderStatusCB because when this is the case
// a first header makes no sense
firstheaderStatusCB->setEnabled(funcEnabled(Tabular::SET_LTFIRSTHEAD)
&& !firstheaderNoContentsCB->isChecked());
//firstheaderStatusCB->setEnabled(!firstheaderNoContentsCB->isChecked());
headerBorderAboveCB->setEnabled(funcEnabled(Tabular::SET_LTHEAD));
headerBorderBelowCB->setEnabled(funcEnabled(Tabular::SET_LTHEAD));
headerStatusCB->setEnabled(funcEnabled(Tabular::SET_LTHEAD));
footerBorderAboveCB->setEnabled(funcEnabled(Tabular::SET_LTFOOT));
footerBorderBelowCB->setEnabled(funcEnabled(Tabular::SET_LTFOOT));
footerStatusCB->setEnabled(funcEnabled(Tabular::SET_LTFOOT));
lastfooterBorderAboveCB->setEnabled(funcEnabled(Tabular::SET_LTLASTFOOT));
lastfooterBorderBelowCB->setEnabled(funcEnabled(Tabular::SET_LTLASTFOOT));
// last footer can only be suppressed when there is a footer
lastfooterNoContentsCB->setEnabled(tabular_.haveLTFoot()
&& !tabular_.haveLTLastFoot());
// check if setting a last footer is allowed
// additionally check lastfooterNoContentsCB because when this is the case
// a last footer makes no sense
lastfooterStatusCB->setEnabled(funcEnabled(Tabular::SET_LTLASTFOOT)
&& !lastfooterNoContentsCB->isChecked());
captionStatusCB->setEnabled(funcEnabled(Tabular::TOGGLE_LTCAPTION));
Tabular::ltType ltt;
bool use_empty;
bool row_set = tabular_.getRowOfLTHead(row, ltt);
@ -813,7 +846,6 @@ void GuiTabular::updateContents()
firstheaderBorderAboveCB->setChecked(false);
firstheaderBorderBelowCB->setChecked(false);
if (use_empty) {
firstheaderNoContentsCB->setChecked(ltt.empty);
if (ltt.empty)
firstheaderStatusCB->setEnabled(false);
}
@ -846,7 +878,6 @@ void GuiTabular::updateContents()
lastfooterBorderAboveCB->setChecked(false);
lastfooterBorderBelowCB->setChecked(false);
if (use_empty) {
lastfooterNoContentsCB->setChecked(ltt.empty);
if (ltt.empty)
lastfooterStatusCB->setEnabled(false);
}
@ -1119,6 +1150,13 @@ void GuiTabular::longTabular(bool yes)
}
// to get the status of the longtable row settings
bool GuiTabular::funcEnabled(Tabular::Feature f) const
{
return getStatus(FuncRequest(getLfun(), featureAsString(f))).enabled();
}
Dialog * createGuiTabular(GuiView & lv) { return new GuiTabular(lv); }

View File

@ -115,6 +115,8 @@ private:
void longTabular(bool yes);
bool funcEnabled(Tabular::Feature f) const;
///
Tabular::idx_type active_cell_;
///

View File

@ -1750,8 +1750,14 @@ Tabular::idx_type Tabular::setLTCaption(row_type row, bool what)
setBottomLine(i, false);
setLeftLine(i, false);
setRightLine(i, false);
} else
// FIXME: when a row is set as caption, then also insert a caption
// dispatch(FuncRequest(LFUN_CAPTION_INSERT));
} else {
unsetMultiColumn(i);
// FIXME: when unsetting a caption row, also all existing captions
// in this row must be dissolved, see (bug 5754)
// dispatch(FuncRequest(LFUN_INSET_DISSOLVE, "caption-insert"));
}
row_info[row].caption = what;
return i;
}
@ -1763,6 +1769,15 @@ bool Tabular::ltCaption(row_type row) const
}
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)
@ -3884,7 +3899,17 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
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;
@ -3893,6 +3918,13 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
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;
@ -3901,6 +3933,13 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
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;
@ -3909,6 +3948,13 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
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;
@ -3921,7 +3967,15 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
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;

View File

@ -426,6 +426,8 @@ public:
///
bool haveLTLastFoot() const;
///
bool haveLTCaption() const;
///
// end longtable support
///
boost::shared_ptr<InsetTableCell> cellInset(idx_type cell) const;