On Feb 12, 2007, at 20:02, Andreas L Delmelle wrote:
On Feb 12, 2007, at 18:00, Vincent Hennebert wrote:
So my question is: is there a possibility of creating a tree of FObj
instances from a corresponding FO fragment, and use it to feed
objects
from the layout engine in order to unit test them? It doesn't seem
to be
the case currently, but how difficult would it be to extract that
from
the current codebase?
The code that constructs a tree of FObjs is located in
fop.fo.FOTreeBuilder: catching SAX startElement() events and
constructing FONodes + trigger the creation of PropertyLists from
the Attributes.
Unfortunately, FOTreeBuilder currently only accommodates
construction of a complete FOTree, starting with the root.
Once a sufficient part of the FOTree is available, the
LayoutManagers are created from the FO subtrees in the main loops
of the getNextKnuthElements() methods (getChildLM() ->
getNextChildLMs()), ultimately triggered by
AreaTreeHandler.endPageSequence().
To elaborate a bit on ideas on how to extract/implement it:
If all you need is
a) a way to test simple documents (build a complete FOTree of them), and
b) only need to control the instantiation of the LMs
then I guess you could create your own subclass of FOEventHandler,
and catch the FO events as they occur. You could write a
FOEventHandler that only handles table-related FOs in a document, and
ignores all the others. They will still be created, by the
FOTreeBuilder, though...
Advantage is that the default AreaTreeHandler can quite easily be
overridden/replaced by a custom one. (The RTFHandler is an example)
If you also need control over the FOTree creation, then you'll need a
special FOSubTreeBuilder as well.
Cheers,
Andreas