From 7f78050957635c50d55a42d66b2d6401fc307919 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 23 Jan 2021 15:22:09 +0100 Subject: [PATCH] Fix metrics of varwidth cells (#12089) --- src/insets/InsetTabular.cpp | 5 +++-- src/insets/InsetTabular.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index c7785d68ab..7636c46e85 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -1385,6 +1385,7 @@ bool Tabular::setMColumnPWidth(Cursor & cur, idx_type cell, bool Tabular::toggleVarwidth(idx_type cell, bool const varwidth) { column_info[cellColumn(cell)].varwidth = varwidth; + cellInset(cell).get()->toggleVarWidth(varwidth); return true; } @@ -4194,7 +4195,7 @@ Tabular::BoxType Tabular::useBox(idx_type cell) const ///////////////////////////////////////////////////////////////////// InsetTableCell::InsetTableCell(Buffer * buf) - : InsetText(buf, InsetText::PlainLayout), isFixedWidth(false), + : InsetText(buf, InsetText::PlainLayout), isFixedWidth(false), isVarwidth(false), isMultiColumn(false), isMultiRow(false), contentAlign(LYX_ALIGN_CENTER) {} @@ -4288,7 +4289,7 @@ void InsetTableCell::metrics(MetricsInfo & mi, Dimension & dim) const // We tell metrics here not to expand on multiple pars // This is the difference to InsetText::Metrics - if (hasFixedWidth()) + if (hasFixedWidth() || isVarwidth) tm.metrics(mi, dim, mi.base.textwidth, false); else tm.metrics(mi, dim, 0, false); diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index a405591af5..0bf0235985 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -68,6 +68,8 @@ public: /// void toggleFixedWidth(bool fw) { isFixedWidth = fw; } /// + void toggleVarWidth(bool vw) { isVarwidth = vw; } + /// void toggleMultiCol(bool m) { isMultiColumn = m; } /// void toggleMultiRow(bool m) { isMultiRow = m; } @@ -123,6 +125,8 @@ private: /// bool isFixedWidth; /// + bool isVarwidth; + /// bool isMultiColumn; /// bool isMultiRow;