On Jun 19, 2008, at 10:01, Jeremias Maerki wrote:
I'm coaching a developer implementing an "ODFHandler" for FOP and
during
implementation we've stumbled over something: the call sequence of
FOEventHandler methods is not correct. Assume the following FO:
<fo:block>
Text1
<fo:block>
Text2
</fo:block>
</fo:block>
The call sequence at the moment is:
startBlock()
startBlock()
characters(Text1)
characters(Text2)
endBlock()
endBlock()
That's due to flushText() processing in FObjMixed. startBlock() is
effectively called too soon. It would have to be deferred until the
first child is added to the block. Obviously that would apply to all
FObjMixed descendants.
I think this can be avoided in FOTreeBuilder itself. I seem to
remember having changed this locally at one point (but apparently
I've reverted this, even though, IIRC, it didn't have any noticeable
impact for the rest...)
Currently in MainFOHandler.startElement() we do, roughly:
1° newNode = FOMaker.make(parentNode);
2° newNode.startOfNode();
3° parentNode.addChildNode(newNode);
4° newNode = parentNode;
Step 2 and 3 should, IMO be swapped. startOfNode() should be called
after the new node has been added as a child, rather than before.
This should fix the problem, as flushText() for 'Text1' will then be
called before the inner block's startBlock(), but I haven't recently
tested if this breaks anything else...
HTH!
Andreas