From 832bbc4329e17437eaafeff2d097b8a178ef99a8 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Sun, 4 May 2008 07:51:50 +0000 Subject: [PATCH] fix: http://bugzilla.lyx.org/show_bug.cgi?id=4688 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24598 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/LyX.py | 2 +- lib/lyx2lyx/lyx_1_6.py | 108 +++- src/Buffer.cpp | 2 +- src/frontends/qt4/GuiTabular.cpp | 13 + src/frontends/qt4/GuiTabular.h | 1 + src/frontends/qt4/ui/TabularUi.ui | 895 ++++++++++++++++++------------ src/insets/InsetTabular.cpp | 61 +- src/insets/InsetTabular.h | 8 + 8 files changed, 736 insertions(+), 354 deletions(-) diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 30718e98a0..c7bf9b8875 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)), ("1_3", [221], minor_versions("1.3" , 7)), ("1_4", range(222,246), minor_versions("1.4" , 5)), ("1_5", range(246,277), minor_versions("1.5" , 2)), - ("1_6", range(277,331), minor_versions("1.6" , 0))] + ("1_6", range(277,332), minor_versions("1.6" , 0))] def formats_list(): diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 24fba6d559..2510999385 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -78,8 +78,6 @@ def find_default_layout(document, start, end): l = find_token(document.body, "\\begin_layout Plain Layout", start, end) return l -#################################################################### - def get_option(document, m, option, default): l = document.body[m].find(option) val = default @@ -104,6 +102,91 @@ def set_option(document, m, option, value): document.body[m] = document.body[m][:-1] + ' ' + option + '="' + value + '">' return l + +#################################################################### + +def convert_ltcaption(document): + i = 0 + while True: + i = find_token(document.body, "\\begin_inset Tabular", i) + if i == -1: + return + j = find_end_of_inset(document.body, i + 1) + if j == -1: + document.warning("Malformed LyX document: Could not find end of tabular.") + continue + + nrows = int(document.body[i+1].split('"')[3]) + ncols = int(document.body[i+1].split('"')[5]) + + m = i + 1 + for k in range(nrows): + m = find_token(document.body, "", m + 1) + # first look for caption insets + mcap = find_token(document.body, "\\begin_inset Caption", m + 1, mend) + # then look for ERT captions + if mcap == -1: + mcap = find_token(document.body, "caption", m + 1, mend) + if mcap > -1: + mcap = find_token(document.body, "\\backslash", mcap - 1, mcap) + if mcap > -1: + caption = 'true' + if caption == 'true': + if (k == 0): + set_option(document, r, 'caption', 'true') + set_option(document, m, 'multicolumn', '1') + set_option(document, m, 'bottomline', 'false') + set_option(document, m, 'topline', 'false') + set_option(document, m, 'rightline', 'false') + set_option(document, m, 'leftline', 'false') + #j = find_end_of_inset(document.body, j + 1) + else: + set_option(document, m, 'multicolumn', '2') + m = m + 1 + m = m + 1 + + i = j + 1 + +def revert_ltcaption(document): + i = 0 + while True: + i = find_token(document.body, "\\begin_inset Tabular", i) + if i == -1: + return + j = find_end_of_inset(document.body, i + 1) + if j == -1: + document.warning("Malformed LyX document: Could not find end of tabular.") + continue + + m = i + 1 + nrows = int(document.body[i+1].split('"')[3]) + ncols = int(document.body[i+1].split('"')[5]) + + for k in range(nrows): + m = find_token(document.body, " DepClean; typedef map > RefCache; diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp index dccad356a5..8b8c2dbaf4 100644 --- a/src/frontends/qt4/GuiTabular.cpp +++ b/src/frontends/qt4/GuiTabular.cpp @@ -393,6 +393,13 @@ void GuiTabular::ltNewpage_clicked() } +void GuiTabular::on_captionStatusCB_toggled() +{ + set(Tabular::TOGGLE_LTCAPTION); + changed(); +} + + void GuiTabular::ltHeaderStatus_clicked() { bool enable = headerStatusCB->isChecked(); @@ -771,8 +778,14 @@ void GuiTabular::updateContents() lastfooterNoContentsCB->setChecked(false); newpageCB->setChecked(false); newpageCB->setEnabled(false); + captionStatusCB->blockSignals(true); + captionStatusCB->setChecked(false); + captionStatusCB->blockSignals(false); return; } + captionStatusCB->blockSignals(true); + captionStatusCB->setChecked(tabular_.ltCaption(row)); + captionStatusCB->blockSignals(false); Tabular::ltType ltt; bool use_empty; diff --git a/src/frontends/qt4/GuiTabular.h b/src/frontends/qt4/GuiTabular.h index b833194673..9a5c8e758f 100644 --- a/src/frontends/qt4/GuiTabular.h +++ b/src/frontends/qt4/GuiTabular.h @@ -67,6 +67,7 @@ private Q_SLOTS: void ltLastFooterBorderAbove_clicked(); void ltLastFooterBorderBelow_clicked(); void ltLastFooterEmpty_clicked(); + void on_captionStatusCB_toggled(); private: /// diff --git a/src/frontends/qt4/ui/TabularUi.ui b/src/frontends/qt4/ui/TabularUi.ui index 64b976abb2..04ee1ebc89 100644 --- a/src/frontends/qt4/ui/TabularUi.ui +++ b/src/frontends/qt4/ui/TabularUi.ui @@ -5,8 +5,8 @@ 0 0 - 432 - 351 + 390 + 336 @@ -248,7 +248,7 @@ - 11 + 9 6 @@ -350,7 +350,7 @@ - 11 + 9 6 @@ -359,8 +359,8 @@ - 5 - 5 + 0 + 0 0 0 @@ -368,265 +368,469 @@ - - 0 - 0 - 0 - - - 230 - 240 - 249 - - - 255 - 255 - 255 - - - 242 - 247 - 252 - - - 115 - 120 - 124 - - - 154 - 160 - 166 - - - 0 - 0 - 0 - - - 255 - 255 - 255 - - - 0 - 0 - 0 - - - 255 - 255 - 255 - - - 255 - 255 - 255 - - - 0 - 0 - 0 - - - 16 - 145 - 210 - - - 255 - 255 - 255 - - - 0 - 0 - 255 - - - 255 - 0 - 255 - - - 232 - 232 - 232 - + + + + 0 + 0 + 0 + + + + + + + 230 + 240 + 249 + + + + + + + 255 + 255 + 255 + + + + + + + 242 + 247 + 252 + + + + + + + 115 + 120 + 124 + + + + + + + 154 + 160 + 166 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 16 + 145 + 210 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 232 + 232 + 232 + + + - - 0 - 0 - 0 - - - 230 - 240 - 249 - - - 255 - 255 - 255 - - - 255 - 255 - 255 - - - 115 - 120 - 124 - - - 154 - 160 - 166 - - - 0 - 0 - 0 - - - 255 - 255 - 255 - - - 0 - 0 - 0 - - - 255 - 255 - 255 - - - 255 - 255 - 255 - - - 0 - 0 - 0 - - - 16 - 145 - 210 - - - 255 - 255 - 255 - - - 0 - 0 - 255 - - - 255 - 0 - 255 - - - 232 - 232 - 232 - + + + + 0 + 0 + 0 + + + + + + + 230 + 240 + 249 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 115 + 120 + 124 + + + + + + + 154 + 160 + 166 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 16 + 145 + 210 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 232 + 232 + 232 + + + - - 128 - 128 - 128 - - - 230 - 240 - 249 - - - 255 - 255 - 255 - - - 255 - 255 - 255 - - - 115 - 120 - 124 - - - 154 - 160 - 166 - - - 0 - 0 - 0 - - - 255 - 255 - 255 - - - 128 - 128 - 128 - - - 255 - 255 - 255 - - - 255 - 255 - 255 - - - 0 - 0 - 0 - - - 16 - 145 - 210 - - - 255 - 255 - 255 - - - 0 - 0 - 255 - - - 255 - 0 - 255 - - - 232 - 232 - 232 - + + + + 128 + 128 + 128 + + + + + + + 230 + 240 + 249 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 115 + 120 + 124 + + + + + + + 154 + 160 + 166 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 128 + 128 + 128 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 16 + 145 + 210 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 255 + + + + + + + 255 + 0 + 255 + + + + + + + 232 + 232 + 232 + + + @@ -638,17 +842,17 @@ - 3 + 9 6 - + - 1 - 1 + 0 + 0 0 0 @@ -806,8 +1010,8 @@ - 20 - 40 + 91 + 31 @@ -835,7 +1039,7 @@ - 11 + 9 6 @@ -847,62 +1051,65 @@ - - + + - Header: + Border above - - + + - Footer: + Border below - - + + - First header: + Contents - - + + - Last footer: + Header: - - + + + + Repeat this row as header on every (except the first) page + - Contents + on - - + + + + + - Border above + double - - + + - Border below + double - - - - Repeat this row as header on every (except the first) page - + + - on + First header: @@ -919,40 +1126,44 @@ - - - - Repeat this row as footer on every (except the last) page + + + + double + + + + - on + double - - + + - This row is the footer of the last page + Don't output the first header - on + is empty - - - - - + + - double + Footer: - - + + + + Repeat this row as footer on every (except the last) page + - double + on @@ -963,36 +1174,39 @@ - - + + double - - + + - double + Last footer: - - + + + + This row is the footer of the last page + - double + on - - + + double - - + + double @@ -1008,13 +1222,17 @@ - - - - Don't output the first header + + + + Caption: + + + + - is empty + on @@ -1054,7 +1272,7 @@ - 1 + 0 0 0 0 @@ -1078,7 +1296,7 @@ - 1 + 0 0 0 0 @@ -1118,7 +1336,7 @@ - 1 + 0 0 0 0 @@ -1136,24 +1354,16 @@ - - - qt_i18n.h - LengthCombo QComboBox
LengthCombo.h
- 0 -
GuiSetBorder QWidget
GuiSetBorder.h
- 0 -
@@ -1197,6 +1407,9 @@ lastfooterNoContentsCB newpageCB + + qt_i18n.h + diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index aa445ff517..2b2d57ae0f 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -151,6 +151,7 @@ TabularFeature tabularFeature[] = { Tabular::SET_LTLASTFOOT, "set-ltlastfoot" }, { Tabular::UNSET_LTLASTFOOT, "unset-ltlastfoot" }, { Tabular::SET_LTNEWPAGE, "set-ltnewpage" }, + { Tabular::TOGGLE_LTCAPTION, "toggle-ltcaption" }, { Tabular::SET_SPECIAL_COLUMN, "set-special-column" }, { Tabular::SET_SPECIAL_MULTI, "set-special-multi" }, { Tabular::SET_BOOKTABS, "set-booktabs" }, @@ -546,7 +547,8 @@ Tabular::RowData::RowData() endfirsthead(false), endfoot(false), endlastfoot(false), - newpage(false) + newpage(false), + caption(false) {} @@ -1280,6 +1282,7 @@ void Tabular::write(ostream & os) const << write_attribute("endfoot", row_info[i].endfoot) << write_attribute("endlastfoot", row_info[i].endlastfoot) << write_attribute("newpage", row_info[i].newpage) + << write_attribute("caption", row_info[i].caption) << ">\n"; for (col_type j = 0; j < column_info.size(); ++j) { os << " 0 && rightLine(cellIndex(r, c - 1)); ismulticol = isMultiColumn(cell) || (c == 0 && colleft != leftLine(cell)) - || (c > 0 && !(colleft || prevcellright) && leftLine(cell)) || ((colright || nextcolleft) && !rightLine(cell) && !nextcellleft) || (!colright && !nextcolleft && (rightLine(cell) || nextcellleft)) || (coldouble != celldouble); @@ -1922,6 +1949,9 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell, bool & ismulticol) int Tabular::TeXCellPostamble(odocstream & os, idx_type cell, bool ismulticol) const { int ret = 0; + row_type const r = cellRow(cell); + if (is_long_tabular && row_info[r].caption) + return ret; // usual cells if (getUsebox(cell) == BOX_PARBOX) @@ -3503,12 +3533,9 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, case Tabular::DELETE_COLUMN: case Tabular::COPY_ROW: case Tabular::COPY_COLUMN: - case Tabular::SET_ALL_LINES: - case Tabular::UNSET_ALL_LINES: case Tabular::SET_TOP_SPACE: case Tabular::SET_BOTTOM_SPACE: case Tabular::SET_INTERLINE_SPACE: - case Tabular::SET_BORDER_LINES: status.clear(); return true; @@ -3517,19 +3544,29 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, status.setOnOff(tabular.isMultiColumn(cur.idx())); break; + case Tabular::SET_ALL_LINES: + case Tabular::UNSET_ALL_LINES: + case Tabular::SET_BORDER_LINES: + status.enabled(!tabular.ltCaption(tabular.cellRow(cur.idx()))); + break; + case Tabular::TOGGLE_LINE_TOP: + status.enabled(!tabular.ltCaption(tabular.cellRow(cur.idx()))); status.setOnOff(tabular.topLine(cur.idx())); break; case Tabular::TOGGLE_LINE_BOTTOM: + status.enabled(!tabular.ltCaption(tabular.cellRow(cur.idx()))); status.setOnOff(tabular.bottomLine(cur.idx())); break; case Tabular::TOGGLE_LINE_LEFT: + status.enabled(!tabular.ltCaption(tabular.cellRow(cur.idx()))); status.setOnOff(tabular.leftLine(cur.idx())); break; case Tabular::TOGGLE_LINE_RIGHT: + status.enabled(!tabular.ltCaption(tabular.cellRow(cur.idx()))); status.setOnOff(tabular.rightLine(cur.idx())); break; @@ -3645,6 +3682,11 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, status.setOnOff(tabular.getLTNewPage(sel_row_start)); break; + case Tabular::TOGGLE_LTCAPTION: + status.enabled(sel_row_start == sel_row_end); + status.setOnOff(tabular.ltCaption(sel_row_start)); + break; + case Tabular::SET_BOOKTABS: status.setOnOff(tabular.use_booktabs); break; @@ -4375,6 +4417,13 @@ void InsetTabular::tabularFeatures(Cursor & cur, tabular.setLTNewPage(row, !tabular.getLTNewPage(row)); break; + case Tabular::TOGGLE_LTCAPTION: + cur.idx() = tabular.setLTCaption(row, !tabular.ltCaption(row)); + cur.pit() = 0; + cur.pos() = 0; + cur.selection() = false; + break; + case Tabular::SET_BOOKTABS: tabular.use_booktabs = true; break; diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 6a76127116..27b059dd0e 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -160,6 +160,8 @@ public: /// SET_LTNEWPAGE, /// + TOGGLE_LTCAPTION, + /// SET_SPECIAL_COLUMN, /// SET_SPECIAL_MULTI, @@ -406,6 +408,10 @@ public: /// bool getLTNewPage(row_type row) const; /// + idx_type setLTCaption(row_type row, bool what); + /// + bool ltCaption(row_type row) const; + /// bool haveLTHead() const; /// bool haveLTFirstHead() const; @@ -508,6 +514,8 @@ public: bool endlastfoot; /// row for a newpage bool newpage; + /// caption + bool caption; }; /// typedef std::vector row_vector; -- 2.39.2