Hi

I am new to this mailing list (also fop user mailing list too),
although I have been using FOP for about a year.

Anyway, I had a small problem with dots leader, they did not line up 
at the end, and the gap is less than one dot. But still my client 
didn't like it. (I am using FOP-0.20.5 July 15, 2003 build version)

My  stylesheet like this

<xsl:template match="tableContents">
    <fo:table table-layout="fixed">
        <fo:table-column column-width="90mm"/>
        <fo:table-column column-width="10mm"/>
        <fo:table-body>
            <fo:table-row>
                <fo:table-cell>
                    <fo:block text-align-last="justify"
                     font-size="11.08pt" font-family="Bell Gothic Bold"
                     font-weight="bold">
                        Result 1
                        <fo:leader leader-pattern="dots"/>
                    </fo:block>
               </fo:table-cell>
               <fo:table-cell text-align="right" margin-right="-1.3mm">
                    <fo:block font-size="11.08pt" 
                     font-family="Bell Gothic Bold" font-weight="bold">
                        <fo:page-number-citation ref-id="R1" />
                    </fo:block>
               </fo:table-cell>
            </fo:table-row>
            <xsl:for-each select="AppendixPageContent">
                <xsl:call-template name="addtionalTableContents"/>
            </xsl:for-each>

.... more contents

        </fo:table-body>
    </fo:table>
</xsl:template>

<xsl:template name="addtionalTableContents">
    <fo:table-row>
        <fo:table-cell>
            <fo:block text-align-last="justify" font-size="11.08pt"
             font-family="Bell Gothic Bold" font-weight="bold" >
                 &#160;&#160;&#160;&#160;&#160;<xsl:value-of
                 select="value"/>&#160;<fo:leader  leader-pattern="dots"/>
             </fo:block>
        </fo:table-cell>
        <fo:table-cell>
            <fo:block text-align="end" font-size="11.08pt"
                font-family="Bell Gothic Bold" font-weight="bold">
            <xsl:value-of select="page"/></fo:block>
        </fo:table-cell>
   </fo:table-row>
</xsl:template>


(margin-right for page-number-citation cell is to adjust with the other
page numbers from addtionalTableContents)

Some dots leader didn't reach to the table cell end, i.e.
they don't line up. If dots change to rule, it is fine.

So I look at the source code src.org.apache.fop.layout.LineArea.jave 
that generate leaders.
From line 205, it is generating leader.

+++++++++++  Original Source +++++++++++++++++++++++
int factor = (int)Math.floor(leaderLengthOptimum / dotWidth);
char[] leaderChars = new char[factor];
for (int i = 0; i < factor; i++) {
leaderChars[i] = dot;
}

String leaderWord = new String(leaderChars);
int leaderWordWidth = fontState.getWordWidth(leaderWord);
WordArea leaderPatternArea =
new WordArea(fontState, red, green, blue,
             leaderWord,leaderWordWidth);
leaderPatternArea.setYOffset(placementOffset);
children.add(idx, leaderPatternArea);
int spaceAfterLeader = leaderLengthOptimum
- leaderWordWidth;
if (spaceAfterLeader!=0) {
children.add(idx+1, new InlineSpace(spaceAfterLeader,false));

++++++++++ Original Source End +++++++++++++++++++++++++++++

factor is the number how many dots can be fit in the space.
and added it to children and add left space as "space"
So, the dot line end did not line up.
First I tried to replace the order InlineSpace and leaderPatterArea 
but it didn't work (nothing changed)

So, I generated additional WordArea using 1pt space and added before dot
leader. The source is like this.

+++++++++++  Changing Source +++++++++++++++++++++++

    if (spaceAfterLeader > 0) {
        // create WordArea with 1pt space to fill space before leader
        FontState newFontState = null;
        try{
            newFontState = new FontState(fontState.getFontInfo(),
                                       fontState.getFontFamily(), 
                                       fontState.getFontStyle(),
                                       fontState.getFontWeight(), 1000,
                                       fontState.getFontVariant());
           }
       catch(FOPException e)
       {  }
           
       int subSpaceWidth = newFontState.getCharWidth(space);
       int spaceFactor = (int)Math.floor((double)spaceAfterLeader 
                                        / (double)subSpaceWidth);
       char[] spaceLeaderChars = new char[spaceFactor];
       for (int i = 0; i < spaceFactor; i++) {
           spaceLeaderChars[i] = space;
       }
       String spaceLeaderWord = new String(spaceLeaderChars);
       WordArea spaceLeaderPatternArea =
       new WordArea(newFontState, red, green, blue,
       spaceLeaderWord,subSpaceWidth * spaceFactor);
       leaderPatternArea.setYOffset(placementOffset);

        spaceLeaderPatternArea.setYOffset(placementOffset);
        children.add(idx, spaceLeaderPatternArea);
        idx++;
        children.add(idx, leaderPatternArea);
        idx++;

++++++++++ Changing Source End +++++++++++++++++++++++++++++

,,,,

It solved the problem.
But if there are another text after leader, the leader should be 
centered ? 

Since I was just a FOP user and have not been involved as a developer
in any apache projects, I just ask your opinion for this changing.


Thank you

Midori Aida(Jaid Technology)
[EMAIL PROTECTED]

Reply via email to