xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lfur...@apache.org
Subject svn commit: r279338 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop: fo/FOPropertyMapping.java fo/flow/Block.java layoutmgr/inline/LineLayoutManager.java
Date Wed, 07 Sep 2005 15:03:21 GMT
Author: lfurini
Date: Wed Sep  7 08:03:06 2005
New Revision: 279338

URL: http://svn.apache.org/viewcvs?rev=279338&view=rev
Log:
Using the fo property last-line-end-indent instead of a hard coded value.
This fixes item 1) in bug 36533.

Note that the old behaviour (before the changes) was not completely equivalent to the one
requested by the specs, as the empty space was not necessarily placed at the end of the line;
for example, the last line in a right-aligned paragraph was aligned as the previous lines,
although shorter.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java?rev=279338&r1=279337&r2=279338&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java Wed Sep  7 08:03:06
2005
@@ -1582,6 +1582,7 @@
         m  = new LengthProperty.Maker(PR_LAST_LINE_END_INDENT);
         m.setInherited(true);
         m.setDefault("0pt");
+        m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
         addPropertyMaker("last-line-end-indent", m);
 
         // line-height

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java?rev=279338&r1=279337&r2=279338&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java Wed Sep  7 08:03:06 2005
@@ -298,6 +298,13 @@
     }
 
     /**
+     * @return the "last-line-end-indent" property.
+     */
+    public Length getLastLineEndIndent() {
+        return lastLineEndIndent;
+    }
+
+    /**
      * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
      * XSL Content Model: marker* initial-property-set? (#PCDATA|%inline;|%block;)*
      * Additionally: "An fo:bidi-override that is a descendant of an fo:leader

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=279338&r1=279337&r2=279338&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
Wed Sep  7 08:03:06 2005
@@ -72,6 +72,7 @@
         bTextAlignment = fobj.getTextAlign();
         bTextAlignmentLast = fobj.getTextAlignLast();
         textIndent = fobj.getTextIndent();
+        lastLineEndIndent = fobj.getLastLineEndIndent();
         hyphProps = fobj.getCommonHyphenation();
         
         //
@@ -135,6 +136,7 @@
     private int bTextAlignmentLast;
     private int effectiveAlignment;
     private Length textIndent;
+    private Length lastLineEndIndent;
     private int iIndents = 0;
     private CommonHyphenation hyphProps;
     //private LayoutProps layoutProps;
@@ -185,17 +187,19 @@
         private int textAlignment;
         private int textAlignmentLast;
         private int textIndent;
+        private int lastLineEndIndent;
         private int lineWidth;
         // the LM which created the paragraph
         private LineLayoutManager layoutManager;
 
         public Paragraph(LineLayoutManager llm, int alignment, int alignmentLast,
-                         int indent) {
+                         int indent, int endIndent) {
             super(true);
             layoutManager = llm;
             textAlignment = alignment;
             textAlignmentLast = alignmentLast;
             textIndent = indent;
+            lastLineEndIndent = endIndent;
         }
 
         public void startParagraph(int lw) {
@@ -207,9 +211,9 @@
             // set the minimum amount of empty space at the end of the
             // last line
             if (bTextAlignment == EN_CENTER) {
-                lineFiller = new MinOptMax(0); 
+                lineFiller = new MinOptMax(lastLineEndIndent); 
             } else {
-                lineFiller = new MinOptMax(0, (int)(lineWidth / 12), lineWidth); 
+                lineFiller = new MinOptMax(lastLineEndIndent, lastLineEndIndent, lineWidth);

             }
 
             // add auxiliary elements at the beginning of the paragraph
@@ -244,7 +248,7 @@
                     && bTextAlignmentLast != EN_JUSTIFY) {
                     this.add(new KnuthGlue(0, 3 * DEFAULT_SPACE_WIDTH, 0,
                                            null, false));
-                    this.add(new KnuthPenalty(0, -KnuthElement.INFINITE,
+                    this.add(new KnuthPenalty(lineFiller.opt, -KnuthElement.INFINITE,
                                               false, null, false));
                     ignoreAtEnd = 2;
                 } else if (bTextAlignmentLast != EN_JUSTIFY) {
@@ -253,15 +257,15 @@
                     // and the forced break
                     this.add(new KnuthPenalty(0, KnuthElement.INFINITE, 
                                               false, null, false));
-                    this.add(new KnuthGlue(lineFiller.opt, 
+                    this.add(new KnuthGlue(0, 
                             lineFiller.max - lineFiller.opt, 
                             lineFiller.opt - lineFiller.min, null, false));
-                    this.add(new KnuthPenalty(0, -KnuthElement.INFINITE,
+                    this.add(new KnuthPenalty(lineFiller.opt, -KnuthElement.INFINITE,
                                               false, null, false));
                     ignoreAtEnd = 3;
                 } else {
                     // add only the element representing the forced break
-                    this.add(new KnuthPenalty(0, -KnuthElement.INFINITE,
+                    this.add(new KnuthPenalty(lineFiller.opt, -KnuthElement.INFINITE,
                                               false, null, false));
                     ignoreAtEnd = 1;
                 }
@@ -393,7 +397,7 @@
             // compute indent and adjustment ratio, according to
             // the value of text-align and text-align-last
             int indent = 0;
-            int difference = (bestActiveNode.line < total) ? bestActiveNode.difference
: bestActiveNode.difference + fillerMinWidth;
+            int difference = bestActiveNode.difference;
             int textAlign = (bestActiveNode.line < total) ? alignment : alignmentLast;
             indent += (textAlign == Constants.EN_CENTER) ?
                           difference / 2 :
@@ -740,7 +744,7 @@
                         if (lastPar == null) { 
                             lastPar = new Paragraph(this, 
                                                     bTextAlignment, bTextAlignmentLast, 
-                                                    textIndent.getValue(this));
+                                                    textIndent.getValue(this), lastLineEndIndent.getValue(this));
                             lastPar.startParagraph(availIPD.opt);
                             if (log.isTraceEnabled()) {
                                 trace.append(" [");
@@ -1610,7 +1614,6 @@
                 KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(iCurrParIndex); 
                 iEndElement = lbp.getLeafPos();
     
-                //LineArea lineArea = new LineArea();
                 LineArea lineArea = new LineArea((lbp.getLeafPos() < seq.size() - 1 ?
bTextAlignment : bTextAlignmentLast),
                                                  lbp.difference, lbp.availableStretch, lbp.availableShrink);
                 lineArea.setStartIndent(lbp.startIndent);
@@ -1627,9 +1630,13 @@
                     // ignore the first elements added by the LineLayoutManager
                     iStartElement += (iStartElement == 0) ? currPar.ignoreAtStart : 0;
                     
-                    // ignore the last elements added by the LineLayoutManager
-                    iEndElement -= (iEndElement == (currPar.size() - 1))
-                    ? currPar.ignoreAtEnd : 0;
+                    // if this is the last line area that for this paragraph,
+                    // ignore the last elements added by the LineLayoutManager and
+                    // subtract the last-line-end-indent from the area ipd
+                    if (iEndElement == (currPar.size() - 1)) {
+                        iEndElement -= currPar.ignoreAtEnd;
+                        lineArea.setIPD(lineArea.getIPD() - lastLineEndIndent.getValue(this));
+                    }
                 }
                 
                 // ignore the last element in the line if it is a KnuthGlue object



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


Mime
View raw message