From: Jürgen Vigna Date: Wed, 24 Oct 2001 15:07:39 +0000 (+0000) Subject: Changes to the longtable support. X-Git-Tag: 1.6.10~20431 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e3052dc18bc13cd4ea91cd5e528246e3d4a4ae12;p=features.git Changes to the longtable support. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2934 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 310fad902f..5f7934dbc4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2001-10-24 Juergen Vigna + + * tabular-old.C (ReadOld): below variable changes reflected. + + * tabular.[Ch]: added ltType struct for longtable header/footer + defines and changed all instances where they are used. Added + future support for double top/bottom rows. + 2001-10-24 José Matos * buffer.h (docbookHandleCaption): diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 9e90310c2b..1d2d64b797 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2001-10-24 Juergen Vigna + + * FormTabular.C: changed calls for footer/headers of longtabulars. + 2001-10-23 Jürgen Spitzmüller * forms/form_tabular.fd: Add value choices diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index 428de22351..40098e95a5 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -358,17 +358,17 @@ void FormTabular::update() setEnabled(longtable_options_->radio_lt_newpage, enable); if (enable) { - int dummy; + LyXTabular::ltType dummyltt; fl_set_button(longtable_options_->radio_lt_firsthead, - tabular->GetRowOfLTFirstHead(cell, dummy)); + tabular->GetRowOfLTFirstHead(row-1, dummyltt)); fl_set_button(longtable_options_->radio_lt_head, - tabular->GetRowOfLTHead(cell, dummy)); + tabular->GetRowOfLTHead(row-1, dummyltt)); fl_set_button(longtable_options_->radio_lt_foot, - tabular->GetRowOfLTFoot(cell, dummy)); + tabular->GetRowOfLTFoot(row-1, dummyltt)); fl_set_button(longtable_options_->radio_lt_lastfoot, - tabular->GetRowOfLTLastFoot(cell, dummy)); + tabular->GetRowOfLTLastFoot(row-1, dummyltt)); fl_set_button(longtable_options_->radio_lt_newpage, - tabular->GetLTNewPage(cell)); + tabular->GetLTNewPage(cell)); } else { fl_set_button(longtable_options_->radio_lt_firsthead,0); fl_set_button(longtable_options_->radio_lt_head,0); @@ -392,6 +392,8 @@ bool FormTabular::input(FL_OBJECT * ob, long) string special;; int cell = inset_->getActCell(); + int row = tabular->row_of_cell(cell); + if (actCell_ != cell) { update(); fl_set_object_label(dialog_->text_warning, @@ -468,15 +470,15 @@ bool FormTabular::input(FL_OBJECT * ob, long) if (enable) { num = LyXTabular::SET_LONGTABULAR; - int dummy; + LyXTabular::ltType dummyltt; fl_set_button(longtable_options_->radio_lt_firsthead, - tabular->GetRowOfLTFirstHead(cell, dummy)); + tabular->GetRowOfLTFirstHead(row, dummyltt)); fl_set_button(longtable_options_->radio_lt_head, - tabular->GetRowOfLTHead(cell, dummy)); + tabular->GetRowOfLTHead(row, dummyltt)); fl_set_button(longtable_options_->radio_lt_foot, - tabular->GetRowOfLTFoot(cell, dummy)); + tabular->GetRowOfLTFoot(row, dummyltt)); fl_set_button(longtable_options_->radio_lt_lastfoot, - tabular->GetRowOfLTLastFoot(cell, dummy)); + tabular->GetRowOfLTLastFoot(row, dummyltt)); fl_set_button(longtable_options_->radio_lt_firsthead, tabular->GetLTNewPage(cell)); } else { @@ -503,13 +505,25 @@ bool FormTabular::input(FL_OBJECT * ob, long) num = LyXTabular::SET_USEBOX; special = "2"; } else if (ob == longtable_options_->radio_lt_firsthead) { - num = LyXTabular::SET_LTFIRSTHEAD; + if (fl_get_button(ob)) + num = LyXTabular::SET_LTFIRSTHEAD; + else + num = LyXTabular::UNSET_LTFIRSTHEAD; } else if (ob == longtable_options_->radio_lt_head) { - num = LyXTabular::SET_LTHEAD; + if (fl_get_button(ob)) + num = LyXTabular::SET_LTHEAD; + else + num = LyXTabular::UNSET_LTHEAD; } else if (ob == longtable_options_->radio_lt_foot) { - num = LyXTabular::SET_LTFOOT; + if (fl_get_button(ob)) + num = LyXTabular::SET_LTFOOT; + else + num = LyXTabular::UNSET_LTFOOT; } else if (ob == longtable_options_->radio_lt_lastfoot) { - num = LyXTabular::SET_LTLASTFOOT; + if (fl_get_button(ob)) + num = LyXTabular::SET_LTLASTFOOT; + else + num = LyXTabular::UNSET_LTLASTFOOT; } else if (ob == longtable_options_->radio_lt_newpage) { num = LyXTabular::SET_LTNEWPAGE; } else if (ob == column_options_->input_special_alignment) { diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index ca43d81826..161b91e941 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2001-10-24 Juergen Vigna + + * insettabular.C: use new ltType struct for setting longtable + header and footers also new UNSET enums. + 2001-10-24 José Matos * insettabular.C (linuxdoc): Now exports the ascii's table version. diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 01ec393b5b..2d482028e2 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1662,10 +1662,11 @@ void InsetTabular::tabularFeatures(BufferView * bv, bv->text->cursor.par(), bv->text->cursor.par()->next()); - int row = tabular->row_of_cell(actcell); + LyXTabular::ltType ltt; + int row = ltt.row = tabular->row_of_cell(actcell); int column = tabular->column_of_cell(actcell); bool flag = true; - + switch (feature) { case LyXTabular::SET_PWIDTH: { @@ -1906,17 +1907,25 @@ void InsetTabular::tabularFeatures(BufferView * bv, tabular->GetCellNumber(i, j), val); break; } + case LyXTabular::UNSET_LTFIRSTHEAD: + ltt.row = 0; case LyXTabular::SET_LTFIRSTHEAD: - tabular->SetLTHead(actcell, true); + tabular->SetLTHead(ltt, true); break; + case LyXTabular::UNSET_LTHEAD: + ltt.row = 0; case LyXTabular::SET_LTHEAD: - tabular->SetLTHead(actcell, false); + tabular->SetLTHead(ltt, false); break; + case LyXTabular::UNSET_LTFOOT: + ltt.row = 0; case LyXTabular::SET_LTFOOT: - tabular->SetLTFoot(actcell, false); + tabular->SetLTFoot(ltt, false); break; + case LyXTabular::UNSET_LTLASTFOOT: + ltt.row = 0; case LyXTabular::SET_LTLASTFOOT: - tabular->SetLTFoot(actcell, true); + tabular->SetLTFoot(ltt, true); break; case LyXTabular::SET_LTNEWPAGE: { @@ -2108,6 +2117,7 @@ func_status::value_type InsetTabular::getStatus(string const & what) const int sel_row_start; int sel_row_end; int dummy; + LyXTabular::ltType dummyltt; bool flag = true; if (hasSelection()) { @@ -2262,25 +2272,25 @@ func_status::value_type InsetTabular::getStatus(string const & what) const status |= func_status::ToggleOff; break; case LyXTabular::SET_LTFIRSTHEAD: - if (tabular->GetRowOfLTHead(actcell, dummy)) + if (tabular->GetRowOfLTHead(actcell, dummyltt)) status |= func_status::ToggleOn; else status |= func_status::ToggleOff; break; case LyXTabular::SET_LTHEAD: - if (tabular->GetRowOfLTHead(actcell, dummy)) + if (tabular->GetRowOfLTHead(actcell, dummyltt)) status |= func_status::ToggleOn; else status |= func_status::ToggleOff; break; case LyXTabular::SET_LTFOOT: - if (tabular->GetRowOfLTFoot(actcell, dummy)) + if (tabular->GetRowOfLTFoot(actcell, dummyltt)) status |= func_status::ToggleOn; else status |= func_status::ToggleOff; break; case LyXTabular::SET_LTLASTFOOT: - if (tabular->GetRowOfLTFoot(actcell, dummy)) + if (tabular->GetRowOfLTFoot(actcell, dummyltt)) status |= func_status::ToggleOn; else status |= func_status::ToggleOff; diff --git a/src/tabular-old.C b/src/tabular-old.C index 782d8e71d4..5dbccf0e56 100644 --- a/src/tabular-old.C +++ b/src/tabular-old.C @@ -157,10 +157,10 @@ void LyXTabular::ReadOld(Buffer const * buf, istream & is, return; } getTokenValue(line, "islongtable", is_long_tabular); - getTokenValue(line, "endhead", endhead); - getTokenValue(line, "endfirsthead", endfirsthead); - getTokenValue(line, "endfoot", endfoot); - getTokenValue(line, "endlastfoot", endlastfoot); + getTokenValue(line, "endhead", endhead.row); + getTokenValue(line, "endfirsthead", endfirsthead.row); + getTokenValue(line, "endfoot", endfoot.row); + getTokenValue(line, "endlastfoot", endlastfoot.row); for (int i = 0; i < rows_; ++i) { l_getline(is, line); diff --git a/src/tabular.C b/src/tabular.C index 6448ae4dce..0c201c501a 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -93,6 +93,14 @@ LyXTabular::columnstruct::columnstruct() } +LyXTabular::lttype::lttype() +{ + row = 0; + topDL = false; + bottomDL = false; +} + + /* konstruktor */ LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg) { @@ -211,10 +219,10 @@ void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt) set_row_column_number_info(); is_long_tabular = false; rotate = false; - endhead = 0; - endfirsthead = 0; - endfoot = 0; - endlastfoot = 0; + endhead.row = 0; + endfirsthead.row = 0; + endfoot.row = 0; + endlastfoot.row = 0; } @@ -1089,10 +1097,10 @@ void LyXTabular::Write(Buffer const * buf, ostream & os) const os << "\n"; for (int j = 0; j < columns_; ++j) { os << "(rows_arg); SetLongTabular(is_long_tabular_arg); SetRotateTabular(rotate_arg); - endhead = a + 1; - endfirsthead = b + 1; - endfoot = c + 1; - endlastfoot = d + 1; + endhead.row = a + 1; + endfirsthead.row = b + 1; + endfoot.row = c + 1; + endlastfoot.row = d + 1; for (i = 0; i < rows_; ++i) { a = b = c = d = e = f = g = 0; is >> a >> b >> c >> d; @@ -1812,78 +1823,59 @@ LyXTabular::BoxType LyXTabular::GetUsebox(int cell) const return UseParbox(cell); } - -void LyXTabular::SetLTHead(int cell, bool first) +bool LyXTabular::checkLTType(int row, ltType const & ltt) const { - int const row = row_of_cell(cell); - int const val = (row + 1) * (column_of_cell(cell) ? 1 : -1); + if (!ltt.row || (ltt.row > rows_)) + return false; + return (row == (ltt.row - 1)); +} + +void LyXTabular::SetLTHead(ltType const & hd, bool first) +{ if (first) { - if (endfirsthead == val) - endfirsthead = 0; - else - endfirsthead = val; + endfirsthead = hd; } else { - if (endhead == val) - endhead = 0; - else - endhead = val; + endhead = hd; } } -bool LyXTabular::GetRowOfLTHead(int cell, int & row) const +bool LyXTabular::GetRowOfLTHead(int row, ltType & hd) const { - row = endhead; - if (abs(endhead) > rows_) - return false; - return (row_of_cell(cell) == abs(endhead) - 1); + hd = endhead; + return checkLTType(row, hd); } -bool LyXTabular::GetRowOfLTFirstHead(int cell, int & row) const +bool LyXTabular::GetRowOfLTFirstHead(int row, ltType & hd) const { - row = endfirsthead; - if (abs(endfirsthead) > rows_) - return false; - return (row_of_cell(cell) == abs(endfirsthead) - 1); + hd = endfirsthead; + return checkLTType(row, hd); } -void LyXTabular::SetLTFoot(int cell, bool last) +void LyXTabular::SetLTFoot(ltType const & fd, bool last) { - int const row = row_of_cell(cell); - int const val = (row + 1) * (column_of_cell(cell) ? 1 : -1); - if (last) { - if (endlastfoot == val) - endlastfoot = 0; - else - endlastfoot = val; + endlastfoot = fd; } else { - if (endfoot == val) - endfoot = 0; - else - endfoot = val; + endfoot = fd; } } -bool LyXTabular::GetRowOfLTFoot(int cell, int & row) const +bool LyXTabular::GetRowOfLTFoot(int row, ltType & fd) const { - row = endfoot; - if ((endfoot + 1) > rows_) - return false; - return (row_of_cell(cell) == abs(endfoot) - 1); + fd = endfoot; + return checkLTType(row, fd); } -bool LyXTabular::GetRowOfLTLastFoot(int cell, int & row) const +bool LyXTabular::GetRowOfLTLastFoot(int row, ltType & fd) const { - row = endlastfoot; - if (abs(endlastfoot) > rows_) - return false; - return (row_of_cell(cell) == (abs(endlastfoot)-1)); + fd = endlastfoot; + return checkLTType(row, fd); } @@ -2193,29 +2185,13 @@ int LyXTabular::Latex(Buffer const * buf, for (int i = 0; i < rows_; ++i) { ret += TeXTopHLine(os, i); - int bret = ret; - if (IsLongTabular()) { - if ((endhead < 0) && (i == (abs(endhead)-1))) { - os << "\\endhead\n"; - ++ret; - } - if ((endfirsthead < 0) && (i == (abs(endfirsthead)-1))) { - os << "\\endfirsthead\n"; - ++ret; - } - if ((endfoot < 0) && (i == (abs(endfoot)-1))) { - os << "\\endfoot\n"; - ++ret; - } - if ((endlastfoot < 0) && (i == (abs(endlastfoot)-1))) { - os << "\\endlastfoot\n"; - ++ret; - } - } +#warning Implement top double lines for LT Header/Footers +#if 0 if (ret > bret) { ret += TeXBottomHLine(os, i-1); ret += TeXTopHLine(os, i); } +#endif for (int j = 0; j < columns_; ++j) { if (IsPartOfMultiColumn(i,j)) continue; @@ -2240,26 +2216,31 @@ int LyXTabular::Latex(Buffer const * buf, } os << "\\\\\n"; ret += TeXBottomHLine(os, i); - bret = ret; if (IsLongTabular()) { - if ((endhead > 0) && (i == (endhead - 1))) { + if (i == (endhead.row - 1)) { + if (endhead.bottomDL) + ret += TeXBottomHLine(os, i); os << "\\endhead\n"; ++ret; } - if ((endfirsthead > 0) && (i == (endfirsthead - 1))) { + if (i == (endfirsthead.row - 1)) { + if (endfirsthead.bottomDL) + ret += TeXBottomHLine(os, i); os << "\\endfirsthead\n"; ++ret; } - if ((endfoot > 0) && (i == (endfoot - 1))) { + if (i == (endfoot.row - 1)) { + if (endfoot.bottomDL) + ret += TeXBottomHLine(os, i); os << "\\endfoot\n"; ++ret; } - if ((endlastfoot > 0) && (i == (endlastfoot - 1))) { + if (i == (endlastfoot.row - 1)) { + if (endlastfoot.bottomDL) + ret += TeXBottomHLine(os, i); os << "\\endlastfoot\n"; ++ret; } -// if (ret > bret) -// ret += TeXBottomHLine(os, i); if (row_info[i].newpage) { os << "\\newpage\n"; ++ret; @@ -2369,25 +2350,25 @@ int LyXTabular::DocBook(Buffer const * buf, ostream & os) const if ( IsLongTabular() ) { // Header - if( endhead || endfirsthead ) { + if( endhead.row || endfirsthead.row ) { os << "\n"; - if( endfirsthead ) { - docbookRow( buf, os, abs( endfirsthead) - 1); + if( endfirsthead.row ) { + docbookRow( buf, os, endfirsthead.row - 1); } - if( endhead && abs( endhead) != abs( endfirsthead)) { - docbookRow( buf, os, abs( endhead) - 1); + if( endhead.row && endhead.row != endfirsthead.row) { + docbookRow(buf, os, endhead.row - 1); } os << "\n"; } // Footer - if( endfoot || endlastfoot ) { + if( endfoot.row || endlastfoot.row ) { os << "\n"; - if( endfoot ) { - docbookRow( buf, os, abs( endfoot) - 1); + if( endfoot.row ) { + docbookRow( buf, os, endfoot.row - 1); } - if( endlastfoot && abs( endlastfoot) != endfoot) { - docbookRow( buf, os, abs( endlastfoot) - 1); + if( endlastfoot.row && endlastfoot.row != endfoot.row) { + docbookRow( buf, os, endlastfoot.row - 1); } os << "\n"; } @@ -2399,8 +2380,8 @@ int LyXTabular::DocBook(Buffer const * buf, ostream & os) const os << "\n"; for (int i = 0; i < rows_; ++i) { if(!IsLongTabular() || ( - i != abs(endhead) - 1 && i != abs(endfirsthead) - 1 && - i != abs(endfoot) - 1 && i != abs(endlastfoot) - 1)) { + i != endhead.row - 1 && i != endfirsthead.row - 1 && + i != endfoot.row - 1 && i != endlastfoot.row - 1)) { docbookRow( buf, os, i); } } diff --git a/src/tabular.h b/src/tabular.h index fc458deaaf..b434ab4a95 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -108,12 +108,16 @@ public: SET_USEBOX, /// SET_LTHEAD, + UNSET_LTHEAD, /// SET_LTFIRSTHEAD, + UNSET_LTFIRSTHEAD, /// SET_LTFOOT, + UNSET_LTFOOT, /// SET_LTLASTFOOT, + UNSET_LTLASTFOOT, /// SET_LTNEWPAGE, /// @@ -152,6 +156,19 @@ public: BOX_MINIPAGE = 2 }; + struct lttype { + // constructor + lttype(); + // row of the header/footer type end definition + int row; + // double borders on top + bool topDL; + // double borders on bottom + bool bottomDL; + }; + /// + typedef struct lttype ltType; + /* konstruktor */ /// LyXTabular(InsetTabular *, int columns_arg, int rows_arg); @@ -344,17 +361,19 @@ public: // // Long Tabular Options /// - void SetLTHead(int cell, bool first); + bool checkLTType(int row, ltType const &) const; + /// + void SetLTHead(ltType const &, bool first); /// - bool GetRowOfLTHead(int cell, int & row) const; + bool GetRowOfLTHead(int row, ltType &) const; /// - bool GetRowOfLTFirstHead(int cell, int & row) const; + bool GetRowOfLTFirstHead(int row, ltType &) const; /// - void SetLTFoot(int cell, bool last); + void SetLTFoot(ltType const &, bool last); /// - bool GetRowOfLTFoot(int cell, int & row) const; + bool GetRowOfLTFoot(int row, ltType &) const; /// - bool GetRowOfLTLastFoot(int cell, int & row) const; + bool GetRowOfLTLastFoot(int row, ltType &) const; /// void SetLTNewPage(int cell, bool what); /// @@ -485,13 +504,13 @@ private: /// bool is_long_tabular; /// row of endhead - int endhead; + ltType endhead; /// row of endfirsthead - int endfirsthead; + ltType endfirsthead; /// row of endfoot - int endfoot; + ltType endfoot; /// row of endlastfoot - int endlastfoot; + ltType endlastfoot; /// InsetTabular * owner_;