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 vh...@apache.org on 2007/08/02 18:26:36 UTC
svn commit: r562172 - in
/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table:
RowGroupLayoutManager.java TableContentLayoutManager.java
Author: vhennebert
Date: Thu Aug 2 09:26:36 2007
New Revision: 562172
URL: http://svn.apache.org/viewvc?view=rev&rev=562172
Log:
Move the handling of breaks back in TableContentLM
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?view=diff&rev=562172&r1=562171&r2=562172
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Thu Aug 2 09:26:36 2007
@@ -66,79 +66,60 @@
this.tableStepper = tableStepper;
}
+ int getBreakBefore() {
+ TableRow rowFO = rowGroup[0].getTableRow();
+ if (rowFO == null) {
+ return Constants.EN_AUTO;
+ } else {
+ return rowFO.getBreakBefore();
+ }
+ }
+
+ int getBreakAfter() {
+ TableRow rowFO = rowGroup[rowGroup.length - 1].getTableRow();
+ if (rowFO == null) {
+ return Constants.EN_AUTO;
+ } else {
+ return rowFO.getBreakAfter();
+ }
+ }
+
public LinkedList getNextKnuthElements(LayoutContext context, int alignment, int bodyType) {
LinkedList returnList = new LinkedList();
- //Check for break-before on the table-row at the start of the row group
- TableRow rowFO = rowGroup[0].getTableRow();
- if (rowFO != null && rowFO.getBreakBefore() != Constants.EN_AUTO) {
- log.info("break-before found");
- if (returnList.size() > 0) {
- ListElement last = (ListElement)returnList.getLast();
- if (last.isPenalty()) {
- KnuthPenalty pen = (KnuthPenalty)last;
- pen.setP(-KnuthPenalty.INFINITE);
- pen.setBreakClass(rowFO.getBreakBefore());
- } else {//if (last instanceof BreakElement) { // TODO vh: seems the only possibility
- BreakElement breakPoss = (BreakElement) last;
- breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
- breakPoss.setBreakClass(rowFO.getBreakBefore());
- }
- } else {
- returnList.add(new BreakElement(new Position(tableLM),
- 0, -KnuthPenalty.INFINITE, rowFO.getBreakBefore(), context));
- }
- }
-
- //Border resolution
- if (!tableLM.getTable().isSeparateBorderModel()) {
- resolveNormalBeforeAfterBordersForRowGroup();
- }
+ //Border resolution
+ if (!tableLM.getTable().isSeparateBorderModel()) {
+ resolveNormalBeforeAfterBordersForRowGroup();
+ }
- //Reset keep-with-next when remaining inside the table.
- //The context flag is only used to propagate keep-with-next to the outside.
- //The clearing is ok here because createElementsForRowGroup already handles
- //the keep when inside a table.
- context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
-
- //Element list creation
- createElementsForRowGroup(context, alignment, bodyType,
- returnList, rowGroup);
-
- //Handle keeps
- if (context.isKeepWithNextPending()) {
- log.debug("child LM (row group) signals pending keep-with-next");
- }
- if (context.isKeepWithPreviousPending()) {
- log.debug("child LM (row group) signals pending keep-with-previous");
- if (returnList.size() > 0) {
- //Modify last penalty
- ListElement last = (ListElement)returnList.getLast();
- if (last.isPenalty()) {
- BreakElement breakPoss = (BreakElement)last;
- //Only honor keep if there's no forced break
- if (!breakPoss.isForcedBreak()) {
- breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
- }
- }
- }
- }
-
- //Check for break-after on the table-row at the end of the row group
- rowFO = rowGroup[rowGroup.length - 1].getTableRow();
- if (rowFO != null && rowFO.getBreakAfter() != Constants.EN_AUTO) {
- if (returnList.size() > 0) {
- ListElement last = (ListElement)returnList.getLast();
- if (last instanceof KnuthPenalty) {
- KnuthPenalty pen = (KnuthPenalty)last;
- pen.setP(-KnuthPenalty.INFINITE);
- pen.setBreakClass(rowFO.getBreakAfter());
- } else if (last instanceof BreakElement) {
- BreakElement breakPoss = (BreakElement)last;
- breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
- breakPoss.setBreakClass(rowFO.getBreakAfter());
+ //Reset keep-with-next when remaining inside the table.
+ //The context flag is only used to propagate keep-with-next to the outside.
+ //The clearing is ok here because createElementsForRowGroup already handles
+ //the keep when inside a table.
+ context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, false);
+
+ //Element list creation
+ createElementsForRowGroup(context, alignment, bodyType,
+ returnList, rowGroup);
+
+ //Handle keeps
+ if (context.isKeepWithNextPending()) {
+ log.debug("child LM (row group) signals pending keep-with-next");
+ }
+ if (context.isKeepWithPreviousPending()) {
+ log.debug("child LM (row group) signals pending keep-with-previous");
+ if (returnList.size() > 0) {
+ //Modify last penalty
+ ListElement last = (ListElement)returnList.getLast();
+ if (last.isPenalty()) {
+ BreakElement breakPoss = (BreakElement)last;
+ //Only honor keep if there's no forced break
+ if (!breakPoss.isForcedBreak()) {
+ breakPoss.setPenaltyValue(KnuthPenalty.INFINITE);
}
}
}
+ }
+
return returnList;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?view=diff&rev=562172&r1=562171&r2=562172
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java Thu Aug 2 09:26:36 2007
@@ -214,12 +214,39 @@
LayoutContext context, int alignment, int bodyType) {
LinkedList returnList = new LinkedList();
EffRow[] rowGroup = null;
+ int breakBetween = Constants.EN_AUTO;
while ((rowGroup = iter.getNextRowGroup()) != null) {
- returnList.addAll(new RowGroupLayoutManager(getTableLM(), rowGroup, bodyIter,
- headerIter, footerIter, iter, stepper).getNextKnuthElements(context, alignment,
- bodyType));
+ RowGroupLayoutManager rowGroupLM = new RowGroupLayoutManager(getTableLM(), rowGroup,
+ bodyIter, headerIter, footerIter, iter, stepper);
+ if (breakBetween == Constants.EN_AUTO) {
+ // TODO improve
+ breakBetween = rowGroupLM.getBreakBefore();
+ }
+ if (breakBetween != Constants.EN_AUTO) {
+ if (returnList.size() > 0) {
+ BreakElement breakPoss = (BreakElement) returnList.getLast();
+ breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
+ breakPoss.setBreakClass(breakBetween);
+ } else {
+ returnList.add(new BreakElement(new Position(tableLM),
+ 0, -KnuthPenalty.INFINITE, breakBetween, context));
+ }
+ }
+ returnList.addAll(rowGroupLM.getNextKnuthElements(context, alignment, bodyType));
+ breakBetween = rowGroupLM.getBreakAfter();
+ }
+ // Break after the table's last row
+ // TODO should eventually be handled at the table level
+ if (breakBetween != Constants.EN_AUTO) {
+ if (returnList.size() > 0) {
+ BreakElement breakPoss = (BreakElement) returnList.getLast();
+ breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE);
+ breakPoss.setBreakClass(breakBetween);
+ } else {
+ returnList.add(new BreakElement(new Position(tableLM),
+ 0, -KnuthPenalty.INFINITE, breakBetween, context));
+ }
}
-
if (returnList.size() > 0) {
//Remove the last penalty produced by the combining algorithm (see TableStepper), for the last step
ListElement last = (ListElement)returnList.getLast();
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org