You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2001/03/29 09:34:58 UTC

cvs commit: xml-fop/src/org/apache/fop/layout/inline InlineArea.java

kellyc      01/03/28 23:34:58

  Modified:    docs/examples build.xml
               src/org/apache/fop/layout LineArea.java LinkSet.java
                        LinkedRectangle.java
               src/org/apache/fop/layout/inline InlineArea.java
  Added:       docs/examples/fo newlinktest.fo
  Log:
  Fixed basic-link horizontal position with justification turned on.
  PR: 953
  
  Revision  Changes    Path
  1.16      +2 -0      xml-fop/docs/examples/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-fop/docs/examples/build.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- build.xml	2001/03/04 21:47:40	1.15
  +++ build.xml	2001/03/29 07:34:55	1.16
  @@ -46,6 +46,7 @@
       <fop fofile="${foDir}/table.fo"  pdffile="${testDir}/table.pdf"/>
       <fop fofile="${foDir}/list.fo"   pdffile="${testDir}/list.pdf"/>
       <fop fofile="${foDir}/link.fo"   pdffile="${testDir}/link.pdf"/> 
  +    <fop fofile="${foDir}/newlinktest.fo" pdffile="${testDir}/newlinktest.pdf"/>
       <fop fofile="${foDir}/border.fo"   pdffile="${testDir}/border.pdf"/> 
       <fop fofile="${foDir}/extensive.fo"   pdffile="${testDir}/extensive.pdf"/> 
       <fop fofile="${foDir}/images.fo"   pdffile="${testDir}/images.pdf"/> 
  @@ -85,6 +86,7 @@
       <fop fofile="${foDir}/table.fo"  pdffile="${referenceDir}/table.pdf"/>
       <fop fofile="${foDir}/list.fo"   pdffile="${referenceDir}/list.pdf"/>
       <fop fofile="${foDir}/link.fo"   pdffile="${referenceDir}/link.pdf"/>
  +    <fop fofile="${foDir}/newlinktest.fo"   pdffile="${referenceDir}/newlinktest.pdf"/>
       <fop fofile="${foDir}/border.fo"   pdffile="${referenceDir}/border.pdf"/>
       <fop fofile="${foDir}/extensive.fo"   pdffile="${referenceDir}/extensive.pdf"/>
       <fop fofile="${foDir}/images.fo"   pdffile="${referenceDir}/images.pdf"/>
  
  
  
  1.1                  xml-fop/docs/examples/fo/newlinktest.fo
  
  Index: newlinktest.fo
  ===================================================================
  <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
  
      <!-- layout for the first page -->
      <fo:simple-page-master master-name="first"
                    margin-top="1in" 
                    margin-bottom="1in" 
                    margin-left="1in" 
                    margin-right="1in">
        <fo:region-body/>
      </fo:simple-page-master>
  
  
    </fo:layout-master-set>
    <!-- end: defines page layout -->
  
    <!-- actual layout -->
    <fo:page-sequence master-name="first">
  
  
  
  
  <fo:flow flow-name="xsl-region-body">
  
    <fo:block space-after.optimum="3pt" font-family="serif" id="block1">
       FOP is the world's first print formatter driven by XSL formatting
       objects. It is a Java 1.1 application that reads a formatting object
       tree and then turns it into a PDF document. The formatting object
       tree, can be in the form of an XML document (output by an XSLT engine
       like XT or Xalan) or can be passed in memory as a DOM Document or (in
       the case of XT) SAX events.
    </fo:block>
  
    <fo:block space-after.optimum="12pt" font-family="serif">FOP is part of Apache's XML project. The homepage of FOP is 
       <fo:inline font-style="italic" font-family="serif"><fo:basic-link color="blue" external-destination="http://xml.apache.org/fop">http://xml.apache.org/fop</fo:basic-link></fo:inline>
    </fo:block>
  
  <fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
  align="start"
  </fo:block>
  
  <fo:block space-after.optimum="12pt" font-family="serif" text-align="start">
       Apache FOP is the world's first print formatter driven by XSL formatting
       objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
       tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
       tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
       like XT or Xalan) or can be passed in memory as a DOM Document or (in
       the case of XT) SAX events.
  
    </fo:block>
  
  <fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
  align="center"
  </fo:block>
  
  <fo:block space-after.optimum="12pt" font-family="serif" text-align="center">
       Apache FOP is the world's first print formatter driven by XSL formatting
       objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
       tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
       tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
       like XT or Xalan) or can be passed in memory as a DOM Document or (in
       the case of XT) SAX events.
  
    </fo:block>
  
  <fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
  align="justify"
  </fo:block>
  
    <fo:block space-after.optimum="12pt" font-family="serif" text-align="justify">
       Apache FOP is the world's first print formatter driven by XSL formatting
       objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
       tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
       tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
       like XT or Xalan) or can be passed in memory as a DOM Document or (in
       the case of XT) SAX events.
  
    </fo:block>
  
  <!-- table start -->
      <fo:table>
        <fo:table-column column-width="50mm"/>
        <fo:table-column column-width="50mm"/>
        <fo:table-column column-width="50mm"/>
        <fo:table-body>
          <fo:table-row>
            <fo:table-cell ><fo:block>good</fo:block></fo:table-cell>
            <fo:table-cell ><fo:block>bad</fo:block></fo:table-cell>
            <fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">ugly</fo:basic-link></fo:block></fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell ><fo:block>nice</fo:block></fo:table-cell>
            <fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">dice</fo:basic-link></fo:block></fo:table-cell>
            <fo:table-cell ><fo:block>vice</fo:block></fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell ><fo:block>literature</fo:block></fo:table-cell>
            <fo:table-cell ><fo:block>music</fo:block></fo:table-cell>
            <fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">art</fo:basic-link></fo:block></fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">java</fo:basic-link></fo:block></fo:table-cell>
            <fo:table-cell ><fo:block>perl</fo:block></fo:table-cell>
            <fo:table-cell ><fo:block>python</fo:block></fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
      <!-- table end -->
  
  
  </fo:flow>
  
  </fo:page-sequence>
  </fo:root>
  
  
  
  1.40      +21 -12    xml-fop/src/org/apache/fop/layout/LineArea.java
  
  Index: LineArea.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/LineArea.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- LineArea.java	2001/03/22 18:16:44	1.39
  +++ LineArea.java	2001/03/29 07:34:56	1.40
  @@ -1,4 +1,4 @@
  -/*-- $Id: LineArea.java,v 1.39 2001/03/22 18:16:44 fotis Exp $ --
  +/*-- $Id: LineArea.java,v 1.40 2001/03/29 07:34:56 kellyc Exp $ --
    *
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
  @@ -244,7 +244,7 @@
                                                                ((InlineArea) box).
                                                                getContentWidth(),
                                                                fontState.getFontSize());
  -                                ls.addRect(lr, this);
  +                                ls.addRect(lr, this, (InlineArea)box);
                               }
                           }
                           addChild(box);
  @@ -277,7 +277,7 @@
                               Rectangle lr = new Rectangle(finalWidth, 0,
                                                            ia.getContentWidth(),
                                                            fontState.getFontSize());
  -                            ls.addRect(lr, this);
  +                            ls.addRect(lr, this, ia);
                           }
                           finalWidth += wordWidth;
   
  @@ -419,7 +419,7 @@
                   Rectangle lr = new Rectangle(finalWidth + spaceWidth +
                                                embeddedLinkStart, spaceWidth,
                                                pia.getContentWidth(), fontState.getFontSize());
  -                ls.addRect(lr, this);
  +                ls.addRect(lr, this, pia);
               }
   
               embeddedLinkStart += wordWidth;
  @@ -606,8 +606,7 @@
                   endIndent += padding;
                   break;
               case TextAlign.JUSTIFY: // justify
  -                Vector spaceList = new Vector();
  -
  +		// first pass - count the spaces
                   int spaceCount = 0;
                   Enumeration e = children.elements();
                   while (e.hasMoreElements()) {
  @@ -615,7 +614,6 @@
                       if (b instanceof InlineSpace) {
                           InlineSpace space = (InlineSpace) b;
                           if (space.getResizeable()) {
  -                            spaceList.addElement(space);
                               spaceCount++;
                           }
                       }
  @@ -626,11 +624,22 @@
                   } else { // no spaces
                       padding = 0;
                   }
  -                Enumeration f = spaceList.elements();
  -                while (f.hasMoreElements()) {
  -                    InlineSpace space2 = (InlineSpace) f.nextElement();
  -                    int i = space2.getSize();
  -                    space2.setSize(i + padding);
  +		// second pass - add additional space
  +		spaceCount = 0;
  +		e = children.elements();
  +		while (e.hasMoreElements()) {
  +                    Box b = (Box) e.nextElement();
  +                    if (b instanceof InlineSpace) {
  +                        InlineSpace space = (InlineSpace) b;
  +                        if (space.getResizeable()) {
  +			    space.setSize(space.getSize() + padding);
  +			    spaceCount++;
  +                        }
  +                    }
  +		    else if (b instanceof InlineArea) {
  +			((InlineArea)b).setXOffset(spaceCount * padding);
  +		    }
  +		    
                   }
           }
       }
  
  
  
  1.9       +8 -4      xml-fop/src/org/apache/fop/layout/LinkSet.java
  
  Index: LinkSet.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/LinkSet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LinkSet.java	2000/11/15 21:44:16	1.8
  +++ LinkSet.java	2001/03/29 07:34:57	1.9
  @@ -1,4 +1,4 @@
  -/*-- $Id: LinkSet.java,v 1.8 2000/11/15 21:44:16 fotis Exp $ --
  +/*-- $Id: LinkSet.java,v 1.9 2001/03/29 07:34:57 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -59,6 +59,8 @@
   import java.util.Enumeration;
   import java.awt.Rectangle;
   
  +import org.apache.fop.layout.inline.InlineArea;
  +
   import org.apache.fop.fo.properties.WrapOption; // for enumerated
   // values
   // import org.apache.fop.fo.properties.WhiteSpaceCollapse; // for
  @@ -105,8 +107,8 @@
           this.linkType = linkType;
       }
   
  -    public void addRect(Rectangle r, LineArea lineArea) {
  -        LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea);
  +    public void addRect(Rectangle r, LineArea lineArea, InlineArea inlineArea) {
  +        LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea, inlineArea);
           linkedRectangle.setY(this.yoffset);
           if (this.yoffset > maxY) {
               maxY = this.yoffset;
  @@ -171,7 +173,9 @@
           Enumeration re = rects.elements();
           while (re.hasMoreElements()) {
               LinkedRectangle r = (LinkedRectangle) re.nextElement();
  -            r.setX(r.getX() + r.getLineArea().getStartIndent());
  +            r.setX(r.getX() + 
  +		   r.getLineArea().getStartIndent() + 
  +		   r.getInlineArea().getXOffset());
           }
       }
   
  
  
  
  1.2       +17 -2     xml-fop/src/org/apache/fop/layout/LinkedRectangle.java
  
  Index: LinkedRectangle.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/LinkedRectangle.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LinkedRectangle.java	2000/04/02 03:45:33	1.1
  +++ LinkedRectangle.java	2001/03/29 07:34:57	1.2
  @@ -57,6 +57,8 @@
   // Java
   import java.awt.Rectangle;
   
  +import org.apache.fop.layout.inline.InlineArea;
  +
   /**
    * an object that stores a rectangle that is linked, and the LineArea
    * that it is logically associated with
  @@ -68,15 +70,20 @@
   
       /** the associated LineArea */
       protected LineArea lineArea;
  +
  +    /** the associated InlineArea */
  +    protected InlineArea inlineArea;
   
  -    public LinkedRectangle(Rectangle link, LineArea lineArea) {
  +    public LinkedRectangle(Rectangle link, LineArea lineArea, InlineArea inlineArea) {
   	this.link = link;
   	this.lineArea = lineArea;
  +	this.inlineArea = inlineArea;
       }
       
       public LinkedRectangle(LinkedRectangle lr) {
   	this.link = new Rectangle( lr.getRectangle() );
   	this.lineArea = lr.getLineArea();
  +	this.inlineArea = lr.getInlineArea();
       }
   
       public void setRectangle(Rectangle link) {
  @@ -91,8 +98,16 @@
   	return this.lineArea;
       }
       
  -    public void setLineArea() {
  +    public void setLineArea(LineArea lineArea) {
   	this.lineArea = lineArea;
  +    }
  +
  +    public InlineArea getInlineArea() {
  +	return this.inlineArea;
  +    }
  +    
  +    public void setLineArea(InlineArea inlineArea) {
  +	this.inlineArea = inlineArea;
       }
       
       public void setX(int x) {
  
  
  
  1.5       +12 -1     xml-fop/src/org/apache/fop/layout/inline/InlineArea.java
  
  Index: InlineArea.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/inline/InlineArea.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InlineArea.java	2001/02/01 21:38:07	1.4
  +++ InlineArea.java	2001/03/29 07:34:57	1.5
  @@ -1,4 +1,4 @@
  -/*-- $Id: InlineArea.java,v 1.4 2001/02/01 21:38:07 klease Exp $ --
  +/*-- $Id: InlineArea.java,v 1.5 2001/03/29 07:34:57 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -58,6 +58,9 @@
   public abstract class InlineArea extends Area {
   
       private int yOffset = 0;
  +
  +    /** amount of space added since the original layout - needed by links */
  +    private int xOffset = 0;
       protected int height = 0;
       private int verticalAlign = 0;
       protected String pageNumberId = null;
  @@ -112,6 +115,14 @@
   
       public int getYOffset() {
           return this.yOffset;
  +    }
  +
  +    public void setXOffset(int xOffset) {
  +        this.xOffset = xOffset;
  +    }
  +
  +    public int getXOffset() {
  +        return this.xOffset;
       }
   
       public String getPageNumberID() {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org