images/tabular-feature_multicolumn.svgz \
images/tabular-feature_multirow.svgz \
images/tabular-feature_reset-formal-default.svgz \
- images/tabular-feature_set-all-lines.svgz \
+ images/tabular-feature_toggle-all-lines.svgz \
images/tabular-feature_set-longtabular.svgz \
images/tabular-feature_set-rotate-cell.svgz \
- images/tabular-feature_set-border-lines.svgz \
- images/tabular-feature_set-inner-lines.svgz \
+ images/tabular-feature_toggle-border-lines.svgz \
+ images/tabular-feature_toggle-inner-lines.svgz \
images/tabular-feature_set-rotate-tabular.svgz \
images/tabular-feature_toggle-line-bottom.svgz \
images/tabular-feature_toggle-line-left.svgz \
images/oxygen/tabular-feature_multicolumn.svgz \
images/oxygen/tabular-feature_multirow.svgz \
images/oxygen/tabular-feature_reset-formal-default.svgz \
- images/oxygen/tabular-feature_set-all-lines.svgz \
- images/oxygen/tabular-feature_set-border-lines.svgz \
- images/oxygen/tabular-feature_set-inner-lines.svgz \
+ images/oxygen/tabular-feature_toggle-all-lines.svgz \
+ images/oxygen/tabular-feature_toggle-border-lines.svgz \
+ images/oxygen/tabular-feature_toggle-inner-lines.svgz \
images/oxygen/tabular-feature_set-longtabular.svgz \
images/oxygen/tabular-feature_toggle-line-bottom.svgz \
images/oxygen/tabular-feature_toggle-line-left.svgz \
images/classic/tabular-feature_multicolumn.png \
images/classic/tabular-feature_multirow.png \
images/classic/tabular-feature_reset-formal-default.png \
- images/classic/tabular-feature_set-all-lines.png \
- images/classic/tabular-feature_set-border-lines.png \
- images/classic/tabular-feature_set-inner-lines.png \
+ images/classic/tabular-feature_toggle-all-lines.png \
+ images/classic/tabular-feature_toggle-border-lines.png \
+ images/classic/tabular-feature_toggle-inner-lines.png \
images/classic/tabular-feature_set-longtabular.png \
images/classic/tabular-feature_set-rotate-cell.png \
images/classic/tabular-feature_set-rotate-tabular.png \
#LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 608
+\lyxformat 609
\begin_document
\begin_header
\save_transient_properties true
\html_be_strict false
\docbook_table_output 0
\docbook_mathml_prefix 1
+\author -1382599118 "Daniel"
\author -712698321 "Jürgen Spitzmüller"
\author 630872221 "Jean-Pierre Chrétien" jeanpierre.chretien@free.fr
\end_header
arg "tabular-feature toggle-line-top"
\end_inset
- adds a line at the top of the current cell / row or of a selection
+
+\change_deleted -1382599118 1647157945
+adds
+\change_inserted -1382599118 1647157946
+toggles
+\change_unchanged
+ a line at the top of
+\change_inserted -1382599118 1647158116
+ every cell for
+\change_unchanged
+ the current
+\change_inserted -1382599118 1647157889
+ly
+\change_deleted -1382599118 1647157917
+ cell / row or of a
+\change_unchanged
+ select
+\change_deleted -1382599118 1647157923
+ion
+\change_inserted -1382599118 1647157925
+ed cells
+\change_unchanged
+
\end_layout
\begin_layout Labeling
arg "tabular-feature toggle-line-bottom"
\end_inset
- adds a line at the bottom of the current cell / row or of a selection
+
+\change_deleted -1382599118 1647157963
+adds
+\change_inserted -1382599118 1647157964
+toggles
+\change_unchanged
+ a line at the bottom of
+\change_inserted -1382599118 1647158114
+every cell for
+\change_unchanged
+the current
+\change_inserted -1382599118 1647157991
+ly
+\change_deleted -1382599118 1647158003
+ cell / row or of a
+\change_unchanged
+ select
+\change_deleted -1382599118 1647158007
+ion
+\change_inserted -1382599118 1647158009
+ed cells
+\change_unchanged
+
\end_layout
\begin_layout Labeling
arg "tabular-feature toggle-line-left"
\end_inset
- adds a line at the left side of the current cell / row or of a selection
+
+\change_deleted -1382599118 1647157971
+adds
+\change_inserted -1382599118 1647157972
+toggles
+\change_unchanged
+ a line at the left side of
+\change_inserted -1382599118 1647158111
+every cell for
+\change_unchanged
+the current
+\change_inserted -1382599118 1647158027
+ly
+\change_deleted -1382599118 1647158069
+ cell / row or of a
+\change_unchanged
+ select
+\change_deleted -1382599118 1647158043
+ion
+\change_inserted -1382599118 1647158044
+ed cells
+\change_unchanged
+
\end_layout
\begin_layout Labeling
arg "tabular-feature toggle-line-right"
\end_inset
- adds a line at the right side of the current cell / row or of a selection
+
+\change_deleted -1382599118 1647157974
+adds
+\change_inserted -1382599118 1647157975
+toggles
+\change_unchanged
+ a line at the right side of
+\change_inserted -1382599118 1647158109
+every cell for
+\change_unchanged
+the current
+\change_inserted -1382599118 1647158061
+ly
+\change_deleted -1382599118 1647158072
+ cell / row or of a
+\change_unchanged
+ select
+\change_deleted -1382599118 1647158078
+ion
+\change_inserted -1382599118 1647158082
+ed cells
\change_inserted -712698321 1554289731
\end_layout
\change_inserted -712698321 1554289910
\begin_inset Info
type "icon"
-arg "tabular-feature set-border-lines"
+arg "tabular-feature toggle-border-lines"
+\end_inset
+
+
+\change_deleted -1382599118 1647157966
+adds
+\change_inserted -1382599118 1647157967
+toggles
+\change_inserted -712698321 1554289910
+ a border around the currently selected cells
+\change_inserted -1382599118 1647040213
+
+\end_layout
+
+\begin_layout Labeling
+\labelwidthstring 00.00.0000
+
+\change_inserted -1382599118 1647158092
+\begin_inset Info
+type "icon"
+arg "tabular-feature toggle-inner-lines"
\end_inset
- adds a border around the currently selected cells
+ toggles inner lines for the currently selected cells
\change_unchanged
\end_layout
\labelwidthstring 00.00.0000
\begin_inset Info
type "icon"
-arg "tabular-feature set-all-lines"
+arg "tabular-feature toggle-all-lines"
\end_inset
adds lines around the current or selected cells - if the current cell is
{ Tabular::UNSET_MULTIROW, "unset-multirow", false },
{ Tabular::SET_MROFFSET, "set-mroffset", true },
{ Tabular::SET_ALL_LINES, "set-all-lines", false },
+ { Tabular::TOGGLE_ALL_LINES, "toggle-all-lines", false },
{ Tabular::RESET_FORMAL_DEFAULT, "reset-formal-default", false },
{ Tabular::UNSET_ALL_LINES, "unset-all-lines", false },
{ Tabular::TOGGLE_LONGTABULAR, "toggle-longtabular", false },
{ Tabular::SET_BOTTOM_SPACE, "set-bottom-space", true },
{ Tabular::SET_INTERLINE_SPACE, "set-interline-space", true },
{ Tabular::SET_BORDER_LINES, "set-border-lines", false },
+ { Tabular::TOGGLE_BORDER_LINES, "toggle-border-lines", false },
{ Tabular::TABULAR_VALIGN_TOP, "tabular-valign-top", false},
{ Tabular::TABULAR_VALIGN_MIDDLE, "tabular-valign-middle", false},
{ Tabular::TABULAR_VALIGN_BOTTOM, "tabular-valign-bottom", false},
{ Tabular::SET_DECIMAL_POINT, "set-decimal-point", true },
{ Tabular::SET_TABULAR_WIDTH, "set-tabular-width", true },
{ Tabular::SET_INNER_LINES, "set-inner-lines", false },
+ { Tabular::TOGGLE_INNER_LINES, "toggle-inner-lines", false },
{ Tabular::LAST_ACTION, "", false }
};
}
+bool Tabular::outsideBorders(
+ row_type const sel_row_start, row_type const sel_row_end,
+ col_type const sel_col_start, col_type const sel_col_end) const
+{
+ if (!use_booktabs)
+ for (row_type r = sel_row_start; r <= sel_row_end; ++r) {
+ if (!leftLine(cellIndex(r, sel_col_start))
+ || !rightLine(cellIndex(r, sel_col_end)))
+ return false;
+ }
+ for (col_type c = sel_col_start; c <= sel_col_end; ++c) {
+ if (!topLine(cellIndex(sel_row_start, c))
+ || !bottomLine(cellIndex(sel_row_end, c)))
+ return false;
+ }
+ return true;
+}
+
+
+bool Tabular::innerBorders(
+ row_type const sel_row_start, row_type const sel_row_end,
+ col_type const sel_col_start, col_type const sel_col_end) const
+{
+ // Single cell has no inner borders
+ if (sel_row_start == sel_row_end && sel_col_start == sel_col_end)
+ return false;
+ for (row_type r = sel_row_start; r <= sel_row_end; ++r)
+ for (col_type c = sel_col_start; c <= sel_col_end; ++c) {
+ idx_type const cell = cellIndex(r, c);
+ if ((r != sel_row_start && !topLine(cell)
+ && cell_info[r][c].multirow != CELL_PART_OF_MULTIROW)
+ || (!use_booktabs
+ && c != sel_col_start && !leftLine(cell)
+ && cell_info[r][c].multicolumn != CELL_PART_OF_MULTICOLUMN))
+ return false;
+ }
+ return true;
+}
+
+
+void Tabular::setLines(
+ row_type const sel_row_start, row_type const sel_row_end,
+ col_type const sel_col_start, col_type const sel_col_end,
+ bool setLinesInnerOnly, bool setLines)
+{
+ for (row_type r = sel_row_start; r <= sel_row_end; ++r)
+ for (col_type c = sel_col_start; c <= sel_col_end; ++c) {
+ idx_type const cell = cellIndex(r, c);
+ if (!(setLinesInnerOnly && r == sel_row_start)
+ // for multirows, cell is taken care of at beginning
+ && cell_info[r][c].multirow != CELL_PART_OF_MULTIROW)
+ setTopLine(cell, setLines);
+ if (!(setLinesInnerOnly && r == sel_row_end)
+ && (r == sel_row_end || (!setLines
+ // for multirows, cell is taken care of at the last part
+ && cell_info[r + 1][c].multirow != CELL_PART_OF_MULTIROW)))
+ setBottomLine(cell, setLines);
+ if (!(setLinesInnerOnly && c == sel_col_start)
+ // for multicolumns, cell is taken care of at beginning
+ && cell_info[r][c].multicolumn != CELL_PART_OF_MULTICOLUMN)
+ setLeftLine(cell, setLines);
+ if (!(setLinesInnerOnly && c == sel_col_end)
+ && (c == sel_col_end || (!setLines
+ // for multicolumns, cell is taken care of at the last part
+ && cell_info[r][c + 1].multicolumn != CELL_PART_OF_MULTICOLUMN)))
+ setRightLine(cell, setLines);
+ }
+}
+
+
pair<bool, bool> Tabular::topLineTrim(idx_type const cell) const
{
if (!use_booktabs)
status.setOnOff(tabular.isMultiRow(cur.idx()));
break;
+ case Tabular::TOGGLE_INNER_LINES:
+ status.setOnOff(tabular.innerBorders(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end));
+ status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
+ break;
+ case Tabular::TOGGLE_ALL_LINES:
+ status.setOnOff(tabular.innerBorders(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end)
+ && tabular.outsideBorders(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end));
+ status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
+ break;
case Tabular::SET_ALL_LINES:
case Tabular::UNSET_ALL_LINES:
case Tabular::SET_INNER_LINES:
+ status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
+ break;
+
+ case Tabular::TOGGLE_BORDER_LINES:
+ status.setOnOff(tabular.outsideBorders(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end));
+ // fall through
case Tabular::SET_BORDER_LINES:
status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
break;
row_type sel_row_start;
row_type sel_row_end;
bool setLines = false;
- bool setLinesInnerOnly = false;
+ bool toggle = false;
LyXAlignment setAlign = LYX_ALIGN_LEFT;
Tabular::VAlignment setVAlign = Tabular::LYX_VALIGN_TOP;
break;
}
+ case Tabular::TOGGLE_INNER_LINES:
+ toggle = true;
+ // fall through
case Tabular::SET_INNER_LINES:
- setLinesInnerOnly = true;
+ if (toggle)
+ setLines = !tabular.innerBorders(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end);
+ else
+ setLines = true;
+ tabular.setLines(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end,
+ true, setLines);
+ break;
+
+ case Tabular::TOGGLE_ALL_LINES:
+ toggle = true;
// fall through
case Tabular::SET_ALL_LINES:
- setLines = true;
+ if (toggle)
+ setLines = !tabular.innerBorders(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end)
+ || !tabular.outsideBorders(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end);
+ else
+ setLines = true;
// fall through
case Tabular::UNSET_ALL_LINES:
- for (row_type r = sel_row_start; r <= sel_row_end; ++r)
- for (col_type c = sel_col_start; c <= sel_col_end; ++c) {
- idx_type const cell = tabular.cellIndex(r, c);
- if (!setLinesInnerOnly || r != sel_row_start)
- tabular.setTopLine(cell, setLines);
- if ((!setLinesInnerOnly || r != sel_row_end)
- && (!setLines || r == sel_row_end))
- tabular.setBottomLine(cell, setLines);
- if ((!setLinesInnerOnly || c != sel_col_end)
- && (!setLines || c == sel_col_end))
- tabular.setRightLine(cell, setLines);
- if ((!setLinesInnerOnly || c != sel_col_start))
- tabular.setLeftLine(cell, setLines);
- }
+ tabular.setLines(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end,
+ false, setLines);
break;
case Tabular::RESET_FORMAL_DEFAULT:
}
break;
- case Tabular::SET_BORDER_LINES:
+ case Tabular::TOGGLE_BORDER_LINES:
+ toggle = true;
+ // fall through
+ case Tabular::SET_BORDER_LINES: {
+ bool const border = toggle &&
+ tabular.outsideBorders(sel_row_start, sel_row_end,
+ sel_col_start, sel_col_end)
+ ? false : true;
for (row_type r = sel_row_start; r <= sel_row_end; ++r) {
- tabular.setLeftLine(tabular.cellIndex(r, sel_col_start), true);
- tabular.setRightLine(tabular.cellIndex(r, sel_col_end), true);
+ tabular.setLeftLine(tabular.cellIndex(r, sel_col_start), border);
+ tabular.setRightLine(tabular.cellIndex(r, sel_col_end), border);
}
for (col_type c = sel_col_start; c <= sel_col_end; ++c) {
- tabular.setTopLine(tabular.cellIndex(sel_row_start, c), true);
- tabular.setBottomLine(tabular.cellIndex(sel_row_end, c), true);
+ tabular.setTopLine(tabular.cellIndex(sel_row_start, c), border);
+ tabular.setBottomLine(tabular.cellIndex(sel_row_end, c), border);
}
break;
+ }
case Tabular::TOGGLE_LONGTABULAR:
if (tabular.is_long_tabular)