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 kl...@apache.org on 2002/04/28 23:28:02 UTC

cvs commit: xml-fop/src/org/apache/fop/traits BlockProps.java InlineProps.java LayoutProps.java SpaceVal.java

klease      02/04/28 14:28:02

  Modified:    src/codegen foproperties.xml
               src/org/apache/fop/area BodyRegion.java MinOptMax.java
               src/org/apache/fop/datatypes Space.java
               src/org/apache/fop/fo FOText.java FObj.java FObjMixed.java
                        PropertyManager.java TextInfo.java
               src/org/apache/fop/fo/flow Block.java
               src/org/apache/fop/layout MarginInlineProps.java
               src/org/apache/fop/layoutmgr BlockLayoutManager.java
                        BlockStackingLayoutManager.java
                        LineLayoutManager.java SpaceSpecifier.java
  Added:       src/org/apache/fop/traits BlockProps.java InlineProps.java
                        LayoutProps.java SpaceVal.java
  Log:
  Add BreakPossibility style LayoutManager code as an alternative to
  Keiron's "direct area creation" method. Not currently enabled: to do
  so, one must make 2 changes in the source.
  
  Revision  Changes    Path
  1.31      +5 -2      xml-fop/src/codegen/foproperties.xml
  
  Index: foproperties.xml
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/codegen/foproperties.xml,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- foproperties.xml	23 Feb 2002 16:47:01 -0000	1.30
  +++ foproperties.xml	28 Apr 2002 21:28:01 -0000	1.31
  @@ -1282,8 +1282,11 @@
     <property>
       <name>word-spacing</name>
       <inherited>true</inherited>
  -    <datatype>ToBeImplemented</datatype>
  -    <default>normal</default>
  +    <use-generic>GenericSpace</use-generic>
  +    <default subproperty="precedence">force</default>
  +    <default subproperty="conditionality">discard</default>
  +    <default>0pt</default>
  +    <!-- <default>normal</default> -->
     </property>
   
   <!-- Color-related Properties -->
  
  
  
  1.5       +6 -1      xml-fop/src/org/apache/fop/area/BodyRegion.java
  
  Index: BodyRegion.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/BodyRegion.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BodyRegion.java	17 Feb 2002 21:59:29 -0000	1.4
  +++ BodyRegion.java	28 Apr 2002 21:28:01 -0000	1.5
  @@ -1,5 +1,5 @@
   /*
  - * $Id: BodyRegion.java,v 1.4 2002/02/17 21:59:29 klease Exp $
  + * $Id: BodyRegion.java,v 1.5 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -29,6 +29,11 @@
       // Number of columns when not spanning
       public void setColumnCount(int colCount) {
   	this.columnCount = colCount;
  +    }
  +
  +    // Number of columns when not spanning
  +    public int getColumnCount() {
  +	return this.columnCount ;
       }
   
       // A length (mpoints)
  
  
  
  1.3       +17 -2     xml-fop/src/org/apache/fop/area/MinOptMax.java
  
  Index: MinOptMax.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/area/MinOptMax.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MinOptMax.java	11 Nov 2001 14:10:29 -0000	1.2
  +++ MinOptMax.java	28 Apr 2002 21:28:01 -0000	1.3
  @@ -1,5 +1,5 @@
   /*
  - * $Id: MinOptMax.java,v 1.2 2001/11/11 14:10:29 klease Exp $
  + * $Id: MinOptMax.java,v 1.3 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -14,7 +14,7 @@
    * variables are package visible.
    */
   
  -public class MinOptMax implements java.io.Serializable {
  +public class MinOptMax implements java.io.Serializable, Cloneable {
   
       /** Publicly visible min(imum), opt(imum) and max(imum) values.*/
       public int min;
  @@ -35,6 +35,15 @@
   	this.max = max;
       }
   
  +    public Object clone() {
  +	try {
  +	    return super.clone();
  +	} catch (CloneNotSupportedException ex) {
  +	    // SHOULD NEVER OCCUR - all members are primitive types!
  +	    return null;
  +	}
  +    }
  +
       public static MinOptMax subtract(MinOptMax op1, MinOptMax op2) {
   	return new MinOptMax(op1.min - op2.max, op1.opt - op2.opt,
   			     op1.max - op2.min);
  @@ -43,6 +52,12 @@
       public static MinOptMax add(MinOptMax op1, MinOptMax op2) {
   	return new MinOptMax(op1.min + op2.min, op1.opt + op2.opt,
   			     op1.max + op2.max);
  +    }
  +
  +    public static MinOptMax multiply(MinOptMax op1, double mult) {
  +	return new MinOptMax((int)(op1.min * mult),
  +			     (int)(op1.opt * mult),
  +			     (int)(op1.max * mult));
       }
   
       public void add(MinOptMax op) {
  
  
  
  1.6       +1 -7      xml-fop/src/org/apache/fop/datatypes/Space.java
  
  Index: Space.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/Space.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Space.java	30 Jul 2001 20:29:19 -0000	1.5
  +++ Space.java	28 Apr 2002 21:28:01 -0000	1.6
  @@ -1,5 +1,5 @@
   /*
  - * $Id: Space.java,v 1.5 2001/07/30 20:29:19 tore Exp $
  + * $Id: Space.java,v 1.6 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -50,12 +50,6 @@
       public Property getPrecedence() {
           return this.precedence;
       }
  -
  -    /*
  -     * public boolean isDiscard() {
  -     * return (this.conditionality == DISCARD);
  -     * }
  -     */
   
       public Property getConditionality() {
           return this.conditionality;
  
  
  
  1.33      +4 -1      xml-fop/src/org/apache/fop/fo/FOText.java
  
  Index: FOText.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FOText.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- FOText.java	26 Apr 2002 09:40:56 -0000	1.32
  +++ FOText.java	28 Apr 2002 21:28:01 -0000	1.33
  @@ -1,5 +1,5 @@
   /*
  - * $Id: FOText.java,v 1.32 2002/04/26 09:40:56 keiron Exp $
  + * $Id: FOText.java,v 1.33 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources."
  @@ -17,6 +17,7 @@
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.layoutmgr.LayoutManager;
   import org.apache.fop.layoutmgr.TextLayoutManager;
  +import org.apache.fop.layoutmgr.TextBPLayoutManager;
   
   import java.util.NoSuchElementException;
   import java.util.List;
  @@ -81,6 +82,8 @@
               System.arraycopy(tmp, 0, ca, 0, length);
           }
           list.add(new TextLayoutManager(this, ca, textInfo));
  +	// TEST VARIANT USING Karen's BreakPoss scheme
  +        // list.add(new TextBPLayoutManager(this, ca, textInfo));
       }
   
       public CharIterator charIterator() {
  
  
  
  1.30      +10 -1     xml-fop/src/org/apache/fop/fo/FObj.java
  
  Index: FObj.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FObj.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- FObj.java	26 Apr 2002 09:40:56 -0000	1.29
  +++ FObj.java	28 Apr 2002 21:28:01 -0000	1.30
  @@ -1,5 +1,5 @@
   /*
  - * $Id: FObj.java,v 1.29 2002/04/26 09:40:56 keiron Exp $
  + * $Id: FObj.java,v 1.30 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -378,5 +378,14 @@
       public ArrayList getMarkers() {
           return new ArrayList(markers.values());
       }
  +
  +    /**
  +     * lets layout managers access FO properties via PropertyManager
  +     * @return the property manager for this FO
  +     */
  +    public PropertyManager getPropertyManager() {
  +        return this.propMgr;
  +    }
  +
   }
   
  
  
  
  1.22      +6 -21     xml-fop/src/org/apache/fop/fo/FObjMixed.java
  
  Index: FObjMixed.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FObjMixed.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- FObjMixed.java	26 Apr 2002 09:40:56 -0000	1.21
  +++ FObjMixed.java	28 Apr 2002 21:28:01 -0000	1.22
  @@ -1,5 +1,5 @@
   /*
  - * $Id: FObjMixed.java,v 1.21 2002/04/26 09:40:56 keiron Exp $
  + * $Id: FObjMixed.java,v 1.22 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -45,26 +45,11 @@
       }
   
       protected void addCharacters(char data[], int start, int length) {
  -        if (textInfo == null) {
  -            textInfo = new TextInfo();
  -
  -            try {
  -                textInfo.fs = propMgr.getFontState(fontInfo);
  -            } catch (FOPException fopex) {
  -                log.error("Error setting FontState for characters: " +
  -                          fopex.getMessage());
  -            }
  -
  -            ColorType c = getProperty("color").getColorType();
  -            textInfo.color = c;
  -
  -            textInfo.verticalAlign =
  -              getProperty("vertical-align").getEnum();
  -
  -            textInfo.wrapOption = getProperty("wrap-option").getEnum();
  -            textInfo.whiteSpaceCollapse =
  -              getProperty("white-space-collapse").getEnum();
  -
  +        if(textInfo == null) {
  +	    // Really only need one of these, but need to get fontInfo
  +	    // stored in propMgr for later use.
  +	    propMgr.setFontInfo(fontInfo);
  +	    textInfo = propMgr.getTextLayoutProps(fontInfo);
           }
   
           FOText ft = new FOText(data, start, length, textInfo);
  
  
  
  1.10      +88 -2     xml-fop/src/org/apache/fop/fo/PropertyManager.java
  
  Index: PropertyManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/PropertyManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PropertyManager.java	18 Feb 2002 22:49:22 -0000	1.9
  +++ PropertyManager.java	28 Apr 2002 21:28:01 -0000	1.10
  @@ -1,5 +1,5 @@
   /*
  - * $Id: PropertyManager.java,v 1.9 2002/02/18 22:49:22 klease Exp $
  + * $Id: PropertyManager.java,v 1.10 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -11,20 +11,26 @@
   import java.awt.geom.Rectangle2D;
   import org.apache.fop.area.CTM;
   import org.apache.fop.datatypes.FODimension;
  +import org.apache.fop.fo.TextInfo; // should be somewhere else probably...
   import org.apache.fop.layout.FontState;
   import org.apache.fop.layout.FontInfo;
   import org.apache.fop.layout.BorderAndPadding;
   import org.apache.fop.layout.MarginProps;
  -import org.apache.fop.layout.BackgroundProps;
   import org.apache.fop.layout.MarginInlineProps;
  +import org.apache.fop.layout.BackgroundProps;
   import org.apache.fop.layout.AccessibilityProps;
   import org.apache.fop.layout.AuralProps;
   import org.apache.fop.layout.RelativePositionProps;
   import org.apache.fop.layout.AbsolutePositionProps;
  +import org.apache.fop.traits.BlockProps;
  +import org.apache.fop.traits.InlineProps;
  +import org.apache.fop.traits.SpaceVal;
  +import org.apache.fop.traits.LayoutProps;  // keep, break, span, space?
   import org.apache.fop.fo.properties.BreakAfter;
   import org.apache.fop.fo.properties.BreakBefore;
   import org.apache.fop.fo.properties.Constants;
   import org.apache.fop.fo.properties.WritingMode;
  +import org.apache.fop.fo.properties.Span;
   import org.apache.fop.layout.HyphenationProps;
   import org.apache.fop.apps.FOPException;
   import java.text.MessageFormat;
  @@ -35,9 +41,11 @@
   public class PropertyManager {
   
       private PropertyList properties;
  +    private FontInfo m_fontInfo = null;
       private FontState fontState = null;
       private BorderAndPadding borderAndPadding = null;
       private HyphenationProps hyphProps = null;
  +    private TextInfo textInfo = null;
   
       private String[] saLeft;
       private String[] saRight;
  @@ -57,6 +65,10 @@
           this.properties = pList;
       }
   
  +    public void setFontInfo(FontInfo fontInfo) {
  +	m_fontInfo = fontInfo;
  +    }
  +
       private void initDirections() {
           saLeft = new String[1];
           saRight = new String[1];
  @@ -70,6 +82,12 @@
   
       public FontState getFontState(FontInfo fontInfo) throws FOPException {
           if (fontState == null) {
  +	    if (fontInfo == null) {
  +		fontInfo = m_fontInfo;
  +	    }
  +	    else if (m_fontInfo == null) {
  +		m_fontInfo = fontInfo;
  +	    }
               String fontFamily = properties.get("font-family").getString();
               String fontStyle = properties.get("font-style").getString();
               String fontWeight = properties.get("font-weight").getString();
  @@ -227,6 +245,15 @@
           return props;
       }
   
  +    public InlineProps getInlineProps() {
  +        InlineProps props = new InlineProps();
  +        props.spaceStart = new SpaceVal(properties.get("space-start").
  +					getSpace());
  +        props.spaceEnd = new SpaceVal(properties.get("space-end").
  +					getSpace());
  +        return props;
  +    }
  +
       public AccessibilityProps getAccessibilityProps() {
           AccessibilityProps props = new AccessibilityProps();
           String str;
  @@ -254,6 +281,65 @@
       public AbsolutePositionProps getAbsolutePositionProps() {
           AbsolutePositionProps props = new AbsolutePositionProps();
           return props;
  +    }
  +
  +    public BlockProps getBlockProps() {
  +        BlockProps props = new BlockProps();
  +        props.firstIndent = this.properties.get("text-indent").
  +	    getLength().mvalue();
  +        props.lastIndent = 0; /*this.properties.get("last-line-end-indent").getLength().mvalue(); */
  +        props.textAlign = this.properties.get("text-align").getEnum();
  +        props.textAlignLast = this.properties.get("text-align-last").
  +	    getEnum();
  +	props.lineStackType = this.properties.
  +	    get("line-stacking-strategy").getEnum();
  +
  +        return props;
  +    }
  +
  +    public LayoutProps getLayoutProps() {
  +        LayoutProps props = new LayoutProps();
  +        props.breakBefore = this.properties.get("break-before").getEnum();
  +        props.breakAfter = this.properties.get("break-after").getEnum();
  +	props.bIsSpan = (this.properties.get("span").getEnum() == Span.ALL);
  +        props.spaceBefore = new SpaceVal(this.properties.get("space-before").
  +					 getSpace());
  +        props.spaceAfter = new SpaceVal(this.properties.get("space-after").
  +					getSpace());
  +        return props;
  +    }
  +
  +    public TextInfo getTextLayoutProps(FontInfo fontInfo) {
  +	if (textInfo == null) {
  +	    textInfo = new TextInfo();
  +	    try {
  +		textInfo.fs = getFontState(fontInfo);
  +	    } catch (FOPException fopex) {
  +		/* log.error("Error setting FontState for characters: " +
  +		   fopex.getMessage());*/
  +		// Now what should we do ???
  +	    }
  +	    textInfo.color = properties.get("color").getColorType();
  +
  +	    textInfo.verticalAlign =
  +                properties.get("vertical-align").getEnum();
  +
  +	    textInfo.wrapOption = properties.get("wrap-option").getEnum();
  +	    textInfo.bWrap = (textInfo.wrapOption == Constants.WRAP);
  +
  +	    textInfo.wordSpacing =
  +		new SpaceVal(properties.get("word-spacing").getSpace());
  +
  +	    /* textInfo.letterSpacing =
  +	       new SpaceVal(properties.get("letter-spacing").getSpace());*/
  +
  +	    textInfo.whiteSpaceCollapse =
  +                properties.get("white-space-collapse").getEnum();
  +
  +	    textInfo.lineHeight = this.properties.
  +		get("line-height").getLength().mvalue();
  +	}
  +	return textInfo;
       }
   
       public CTM getCTMandRelDims(Rectangle2D absVPrect, FODimension reldims) {
  
  
  
  1.3       +11 -11    xml-fop/src/org/apache/fop/fo/TextInfo.java
  
  Index: TextInfo.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/TextInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TextInfo.java	2 Apr 2002 11:50:58 -0000	1.2
  +++ TextInfo.java	28 Apr 2002 21:28:01 -0000	1.3
  @@ -1,5 +1,5 @@
   /*
  - * $Id: TextInfo.java,v 1.2 2002/04/02 11:50:58 keiron Exp $
  + * $Id: TextInfo.java,v 1.3 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources."
  @@ -8,27 +8,27 @@
   package org.apache.fop.fo;
   
   // FOP
  -import org.apache.fop.layout.Area;
  -import org.apache.fop.layout.BlockArea;
   import org.apache.fop.layout.FontState;
  -import org.apache.fop.layout.*;
  -import org.apache.fop.datatypes.*;
  -import org.apache.fop.fo.properties.*;
  -import org.apache.fop.apps.FOPException;
  -import org.apache.fop.layoutmgr.LayoutManager;
  -import org.apache.fop.layoutmgr.TextLayoutManager;
  -
  -import java.util.NoSuchElementException;
  +import org.apache.fop.datatypes.ColorType;
  +import org.apache.fop.traits.SpaceVal;
   
   /**
  + * Collection of properties used in
    */
       public class TextInfo {
           public FontState fs;
           public ColorType color;
           public int wrapOption;
  +        public boolean bWrap ; // True if wrap-option = WRAP
           public int whiteSpaceCollapse;
           public int verticalAlign;
           public int lineHeight;
  +
  +	// Props used for calculating inline-progression-dimension
  +        public SpaceVal wordSpacing;
  +        public SpaceVal letterSpacing;
  +
  +	// Add hyphenation props too
   
           // Textdecoration
           public boolean underlined = false;
  
  
  
  1.53      +2 -16     xml-fop/src/org/apache/fop/fo/flow/Block.java
  
  Index: Block.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Block.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- Block.java	26 Apr 2002 09:40:56 -0000	1.52
  +++ Block.java	28 Apr 2002 21:28:01 -0000	1.53
  @@ -1,5 +1,5 @@
   /*
  - * $Id: Block.java,v 1.52 2002/04/26 09:40:56 keiron Exp $
  + * $Id: Block.java,v 1.53 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -376,21 +376,7 @@
   
       public void addLayoutManager(List list) {
           BlockLayoutManager blm = new BlockLayoutManager(this);
  -        TextInfo ti = new TextInfo();
  -
  -        try {
  -            ti.fs = propMgr.getFontState(fontInfo);
  -        } catch (FOPException fopex) {
  -            log.error("Error setting FontState for characters: " +
  -                      fopex.getMessage());
  -        }
  -        ti.lineHeight = this.lineHeight;
  -
  -        ColorType c = getProperty("color").getColorType();
  -        ti.color = c;
  -
  -        ti.verticalAlign = getProperty("vertical-align").getEnum();
  -
  +        TextInfo ti = propMgr.getTextLayoutProps(fontInfo);
           blm.setBlockTextInfo(ti);
           list.add(blm);
       }
  
  
  
  1.2       +5 -6      xml-fop/src/org/apache/fop/layout/MarginInlineProps.java
  
  Index: MarginInlineProps.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/MarginInlineProps.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MarginInlineProps.java	6 Aug 2001 09:14:24 -0000	1.1
  +++ MarginInlineProps.java	28 Apr 2002 21:28:01 -0000	1.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: MarginInlineProps.java,v 1.1 2001/08/06 09:14:24 keiron Exp $
  + * $Id: MarginInlineProps.java,v 1.2 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -7,8 +7,9 @@
   
   package org.apache.fop.layout;
   
  +
   /**
  - * Store all hyphenation related properties on an FO.
  + * Store all inline "margin" related properties
    * Public "structure" allows direct member access.
    */
   public class MarginInlineProps {
  @@ -16,10 +17,8 @@
       public int marginBottom;
       public int marginLeft;
       public int marginRight;
  -    public int spaceBefore;
  -    public int spaceAfter;
  -    public int startIndent;
  -    public int endIndent;
  +    public int spaceStart;
  +    public int spaceEnd;
   
       public MarginInlineProps() {}
   
  
  
  
  1.7       +8 -3      xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
  
  Index: BlockLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BlockLayoutManager.java	26 Apr 2002 09:40:57 -0000	1.6
  +++ BlockLayoutManager.java	28 Apr 2002 21:28:01 -0000	1.7
  @@ -1,5 +1,5 @@
   /*
  - * $Id: BlockLayoutManager.java,v 1.6 2002/04/26 09:40:57 keiron Exp $
  + * $Id: BlockLayoutManager.java,v 1.7 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -58,7 +58,7 @@
       public boolean generateAreas() {
           ArrayList lms = new ArrayList();
           LayoutManager lm = null;
  -
  +	FObj curFobj = fobj;
           if (fobj != null) {
               ListIterator children = fobj.getChildren();
               while (children.hasNext()) {
  @@ -83,8 +83,13 @@
                           break;
                       }
                   }
  -                lm = new LineLayoutManager(inlines, lineHeight, lead,
  +                lm = new LineLayoutManager(curFobj, inlines, lineHeight, lead,
                                              follow);
  +		// !!!! To test BreakPoss Line LayoutManager, uncomment!
  +		/*
  +                lm = new LineBPLayoutManager(curFobj, inlines, lineHeight,
  +		                                lead, follow);
  +		*/
                   lms.set(count, lm);
               }
               lm.setParentLM(this);
  
  
  
  1.5       +3 -3      xml-fop/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
  
  Index: BlockStackingLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BlockStackingLayoutManager.java	26 Apr 2002 09:40:57 -0000	1.4
  +++ BlockStackingLayoutManager.java	28 Apr 2002 21:28:01 -0000	1.5
  @@ -1,5 +1,5 @@
   /*
  - * $Id: BlockStackingLayoutManager.java,v 1.4 2002/04/26 09:40:57 keiron Exp $
  + * $Id: BlockStackingLayoutManager.java,v 1.5 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -117,13 +117,13 @@
   
   
       protected MinOptMax resolveSpaceSpecifier(Area nextArea) {
  -        SpaceSpecifier spaceSpec = new SpaceSpecifier();
  +        SpaceSpecifier spaceSpec = new SpaceSpecifier(false);
           // 	Area prevArea = getCurrentArea().getLast();
           // 	if (prevArea != null) {
           // 	    spaceSpec.addSpace(prevArea.getSpaceAfter());
           // 	}
           // 	spaceSpec.addSpace(nextArea.getSpaceBefore());
  -        return spaceSpec.resolve();
  +        return spaceSpec.resolve(false);
       }
   
       /**
  
  
  
  1.7       +10 -10    xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java
  
  Index: LineLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LineLayoutManager.java	26 Apr 2002 09:40:57 -0000	1.6
  +++ LineLayoutManager.java	28 Apr 2002 21:28:01 -0000	1.7
  @@ -1,5 +1,5 @@
   /*
  - * $Id: LineLayoutManager.java,v 1.6 2002/04/26 09:40:57 keiron Exp $
  + * $Id: LineLayoutManager.java,v 1.7 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -44,7 +44,7 @@
    *
    * How do we handle Unicode BIDI?
    */
  -public class LineLayoutManager extends AbstractLayoutManager {
  +public class LineLayoutManager extends AbstractBPLayoutManager {
       private LineInfo currentLine = null;
       private boolean bFirstLine = true;
       private MinOptMax totalIPD;
  @@ -68,8 +68,8 @@
           // footnotes, floats?
       }
   
  -    public LineLayoutManager(List lms, int lh, int l, int f) {
  -        super(null);
  +    public LineLayoutManager(FObj fobjBlock, List lms, int lh, int l, int f) {
  +        super(fobjBlock);
           lmList = lms;
           lineHeight = lh;
           lead = l;
  @@ -165,7 +165,7 @@
           if (currentLine != null) {
               // Adjust spacing as necessary
               adjustSpacing();
  -            verticalAlign();
  +            verticalAlign(currentLine.area);
   
               boolean res = parentLM.addChild(currentLine.area);
   
  @@ -278,9 +278,9 @@
   
       }
   
  -    private void verticalAlign() {
  +    protected void verticalAlign(LineArea lineArea) {
           int maxHeight = lineHeight;
  -        List inlineAreas = currentLine.area.getInlineAreas();
  +        List inlineAreas = lineArea.getInlineAreas();
   
           // get smallest possible offset to before edge
           // this depends on the height of no and middle alignments
  @@ -376,9 +376,9 @@
               }
           }
           if (before + after > maxHeight) {
  -            currentLine.area.setHeight(before + after);
  +            lineArea.setHeight(before + after);
           } else {
  -            currentLine.area.setHeight(maxHeight);
  +            lineArea.setHeight(maxHeight);
           }
       }
   
  @@ -392,7 +392,7 @@
           return currentLine.area;
       }
   
  -    private void createLine() {
  +    protected void createLine() {
           currentLine = new LineInfo();
           currentLine.startPos = curPos;
           currentLine.area = new LineArea();
  
  
  
  1.3       +99 -8     xml-fop/src/org/apache/fop/layoutmgr/SpaceSpecifier.java
  
  Index: SpaceSpecifier.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/SpaceSpecifier.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SpaceSpecifier.java	8 Jan 2002 09:52:17 -0000	1.2
  +++ SpaceSpecifier.java	28 Apr 2002 21:28:01 -0000	1.3
  @@ -1,5 +1,5 @@
   /*
  - * $Id: SpaceSpecifier.java,v 1.2 2002/01/08 09:52:17 keiron Exp $
  + * $Id: SpaceSpecifier.java,v 1.3 2002/04/28 21:28:01 klease Exp $
    * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
  @@ -7,10 +7,9 @@
   
   package org.apache.fop.layoutmgr;
   
  -import org.apache.fop.area.Area;
   import org.apache.fop.area.MinOptMax;
  -import org.apache.fop.datatypes.Space;
  -
  +import org.apache.fop.traits.SpaceVal;
  +import java.util.Vector;
   
   /**
    * Accumulate a sequence of space-specifiers (XSL space type) on
  @@ -19,13 +18,105 @@
    */
   public class SpaceSpecifier {
   
  +
  +    private boolean m_bStartsRefArea;
  +    private boolean m_bHasForcing=false;
  +    private Vector m_vecSpaceVals = new Vector(3);
  +
  +
  +    public SpaceSpecifier(boolean bStartsRefArea) {
  +	m_bStartsRefArea = bStartsRefArea;
  +    }
  +
  +    /**
  +     * Clear all space specifiers and fences.
  +     */
  +    public void clear() {
  +	m_bHasForcing=false;
  +	m_vecSpaceVals.clear();
  +    }
  +
  +    /**
  +     * Add a new space to the sequence. If this sequence starts a reference
  +     * area, and the added space is conditional, and there are no
  +     * non-conditional values in the sequence yet, then ignore it. Otherwise
  +     * add it to the sequence.
  +     */
  +    public void addSpace(SpaceVal moreSpace) {
  +	if (!m_bStartsRefArea || !moreSpace.bConditional ||
  +	    !m_vecSpaceVals.isEmpty()) {
  +	    if (moreSpace.bForcing) {
  +		if (m_bHasForcing == false) {
  +		    // Remove all other values (must all be non-forcing)
  +		    // Back to the preceding fence
  +		    m_vecSpaceVals.clear();
  +		    m_bHasForcing = true;
  +		}
  +		m_vecSpaceVals.add(moreSpace);
  +	    }
  +	    else if (m_bHasForcing==false) {
  +		m_vecSpaceVals.add(moreSpace);
  +	    }
  +	}
  +    }
  +
       /**
  -     * Combine passed space property value with any existing space.
  +     * Add a "fence" following or preceding any space-specifiers.
  +     * Note that we always add specifiers to the sequence in the
  +     * progression direction, either inline or block. 
        */
  -    public void addSpace(Space moreSpace) {
  +    public void addFence() {
  +	// Fence as first value clears m_bStartsRefArea
  +	// Fence clears m_bHasForcing
       }
   
  -    public MinOptMax resolve() {
  -        return new MinOptMax();
  +    /**
  +     * Resolve the current sequence of space-specifiers, accounting for
  +     * forcing values and "fence" behavior.
  +     * @param bEndsReferenceArea True if the sequence should be resolved
  +     * at the trailing edge of reference area.
  +     * @return The resolved value as a min/opt/max triple.
  +     */
  +    public MinOptMax resolve(boolean bEndsReferenceArea) {
  +	int lastIndex = m_vecSpaceVals.size();
  +	if (bEndsReferenceArea) {
  +	    // Start from the end and count conditional specifiers
  +	    // Stop at first non-conditional or first fence
  +	    for (; lastIndex > 0; --lastIndex) {
  +		SpaceVal sval =
  +		    (SpaceVal)m_vecSpaceVals.elementAt(lastIndex-1);
  +		if (!sval.bConditional) {
  +		    break;
  +		}
  +	    }
  +	}
  +	MinOptMax resSpace = new MinOptMax(0);
  +	// Must calculate in sub-sequences delimited by fences!
  +	int iMaxPrec = -1;
  +	for(int index=0; index < lastIndex; index++) {
  +	    SpaceVal sval = (SpaceVal)m_vecSpaceVals.elementAt(index);
  +	    if (m_bHasForcing) {
  +		resSpace.add(sval.space);
  +	    }
  +	    else if (sval.iPrecedence > iMaxPrec) {
  +		iMaxPrec = sval.iPrecedence;
  +		resSpace = sval.space;
  +	    }
  +	    else if (sval.iPrecedence == iMaxPrec)  {
  +		if (sval.space.opt > resSpace.opt) {
  +		    resSpace = sval.space;
  +		}
  +		else if (sval.space.opt == resSpace.opt) {
  +		    if (resSpace.min < sval.space.min) {
  +			resSpace.min = sval.space.min;
  +		    }
  +		    if (resSpace.max > sval.space.max) {
  +			resSpace.max = sval.space.max;
  +		    }
  +		}
  +	    }
  +	    
  +	}
  +	return resSpace;
       }
   }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/traits/BlockProps.java
  
  Index: BlockProps.java
  ===================================================================
  /*
   * $Id: BlockProps.java,v 1.1 2002/04/28 21:28:02 klease Exp $
   * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.traits;
  
  import org.apache.fop.datatypes.Length;
  
  /**
   * Store all block-level layout properties on an FO.
   * Public "structure" allows direct member access.
   */
  public class BlockProps {
      public int firstIndent; // text-indent
      public int lastIndent;  // last-line-indent
      public int textAlign;
      public int textAlignLast;
      public int lineStackType; // line-stacking-strategy (enum)
  
      public BlockProps() {}
  
  }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/traits/InlineProps.java
  
  Index: InlineProps.java
  ===================================================================
  /*
   * $Id: InlineProps.java,v 1.1 2002/04/28 21:28:02 klease Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.traits;
  
  
  /**
   * Store all inline "margin" related properties
   * Public "structure" allows direct member access.
   */
  public class InlineProps {
      public int marginTop;
      public int marginBottom;
      public int marginLeft;
      public int marginRight;
      public SpaceVal spaceStart;
      public SpaceVal spaceEnd;
  
      public InlineProps() {}
  
  }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/traits/LayoutProps.java
  
  Index: LayoutProps.java
  ===================================================================
  /*
   * $Id: LayoutProps.java,v 1.1 2002/04/28 21:28:02 klease Exp $
   * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.traits;
  
  import org.apache.fop.datatypes.Length;
  import org.apache.fop.fo.properties.Constants;
  
  /**
   * Store properties affecting layout: break-before, break-after, keeps, span.
   * for a block level FO.
   * Public "structure" allows direct member access.
   */
  public class LayoutProps {
      public int breakBefore;  // enum constant BreakBefore.xxx
      public int breakAfter;   // enum constant BreakAfter.xxx
      public boolean bIsSpan;
      public SpaceVal spaceBefore;
      public SpaceVal spaceAfter;
  
      private static final int[] s_breakPriorities = new int[] {
  	Constants.AUTO, Constants.COLUMN, Constants.PAGE };
  
  
      public LayoutProps() {
  	breakBefore = breakAfter = Constants.AUTO;
  	bIsSpan = false;
      }
  
  //     public static int higherBreak(int brkParent, int brkChild) {
  // 	if (brkParent == brkChild) return brkChild;
  // 	for (int i=0; i < s_breakPriorities.length; i++) {
  // 	    int bp = s_breakPriorities[i];
  // 	    if (bp == brkParent) return brkChild;
  // 	    else if (bp == brkChild) return brkParent;
  // 	}
  // 	return brkChild;
  //     }
  
      public void combineWithParent(LayoutProps parentLP) {
  	if (parentLP.breakBefore != breakBefore) {
  	    for (int i=0; i < s_breakPriorities.length; i++) {
  		int bp = s_breakPriorities[i];
  		if (bp == breakBefore) {
  		    breakBefore = parentLP.breakBefore;
  		    break;
  		}
  		else if (bp == parentLP.breakBefore) break;
  	    }
  	}
  	// Parent span always overrides child span
  	bIsSpan = parentLP.bIsSpan;
      }
  }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/traits/SpaceVal.java
  
  Index: SpaceVal.java
  ===================================================================
  /*
   * $Id: SpaceVal.java,v 1.1 2002/04/28 21:28:02 klease Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.traits;
  
  import org.apache.fop.datatypes.Space;
  import org.apache.fop.area.MinOptMax;
  import org.apache.fop.fo.Property;
  import org.apache.fop.fo.properties.Constants;
  
  /**
   * Store a single Space property value in simplified form, with all
   * Length values resolved.
   */
  public class SpaceVal {
      public final MinOptMax space;
      public final boolean bConditional;
      public final boolean bForcing;
      public final int iPrecedence; //  Numeric only, if forcing, set to 0
  
      public SpaceVal(Space spaceprop) {
  	space = new MinOptMax(
  			      spaceprop.getMinimum().getLength().mvalue(),
  			      spaceprop.getOptimum().getLength().mvalue(),
  			      spaceprop.getMaximum().getLength().mvalue());
  	bConditional = (spaceprop.getConditionality().getEnum() ==
  			Constants.DISCARD);
  	Property precProp = spaceprop.getPrecedence();
  	if (precProp.getNumber() != null) {
  	    iPrecedence = precProp.getNumber().intValue();
  	    bForcing = false;
  	}
  	else {
  	    bForcing = (precProp.getEnum() == Constants.FORCE);
  	    iPrecedence=0;
  	}
      }
  
      public SpaceVal(MinOptMax space, boolean bConditional, boolean bForcing,
  		    int iPrecedence) {
  	this.space = space;
  	this.bConditional = bConditional;
  	this.bForcing = bForcing;
  	this.iPrecedence = iPrecedence;
      }
  
  }
  
  
  
  

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