Closed Thejipppp closed 3 years ago
I see that the problem is the filter, and row 2 doesn't have a cell with a row span of 1. But I think it's a valid table though?
Changing it to this makes a stackoverflow, so that's also no solution π
Wow. With implementing row spanning I really opened the Pandora's box... π
Interesting indeed. I will have a look. But no idea if I am able and willing to fix this π
Regarding your picture of the table where each row is colored: There is indeed a difficulty with calculating the height of the yellow part in line 2:
What height should it get? The base height of the regular cells of row 2? But what is it if there is not at least one regular cell in there (i.e. a cell with row span == 1
)?
One option would be to set it to some (configurable?) default height like so:
public float getHeight() {
if (table == null) {
throw new TableNotYetBuiltException();
}
if (height == null) {
this.height = getCells().stream()
.filter(cell -> cell.getRowSpan() == 1)
.map(AbstractCell::getHeight)
.max(naturalOrder())
.orElse(DEFAULT_HEIGHT); // or maybe defaultRowHeight which can be set explicitly ...
}
return height;
}
I am not quite sure yet though if there is any bigger drawback then but can it be worse than a RuntimeException
? :thinking: :smile:
Fixed in v0.8.2 using the approach described above.
Hi
Please don't hate me π The idea of making a general splitter is riping in my head, but it needs some time. In the meanwhile, I found another bug. I'm trying to split my own tables over different pages with A LOT of extra code to do that, but now I found a table that crashes when you ask for it's height. Without height, I can't split. Maybe interesting, the height is on purpose bigger than one page, that is why Lorem Ipsum is fed in π
The code crashes here, in Row.getHeight()
Structure of the table looks like this, each color is a row.
In words, it looks like this
or what you would like more, in code: