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 ac...@apache.org on 2008/04/01 17:09:51 UTC
svn commit: r643433 [6/9] - in
/xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./ lib/ src/codegen/fonts/
src/documentation/ src/documentation/content/
src/documentation/content/xdocs/ src/documentation/content/xdocs/0.93/
src/documentation/content/xd...
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -45,7 +45,6 @@
* LayoutManager for the fo:character formatting object
*/
public class CharacterLayoutManager extends LeafNodeLayoutManager {
- private Character fobj;
private MinOptMax letterSpaceIPD;
private int hyphIPD;
private Font font;
@@ -57,13 +56,13 @@
* @param node the fo:character formatting object
*/
public CharacterLayoutManager(Character node) {
- // @todo better null checking of node
super(node);
- fobj = node;
}
/** {@inheritDoc} */
public void initialize() {
+ Character fobj = (Character)this.fobj;
+
FontInfo fi = fobj.getFOEventHandler().getFontInfo();
FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
@@ -90,7 +89,7 @@
text.addWord(String.valueOf(ch), 0);
}
TraitSetter.setProducerID(text, node.getId());
- TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
+ TraitSetter.addTextDecoration(text, node.getTextDecoration());
return text;
}
@@ -105,6 +104,8 @@
return null;
}
+ Character fobj = (Character)this.fobj;
+
ipd = new MinOptMax(font.getCharWidth(fobj.getCharacter()));
curArea.setIPD(ipd.opt);
@@ -178,14 +179,7 @@
/** {@inheritDoc} */
public boolean applyChanges(List oldList) {
setFinished(false);
- if (isSomethingChanged) {
- // there is nothing to do,
- // possible changes have already been applied
- // in the hyphenate() method
- return true;
- } else {
- return false;
- }
+ return isSomethingChanged;
}
/** {@inheritDoc} */
@@ -236,11 +230,6 @@
setFinished(true);
return returnList;
- }
-
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -19,9 +19,20 @@
package org.apache.fop.layoutmgr.inline;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
+import org.apache.fop.area.LineArea;
+import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.pagination.Title;
import org.apache.fop.layoutmgr.AbstractBaseLayoutManager;
@@ -34,19 +45,8 @@
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.SpaceSpecifier;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.LineArea;
-import org.apache.fop.area.inline.InlineArea;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.ArrayList;
-import java.util.Iterator;
import org.apache.fop.traits.MinOptMax;
-import org.apache.fop.area.Block;
-
/**
* Content Layout Manager.
* For use with objects that contain inline areas such as
@@ -115,7 +115,7 @@
childLC.setLeadingSpace(new SpaceSpecifier(false));
childLC.setTrailingSpace(new SpaceSpecifier(false));
// set stackLimit for lines
- childLC.setStackLimit(new MinOptMax(ipd));
+ childLC.setStackLimitIP(new MinOptMax(ipd));
childLC.setRefIPD(ipd);
int lineHeight = 14000;
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -31,12 +31,10 @@
* and id areas are maintained for later retrieval.
*/
public class ICLayoutManager extends LeafNodeLayoutManager {
- private InlineContainer fobj;
private List childrenLM;
public ICLayoutManager(InlineContainer node, List childLM) {
super(node);
- fobj = node;
childrenLM = childLM;
}
@@ -44,7 +42,4 @@
return null;
}
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -19,12 +19,13 @@
package org.apache.fop.layoutmgr.inline;
-import java.util.ListIterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.InlineBlockParent;
@@ -47,12 +48,12 @@
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.NonLeafPosition;
-import org.apache.fop.layoutmgr.SpaceSpecifier;
-import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.NonLeafPosition;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
+import org.apache.fop.layoutmgr.SpaceSpecifier;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.traits.SpaceVal;
@@ -296,7 +297,7 @@
);
}
- while ((curLM = (LayoutManager) getChildLM()) != null) {
+ while ((curLM = getChildLM()) != null) {
if (!(curLM instanceof InlineLevelLayoutManager)) {
// A block LM
@@ -435,7 +436,7 @@
// layout context given to lastLM, but must be cleared in the
// layout context given to the other LMs.
LinkedList positionList = new LinkedList();
- NonLeafPosition pos = null;
+ NonLeafPosition pos;
LayoutManager lastLM = null;// last child LM in this iterator
Position lastPos = null;
while (parentIter.hasNext()) {
@@ -597,11 +598,6 @@
this.auxiliaryPosition = new NonLeafPosition(this, null);
//}
return this.auxiliaryPosition;
- }
-
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -75,15 +75,9 @@
private Area currentArea; // LineArea or InlineParent
- //private BreakPoss prevBP;
-
/** The child layout context */
protected LayoutContext childLC;
- private boolean bAreaCreated = false;
-
- //private LayoutManager currentLM = null;
-
/** Used to store previous content IPD for each child LM. */
private HashMap hmPrevIPD = new HashMap();
@@ -171,14 +165,6 @@
}
/**
- * This method is called by addAreas() so IDs can be added to a page for FOs that
- * support the 'id' property.
- */
- protected void addId() {
- // Do nothing here, overriden in subclasses that have an 'id' property.
- }
-
- /**
* Returns the current area.
* @return the current area
*/
@@ -255,7 +241,7 @@
// "unwrap" the Position stored in each element of oldList
while (oldListIterator.hasNext()) {
element = (KnuthElement) oldListIterator.next();
- element.setPosition(((NonLeafPosition)element.getPosition()).getPosition());
+ element.setPosition(element.getPosition().getPosition());
}
// The last element may not have a layout manager (its position == null);
@@ -288,7 +274,7 @@
// "unwrap" the Position stored in each element of oldList
while (oldListIterator.hasNext()) {
element = (KnuthElement) oldListIterator.next();
- element.setPosition(((NonLeafPosition)element.getPosition()).getPosition());
+ element.setPosition(element.getPosition().getPosition());
}
((InlineLevelLayoutManager)
@@ -298,14 +284,14 @@
/** {@inheritDoc} */
public void getWordChars(StringBuffer sbChars, Position pos) {
- Position newPos = ((NonLeafPosition) pos).getPosition();
+ Position newPos = pos.getPosition();
((InlineLevelLayoutManager)
newPos.getLM()).getWordChars(sbChars, newPos);
}
/** {@inheritDoc} */
public void hyphenate(Position pos, HyphContext hc) {
- Position newPos = ((NonLeafPosition) pos).getPosition();
+ Position newPos = pos.getPosition();
((InlineLevelLayoutManager)
newPos.getLM()).hyphenate(newPos, hc);
}
@@ -318,7 +304,7 @@
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement) oldListIterator.next();
oldElement.setPosition
- (((NonLeafPosition) oldElement.getPosition()).getPosition());
+ (oldElement.getPosition().getPosition());
}
// reset the iterator
oldListIterator = oldList.listIterator();
@@ -385,7 +371,7 @@
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement) oldListIterator.next();
oldElement.setPosition
- (((NonLeafPosition) oldElement.getPosition()).getPosition());
+ (oldElement.getPosition().getPosition());
}
// reset the iterator
oldListIterator = oldList.listIterator();
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -339,11 +339,6 @@
return returnList;
}
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
-
/**
* {@inheritDoc}
*/
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -65,8 +65,6 @@
/** The alignment context applying to this area */
protected AlignmentContext alignmentContext = null;
- private MinOptMax ipd;
-
/** Flag to indicate if something was changed as part of the getChangeKnuthElements sequence */
protected boolean isSomethingChanged = false;
/** Our area info for the Knuth elements */
@@ -202,14 +200,6 @@
*/
protected InlineArea getEffectiveArea() {
return curArea;
- }
-
- /**
- * This method is called by addAreas() so IDs can be added to a page for FOs that
- * support the 'id' property.
- */
- protected void addId() {
- // Do nothing here, overriden in subclasses that have an 'id' property.
}
/**
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.LineArea;
import org.apache.fop.area.Trait;
@@ -582,9 +583,6 @@
// Get a break from currently active child LM
// Set up constraints for inline level managers
- // IPD remaining in line
- MinOptMax availIPD = context.getStackLimit();
-
clearPrevIPD();
//PHASE 1: Create Knuth elements
@@ -646,7 +644,7 @@
InlineLevelLayoutManager curLM;
LinkedList returnedList = null;
- iLineWidth = context.getStackLimit().opt;
+ iLineWidth = context.getStackLimitIP().opt;
// convert all the text in a sequence of paragraphs made
// of KnuthBox, KnuthGlue and KnuthPenalty objects
@@ -1687,7 +1685,7 @@
*/
if (false && textAlignment == EN_JUSTIFY) {
// re-compute space adjust ratio
- int updatedDifference = context.getStackLimit().opt
+ int updatedDifference = context.getStackLimitIP().opt
- lbp.lineWidth + lbp.difference;
double updatedRatio = 0.0;
if (updatedDifference > 0) {
@@ -1701,12 +1699,12 @@
} else if (false && textAlignment == EN_CENTER) {
// re-compute indent
int updatedIndent = lbp.startIndent
- + (context.getStackLimit().opt - lbp.lineWidth) / 2;
+ + (context.getStackLimitIP().opt - lbp.lineWidth) / 2;
lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent));
} else if (false && textAlignment == EN_END) {
// re-compute indent
int updatedIndent = lbp.startIndent
- + (context.getStackLimit().opt - lbp.lineWidth);
+ + (context.getStackLimitIP().opt - lbp.lineWidth);
lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent));
}
@@ -1770,7 +1768,7 @@
// set last area flag
blocklc.setFlags(LayoutContext.LAST_AREA,
(context.isLastArea() && childLM == lastLM));
- blocklc.setStackLimit(context.getStackLimit());
+ blocklc.setStackLimitsFrom(context);
// Add the line areas to Area
childLM.addAreas(childPosIter, blocklc);
blocklc.setLeadingSpace(blocklc.getTrailingSpace());
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -42,7 +42,7 @@
* Constructor
*
* @param node the fo:page-number formatting object that creates the area
- * @todo better null checking of node, font
+ * TODO better null checking of node, font
*/
public PageNumberLayoutManager(PageNumber node) {
super(node);
@@ -131,9 +131,5 @@
return width;
}
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -19,29 +19,29 @@
package org.apache.fop.layoutmgr.list;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
import org.apache.fop.fo.flow.ListBlock;
-import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.ConditionalElementListener;
import org.apache.fop.layoutmgr.ElementListUtils;
-import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.RelSide;
import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.traits.SpaceVal;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
/**
* LayoutManager for a list-block FO.
* A list block contains list items which are stacked within
@@ -156,11 +156,11 @@
addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore()));
}
- getPSLM().addIDToPage(getListBlockFO().getId());
+ addId();
// the list block contains areas stacked from each list item
- LayoutManager childLM = null;
+ LayoutManager childLM;
LayoutContext lc = new LayoutContext(0);
LayoutManager firstLM = null;
LayoutManager lastLM = null;
@@ -181,10 +181,10 @@
}
if (pos instanceof NonLeafPosition
&& (pos.getPosition() != null)
- && ((NonLeafPosition) pos).getPosition().getLM() != this) {
+ && pos.getPosition().getLM() != this) {
// pos was created by a child of this ListBlockLM
- positionList.add(((NonLeafPosition) pos).getPosition());
- lastLM = ((NonLeafPosition) pos).getPosition().getLM();
+ positionList.add(pos.getPosition());
+ lastLM = pos.getPosition().getLM();
if (firstLM == null) {
firstLM = lastLM;
}
@@ -200,7 +200,7 @@
lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
lc.setFlags(LayoutContext.FIRST_AREA, childLM == firstLM);
lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM);
- lc.setStackLimit(layoutContext.getStackLimit());
+ lc.setStackLimitBP(layoutContext.getStackLimitBP());
childLM.addAreas(childPosIter, lc);
}
@@ -218,7 +218,7 @@
curBlockArea = null;
resetSpaces();
- getPSLM().notifyEndOfLayout(((ListBlock)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
}
/**
@@ -280,7 +280,7 @@
/** {@inheritDoc} */
public boolean mustKeepTogether() {
//TODO Keeps will have to be more sophisticated sooner or later
- return ((BlockLevelLayoutManager)getParent()).mustKeepTogether()
+ return super.mustKeepTogether()
|| !getListBlockFO().getKeepTogether().getWithinPage().isAuto()
|| !getListBlockFO().getKeepTogether().getWithinColumn().isAuto();
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -19,24 +19,24 @@
package org.apache.fop.layoutmgr.list;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
import org.apache.fop.fo.flow.AbstractListItemPart;
import org.apache.fop.fo.flow.ListItemBody;
import org.apache.fop.fo.flow.ListItemLabel;
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
-import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
/**
* LayoutManager for a list-item-label or list-item-body FO.
@@ -115,9 +115,9 @@
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(getPartFO().getId());
+ addId();
- LayoutManager childLM = null;
+ LayoutManager childLM;
LayoutContext lc = new LayoutContext(0);
LayoutManager firstLM = null;
LayoutManager lastLM = null;
@@ -141,8 +141,8 @@
}
if (pos instanceof NonLeafPosition) {
// pos was created by a child of this ListBlockLM
- positionList.add(((NonLeafPosition) pos).getPosition());
- lastLM = ((NonLeafPosition) pos).getPosition().getLM();
+ positionList.add(pos.getPosition());
+ lastLM = pos.getPosition().getLM();
if (firstLM == null) {
firstLM = lastLM;
}
@@ -162,7 +162,7 @@
lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM);
// set the space adjustment ratio
lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
- lc.setStackLimit(layoutContext.getStackLimit());
+ lc.setStackLimitBP(layoutContext.getStackLimitBP());
childLM.addAreas(childPosIter, lc);
}
@@ -172,7 +172,7 @@
curBlockArea = null;
- getPSLM().notifyEndOfLayout(((AbstractListItemPart)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
}
/**
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -19,8 +19,16 @@
package org.apache.fop.layoutmgr.list;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.area.Area;
+import org.apache.fop.area.Block;
import org.apache.fop.fo.flow.ListItem;
import org.apache.fop.fo.flow.ListItemBody;
import org.apache.fop.fo.flow.ListItemLabel;
@@ -30,28 +38,21 @@
import org.apache.fop.layoutmgr.ConditionalElementListener;
import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.layoutmgr.ElementListUtils;
-import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.KnuthBox;
+import org.apache.fop.layoutmgr.KnuthElement;
+import org.apache.fop.layoutmgr.KnuthPenalty;
+import org.apache.fop.layoutmgr.KnuthPossPosIter;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
+import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.RelSide;
import org.apache.fop.layoutmgr.SpaceResolver;
import org.apache.fop.layoutmgr.TraitSetter;
-import org.apache.fop.layoutmgr.KnuthElement;
-import org.apache.fop.layoutmgr.KnuthBox;
-import org.apache.fop.layoutmgr.KnuthPenalty;
-import org.apache.fop.layoutmgr.KnuthPossPosIter;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.traits.SpaceVal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.ListIterator;
-
/**
* LayoutManager for a list-item FO.
* The list item contains a list item label and a list item body.
@@ -72,8 +73,6 @@
private LinkedList labelList = null;
private LinkedList bodyList = null;
- private int listItemHeight;
-
private boolean discardBorderBefore;
private boolean discardBorderAfter;
private boolean discardPaddingBefore;
@@ -83,7 +82,9 @@
private boolean keepWithNextPendingOnLabel;
private boolean keepWithNextPendingOnBody;
-
+
+ private int listItemHeight;
+
private class ListItemPosition extends Position {
private int iLabelFirstIndex;
private int iLabelLastIndex;
@@ -116,6 +117,11 @@
}
/** {@inheritDoc} */
+ public boolean generatesAreas() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
public String toString() {
StringBuffer sb = new StringBuffer("ListItemPosition:");
sb.append(getIndex()).append("(");
@@ -301,12 +307,12 @@
int additionalPenaltyHeight = 0;
KnuthElement endEl = (KnuthElement)elementLists[0].get(end[0]);
if (endEl instanceof KnuthPenalty) {
- additionalPenaltyHeight = ((KnuthPenalty)endEl).getW();
+ additionalPenaltyHeight = endEl.getW();
}
endEl = (KnuthElement)elementLists[1].get(end[1]);
if (endEl instanceof KnuthPenalty) {
additionalPenaltyHeight = Math.max(
- additionalPenaltyHeight, ((KnuthPenalty)endEl).getW());
+ additionalPenaltyHeight, endEl.getW());
}
int boxHeight = step - addedBoxHeight - penaltyHeight;
@@ -413,10 +419,10 @@
// body
// "unwrap" the Positions stored in the elements
ListIterator oldListIterator = oldList.listIterator();
- KnuthElement oldElement = null;
+ KnuthElement oldElement;
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement)oldListIterator.next();
- Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition();
+ Position innerPosition = oldElement.getPosition().getPosition();
//log.debug(" BLM> unwrapping: " + (oldElement.isBox()
// ? "box " : (oldElement.isGlue() ? "glue " : "penalty"))
// + " creato da " + oldElement.getLayoutManager().getClass().getName());
@@ -459,7 +465,7 @@
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(getListItemFO().getId());
+ addId();
LayoutContext lc = new LayoutContext(0);
Position firstPos = null;
@@ -478,7 +484,7 @@
}
if (pos instanceof NonLeafPosition && pos.getPosition() != null) {
// pos contains a ListItemPosition created by this ListBlockLM
- positionList.add(((NonLeafPosition) pos).getPosition());
+ positionList.add(pos.getPosition());
}
}
@@ -510,7 +516,7 @@
// set the space adjustment ratio
lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
// TO DO: use the right stack limit for the label
- lc.setStackLimit(layoutContext.getStackLimit());
+ lc.setStackLimitBP(layoutContext.getStackLimitBP());
label.addAreas(labelIter, lc);
}
@@ -531,7 +537,7 @@
// set the space adjustment ratio
lc.setSpaceAdjust(layoutContext.getSpaceAdjust());
// TO DO: use the right stack limit for the body
- lc.setStackLimit(layoutContext.getStackLimit());
+ lc.setStackLimitBP(layoutContext.getStackLimitBP());
body.addAreas(bodyIter, lc);
}
@@ -554,7 +560,7 @@
curBlockArea = null;
resetSpaces();
- getPSLM().notifyEndOfLayout(((ListItem)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
}
/**
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java Tue Apr 1 08:08:24 2008
@@ -33,6 +33,8 @@
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthPenalty;
+import org.apache.fop.layoutmgr.MinOptMaxUtil;
+import org.apache.fop.traits.MinOptMax;
/**
* A cell playing in the construction of steps for a row-group.
@@ -133,6 +135,49 @@
}
}
+ // TODO to be removed along with the RowPainter#computeContentLength method
+ /** See {@link ActiveCell#handleExplicitHeight(MinOptMax, MinOptMax)}. */
+ private static class FillerPenalty extends KnuthPenalty {
+
+ private int contentLength;
+
+ FillerPenalty(KnuthPenalty p, int length) {
+ super(length, p.getP(), p.isFlagged(), p.getBreakClass(),
+ p.getPosition(), p.isAuxiliary());
+ contentLength = p.getW();
+ }
+
+ FillerPenalty(int length) {
+ super(length, 0, false, null, true);
+ contentLength = 0;
+ }
+ }
+
+ /** See {@link ActiveCell#handleExplicitHeight(MinOptMax, MinOptMax)}. */
+ private static class FillerBox extends KnuthBox {
+ FillerBox(int length) {
+ super(length, null, true);
+ }
+ }
+
+ /**
+ * Returns the actual length of the content represented by the given element. In the
+ * case where this element is used as a filler to match a row's fixed height, the
+ * value returned by the getW() method will be higher than the actual content.
+ *
+ * @param el an element
+ * @return the actual content length corresponding to the element
+ */
+ static int getElementContentLength(KnuthElement el) {
+ if (el instanceof FillerPenalty) {
+ return ((FillerPenalty) el).contentLength;
+ } else if (el instanceof FillerBox) {
+ return 0;
+ } else {
+ return el.getW();
+ }
+ }
+
ActiveCell(PrimaryGridUnit pgu, EffRow row, int rowIndex, int previousRowsLength,
TableLayoutManager tableLM) {
this.pgu = pgu;
@@ -149,23 +194,10 @@
+ pgu.getBeforeBorderWidth(0, ConditionalBorder.REST);
bpAfterNormal = paddingAfterNormal + pgu.getAfterBorderWidth(ConditionalBorder.NORMAL);
bpAfterTrailing = paddingAfterTrailing + pgu.getAfterBorderWidth(0, ConditionalBorder.REST);
- boolean makeBoxForWholeRow = false;
- if (row.getExplicitHeight().min > 0) {
- boolean contentsSmaller = ElementListUtils.removeLegalBreaks(
- pgu.getElements(), row.getExplicitHeight());
- if (contentsSmaller) {
- makeBoxForWholeRow = true;
- }
- }
- if (makeBoxForWholeRow) {
- elementList = new java.util.ArrayList(1);
- int height = row.getHeight().opt;
- height -= 2 * tableLM.getHalfBorderSeparationBPD();
- height -= bpBeforeNormal + bpAfterNormal;
- elementList.add(new KnuthBoxCellWithBPD(height));
- } else {
- elementList = pgu.getElements();
- }
+ elementList = pgu.getElements();
+ handleExplicitHeight(
+ MinOptMaxUtil.toMinOptMax(pgu.getCell().getBlockProgressionDimension(), tableLM),
+ row.getExplicitHeight());
knuthIter = elementList.listIterator();
includedLength = -1; // Avoid troubles with cells having content of zero length
totalLength = previousRowsLength + ElementListUtils.calcContentLength(elementList);
@@ -182,6 +214,46 @@
}
}
+ /**
+ * Modifies the cell's element list by putting filler elements, so that the cell's or
+ * row's explicit height is always reached.
+ *
+ * TODO this will work properly only for the first break. Then the limitation
+ * explained on http://wiki.apache.org/xmlgraphics-fop/TableLayout/KnownProblems
+ * occurs. The list of elements needs to be re-adjusted after each break.
+ */
+ private void handleExplicitHeight(MinOptMax cellBPD, MinOptMax rowBPD) {
+ int minBPD = Math.max(cellBPD.min, rowBPD.min);
+ if (minBPD > 0) {
+ ListIterator iter = elementList.listIterator();
+ int cumulateLength = 0;
+ boolean prevIsBox = false;
+ while (iter.hasNext() && cumulateLength < minBPD) {
+ KnuthElement el = (KnuthElement) iter.next();
+ if (el.isBox()) {
+ prevIsBox = true;
+ cumulateLength += el.getW();
+ } else if (el.isGlue()) {
+ if (prevIsBox) {
+ elementList.add(iter.nextIndex() - 1,
+ new FillerPenalty(minBPD - cumulateLength));
+ }
+ prevIsBox = false;
+ cumulateLength += el.getW();
+ } else {
+ prevIsBox = false;
+ if (cumulateLength + el.getW() < minBPD) {
+ iter.set(new FillerPenalty((KnuthPenalty) el, minBPD - cumulateLength));
+ }
+ }
+ }
+ }
+ int optBPD = Math.max(minBPD, Math.max(cellBPD.opt, rowBPD.opt));
+ if (pgu.getContentLength() < optBPD) {
+ elementList.add(new FillerBox(optBPD - pgu.getContentLength()));
+ }
+ }
+
PrimaryGridUnit getPrimaryGridUnit() {
return pgu;
}
@@ -265,14 +337,22 @@
}
/**
- * Returns the last step for this cell.
+ * Returns the last step for this cell. This includes the normal border- and
+ * padding-before, the whole content, the normal padding-after, and the
+ * <em>trailing</em> after border. Indeed, if the normal border is taken instead,
+ * and appears to be smaller than the trailing one, the last step may be smaller than
+ * the current step (see TableStepper#considerRowLastStep). This will produce a wrong
+ * infinite penalty, plus the cell's content won't be taken into account since the
+ * final step will be smaller than the current one (see {@link #signalNextStep(int)}).
+ * This actually means that the content will be swallowed.
*
- * @return the step including all of the cell's content plus the normal borders and paddings
+ * @return the length of last step
*/
int getLastStep() {
assert nextStep.end == elementList.size() - 1;
assert nextStep.contentLength == totalLength && nextStep.penaltyLength == 0;
- int lastStep = bpBeforeNormal + totalLength + bpAfterNormal;
+ int lastStep = bpBeforeNormal + totalLength + paddingAfterNormal
+ + pgu.getAfterBorderWidth(ConditionalBorder.LEADING_TRAILING);
log.debug(this + ": last step = " + lastStep);
return lastStep;
}
@@ -394,8 +474,12 @@
*/
void endRow(int rowIndex) {
if (endsOnRow(rowIndex)) {
+ // Subtract the old value of bpAfterTrailing...
+ nextStep.totalLength -= bpAfterTrailing;
bpAfterTrailing = paddingAfterNormal
+ pgu.getAfterBorderWidth(ConditionalBorder.LEADING_TRAILING);
+ // ... and add the new one
+ nextStep.totalLength += bpAfterTrailing;
lastCellPart = true;
} else {
bpBeforeLeading = paddingBeforeLeading
@@ -445,13 +529,6 @@
return new CellPart(pgu, nextStep.start, previousStep.end, lastCellPart,
0, 0, previousStep.penaltyLength,
bpBeforeNormal, bpBeforeFirst, bpAfterNormal, bpAfterTrailing);
- } else if (nextStep.start == 0 && nextStep.end == 0
- && elementList.size() == 1
- && elementList.get(0) instanceof KnuthBoxCellWithBPD) {
- //Special case: Cell with fixed BPD
- return new CellPart(pgu, 0, pgu.getElements().size() - 1, lastCellPart,
- nextStep.condBeforeContentLength, length, nextStep.penaltyLength,
- bpBeforeNormal, bpBeforeFirst, bpAfterNormal, bpAfterTrailing);
} else {
return new CellPart(pgu, nextStep.start, nextStep.end, lastCellPart,
nextStep.condBeforeContentLength, length, nextStep.penaltyLength,
@@ -463,20 +540,9 @@
return keepWithNextSignal;
}
-
+
/** {@inheritDoc} */
public String toString() {
return "Cell " + (pgu.getRowIndex() + 1) + "." + (pgu.getColIndex() + 1);
- }
-
-
- /**
- * Marker class denoting table cells fitting in just one box (no legal break inside).
- */
- private static class KnuthBoxCellWithBPD extends KnuthBox {
-
- public KnuthBoxCellWithBPD(int w) {
- super(w, null, true);
- }
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -19,16 +19,16 @@
package org.apache.fop.layoutmgr.table;
+import java.util.Iterator;
import java.util.LinkedList;
-import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.table.EffRow;
import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
+import org.apache.fop.fo.flow.table.TableColumn;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.LengthRangeProperty;
@@ -94,137 +94,119 @@
private void createElementsForRowGroup(LayoutContext context, int alignment,
int bodyType, LinkedList returnList) {
log.debug("Handling row group with " + rowGroup.length + " rows...");
+ EffRow row;
+ for (int rgi = 0; rgi < rowGroup.length; rgi++) {
+ row = rowGroup[rgi];
+ for (Iterator iter = row.getGridUnits().iterator(); iter.hasNext();) {
+ GridUnit gu = (GridUnit) iter.next();
+ if (gu.isPrimary()) {
+ PrimaryGridUnit primary = gu.getPrimary();
+ // TODO a new LM must be created for every new static-content
+ primary.createCellLM();
+ primary.getCellLM().setParent(tableLM);
+ //Calculate width of cell
+ int spanWidth = 0;
+ Iterator colIter = tableLM.getTable().getColumns().listIterator(
+ primary.getColIndex());
+ for (int i = 0, c = primary.getCell().getNumberColumnsSpanned(); i < c; i++) {
+ spanWidth += ((TableColumn) colIter.next()).getColumnWidth().getValue(
+ tableLM);
+ }
+ LayoutContext childLC = new LayoutContext(0);
+ childLC.setStackLimitBP(context.getStackLimitBP()); //necessary?
+ childLC.setRefIPD(spanWidth);
+
+ //Get the element list for the cell contents
+ LinkedList elems = primary.getCellLM().getNextKnuthElements(
+ childLC, alignment);
+ ElementListObserver.observe(elems, "table-cell", primary.getCell().getId());
+ primary.setElements(elems);
+ }
+ }
+ }
+ computeRowHeights();
+ LinkedList elements = tableStepper.getCombinedKnuthElementsForRowGroup(context,
+ rowGroup, bodyType);
+ returnList.addAll(elements);
+ }
+
+ /**
+ * Calculate the heights of the rows in the row group, see CSS21, 17.5.3 Table height
+ * algorithms.
+ *
+ * TODO this method will need to be adapted once clarification has been made by the
+ * W3C regarding whether borders or border-separation must be included or not
+ */
+ private void computeRowHeights() {
+ log.debug("rowGroup:");
MinOptMax[] rowHeights = new MinOptMax[rowGroup.length];
- MinOptMax[] explicitRowHeights = new MinOptMax[rowGroup.length];
EffRow row;
- List pgus = new java.util.ArrayList(); //holds a list of a row's primary grid units
for (int rgi = 0; rgi < rowGroup.length; rgi++) {
row = rowGroup[rgi];
- rowHeights[rgi] = new MinOptMax(0, 0, Integer.MAX_VALUE);
- explicitRowHeights[rgi] = new MinOptMax(0, 0, Integer.MAX_VALUE);
-
- pgus.clear();
- TableRow tableRow = null;
- // The row's minimum content height; 0 if the row's height is auto, otherwise
- // the .minimum component of the explicitly specified value
- int minRowBPD = 0;
// The BPD of the biggest cell in the row
- int maxCellBPD = 0;
- for (int j = 0; j < row.getGridUnits().size(); j++) {
- GridUnit gu = row.getGridUnit(j);
- if ((gu.isPrimary() || (gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()))
- && !gu.isEmpty()) {
+// int maxCellBPD = 0;
+ MinOptMax explicitRowHeight;
+ TableRow tableRowFO = rowGroup[rgi].getTableRow();
+ if (tableRowFO == null) {
+ rowHeights[rgi] = new MinOptMax(0, 0, Integer.MAX_VALUE);
+ explicitRowHeight = new MinOptMax(0, 0, Integer.MAX_VALUE);
+ } else {
+ LengthRangeProperty rowBPD = tableRowFO.getBlockProgressionDimension();
+ rowHeights[rgi] = MinOptMaxUtil.toMinOptMax(rowBPD, tableLM);
+ explicitRowHeight = MinOptMaxUtil.toMinOptMax(rowBPD, tableLM);
+ }
+ for (Iterator iter = row.getGridUnits().iterator(); iter.hasNext();) {
+ GridUnit gu = (GridUnit) iter.next();
+ if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) {
PrimaryGridUnit primary = gu.getPrimary();
-
- if (gu.isPrimary()) {
- // TODO a new LM must be created for every new static-content
- primary.createCellLM();
- primary.getCellLM().setParent(tableLM);
-
- //Determine the table-row if any
- if (tableRow == null && primary.getRow() != null) {
- tableRow = primary.getRow();
-
- //Check for bpd on row, see CSS21, 17.5.3 Table height algorithms
- LengthRangeProperty rowBPD = tableRow.getBlockProgressionDimension();
- if (!rowBPD.getMinimum(tableLM).isAuto()) {
- minRowBPD = Math.max(minRowBPD,
- rowBPD.getMinimum(tableLM).getLength().getValue(tableLM));
- }
- MinOptMaxUtil.restrict(explicitRowHeights[rgi], rowBPD, tableLM);
-
- }
-
- //Calculate width of cell
- int spanWidth = 0;
- for (int i = primary.getColIndex();
- i < primary.getColIndex()
- + primary.getCell().getNumberColumnsSpanned();
- i++) {
- if (tableLM.getColumns().getColumn(i + 1) != null) {
- spanWidth += tableLM.getColumns().getColumn(i + 1)
- .getColumnWidth().getValue(tableLM);
- }
- }
- LayoutContext childLC = new LayoutContext(0);
- childLC.setStackLimit(context.getStackLimit()); //necessary?
- childLC.setRefIPD(spanWidth);
-
- //Get the element list for the cell contents
- LinkedList elems = primary.getCellLM().getNextKnuthElements(
- childLC, alignment);
- ElementListObserver.observe(elems, "table-cell", primary.getCell().getId());
- primary.setElements(elems);
- }
-
- //Calculate height of row, see CSS21, 17.5.3 Table height algorithms
- if (gu.isLastGridUnitRowSpan()) {
- // The effective cell's bpd, after taking into account bpd
- // (possibly explicitly) set on the row or on the cell, and the
- // cell's content length
- int effectiveCellBPD = minRowBPD;
- LengthRangeProperty cellBPD = primary.getCell()
- .getBlockProgressionDimension();
- if (!cellBPD.getMinimum(tableLM).isAuto()) {
- effectiveCellBPD = Math.max(effectiveCellBPD,
- cellBPD.getMinimum(tableLM).getLength().getValue(tableLM));
- }
- if (!cellBPD.getOptimum(tableLM).isAuto()) {
- effectiveCellBPD = Math.max(effectiveCellBPD,
- cellBPD.getOptimum(tableLM).getLength().getValue(tableLM));
- }
- if (gu.getRowSpanIndex() == 0) {
- //TODO ATM only non-row-spanned cells are taken for this
- MinOptMaxUtil.restrict(explicitRowHeights[rgi], cellBPD, tableLM);
- }
- effectiveCellBPD = Math.max(effectiveCellBPD,
- primary.getContentLength());
-
- int borderWidths = primary.getBeforeAfterBorderWidth();
- int padding = 0;
- maxCellBPD = Math.max(maxCellBPD, effectiveCellBPD);
- CommonBorderPaddingBackground cbpb
- = primary.getCell().getCommonBorderPaddingBackground();
- padding += cbpb.getPaddingBefore(false, primary.getCellLM());
- padding += cbpb.getPaddingAfter(false, primary.getCellLM());
- int effRowHeight = effectiveCellBPD
- + padding + borderWidths;
- for (int previous = 0; previous < gu.getRowSpanIndex(); previous++) {
- effRowHeight -= rowHeights[rgi - previous - 1].opt;
- }
- if (effRowHeight > rowHeights[rgi].min) {
- //This is the new height of the (grid) row
- MinOptMaxUtil.extendMinimum(rowHeights[rgi], effRowHeight, false);
- }
+ int effectiveCellBPD = 0;
+ LengthRangeProperty cellBPD = primary.getCell().getBlockProgressionDimension();
+ if (!cellBPD.getMinimum(tableLM).isAuto()) {
+ effectiveCellBPD = cellBPD.getMinimum(tableLM).getLength()
+ .getValue(tableLM);
}
-
- if (gu.isPrimary()) {
- pgus.add(primary);
+ if (!cellBPD.getOptimum(tableLM).isAuto()) {
+ effectiveCellBPD = cellBPD.getOptimum(tableLM).getLength()
+ .getValue(tableLM);
+ }
+ if (gu.getRowSpanIndex() == 0) {
+ effectiveCellBPD = Math.max(effectiveCellBPD, explicitRowHeight.opt);
+ }
+ effectiveCellBPD = Math.max(effectiveCellBPD, primary.getContentLength());
+ int borderWidths = primary.getBeforeAfterBorderWidth();
+ int padding = 0;
+ CommonBorderPaddingBackground cbpb = primary.getCell()
+ .getCommonBorderPaddingBackground();
+ padding += cbpb.getPaddingBefore(false, primary.getCellLM());
+ padding += cbpb.getPaddingAfter(false, primary.getCellLM());
+ int effRowHeight = effectiveCellBPD + padding + borderWidths;
+ for (int prev = rgi - 1; prev >= rgi - gu.getRowSpanIndex(); prev--) {
+ effRowHeight -= rowHeights[prev].opt;
+ }
+ if (effRowHeight > rowHeights[rgi].min) {
+ // This is the new height of the (grid) row
+ MinOptMaxUtil.extendMinimum(rowHeights[rgi], effRowHeight);
}
}
}
row.setHeight(rowHeights[rgi]);
- row.setExplicitHeight(explicitRowHeights[rgi]);
- if (maxCellBPD > row.getExplicitHeight().max) {
- log.warn(FONode.decorateWithContextInfo(
- "The contents of row " + (row.getIndex() + 1)
- + " are taller than they should be (there is a"
- + " block-progression-dimension or height constraint on the indicated row)."
- + " Due to its contents the row grows"
- + " to " + maxCellBPD + " millipoints, but the row shouldn't get"
- + " any taller than " + row.getExplicitHeight() + " millipoints.",
- row.getTableRow()));
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("rowGroup:");
- for (int i = 0; i < rowHeights.length; i++) {
- log.debug(" height=" + rowHeights[i] + " explicit=" + explicitRowHeights[i]);
+ row.setExplicitHeight(explicitRowHeight);
+ // TODO re-enable and improve after clarification
+// if (maxCellBPD > row.getExplicitHeight().max) {
+// log.warn(FONode.decorateWithContextInfo(
+// "The contents of row " + (row.getIndex() + 1)
+// + " are taller than they should be (there is a"
+// + " block-progression-dimension or height constraint
+// + " on the indicated row)."
+// + " Due to its contents the row grows"
+// + " to " + maxCellBPD + " millipoints, but the row shouldn't get"
+// + " any taller than " + row.getExplicitHeight() + " millipoints.",
+// row.getTableRow()));
+// }
+ if (log.isDebugEnabled()) {
+ log.debug(" height=" + rowHeights[rgi] + " explicit=" + explicitRowHeight);
}
}
- LinkedList elements = tableStepper.getCombinedKnuthElementsForRowGroup(context,
- rowGroup, bodyType);
- returnList.addAll(elements);
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Tue Apr 1 08:08:24 2008
@@ -23,25 +23,27 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.area.Block;
import org.apache.fop.fo.flow.table.ConditionalBorder;
import org.apache.fop.fo.flow.table.EffRow;
import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
-import org.apache.fop.fo.flow.table.TableRow;
+import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthPossPosIter;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.SpaceResolver;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.traits.BorderProps;
class RowPainter {
private static Log log = LogFactory.getLog(RowPainter.class);
- /** The fo:table-row containing the currently handled grid rows. */
- private TableRow rowFO = null;
private int colCount;
private int currentRowOffset = 0;
/** Currently handled row (= last encountered row). */
@@ -71,6 +73,13 @@
private CellPart[] firstCellParts;
private CellPart[] lastCellParts;
+ /** y-offset of the current table part. */
+ private int tablePartOffset = 0;
+ /** See {@link RowPainter#registerPartBackgroundArea(Block)}. */
+ private CommonBorderPaddingBackground tablePartBackground;
+ /** See {@link RowPainter#registerPartBackgroundArea(Block)}. */
+ private List tablePartBackgroundAreas;
+
private TableContentLayoutManager tclm;
RowPainter(TableContentLayoutManager tclm, LayoutContext layoutContext) {
@@ -85,6 +94,44 @@
this.firstRowOnPageIndex = -1;
}
+ void startTablePart(TableBody tablePart) {
+ CommonBorderPaddingBackground background = tablePart.getCommonBorderPaddingBackground();
+ if (background.hasBackground()) {
+ tablePartBackground = background;
+ if (tablePartBackgroundAreas == null) {
+ tablePartBackgroundAreas = new ArrayList();
+ }
+ }
+ tablePartOffset = currentRowOffset;
+ }
+
+ /**
+ * Signals that the end of the current table part is reached.
+ *
+ * @param lastInBody true if the part is the last table-body element to be displayed
+ * on the current page. In which case all the cells must be flushed even if they
+ * aren't finished, plus the proper collapsed borders must be selected (trailing
+ * instead of normal, or rest if the cell is unfinished)
+ * @param lastOnPage true if the part is the last to be displayed on the current page.
+ * In which case collapsed after borders for the cells on the last row must be drawn
+ * in the outer mode
+ */
+ void endTablePart(boolean lastInBody, boolean lastOnPage) {
+ addAreasAndFlushRow(lastInBody, lastOnPage);
+
+ if (tablePartBackground != null) {
+ TableLayoutManager tableLM = tclm.getTableLM();
+ for (Iterator iter = tablePartBackgroundAreas.iterator(); iter.hasNext();) {
+ Block backgroundArea = (Block) iter.next();
+ TraitSetter.addBackground(backgroundArea, tablePartBackground, tableLM,
+ -backgroundArea.getXOffset(), tablePartOffset - backgroundArea.getYOffset(),
+ tableLM.getContentAreaIPD(), currentRowOffset - tablePartOffset);
+ }
+ tablePartBackground = null;
+ tablePartBackgroundAreas.clear();
+ }
+ }
+
int getAccumulatedBPD() {
return currentRowOffset;
}
@@ -108,7 +155,6 @@
currentRow = row;
}
}
- rowFO = currentRow.getTableRow();
if (firstRowIndex < 0) {
firstRowIndex = currentRow.getIndex();
if (firstRowOnPageIndex < 0) {
@@ -148,7 +194,7 @@
* displayed on the current page. In which case collapsed after borders must be drawn
* in the outer mode
*/
- void addAreasAndFlushRow(boolean lastInPart, boolean lastOnPage) {
+ private void addAreasAndFlushRow(boolean lastInPart, boolean lastOnPage) {
if (log.isDebugEnabled()) {
log.debug("Remembering yoffset for row " + currentRow.getIndex() + ": "
+ currentRowOffset);
@@ -182,8 +228,6 @@
}
// Then add areas for cells finishing on the current row
- tclm.addRowBackgroundArea(rowFO, actualRowHeight, layoutContext.getRefIPD(),
- currentRowOffset);
for (int i = 0; i < colCount; i++) {
GridUnit currentGU = currentRow.getGridUnit(i);
if (!currentGU.isEmpty() && currentGU.getColSpanIndex() == 0
@@ -255,18 +299,22 @@
// cell, in most cases)
return 0;
} else {
- int actualStart = startIndex;
+ ListIterator iter = pgu.getElements().listIterator(startIndex);
// Skip from the content length calculation glues and penalties occurring at the
// beginning of the page
- while (actualStart <= endIndex
- && !((KnuthElement) pgu.getElements().get(actualStart)).isBox()) {
- actualStart++;
- }
- int len = ElementListUtils.calcContentLength(
- pgu.getElements(), actualStart, endIndex);
- KnuthElement el = (KnuthElement)pgu.getElements().get(endIndex);
- if (el.isPenalty()) {
- len += el.getW();
+ boolean nextIsBox = false;
+ while (iter.nextIndex() <= endIndex && !nextIsBox) {
+ nextIsBox = ((KnuthElement) iter.next()).isBox();
+ }
+ int len = 0;
+ if (((KnuthElement) iter.previous()).isBox()) {
+ while (iter.nextIndex() < endIndex) {
+ KnuthElement el = (KnuthElement) iter.next();
+ if (el.isBox() || el.isGlue()) {
+ len += el.getW();
+ }
+ }
+ len += ActiveCell.getElementContentLength((KnuthElement) iter.next());
}
return len;
}
@@ -278,8 +326,20 @@
* Determine the index of the first row of this cell that will be displayed on the
* current page.
*/
- int startRowIndex = Math.max(pgu.getRowIndex(), firstRowIndex);
int currentRowIndex = currentRow.getIndex();
+ int startRowIndex;
+ int firstRowHeight;
+ if (pgu.getRowIndex() >= firstRowIndex) {
+ startRowIndex = pgu.getRowIndex();
+ if (startRowIndex < currentRowIndex) {
+ firstRowHeight = getRowOffset(startRowIndex + 1) - getRowOffset(startRowIndex);
+ } else {
+ firstRowHeight = rowHeight;
+ }
+ } else {
+ startRowIndex = firstRowIndex;
+ firstRowHeight = 0;
+ }
/*
* In collapsing-border model, if the cell spans over several columns/rows then
@@ -319,7 +379,25 @@
cellLM.addAreas(new KnuthPossPosIter(pgu.getElements(), startPos, endPos + 1),
layoutContext, spannedGridRowHeights, startRowIndex - pgu.getRowIndex(),
currentRowIndex - pgu.getRowIndex(), borderBeforeWhich, borderAfterWhich,
- startRowIndex == firstRowOnPageIndex, lastOnPage);
+ startRowIndex == firstRowOnPageIndex, lastOnPage, this, firstRowHeight);
+ }
+
+
+ /**
+ * Registers the given area, that will be used to render the part of
+ * table-header/footer/body background covered by a table-cell. If percentages are
+ * used to place the background image, the final bpd of the (fraction of) table part
+ * that will be rendered on the current page must be known. The traits can't then be
+ * set when the areas for the cell are created since at that moment this bpd is yet
+ * unknown. So they will instead be set in
+ * {@link #addAreasAndFlushRow(boolean, boolean)}.
+ *
+ * @param backgroundArea the block of the cell's dimensions that will hold the part
+ * background
+ */
+ void registerPartBackgroundArea(Block backgroundArea) {
+ tclm.getTableLM().addBackgroundArea(backgroundArea);
+ tablePartBackgroundAreas.add(backgroundArea);
}
/**
@@ -357,11 +435,13 @@
}
// TODO get rid of that
+ /** Signals that the first table-body instance has started. */
void startBody() {
Arrays.fill(firstCellOnPage, true);
}
// TODO get rid of that
+ /** Signals that the last table-body instance has ended. */
void endBody() {
Arrays.fill(firstCellOnPage, false);
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -23,7 +23,6 @@
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -36,8 +35,7 @@
* @todo Implement getNextKnuthElements()
*/
public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
- private TableAndCaption fobj;
-
+
private Block curBlockArea;
//private List childBreaks = new java.util.ArrayList();
@@ -48,7 +46,6 @@
*/
public TableAndCaptionLayoutManager(TableAndCaption node) {
super(node);
- fobj = node;
}
/**
@@ -134,7 +131,7 @@
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(fobj.getId());
+ addId();
/* TODO: Reimplement using Knuth approach
LayoutManager childLM;
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -23,7 +23,6 @@
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.Position;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
@@ -34,7 +33,6 @@
* @todo Implement getNextKnuthElements()
*/
public class TableCaptionLayoutManager extends BlockStackingLayoutManager {
- private TableCaption fobj;
private Block curBlockArea;
@@ -46,7 +44,6 @@
*/
public TableCaptionLayoutManager(TableCaption node) {
super(node);
- fobj = node;
}
/**
@@ -133,7 +130,7 @@
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
getParentArea(null);
- getPSLM().addIDToPage(fobj.getId());
+ addId();
/* TODO: Reimplement using Knuth approach
LayoutManager childLM;
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=643433&r1=643432&r2=643433&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java Tue Apr 1 08:08:24 2008
@@ -23,16 +23,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.Trait;
import org.apache.fop.datatypes.PercentBaseContext;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.table.ConditionalBorder;
import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.Table;
+import org.apache.fop.fo.flow.table.TableBody;
import org.apache.fop.fo.flow.table.TableCell;
+import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
import org.apache.fop.layoutmgr.AreaAdditionUtil;
@@ -71,9 +74,8 @@
private int xoffset;
private int yoffset;
private int cellIPD;
- private int rowHeight;
+ private int totalHeight;
private int usedBPD;
- private int borderAndPaddingBPD;
private boolean emptyCell = true;
/**
@@ -96,31 +98,11 @@
return getTable().isSeparateBorderModel();
}
- /** {@inheritDoc} */
- public void initialize() {
- borderAndPaddingBPD = 0;
- borderAndPaddingBPD += getTableCell()
- .getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
- borderAndPaddingBPD += getTableCell()
- .getCommonBorderPaddingBackground().getBorderAfterWidth(false);
- if (!isSeparateBorderModel()) {
- borderAndPaddingBPD /= 2;
- }
- borderAndPaddingBPD += getTableCell().getCommonBorderPaddingBackground()
- .getPaddingBefore(false, this);
- borderAndPaddingBPD += getTableCell().getCommonBorderPaddingBackground()
- .getPaddingAfter(false, this);
- }
-
/**
* @return the table owning this cell
*/
public Table getTable() {
- FONode node = fobj.getParent();
- while (!(node instanceof Table)) {
- node = node.getParent();
- }
- return (Table)node;
+ return getTableCell().getTable();
}
@@ -148,13 +130,13 @@
* {@inheritDoc}
*/
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
- MinOptMax stackLimit = new MinOptMax(context.getStackLimit());
+ MinOptMax stackLimit = new MinOptMax(context.getStackLimitBP());
referenceIPD = context.getRefIPD();
cellIPD = referenceIPD;
cellIPD -= getIPIndents();
- LinkedList returnedList = null;
+ LinkedList returnedList;
LinkedList contentList = new LinkedList();
LinkedList returnList = new LinkedList();
@@ -163,8 +145,8 @@
while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
LayoutContext childLC = new LayoutContext(0);
// curLM is a ?
- childLC.setStackLimit(MinOptMax.subtract(context
- .getStackLimit(), stackLimit));
+ childLC.setStackLimitBP(MinOptMax.subtract(context
+ .getStackLimitBP(), stackLimit));
childLC.setRefIPD(cellIPD);
// get elements from curLM
@@ -260,7 +242,7 @@
p.setP(0);
}
- getPSLM().notifyEndOfLayout(((TableCell)getFObj()).getId());
+ getPSLM().notifyEndOfLayout(fobj.getId());
setFinished(true);
return returnList;
@@ -303,7 +285,7 @@
* @param h the height of cell
*/
public void setTotalHeight(int h) {
- rowHeight = h;
+ totalHeight = h;
}
/**
@@ -330,6 +312,10 @@
* which case collapsed before borders must be drawn in the outer mode
* @param lastOnPage true if the cell will be the very last one on the page, in which
* case collapsed after borders must be drawn in the outer mode
+ * @param painter painter
+ * @param firstRowHeight height of the first row spanned by this cell (may be zero if
+ * this row is placed on a previous page). Used to calculate the placement of the
+ * row's background image if any
*/
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext,
@@ -339,13 +325,25 @@
int borderBeforeWhich,
int borderAfterWhich,
boolean firstOnPage,
- boolean lastOnPage) {
+ boolean lastOnPage,
+ RowPainter painter,
+ int firstRowHeight) {
getParentArea(null);
- getPSLM().addIDToPage(getTableCell().getId());
+ addId();
int borderBeforeWidth = primaryGridUnit.getBeforeBorderWidth(startRow, borderBeforeWhich);
int borderAfterWidth = primaryGridUnit.getAfterBorderWidth(endRow, borderAfterWhich);
+
+ CommonBorderPaddingBackground padding = primaryGridUnit.getCell()
+ .getCommonBorderPaddingBackground();
+ int paddingRectBPD = totalHeight - borderBeforeWidth - borderAfterWidth;
+ int cellBPD = paddingRectBPD;
+ cellBPD -= padding.getPaddingBefore(borderBeforeWhich == ConditionalBorder.REST, this);
+ cellBPD -= padding.getPaddingAfter(borderAfterWhich == ConditionalBorder.REST, this);
+
+ addBackgroundAreas(painter, firstRowHeight, borderBeforeWidth, paddingRectBPD);
+
if (isSeparateBorderModel()) {
if (!emptyCell || getTableCell().showEmptyCells()) {
if (borderBeforeWidth > 0) {
@@ -421,7 +419,7 @@
int dx = xoffset;
for (int x = 0; x < gridUnits.length; x++) {
int ipd = getTable().getColumn(primaryGridUnit.getColIndex() + x)
- .getColumnWidth().getValue((PercentBaseContext) getParent());
+ .getColumnWidth().getValue(getParent());
if (blocks[y][x] != null) {
Block block = blocks[y][x];
adjustYOffset(block, dy);
@@ -437,18 +435,12 @@
}
}
- CommonBorderPaddingBackground padding = primaryGridUnit.getCell()
- .getCommonBorderPaddingBackground();
TraitSetter.addPadding(curBlockArea,
padding,
borderBeforeWhich == ConditionalBorder.REST,
borderAfterWhich == ConditionalBorder.REST,
false, false, this);
- int cellBPD = rowHeight - borderBeforeWidth - borderAfterWidth;
- cellBPD -= padding.getPaddingBefore(borderBeforeWhich == ConditionalBorder.REST, this);
- cellBPD -= padding.getPaddingAfter(borderAfterWhich == ConditionalBorder.REST, this);
-
//Handle display-align
if (usedBPD < cellBPD) {
if (getTableCell().getDisplayAlign() == EN_CENTER) {
@@ -468,16 +460,9 @@
curBlockArea.setBPD(cellBPD);
// Add background after we know the BPD
- if (isSeparateBorderModel()) {
- if (!emptyCell || getTableCell().showEmptyCells()) {
- TraitSetter.addBackground(curBlockArea,
- getTableCell().getCommonBorderPaddingBackground(),
- this);
- }
- } else {
+ if (!isSeparateBorderModel() || !emptyCell || getTableCell().showEmptyCells()) {
TraitSetter.addBackground(curBlockArea,
- getTableCell().getCommonBorderPaddingBackground(),
- this);
+ getTableCell().getCommonBorderPaddingBackground(), this);
}
flush();
@@ -485,6 +470,33 @@
curBlockArea = null;
}
+ /** Adds background areas for the column, body and row, if any. */
+ private void addBackgroundAreas(RowPainter painter, int firstRowHeight, int borderBeforeWidth,
+ int paddingRectBPD) {
+ TableColumn column = getTable().getColumn(primaryGridUnit.getColIndex());
+ if (column.getCommonBorderPaddingBackground().hasBackground()) {
+ Block colBackgroundArea = getBackgroundArea(paddingRectBPD, borderBeforeWidth);
+ ((TableLayoutManager) parentLM).registerColumnBackgroundArea(column, colBackgroundArea,
+ -startIndent);
+ }
+
+ TableBody body = primaryGridUnit.getTableBody();
+ if (body.getCommonBorderPaddingBackground().hasBackground()) {
+ painter.registerPartBackgroundArea(
+ getBackgroundArea(paddingRectBPD, borderBeforeWidth));
+ }
+
+ TableRow row = primaryGridUnit.getRow();
+ if (row != null && row.getCommonBorderPaddingBackground().hasBackground()) {
+ Block rowBackgroundArea = getBackgroundArea(paddingRectBPD, borderBeforeWidth);
+ ((TableLayoutManager) parentLM).addBackgroundArea(rowBackgroundArea);
+ TraitSetter.addBackground(rowBackgroundArea, row.getCommonBorderPaddingBackground(),
+ parentLM,
+ -xoffset - startIndent, -borderBeforeWidth,
+ parentLM.getContentAreaIPD(), firstRowHeight);
+ }
+ }
+
private void addBorder(Block[][] blocks, int i, int j, Integer side, BorderInfo border,
boolean outer) {
if (blocks[i][j] == null) {
@@ -511,6 +523,21 @@
private static void adjustBPD(Block block, int amount) {
block.setBPD(block.getBPD() + amount);
+ }
+
+ private Block getBackgroundArea(int bpd, int borderBeforeWidth) {
+ CommonBorderPaddingBackground padding = getTableCell().getCommonBorderPaddingBackground();
+ int paddingStart = padding.getPaddingStart(false, this);
+ int paddingEnd = padding.getPaddingEnd(false, this);
+
+ Block block = new Block();
+ TraitSetter.setProducerID(block, getTable().getId());
+ block.setPositioning(Block.ABSOLUTE);
+ block.setIPD(cellIPD + paddingStart + paddingEnd);
+ block.setBPD(bpd);
+ block.setXOffset(xoffset + startIndent - paddingStart);
+ block.setYOffset(yoffset + borderBeforeWidth);
+ return block;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org