Victor Mote wrote:

OK. I just committed a set of changes that should get you going. You will
need to create an instance of your subclass, then use the
LayoutManagerLS.setAddLMVisitor method to tell FOP to use that.

At the moment I can't find a way to either get hold of the assigned LayoutManagerLS instance or to set a new LayoutManagerLS. I assume that it is just a temporary issue as long as
- the Document creation is hardwired in Driver
- no accessor exists for currentDocument and
- the LayoutManagerLS creation is also hardwired in Driver.


Or perhaps I have just overlooked the right spot to access setAddLMVisitor.

> Also I added
some accessor methods in AddLMVisitor that will give your subclass access to
the list objects that are there, as you will probably need them.

Yes, I need some way to add the LM's, and the accessor is fine.


I tested it on my side by commenting out the method for "Block" in
AddLMVisitor, and creating a subclass that had only "Block" in it. I watched
it go through the debugger as expected & the output seemed fine. (That was
without any casting -- unless I am missing something, you should be able to
eliminate the cast in your code as well,

I could be wrong, but I dont't think I can get by without the cast. Without a cast the invocation in my acceptVisitor is compiled to java byte code:


invokevirtual <Method void serveVisitor(org.apache.fop.fo.FObjMixed)>

and with a cast it turns into:

invokevirtual <Method void serveVisitor(dk.innovasion.fop.TextField)>

The difference is that the FOTreeVisitor interface does not know anything about my FObjMixed subclass called dk.innovasion.fop.TextField. This is compiled with jdk1.4, but I think all java compilers must behave like this.

If you want to test this yourself, you should perhaps remove the serveVisitor(Block) method from both AddLMVisitor and from FOTreeVisitor.

Otherwise your changes works nicely for me. Thanks for your quick help and response.


[finn]


> I'm not sure how a AddLMVisitor subclass would work if two different
> extensions are used in the same document, but that is not an issue in
> my use.

[Victor]

> AFAIK, it should just be a matter of setting up a method in the
> subclass for each of the extensions. But maybe I am misunderstanding
> your question.

I was think of the situation where two independently developed extensions both need to add their own serveXXX methods to the AddLMVisitor instance. Since there is only one AddMVisitor instance, my extension will exclude the use of all other 3rd party extensions. But this is not yet an actual issue for me.


regards, finn



Reply via email to