You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Peter Herweg <ph...@web.de> on 2004/01/26 16:17:00 UTC

RTF: white-space-treatment and linefeed-treatment

Hello,

i am currently working on support for white-space-treatment and
linefeed-treatment for the RTF module. Of course i don't want to reinvent
the wheel, so i tried wanted Block.handleWhiteSpace method to do the job.

But when i read the text data which is passed to RtfHandler.characters there
is no support for white-space-treatment and linefeed-treatment. The
handleWhiteSpace method seems to process the text data at later time.

If i loop through Block.children in RtfHandler.endBlock and look for FOText
objects the text data is processed correctly. But unfortunately i need the
text data in RtfHandler.characters - in RtfHandler.endBlock it's to late.

I see following possibilities to solve this problem:

(1) I re-implement support for white-space-treatment and linefeed-treatment
in the RTF module and call this algorithm from RtfHandler.characters -
independend of Block.handleWhiteSpace. (IMHO not a good idea)

(2) I defer the processing of all inline-generating, text-containing FOs,
and process them in RtfHandler.endBlock. (Maybe it could be difficult to
determine when to defer processing and when not. For example i'll have to be
carefull with nested fo:block's. Quite difficult.)

(3) I defer the processing of all FOs until endPageSequence, and then loop
recursively through all children and call startXXX and endXXX events
explicitly. (Maybe the best solution. On one hand this would be a quite big
revolution for just two properties, on the other hand maybe there are
similar issues in future.)

Any comments or opinions appreciated.

Kind regards
Peter Herweg



RE: AW: RTF: white-space-treatment and linefeed-treatment

Posted by Peter Herweg <ph...@web.de>.
> I think you can flush the queue each time a nested block
> starts and each time a block ends.

I have no queue to flush. All i do is ignoring all event handler functions
until endBlock is called for a not-nested Block. Then i iterate recursively
through its children an call all appropriate event handlers.

For this purpose i have implemented a reference counter. Eachtime startBlock
is entered the counter is incremented. Eachtime endBlock is entered the
counter is decremented. So when the reference counter reachs 0, a not-nested
block is finished and i can process all deferred FOs. Works quite good.

Kind regards
Peter Herweg

> -----Original Message-----
> From: fop-dev-return-23052-pherweg=web.de@xml.apache.org
> [mailto:fop-dev-return-23052-pherweg=web.de@xml.apache.org]On Behalf Of
> J.Pietschmann
> Sent: Tuesday, January 27, 2004 9:16 PM
> To: fop-dev@xml.apache.org
> Subject: Re: AW: RTF: white-space-treatment and linefeed-treatment
>
>
> Peter Herweg wrote:
> > Maybe difficulties is the wrong word. Just a thing i have to
> care for. If i
> > do the processing of FOs in endBlock, i have to suppress the processing
> > within nested blocks. Or the nested blocks will be processed twice.
>
> I think you can flush the queue each time a nested block
> starts and each time a block ends. The start of a new block
> forces a new line, so you can finish the current line,
> including whitespace processing.
>
> J.Pietschmann


Re: AW: RTF: white-space-treatment and linefeed-treatment

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Peter Herweg wrote:
> Maybe difficulties is the wrong word. Just a thing i have to care for. If i
> do the processing of FOs in endBlock, i have to suppress the processing
> within nested blocks. Or the nested blocks will be processed twice.

I think you can flush the queue each time a nested block
starts and each time a block ends. The start of a new block
forces a new line, so you can finish the current line,
including whitespace processing.

J.Pietschmann

AW: RTF: white-space-treatment and linefeed-treatment

Posted by Peter Herweg <ph...@web.de>.
> What are the difficulties for nested blocks?

Maybe difficulties is the wrong word. Just a thing i have to care for. If i
do the processing of FOs in endBlock, i have to suppress the processing
within nested blocks. Or the nested blocks will be processed twice.

Kind regards
Peter Herweg


> -----Ursprungliche Nachricht-----
> Von: fop-dev-return-23036-pherweg=web.de@xml.apache.org
> [mailto:fop-dev-return-23036-pherweg=web.de@xml.apache.org]Im Auftrag
> von J.Pietschmann
> Gesendet: Monday, January 26, 2004 8:58 PM
> An: fop-dev@xml.apache.org
> Betreff: Re: RTF: white-space-treatment and linefeed-treatment
>
>
> Peter Herweg wrote:
> > (2) I defer the processing of all inline-generating,
> text-containing FOs,
> > and process them in RtfHandler.endBlock.
>
> I'd say start with this option, although I'm starting to believe we
> could and should move whitespace processing to before the invocation
> of the structure renderer's character event call. You still have to
> delay some output because space before/after a line break must be
> stripped for many settings.
>
> What are the difficulties for nested blocks?
>
> J.Pietschmann


Re: RTF: white-space-treatment and linefeed-treatment

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Peter Herweg wrote:
> (2) I defer the processing of all inline-generating, text-containing FOs,
> and process them in RtfHandler.endBlock.

I'd say start with this option, although I'm starting to believe we
could and should move whitespace processing to before the invocation
of the structure renderer's character event call. You still have to
delay some output because space before/after a line break must be
stripped for many settings.

What are the difficulties for nested blocks?

J.Pietschmann