On 19 Mar 2011, at 22:22, Matthias Reischenbacher wrote:
(Note: actually slightly off-topic for the users list... ;-))
> Today I had been looking at the same code as you and I found it odd that the
> table keep condition is only taken into account inside
> TableStepper.getCombinedKnuthElementsForRowGroup() if the rowFinished value
> is set to false. Do you have any idea what rowFinished means in this
> context? When debugging the code with my test case the value of rowFinished
> is always true and therefore the if statement seems to be dead code.
Unfortunately, I have not yet spent too much time in the table-layout code, so
I am unsure of its precise meaning. Did you try debugging a variety of cases,
or only this particular case? If I were to venture a guess, I would say it is
related to cases where there are overlapping row-spans (?)
> Do you think it would be a solution to just move out lines 250 and 252 of
> the if statement and execute it always. Perhaps then the additional keep
> condition handling inside TableContentLM.getKnuthElementsForRowIterator()
> could be removed?
That was my first thought as well. The issue seemed to be that
LayoutContext.clearKeepsPending() is called, and the very first call to
RowGroupLM.getNextKE() has both keep-with-previous and keep-with-next set to
"auto", which it passes down to the TableCellLM.
Only when there is at least one more row-group, the table's keep-together
starts weighing in, but only as of that latter row-group. Within the first
row-group, breaks would still be allowed.
Forcing the keeps there, however, does not seem to solve the issue, because, as
you point out, they are overridden again in TableStepper.getCombined...() So,
the code needs a correction there.
I quickly tried starting off getTableLM().getKeepTogether(), instead of
Keep.KEEP_AUTO (around line 240), which goes in the right direction. It moves
the entire table to the second page, but also enforces a keep-with-previous
between the preceding block, dragging that along. Similar effects are to be
expected with a following block, and keep-with-next.