diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-04-08 15:05:50 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-04-08 16:44:51 +0200 |
commit | 126b1826c465002dccc7c354a584731fa70ec5fd (patch) | |
tree | cb04182a2b2ef3e8d22ef24f3a3316ba33f8fd8c | |
parent | ad7b90fc541413f091f6ff4bc7e2ced9fee8700b (diff) |
tdf#148423: Half a hack
"Regression" introduced with de4d296619b978ec303f1d7b1e2c78e13fa7a512 "Avoid
overflow in ScColumn::GetOptimalColWidth", which, for this bug document's
nWidth/nPPTX = 6004/0.0647708 = 92696.1, changed the calculation of nTwips from
the undefined-behavior 92696 % 65536 = 27161 to the clamped 65535, but which is
apparently a value large enough to cause "silent" issues (i.e., not causing
further undefined behavior) down the road, leading to a super-narrow column.
That commit already wondered whether sal_uInt16 is a useful choice here, but
lets keep that question unanswered and just clamp at half the previous value,
which happens to cause presumably more pleasing results.
Change-Id: I1df642b2b9d6818c8be0f8d8f4567a00c399c154
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132734
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | sc/source/core/data/column2.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 249d4c1346ac..f0270e07eee9 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -825,7 +825,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( { nWidth += 2; sal_uInt16 nTwips = static_cast<sal_uInt16>( - std::min(nWidth / nPPTX, double(std::numeric_limits<sal_uInt16>::max()))); + std::min(nWidth / nPPTX, double(std::numeric_limits<sal_uInt16>::max() / 2))); return nTwips; } else |