summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-04-08 15:05:50 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-04-12 11:40:06 +0200
commitd4f46f0968c30d525c9a5274c6ffeac2f8358262 (patch)
tree74db75d4440b3c23e718560784030438610066d4
parent8a62db9759696cd3e5ba980f687c9be91490b4a5 (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> (cherry picked from commit 126b1826c465002dccc7c354a584731fa70ec5fd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132708 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sc/source/core/data/column2.cxx2
1 files changed, 1 insertions, 1 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 92f57bc765a5..d584f11df806 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -822,7 +822,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