[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master c3055e7 5/6: Don't shrink PDF table columns t
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master c3055e7 5/6: Don't shrink PDF table columns too much |
Date: |
Thu, 8 Mar 2018 21:04:49 -0500 (EST) |
branch: master
commit c3055e7848f1a3000892cd7b91d5fa71273999e5
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Don't shrink PDF table columns too much
The total width of the columns could be made less than the available
width if it had initially been too big as the code adjusting the margins
shrunk them too much, due to rounding errors inevitable when using
integer division.
Compensate for them by explicitly adding the "missing" pixels back.
---
wx_table_generator.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index 846254c..604351e 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -207,10 +207,18 @@ void
wx_table_generator::do_compute_column_widths_if_necessary()
// reduce them by up to half if really needed.
if(!num_expand)
{
+ // We need to round up in division here to be sure that all columns
+ // fit into the available width.
auto const overflow_per_column =
(overflow + num_columns - 1)/num_columns;
if(overflow_per_column <= column_margin_)
{
+ // We are going to reduce the total width by more than
+ // necessary, in general, because of rounding up above, so
+ // compensate for it by giving 1 extra pixel until we run out
+ // of these "underflow" pixels.
+ auto underflow = overflow_per_column*num_columns - overflow;
+
for(auto& i : columns_)
{
if(i.is_hidden())
@@ -219,6 +227,12 @@ void
wx_table_generator::do_compute_column_widths_if_necessary()
}
i.width_ -= overflow_per_column;
+
+ if(underflow > 0)
+ {
+ i.width_++;
+ underflow--;
+ }
}
column_margin_ -= (overflow_per_column + 1)/2;
- [lmi-commits] [lmi] master updated (2c3b7b1 -> e5e8b40), Greg Chicares, 2018/03/08
- [lmi-commits] [lmi] master 5d77eed 1/6: Remove executable bit from a PNG file, Greg Chicares, 2018/03/08
- [lmi-commits] [lmi] master 59e8cfe 2/6: Decrease margins in PDF illustrations, Greg Chicares, 2018/03/08
- [lmi-commits] [lmi] master cc8d6e6 4/6: Fix table column shrinking when some columns are hidden, Greg Chicares, 2018/03/08
- [lmi-commits] [lmi] master c3055e7 5/6: Don't shrink PDF table columns too much,
Greg Chicares <=
- [lmi-commits] [lmi] master e5e8b40 6/6: Rectify a technical term, Greg Chicares, 2018/03/08
- [lmi-commits] [lmi] master 7721184 3/6: Allocate more space for illustration table columns, Greg Chicares, 2018/03/08