mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 19:14:51 +00:00
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24598 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fc12716a97
commit
832bbc4329
@ -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():
|
||||
|
@ -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, "<row", m)
|
||||
r = m
|
||||
caption = 'false'
|
||||
for k in range(ncols):
|
||||
m = find_token(document.body, "<cell", m)
|
||||
if (k == 0):
|
||||
mend = find_token(document.body, "</cell>", 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, "<row", m)
|
||||
caption = get_option(document, m, 'caption', 'false')
|
||||
if caption == 'true':
|
||||
remove_option(document, m, 'caption')
|
||||
for k in range(ncols):
|
||||
m = find_token(document.body, "<cell", m)
|
||||
remove_option(document, m, 'multicolumn')
|
||||
if k == 0:
|
||||
m = find_token(document.body, "\\begin_inset Caption", m)
|
||||
if m == -1:
|
||||
return
|
||||
m = find_end_of_inset(document.body, m + 1)
|
||||
document.body[m] += wrap_into_ert("","","\\backslash\n\\backslash\n%")
|
||||
m = m + 1
|
||||
m = m + 1
|
||||
i = j + 1
|
||||
|
||||
|
||||
def convert_tablines(document):
|
||||
i = 0
|
||||
while True:
|
||||
@ -197,6 +280,15 @@ def revert_tablines(document):
|
||||
lines.append([top, bottom, left, right])
|
||||
m = m + 1
|
||||
|
||||
# we will want to ignore longtable captions
|
||||
m = i + 1
|
||||
caption_info = []
|
||||
for k in range(nrows):
|
||||
m = find_token(document.body, "<row", m)
|
||||
caption = get_option(document, m, 'caption', 'false')
|
||||
caption_info.append([caption])
|
||||
m = m + 1
|
||||
|
||||
m = i + 1
|
||||
col_info = []
|
||||
for k in range(ncols):
|
||||
@ -204,13 +296,13 @@ def revert_tablines(document):
|
||||
left = 'true'
|
||||
for l in range(nrows):
|
||||
left = lines[l*ncols + k][2]
|
||||
if left == 'false':
|
||||
if left == 'false' and caption_info[l] == 'false':
|
||||
break
|
||||
set_option(document, m, 'leftline', left)
|
||||
right = 'true'
|
||||
for l in range(nrows):
|
||||
right = lines[l*ncols + k][3]
|
||||
if right == 'false':
|
||||
if right == 'false' and caption_info[l] == 'false':
|
||||
break
|
||||
set_option(document, m, 'rightline', right)
|
||||
m = m + 1
|
||||
@ -223,12 +315,16 @@ def revert_tablines(document):
|
||||
top = lines[k*ncols + l][0]
|
||||
if top == 'false':
|
||||
break
|
||||
if caption_info[k] == 'false':
|
||||
top = 'false'
|
||||
set_option(document, m, 'topline', top)
|
||||
bottom = 'true'
|
||||
for l in range(ncols):
|
||||
bottom = lines[k*ncols + l][1]
|
||||
if bottom == 'false':
|
||||
break
|
||||
if caption_info[k] == 'false':
|
||||
bottom = 'false'
|
||||
set_option(document, m, 'bottomline', bottom)
|
||||
m = m + 1
|
||||
|
||||
@ -2139,9 +2235,11 @@ convert = [[277, [fix_wrong_tables]],
|
||||
[328, [remove_embedding, remove_extra_embedded_files, remove_inzip_options]],
|
||||
[329, []],
|
||||
[330, []],
|
||||
[331, [convert_ltcaption]],
|
||||
]
|
||||
|
||||
revert = [[329, [revert_leftarrowfill, revert_rightarrowfill, revert_upbracefill, revert_downbracefill]],
|
||||
revert = [[330, [revert_ltcaption]],
|
||||
[329, [revert_leftarrowfill, revert_rightarrowfill, revert_upbracefill, revert_downbracefill]],
|
||||
[328, [revert_master]],
|
||||
[327, []],
|
||||
[326, [revert_mexican]],
|
||||
|
@ -115,7 +115,7 @@ namespace os = support::os;
|
||||
|
||||
namespace {
|
||||
|
||||
int const LYX_FORMAT = 330;
|
||||
int const LYX_FORMAT = 331;
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -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;
|
||||
|
@ -67,6 +67,7 @@ private Q_SLOTS:
|
||||
void ltLastFooterBorderAbove_clicked();
|
||||
void ltLastFooterBorderBelow_clicked();
|
||||
void ltLastFooterEmpty_clicked();
|
||||
void on_captionStatusCB_toggled();
|
||||
|
||||
private:
|
||||
///
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 << "<cell"
|
||||
@ -1380,6 +1383,7 @@ void Tabular::read(Lexer & lex)
|
||||
getTokenValue(line, "endfoot", row_info[i].endfoot);
|
||||
getTokenValue(line, "endlastfoot", row_info[i].endlastfoot);
|
||||
getTokenValue(line, "newpage", row_info[i].newpage);
|
||||
getTokenValue(line, "caption", row_info[i].caption);
|
||||
for (col_type j = 0; j < column_info.size(); ++j) {
|
||||
l_getline(is, line);
|
||||
if (!prefixIs(line, "<cell")) {
|
||||
@ -1686,6 +1690,28 @@ bool Tabular::haveLTLastFoot() const
|
||||
}
|
||||
|
||||
|
||||
Tabular::idx_type Tabular::setLTCaption(row_type row, bool what)
|
||||
{
|
||||
idx_type i = getFirstCellInRow(row);
|
||||
if (what) {
|
||||
setMultiColumn(i, column_info.size());
|
||||
setTopLine(i, false);
|
||||
setBottomLine(i, false);
|
||||
setLeftLine(i, false);
|
||||
setRightLine(i, false);
|
||||
} else
|
||||
unsetMultiColumn(i);
|
||||
row_info[row].caption = what;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
bool Tabular::ltCaption(row_type row) const
|
||||
{
|
||||
return row_info[row].caption;
|
||||
}
|
||||
|
||||
|
||||
// end longtable support functions
|
||||
|
||||
void Tabular::setRowAscent(row_type row, int height)
|
||||
@ -1814,12 +1840,14 @@ int Tabular::TeXBottomHLine(odocstream & os, row_type row) const
|
||||
int Tabular::TeXCellPreamble(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;
|
||||
|
||||
Tabular::VAlignment valign = getVAlignment(cell, !isMultiColumn(cell));
|
||||
LyXAlignment align = getAlignment(cell, !isMultiColumn(cell));
|
||||
// figure out how to set the lines
|
||||
// we always set double lines to the right of the cell
|
||||
row_type const r = cellRow(cell);
|
||||
col_type const c = cellColumn(cell);
|
||||
col_type const nextcol = c + columnSpan(cell);
|
||||
bool colright = columnRightLine(c);
|
||||
@ -1832,7 +1860,6 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell, bool & ismulticol)
|
||||
bool prevcellright = c > 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;
|
||||
|
@ -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<RowData> row_vector;
|
||||
|
Loading…
Reference in New Issue
Block a user