[reportlab-users] bugfix for reordering problem
Matt Folwell
mjf at pearson.co.uk
Thu Jan 28 07:52:51 EST 2010
On 28/01/2010 10:52, Robin Becker wrote:
> On 27/01/2010 16:32, Robert Hölzl wrote:
> I'm not certain I understand the problem you are encountering; if I use
> KeepTogether instead of your SmartKeepTogether in your script
> then the result looks like test_ok.pdf; if I use your SmartKeepTogether
> then the result looks like test_error.pdf.
>
> However, it seems you wish to achieve something else with your class. So
> far as I can tell it seems to be performing as expected from its
> definition.
>
Robert's SmartKeepTogether is trying to do this:
If the content fits in the current frame, just issue the content.
If the content doesn't fit in the current frame, but we're already at the
top of the frame, just issue the content and let it overflow.
If the content doesn't fit in the current frame, and we're not at the top,
issue a break + the content.
It handles the last 2 by always issuing a NotAtTopPageBreak
The problem would be clear if he'd added another flowable to his story, like
the attached. The page break is delayed until after the contents of the
SmartKeepTogether.
The problem comes from how generated content interacts with split():
Normally we pop a flowable from the front of the flowables list and handle
it. Then, if it produced any generated content, the is inserted at the start
of the flowables list.
When a flowable splits, we immediately handle the first item produced, and
insert the rest at the start of the flowables list.
But if the first item from the split produces generated content, that gets
inserted at the start of the flowables list, and then the rest of the split
gets inserted before it.
Robert's patch reverse the order of those two inserts, so in the resulting
flowables list you get the generated content from the first split item
before the rest of the split items.
A couple more questions:
If frame.split() is allowed to add generated content where should that
content go? Possibly another call to _addGeneratedContent is needed there.
Line 775 of doctemplate.py postpones handling PageBreaks and ActionFlowables
when they're the first item of a split. Should that also apply to
FrameActionFlowables?
That would solve this instance of the problem, but it would still remain
if non-action flowables add generated content.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: reordering_test2.py
Url: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100128/4dcba7a7/attachment.ksh>
More information about the reportlab-users
mailing list