Fix cline/cmidrule calculation once more

This commit is contained in:
Juergen Spitzmueller 2019-08-14 11:25:31 +02:00
parent 5621c12135
commit 28b126b100

View File

@ -2434,21 +2434,25 @@ void Tabular::TeXTopHLine(otexstream & os, row_type row, string const & lang,
} }
} else if (realfirstrow || have_trims) { } else if (realfirstrow || have_trims) {
string const cline = use_booktabs ? "\\cmidrule" : "\\cline"; string const cline = use_booktabs ? "\\cmidrule" : "\\cline";
for (auto & c : columns) { col_type c = 0;
for (auto & cl : columns) {
if (cl < c)
continue;
c = cl;
if (topline.find(c)->second) { if (topline.find(c)->second) {
col_type offset = 0; col_type offset = 0;
for (col_type j = 0 ; j < c; ++j) for (col_type j = 0 ; j < c; ++j)
if (column_info[j].alignment == LYX_ALIGN_DECIMAL) if (column_info[j].alignment == LYX_ALIGN_DECIMAL)
++offset; ++offset;
string const firstcol = convert<string>(c + 1 + offset);
while (isPartOfMultiColumn(row, c)) while (isPartOfMultiColumn(row, c))
++c; ++c;
string trim; string trim;
if (topltrims.find(c) != topltrims.end() if (topltrims.find(c) != topltrims.end()
&& topltrims.find(c)->second) && topltrims.find(c)->second)
trim = "l"; trim = "l";
string const firstcol = convert<string>(c + 1 + offset);
col_type cstart = c; col_type cstart = c;
for ( ; c < ncols() && topline.find(c)->second ; ++c) { for ( ; c < ncols() - 1 && topline.find(c + 1)->second ; ++c) {
if (isMultiColumn(cellIndex(row, c)) if (isMultiColumn(cellIndex(row, c))
&& c < ncols() - 1 && isPartOfMultiColumn(row, c + 1)) && c < ncols() - 1 && isPartOfMultiColumn(row, c + 1))
continue; continue;
@ -2465,7 +2469,7 @@ void Tabular::TeXTopHLine(otexstream & os, row_type row, string const & lang,
for (col_type j = cstart ; j < c ; ++j) for (col_type j = cstart ; j < c ; ++j)
if (column_info[j].alignment == LYX_ALIGN_DECIMAL) if (column_info[j].alignment == LYX_ALIGN_DECIMAL)
++offset; ++offset;
col_type const lastcol = c + offset; col_type const lastcol = c + 1 + offset;
if (toprtrims.find(c) != toprtrims.end() if (toprtrims.find(c) != toprtrims.end()
&& toprtrims.find(c)->second) && toprtrims.find(c)->second)
trim += "r"; trim += "r";
@ -2486,6 +2490,7 @@ void Tabular::TeXTopHLine(otexstream & os, row_type row, string const & lang,
os << lastcol << "}"; os << lastcol << "}";
if (c == ncols() - 1) if (c == ncols() - 1)
break; break;
++c;
} }
} }
} }
@ -2563,26 +2568,31 @@ void Tabular::TeXBottomHLine(otexstream & os, row_type row, string const & lang,
os << "\\hline "; os << "\\hline ";
} else { } else {
string const cline = use_booktabs ? "\\cmidrule" : "\\cline"; string const cline = use_booktabs ? "\\cmidrule" : "\\cline";
for (auto & c : columns) { col_type c = 0;
for (auto & cl : columns) {
if (cl < c)
continue;
c = cl;
if (bottomline.find(c)->second) { if (bottomline.find(c)->second) {
col_type offset = 0; col_type offset = 0;
for (col_type j = 0 ; j < c; ++j) for (col_type j = 0 ; j < c; ++j)
if (column_info[j].alignment == LYX_ALIGN_DECIMAL) if (column_info[j].alignment == LYX_ALIGN_DECIMAL)
++offset; ++offset;
string const firstcol = convert<string>(c + 1 + offset);
while (isPartOfMultiColumn(row, c)) while (isPartOfMultiColumn(row, c))
++c; ++c;
string trim; string trim;
if (bottomltrims.find(c) != bottomltrims.end() if (bottomltrims.find(c) != bottomltrims.end()
&& bottomltrims.find(c)->second) && bottomltrims.find(c)->second)
trim = "l"; trim = "l";
string const firstcol = convert<string>(c + 1 + offset);
col_type cstart = c; col_type cstart = c;
for ( ; c < ncols() && bottomline.find(c)->second ; ++c) { for ( ; c < ncols() - 1 && bottomline.find(c + 1)->second ; ++c) {
if (isMultiColumn(cellIndex(row, c)) if (isMultiColumn(cellIndex(row, c))
&& c < ncols() - 1 && c < ncols() - 1
&& isPartOfMultiColumn(row, c + 1)) && isPartOfMultiColumn(row, c + 1))
continue; continue;
if (c > cstart && bottomltrims.find(c) != bottomltrims.end() if (c > cstart
&& bottomltrims.find(c) != bottomltrims.end()
&& bottomltrims.find(c)->second) { && bottomltrims.find(c)->second) {
if (!isPartOfMultiColumn(row, c)) if (!isPartOfMultiColumn(row, c))
--c; --c;
@ -2595,7 +2605,7 @@ void Tabular::TeXBottomHLine(otexstream & os, row_type row, string const & lang,
for (col_type j = cstart ; j < c ; ++j) for (col_type j = cstart ; j < c ; ++j)
if (column_info[j].alignment == LYX_ALIGN_DECIMAL) if (column_info[j].alignment == LYX_ALIGN_DECIMAL)
++offset; ++offset;
col_type const lastcol = c + offset; col_type const lastcol = c + 1 + offset;
if (bottomrtrims.find(c) != bottomrtrims.end() if (bottomrtrims.find(c) != bottomrtrims.end()
&& bottomrtrims.find(c)->second) && bottomrtrims.find(c)->second)
trim += "r"; trim += "r";
@ -2616,6 +2626,7 @@ void Tabular::TeXBottomHLine(otexstream & os, row_type row, string const & lang,
os << lastcol << "}"; os << lastcol << "}";
if (c == ncols() - 1) if (c == ncols() - 1)
break; break;
++c;
} }
} }
} }