commit 94b3f6e4e2b09509f36fe66f94aae8593d07440d
Author: Juergen Spitzmueller <[email protected]>
Date: Tue Jul 8 11:34:57 2025 +0200
Fix tabular metrics calculation
with xtabular, varwidth columns and a multicol spanning
the whole tabular
(cherry picked from commit 203d3b00dbc8de7ee9d1f3d80cdf0a1396a286e0)
---
src/frontends/qt/GuiTabular.cpp | 2 ++
src/insets/InsetTabular.cpp | 14 ++++++++++++--
src/support/Length.cpp | 9 +++++++++
src/support/Length.h | 2 ++
status.24x | 3 +++
5 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/frontends/qt/GuiTabular.cpp b/src/frontends/qt/GuiTabular.cpp
index 26f3f6debb..a045613431 100644
--- a/src/frontends/qt/GuiTabular.cpp
+++ b/src/frontends/qt/GuiTabular.cpp
@@ -183,6 +183,8 @@ GuiTabular::GuiTabular(QWidget * parent)
this, SLOT(checkEnabled()));
connect(tabularWidthED, SIGNAL(textEdited(const QString &)),
this, SLOT(checkEnabled()));
+ connect(tabularWidthUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SLOT(checkEnabled()));
decimalPointED->setValidator(new
QRegularExpressionValidator(QRegularExpression("\\S"), this));
decimalPointED->setMaxLength(1);
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 838008fda9..37d4daa7db 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -1309,9 +1309,14 @@ bool Tabular::updateColumnWidths(MetricsInfo & mi)
// If no tabular width is specified with X columns,
// we use 100% colwidth
tab_width = Length(100, Length::PCW);
+ int table_width = mi.base.inPixels(tab_width);
+ if (tab_width.isWorkareaWidth())
+ // Subtract the additional widths from the table width
+ // to keep the too large markers sleeping
+ table_width -= 2 * ADD_TO_TABULAR_WIDTH;
int restwidth = -1;
if (!tab_width.zero()) {
- restwidth = mi.base.inPixels(tab_width);
+ restwidth = table_width;
// Subtract the fixed widths from the table width
for (auto const & w : max_pwidth)
restwidth -= w.second;
@@ -1384,7 +1389,12 @@ bool Tabular::updateColumnWidths(MetricsInfo & mi)
for(col_type j = c; j < c + span ; ++j)
old_width += column_info[j].width;
- if (cellInfo(i).width > old_width) {
+ if (tabularx && span == int(ncols())) {
+ // With tabularx and multicolumns spanning all
columns,
+ // we assign tabular width
+ column_info[c + span - 1].width +=
max(table_width, column_info[c + span - 1].width) - old_width;
+ update = false;
+ } else if (cellInfo(i).width > old_width) {
column_info[c + span - 1].width +=
cellInfo(i).width - old_width;
// Do not trigger update when no space is left
for variable
// columns, as this will loop
diff --git a/src/support/Length.cpp b/src/support/Length.cpp
index e4339953cf..05afd08163 100644
--- a/src/support/Length.cpp
+++ b/src/support/Length.cpp
@@ -278,6 +278,15 @@ Length::UNIT Length::defaultUnit()
}
+bool Length::isWorkareaWidth() const
+{
+ return val_ == 100.0
+ && (unit_ == PCW
+ || unit_ == PTW
+ || unit_ == PLW);
+}
+
+
/////////////////////////////////////////////////////////////////////
//
// GlueLength
diff --git a/src/support/Length.h b/src/support/Length.h
index cb612b6135..9556ebd712 100644
--- a/src/support/Length.h
+++ b/src/support/Length.h
@@ -80,6 +80,8 @@ public:
bool zero() const { return val_ == 0.0; }
///
bool empty() const { return unit_ == Length::UNIT_NONE; }
+ /// This amounts to 100% of the workarea width
+ bool isWorkareaWidth() const;
/// return string representation
std::string const asString() const;
/// return string representation
diff --git a/status.24x b/status.24x
index 78636c8980..52072738fe 100644
--- a/status.24x
+++ b/status.24x
@@ -57,6 +57,9 @@ What's new
* USER INTERFACE
+- Fix tabular metrics crash with with xtabular, varwidth columns and a
+ multicol spanning the whole table.
+
- Fix false warning when closing document settings with read-only document.
- In mathed, do not wrap \underbar in \text.
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs