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 woolly <p....@lbs-ltd.com> on 2006/10/05 12:00:34 UTC

Page-Number-Citation Alignment

Hi all,

I'm desperately trying to fix the page-number-citation justify alignment bug
as we came across it late in development of our product and the release date
is end of October! I'm new to Fop development and am kind of lost at the
moment. Has anyone worked on this problem and have any pointers? Am I
mailing the correct list (or is there a bugzilla type thing where people can
discuss this problem in particular)?

My understanding so far:

Fop reads in the fo source and creates an area tree from it.
Whilst the area tree is being created,
PageNumberCitationLayoutManager.getPageNumberCitationInlineArea(LayoutManager
parentLM) is used to generate InlineAreas. In this method, if the page
number is known, a TextArea is returned with the proper number, otherwise an
UnresolvedPageNumber containing the string "MMM" is returned
(UnresolvedPageNumber is a TextArea subclass).
More processing happens, all layout adjustments are made (I think this
happens in AbstractBreaker.doLayout())
Towards the end of creating the area tree, page-number-citations are
resolved through AreaTreeHandler.tryIDResolution()

Hence, the page numbers were "MMM" when all the layout was being done, but
are later changed to the correct number without any further layout change.

The problem seems to be that as the area tree is being created, a page is
laid out after each one is created, when really, the layout should come at
the end after all pages (and hence page-number-citation references) are
known.

Don't know how correct I am with this but any opinions / corrections / help
would be very gratefully received.

Thanks,

Phil.
-- 
View this message in context: http://www.nabble.com/Page-Number-Citation-Alignment-tf2387523.html#a6655821
Sent from the FOP - Dev mailing list archive at Nabble.com.


Re: Page-Number-Citation Alignment

Posted by Chris Bowditch <bo...@hotmail.com>.
woolly wrote:

<snip/>

> Fop reads in the fo source and creates an area tree from it.
> Whilst the area tree is being created,
> PageNumberCitationLayoutManager.getPageNumberCitationInlineArea(LayoutManager
> parentLM) is used to generate InlineAreas. In this method, if the page
> number is known, a TextArea is returned with the proper number, otherwise an
> UnresolvedPageNumber containing the string "MMM" is returned
> (UnresolvedPageNumber is a TextArea subclass).
> More processing happens, all layout adjustments are made (I think this
> happens in AbstractBreaker.doLayout())
> Towards the end of creating the area tree, page-number-citations are
> resolved through AreaTreeHandler.tryIDResolution()
> 
> Hence, the page numbers were "MMM" when all the layout was being done, but
> are later changed to the correct number without any further layout change.
> 
> The problem seems to be that as the area tree is being created, a page is
> laid out after each one is created, when really, the layout should come at
> the end after all pages (and hence page-number-citation references) are
> known.

I think your assesment is okay so far. Although IIUC your suggested 
"fix" will cause many other problems. The approach that was adopted in 
0.20.x was to do a minor correction on lines containing the 
page-number-citation at the same point as 
AreaTreeHandler.tryIDResolution is called. By minor correction I mean 
altering the word spacing on the line to compensate for the different 
width of the page number. Whilst this is a sub optimal solution it is 
prefarable to your solution or a solution involving two layout passes.

Just my 2 cents,

Chris




Re: Page-Number-Citation Alignment

Posted by Simon Pepping <sp...@leverkruid.eu>.
On Fri, Oct 13, 2006 at 10:31:48AM +0200, Jeremias Maerki wrote:
> Great work on the page-number-citiation front, Simon. I've just
> test-generated the XSLT 1.0 specification using FOP Trunk and all the
> page reference I've seen so far look good! Looks like this is a big step
> forward for DocBook users.

Actually, it is an extension of work that Luca did last year. It was a
lot of work to find out how exactly to extend it. All the time I
wondered whether I was letting myself be sidetracked or whether this
was useful stuff, especially for book-like publications. Fortunately,
the latter feeling prevailed. I am glad it is useful.

Simon

-- 
Simon Pepping
home page: http://www.leverkruid.eu

Re: Page-Number-Citation Alignment

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Great work on the page-number-citiation front, Simon. I've just
test-generated the XSLT 1.0 specification using FOP Trunk and all the
page reference I've seen so far look good! Looks like this is a big step
forward for DocBook users.

On 06.10.2006 20:06:28 Simon Pepping wrote:
> I fixed a bug in the rendering of the resolved page number. I hope
> that solves your problem.
> 
> Regards, Simon
> 
> On Thu, Oct 05, 2006 at 07:17:08AM -0700, woolly wrote:
> > 
> > Thanks for the help. As a temporary nasty hack I have simply done the
> > following in UnresolvedPageNumber.resolveIDRef(String id, List pages):
> > 
> > ================================================
> > String pg = page.getPageNumberString(); // original code, nasty hack follows
> > 
> > // pad out the word in the text area to be 
> > final int ESTIMATED_RESERVE = "MMM".length();
> > for (int i = 0; i < ESTIMATED_RESERVE - pg.length(); i++)
> > {
> >    // adding a double space which hopefully is the same as the letter "M"
> >    addWord("  ",0);
> > }
> > 
> > addWord(pg, 0); // back to original code again
> > ================================================
> > 
> > 
> > In my particular use case, this works, but I'll be looking at the proper
> > solutions and trying to implement them as well. Although I get the feeling
> > I'm going to be knee deep in XSL-FO spec before I work it out. If I manage a
> > real solution I'll be certain to post back here.
> > -- 
> > View this message in context: http://www.nabble.com/Page-Number-Citation-Alignment-tf2387523.html#a6659459
> > Sent from the FOP - Dev mailing list archive at Nabble.com.
> > 
> 
> -- 
> Simon Pepping
> home page: http://www.leverkruid.eu



Jeremias Maerki


Re: Page-Number-Citation Alignment

Posted by Simon Pepping <sp...@leverkruid.eu>.
I fixed a bug in the rendering of the resolved page number. I hope
that solves your problem.

Regards, Simon

On Thu, Oct 05, 2006 at 07:17:08AM -0700, woolly wrote:
> 
> Thanks for the help. As a temporary nasty hack I have simply done the
> following in UnresolvedPageNumber.resolveIDRef(String id, List pages):
> 
> ================================================
> String pg = page.getPageNumberString(); // original code, nasty hack follows
> 
> // pad out the word in the text area to be 
> final int ESTIMATED_RESERVE = "MMM".length();
> for (int i = 0; i < ESTIMATED_RESERVE - pg.length(); i++)
> {
>    // adding a double space which hopefully is the same as the letter "M"
>    addWord("  ",0);
> }
> 
> addWord(pg, 0); // back to original code again
> ================================================
> 
> 
> In my particular use case, this works, but I'll be looking at the proper
> solutions and trying to implement them as well. Although I get the feeling
> I'm going to be knee deep in XSL-FO spec before I work it out. If I manage a
> real solution I'll be certain to post back here.
> -- 
> View this message in context: http://www.nabble.com/Page-Number-Citation-Alignment-tf2387523.html#a6659459
> Sent from the FOP - Dev mailing list archive at Nabble.com.
> 

-- 
Simon Pepping
home page: http://www.leverkruid.eu

Re: Page-Number-Citation Alignment

Posted by woolly <p....@lbs-ltd.com>.
Thanks for the help. As a temporary nasty hack I have simply done the
following in UnresolvedPageNumber.resolveIDRef(String id, List pages):

================================================
String pg = page.getPageNumberString(); // original code, nasty hack follows

// pad out the word in the text area to be 
final int ESTIMATED_RESERVE = "MMM".length();
for (int i = 0; i < ESTIMATED_RESERVE - pg.length(); i++)
{
   // adding a double space which hopefully is the same as the letter "M"
   addWord("  ",0);
}

addWord(pg, 0); // back to original code again
================================================


In my particular use case, this works, but I'll be looking at the proper
solutions and trying to implement them as well. Although I get the feeling
I'm going to be knee deep in XSL-FO spec before I work it out. If I manage a
real solution I'll be certain to post back here.
-- 
View this message in context: http://www.nabble.com/Page-Number-Citation-Alignment-tf2387523.html#a6659459
Sent from the FOP - Dev mailing list archive at Nabble.com.


Re: Page-Number-Citation Alignment

Posted by Simon Pepping <sp...@leverkruid.eu>.
On Thu, Oct 05, 2006 at 03:00:34AM -0700, woolly wrote:
> 
> Hi all,
> 
> I'm desperately trying to fix the page-number-citation justify alignment bug
> as we came across it late in development of our product and the release date
> is end of October! I'm new to Fop development and am kind of lost at the
> moment. Has anyone worked on this problem and have any pointers? Am I
> mailing the correct list (or is there a bugzilla type thing where people can
> discuss this problem in particular)?
> 
> My understanding so far:
> 
> Fop reads in the fo source and creates an area tree from it.
> Whilst the area tree is being created,
> PageNumberCitationLayoutManager.getPageNumberCitationInlineArea(LayoutManager
> parentLM) is used to generate InlineAreas. In this method, if the page
> number is known, a TextArea is returned with the proper number, otherwise an
> UnresolvedPageNumber containing the string "MMM" is returned
> (UnresolvedPageNumber is a TextArea subclass).
> More processing happens, all layout adjustments are made (I think this
> happens in AbstractBreaker.doLayout())
> Towards the end of creating the area tree, page-number-citations are
> resolved through AreaTreeHandler.tryIDResolution()
> 
> Hence, the page numbers were "MMM" when all the layout was being done, but
> are later changed to the correct number without any further layout change.
> 
> The problem seems to be that as the area tree is being created, a page is
> laid out after each one is created, when really, the layout should come at
> the end after all pages (and hence page-number-citation references) are
> known.

That is almost not possible. Two suggestions have been made to correct
the problem:

1. Relayout the paragraph with the page number citation, when the
   citation has been resolved.

2. Write the resolved references to an auxiliary file, which on the
   next run could be loaded as hints for the values to be expected.

Neither is a small fix. But if you are willing to work on it,
especially 1), that would be cool.

Regards, Simon

-- 
Simon Pepping
home page: http://www.leverkruid.eu