genericPadding = new LengthProperty.Maker(0);
genericPadding.setInherited(false);
genericPadding.setDefault("0pt");
+ genericPadding.setPercentBase(LengthBase.BLOCK_WIDTH);
genericPadding.addShorthand(s_generics[PR_PADDING]);
// GenericCondBorderWidth
m.setInherited(false);
m.setDefault("0pt");
m.addShorthand(s_generics[PR_MARGIN]);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin-top", m);
// margin-bottom
m.setInherited(false);
m.setDefault("0pt");
m.addShorthand(s_generics[PR_MARGIN]);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin-bottom", m);
// margin-left
m.setInherited(false);
m.setDefault("0pt");
m.addShorthand(s_generics[PR_MARGIN]);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin-left", m);
// margin-right
m.setInherited(false);
m.setDefault("0pt");
m.addShorthand(s_generics[PR_MARGIN]);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin-right", m);
// space-before
// block-progression-dimension
m = new LengthRangeProperty.Maker(PR_BLOCK_PROGRESSION_DIMENSION);
m.setInherited(false);
+ m.setPercentBase(LengthBase.BLOCK_HEIGHT);
l = new LengthProperty.Maker(CP_MINIMUM);
l.setDefault("auto");
{PR_MAX_HEIGHT, PR_MAX_HEIGHT, PR_MAX_WIDTH, }
});
pdim.setRelative(true);
+ m.setCorresponding(pdim);
addPropertyMaker("block-progression-dimension", m);
// content-height
// inline-progression-dimension
m = new LengthRangeProperty.Maker(PR_INLINE_PROGRESSION_DIMENSION);
m.setInherited(false);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
l = new LengthProperty.Maker(CP_MINIMUM);
l.setDefault("auto");
{PR_MIN_WIDTH, PR_MIN_WIDTH, PR_MIN_HEIGHT, },
{PR_MAX_WIDTH, PR_MAX_WIDTH, PR_MAX_HEIGHT, }
});
+ m.setCorresponding(pdim);
addPropertyMaker("inline-progression-dimension", m);
// max-height
l = new LengthProperty.Maker(PR_WIDTH);
l.setInherited(false);
l.setAutoOk(true);
- l.setPercentBase(LengthBase.CONTAINING_BOX);
+ l.setPercentBase(LengthBase.BLOCK_WIDTH);
l.setDefault("auto");
addPropertyMaker("width", l);
}
m = new LengthProperty.Maker(PR_TEXT_INDENT);
m.setInherited(false);
m.setDefault("0pt");
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("text-indent", m);
// white-space-collapse
m = new LengthProperty.Maker(PR_COLUMN_WIDTH);
m.setInherited(false);
m.setDefault("proportional-column-width(1)", true);
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("column-width", m);
// empty-cells
m.setInherited(false);
m.setDefault("");
m.setDatatypeParser(new BoxPropShorthandParser());
+ m.setPercentBase(LengthBase.BLOCK_WIDTH);
addPropertyMaker("margin", m);
// padding
*/
protected Map markers = null;
+ /**
+ * Dynamic layout dimension. Used to resolve relative lengths.
+ */
+ protected Map layoutDimension = null;
+
/**
* Create a new formatting object.
* All formatting object classes extend this class.
return new PropertyManager(propertyList);
}
+ /* This section is the implemenation of the property context. */
+
+ /**
+ * Assign the size of a layout dimension to the key.
+ * @param key the Layout dimension, from PercentBase.
+ * @param dimension The layout length.
+ */
+ public void setLayoutDimension(Integer key, int dimension) {
+ if (layoutDimension == null){
+ layoutDimension = new HashMap();
+ }
+ layoutDimension.put(key, new Integer(dimension));
+ }
+
+ /**
+ * Assign the size of a layout dimension to the key.
+ * @param key the Layout dimension, from PercentBase.
+ * @param dimension The layout length.
+ */
+ public void setLayoutDimension(Integer key, float dimension) {
+ if (layoutDimension == null){
+ layoutDimension = new HashMap();
+ }
+ layoutDimension.put(key, new Float(dimension));
+ }
+
+ /**
+ * Return the size associated with the key.
+ * @param key The layout dimension key.
+ * @return the length.
+ */
+ public Number getLayoutDimension(Integer key) {
+ if (layoutDimension != null) {
+ Number result = (Number) layoutDimension.get(key);
+ if (result != null) {
+ return result;
+ }
+ }
+ if (parent != null) {
+ return ((FObj) parent).getLayoutDimension(key);
+ }
+ return new Integer(0);
+ }
+
/**
* Add the child to this object.
*
*/
public BlockProps getBlockProps() {
BlockProps props = new BlockProps();
- props.firstIndent = this.propertyList.get(PR_TEXT_INDENT).getLength().getValue();
+ props.firstIndent = this.propertyList.get(PR_TEXT_INDENT).getLength();
props.lastIndent = 0;
/*this.propertyList.get("last-line-end-indent").getLength().mvalue(); */
props.textAlign = this.propertyList.get(PR_TEXT_ALIGN).getEnum();
package org.apache.fop.fo.flow;
// XML
-import org.xml.sax.Attributes;
+import java.awt.geom.Rectangle2D;
-// FOP
import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOTreeVisitor;
-import org.apache.fop.fo.properties.LengthProperty;
-import org.apache.fop.image.ImageFactory;
+import org.apache.fop.fo.FObj;
import org.apache.fop.image.FopImage;
-// Java
-import java.awt.geom.Rectangle2D;
+import org.apache.fop.image.ImageFactory;
+import org.xml.sax.Attributes;
/**
* External graphic formatting object.
url = ImageFactory.getURL(url);
// assume lr-tb for now and just use the .optimum value of the range
- LengthProperty ipd = propertyList.get(PR_INLINE_PROGRESSION_DIMENSION).
+ Length ipd = propertyList.get(PR_INLINE_PROGRESSION_DIMENSION).
getLengthRange().getOptimum().getLength();
if (!ipd.isAuto()) {
viewWidth = ipd.getValue();
viewWidth = ipd.getValue();
}
}
- LengthProperty bpd = propertyList.get(PR_BLOCK_PROGRESSION_DIMENSION | CP_OPTIMUM).getLength();
+ Length bpd = propertyList.get(PR_BLOCK_PROGRESSION_DIMENSION | CP_OPTIMUM).getLength();
if (!bpd.isAuto()) {
viewHeight = bpd.getValue();
} else {
int cwidth = -1;
int cheight = -1;
- LengthProperty ch = propertyList.get(PR_CONTENT_HEIGHT).getLength();
+ Length ch = propertyList.get(PR_CONTENT_HEIGHT).getLength();
if (!ch.isAuto()) {
/*if (ch.scaleToFit()) {
if (viewHeight != -1) {
} else {*/
cheight = ch.getValue();
}
- LengthProperty cw = propertyList.get(PR_CONTENT_WIDTH).getLength();
+ Length cw = propertyList.get(PR_CONTENT_WIDTH).getLength();
if (!cw.isAuto()) {
/*if (cw.scaleToFit()) {
if (viewWidth != -1) {
import org.apache.fop.fo.properties.CommonBackground;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
-import org.apache.fop.fo.properties.Property;
/**
* Class modelling the fo:table-column object. See Sec. 6.7.4 of the XSL-FO
private ColorType backgroundColor;
- private Length columnWidthPropVal;
- private int columnWidth;
+ private Length columnWidth;
private int columnOffset;
private int numColumnsRepeated;
private int iColumnNumber;
/**
* @return Length object containing column width
*/
- public Length getColumnWidthAsLength() {
- return columnWidthPropVal;
- }
-
- /**
- * @return the column width (in millipoints ??)
- */
- public int getColumnWidth() {
+ public Length getColumnWidth() {
return columnWidth;
}
- /**
- * Set the column width value, overriding the value from the column-width
- * Property.
- * @param columnWidth the column width value in base units (millipoints ??)
- */
- public void setColumnWidth(int columnWidth) {
- this.columnWidth = columnWidth;
- }
-
/**
* @return column number
*/
this.backgroundColor =
this.propertyList.get(PR_BACKGROUND_COLOR).getColorType();
- Property prop = this.propertyList.get(PR_COLUMN_WIDTH);
- if (prop != null) {
- columnWidthPropVal = propertyList.get(PR_COLUMN_WIDTH).getLength();
-
- // This won't include resolved table-units or % values yet.
- columnWidth = columnWidthPropVal.getValue();
- } else {
- columnWidth = 300000;
- }
+ columnWidth = this.propertyList.get(PR_COLUMN_WIDTH).getLength();
// initialize id
setupID();
import org.apache.fop.area.CTM;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.traits.MinOptMax;
/**
// stackSize.add(spaceBefore);
BreakPoss lastPos = null;
+ fobj.setLayoutDimension(PercentBase.BLOCK_IPD, ipd);
+ fobj.setLayoutDimension(PercentBase.BLOCK_BPD, bpd - bIndents);
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, ipd);
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, bpd - bIndents);
+
while ((curLM = getChildLM()) != null) {
// Make break positions and return blocks!
// Set up a LayoutContext
import java.util.ArrayList;
import java.util.List;
+import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.TextInfo;
import org.apache.fop.fo.PropertyManager;
BreakPoss lastPos = null;
+ // Set context for percentage property values.
+ fobj.setLayoutDimension(PercentBase.BLOCK_IPD, ipd);
+ fobj.setLayoutDimension(PercentBase.BLOCK_BPD, -1);
+
while ((curLM = getChildLM()) != null) {
// Make break positions and return blocks!
// Set up a LayoutContext
*/
package org.apache.fop.layoutmgr;
+import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.PropertyManager;
import org.apache.fop.fo.properties.CommonMarginBlock;
import org.apache.fop.fo.properties.CommonHyphenation;
private BreakPoss prevBP = null; // Last confirmed break position
private int bTextAlignment = TextAlign.JUSTIFY;
- private int iTextIndent = 0;
+ private Length textIndent;
private int iIndents = 0;
private CommonHyphenation hyphProps;
iIndents = marginProps.startIndent + marginProps.endIndent;
BlockProps blockProps = propMgr.getBlockProps();
bTextAlignment = blockProps.textAlign;
- iTextIndent = blockProps.firstIndent;
+ textIndent = blockProps.firstIndent;
hyphProps = propMgr.getHyphenationProps();
}
clearPrevIPD();
int iPrevLineEnd = vecInlineBreaks.size();
- // Adjust available line length by text-indent.
if (iPrevLineEnd == 0 && bTextAlignment == TextAlign.START) {
- availIPD.subtract(new MinOptMax(iTextIndent));
- }
+ availIPD.subtract(new MinOptMax(textIndent.getValue()));
+ }
prevBP = null;
while ((curLM = getChildLM()) != null) {
if (prev == null) {
vecInlineBreaks.clear();
} else if ((iPrev = vecInlineBreaks.indexOf(prev)) != -1) {
- for (int i = vecInlineBreaks.size(); iPrev < i; --i) {
+ for (int i = vecInlineBreaks.size()-1; iPrev < i; --i) {
vecInlineBreaks.remove(i);
}
}
break;
case TextAlign.START:
if (prevLineEnd == 0) {
- indent = iTextIndent;
+ indent = textIndent.getValue();
}
- break;
+ break;
case TextAlign.CENTER:
indent = (targetWith - realWidth) / 2;
break;
import org.apache.fop.area.Footnote;
import org.apache.fop.area.Resolveable;
+import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.datatypes.FODimension;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.pagination.PageNumberGenerator;
childLC.setRefIPD(flowIPD);
if (!curLM.isFinished()) {
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD);
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD);
bp = curLM.getNextBreakPoss(childLC);
}
if (bp != null) {
spm.propertyList.get(PR_PAGE_WIDTH).getLength().getValue();
int pageHeight =
spm.propertyList.get(PR_PAGE_HEIGHT).getLength().getValue();
+ // Set the page dimension as the toplevel containing block for margin.
+ ((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth);
+ ((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight);
+
// Get absolute margin properties (top, left, bottom, right)
CommonMarginBlock mProps = spm.getPropertyManager().getMarginProps();
for (Iterator regenum = spm.getRegions().values().iterator();
regenum.hasNext();) {
Region r = (Region)regenum.next();
+ r.setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth);
+ r.setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight);
RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM);
if (r.getRegionClassCode() == Region.BODY_CODE) {
rvp.setRegion(makeRegionBodyReferenceArea(r, rvp.getViewArea()));
*/
package org.apache.fop.layoutmgr.table;
+import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyManager;
import org.apache.fop.layoutmgr.AbstractLayoutManager;
* column properties.
*/
public class Column extends AbstractLayoutManager {
- private int columnWidth;
private CommonBorderAndPadding borderProps = null;
private CommonBackground backgroundProps;
*/
public void setFObj(FObj fobj) {
super.setFObj(fobj);
- columnWidth = ((TableColumn)fobj).getColumnWidth();
}
/**
*
* @return the width of the column
*/
- public int getWidth() {
- return columnWidth;
+ public Length getWidth() {
+ return ((TableColumn)fobj).getColumnWidth();
}
/**
} else {
col = (Column)columns.get(cellcount - 1);
}
- childLC.setRefIPD(col.getWidth());
+ childLC.setRefIPD(col.getWidth().getValue());
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
childLM.setRowHeight(rowHeight);
childLM.addAreas(breakPosIter, lc);
}
- xoffset += col.getWidth();
+ xoffset += col.getWidth().getValue();
}
}
*/
package org.apache.fop.layoutmgr.table;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBase;
import org.apache.fop.fo.PropertyManager;
+import org.apache.fop.fo.properties.TableColLength;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutProcessor;
import org.apache.fop.layoutmgr.LeafPosition;
import org.apache.fop.fo.properties.CommonBackground;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
/**
// stackSize.add(spaceBefore);
BreakPoss lastPos = null;
+ fobj.setLayoutDimension(PercentBase.BLOCK_IPD, context.getRefIPD());
+ fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, context.getRefIPD());
+ fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
+
+ int sumCols = 0;
+ float factors = 0;
+ if (columns != null) {
+ for (Iterator i = columns.iterator(); i.hasNext(); ) {
+ Column column = (Column) i.next();
+ Length width = column.getWidth();
+ sumCols += width.getValue();
+ if (width instanceof TableColLength) {
+ factors += ((TableColLength) width).getTableUnits();
+ }
+ }
+ }
+ if (sumCols < context.getRefIPD()) {
+ fobj.setLayoutDimension(PercentBase.TABLE_UNITS, (context.getRefIPD() - sumCols) / factors);
+ }
MinOptMax headerSize = null;
if (tableHeader != null) {
tableHeader.setUserAgent(getUserAgent());
}
try {
- Integer iWidth = new Integer(tc.getColumnWidth() / 1000);
+ Integer iWidth = new Integer(tc.getColumnWidth().getValue() / 1000);
builderContext.getTableContext().setNextColumnWidth(iWidth.toString() + "pt");
builderContext.getTableContext().setNextColumnRowSpanning(new Integer(0), null);
} catch (Exception e) {
*/
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 Length firstIndent; // text-indent
public int lastIndent; // last-line-indent
public int textAlign;
public int textAlignLast;