diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-09-01 10:06:57 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-09-01 10:06:57 +0000 |
commit | 9e8ee287772a7cc96a0424fd171966f1208b5b05 (patch) | |
tree | 992c9f06bc95b83f1ca3e6225c6098bdc4212446 /src/java/org/apache | |
parent | a153841f94703d85d500e008614af8e4db3a1fc2 (diff) | |
download | xmlgraphics-fop-9e8ee287772a7cc96a0424fd171966f1208b5b05.tar.gz xmlgraphics-fop-9e8ee287772a7cc96a0424fd171966f1208b5b05.zip |
Merged revisions 690319,690324,690382,690532,690903 via svnmerge from
https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r690319 | jeremias | 2008-08-29 17:36:17 +0100 (Fri, 29 Aug 2008) | 1 line
Added missing generation of areas for empty grid units in tables with collapsing border model.
........
r690324 | jeremias | 2008-08-29 17:42:38 +0100 (Fri, 29 Aug 2008) | 1 line
Added missing generation of areas for empty grid units in tables with collapsing border model. (missing test case)
........
r690382 | adelmelle | 2008-08-29 21:12:34 +0100 (Fri, 29 Aug 2008) | 2 lines
Bugzilla 45667: avoid NullPointerExceptions during hyphenation for empty inlines.
........
r690532 | adelmelle | 2008-08-30 17:37:53 +0100 (Sat, 30 Aug 2008) | 1 line
Partial fix for Bugzilla 45702: instead of wrapping the forcedBreakAfterLast element, simply add it to the returnList
........
r690903 | jeremias | 2008-09-01 09:12:43 +0100 (Mon, 01 Sep 2008) | 1 line
Avoid test failure if the backup directory is not available, yet.
........
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@690933 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
4 files changed, 115 insertions, 11 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index 8837b1a0f..64b8bbc0d 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -406,7 +406,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (forcedBreakAfterLast != null) { forcedBreakAfterLast.clearPendingMarks(); - wrapPositionElement(forcedBreakAfterLast, returnList, false); + returnList.add(forcedBreakAfterLast); } context.updateKeepWithNextPending(getKeepWithNextStrength()); @@ -1043,7 +1043,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } return breakBefore; } - + /** * Creates Knuth elements for break-after and adds them to the return list. * @param returnList return list to add the additional elements to diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java index a27fc6516..963b98b37 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java @@ -334,7 +334,8 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager fromIndex = oldListIterator.previousIndex(); } else if (currLM == prevLM) { bSomethingChanged - = prevLM.applyChanges(oldList.subList(fromIndex, oldList.size())) + = (prevLM != null) + && prevLM.applyChanges(oldList.subList(fromIndex, oldList.size())) || bSomethingChanged; } else { bSomethingChanged diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java index b2851c39f..7e32fdd5e 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java @@ -27,13 +27,19 @@ 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.area.Trait; import org.apache.fop.fo.flow.table.ConditionalBorder; import org.apache.fop.fo.flow.table.EffRow; +import org.apache.fop.fo.flow.table.EmptyGridUnit; 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.TableColumn; import org.apache.fop.fo.flow.table.TablePart; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; +import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthPossPosIter; @@ -202,10 +208,16 @@ class RowPainter { recordRowOffset(currentRow.getIndex(), currentRowOffset); // Need to compute the actual row height first + // and determine border behaviour for empty cells + boolean firstCellPart = true; + boolean lastCellPart = true; int actualRowHeight = 0; for (int i = 0; i < colCount; i++) { GridUnit currentGU = currentRow.getGridUnit(i); - if (!currentGU.isEmpty() && currentGU.getColSpanIndex() == 0 + if (currentGU.isEmpty()) { + continue; + } + if (currentGU.getColSpanIndex() == 0 && (lastInPart || currentGU.isLastGridUnitRowSpan()) && firstCellParts[i] != null) { // TODO @@ -225,21 +237,53 @@ class RowPainter { actualRowHeight = Math.max(actualRowHeight, cellOffset + cellHeight - currentRowOffset); } + + if (firstCellParts[i] != null && !firstCellParts[i].isFirstPart()) { + firstCellPart = false; + } + if (lastCellParts[i] != null && !lastCellParts[i].isLastPart()) { + lastCellPart = false; + } } // Then add areas for cells finishing on the current row for (int i = 0; i < colCount; i++) { GridUnit currentGU = currentRow.getGridUnit(i); - if (currentGU.isEmpty()) { - // TODO remove once missing cells are properly implemented (i.e., replaced - // by an fo:table-cell element containing an empty fo:block) + if (currentGU.isEmpty() && !tclm.isSeparateBorderModel()) { + int borderBeforeWhich; + if (firstCellPart) { + if (firstCellOnPage[i]) { + borderBeforeWhich = ConditionalBorder.LEADING_TRAILING; + } else { + borderBeforeWhich = ConditionalBorder.NORMAL; + } + } else { + borderBeforeWhich = ConditionalBorder.REST; + } + int borderAfterWhich; + if (lastCellPart) { + if (lastInPart) { + borderAfterWhich = ConditionalBorder.LEADING_TRAILING; + } else { + borderAfterWhich = ConditionalBorder.NORMAL; + } + } else { + borderAfterWhich = ConditionalBorder.REST; + } + addAreaForEmptyGridUnit((EmptyGridUnit)currentGU, + currentRow.getIndex(), i, + actualRowHeight, + borderBeforeWhich, borderAfterWhich, + lastOnPage); + firstCellOnPage[i] = false; } else if (currentGU.getColSpanIndex() == 0 && (lastInPart || currentGU.isLastGridUnitRowSpan()) && firstCellParts[i] != null) { assert firstCellParts[i].pgu == currentGU.getPrimary(); + int borderBeforeWhich; - if (firstCellParts[i].start == 0) { + if (firstCellParts[i].isFirstPart()) { if (firstCellOnPage[i]) { borderBeforeWhich = ConditionalBorder.LEADING_TRAILING; } else { @@ -259,6 +303,7 @@ class RowPainter { } else { borderAfterWhich = ConditionalBorder.REST; } + addAreasForCell(firstCellParts[i].pgu, firstCellParts[i].start, lastCellParts[i].end, actualRowHeight, borderBeforeWhich, borderAfterWhich, @@ -387,6 +432,56 @@ class RowPainter { startRowIndex == firstRowOnPageIndex, lastOnPage, this, firstRowHeight); } + private void addAreaForEmptyGridUnit(EmptyGridUnit gu, int rowIndex, int colIndex, + int actualRowHeight, + int borderBeforeWhich, int borderAfterWhich, boolean lastOnPage) { + + //get effective borders + BorderInfo borderBefore = gu.getBorderBefore(borderBeforeWhich); + BorderInfo borderAfter = gu.getBorderAfter(borderAfterWhich); + BorderInfo borderStart = gu.getBorderStart(); + BorderInfo borderEnd = gu.getBorderEnd(); + if (borderBefore.getRetainedWidth() == 0 + && borderAfter.getRetainedWidth() == 0 + && borderStart.getRetainedWidth() == 0 + && borderEnd.getRetainedWidth() == 0) { + return; //no borders, no area necessary + } + + TableLayoutManager tableLM = tclm.getTableLM(); + Table table = tableLM.getTable(); + TableColumn col = tclm.getColumns().getColumn(colIndex + 1); + + //position information + boolean firstOnPage = (rowIndex == firstRowOnPageIndex); + boolean inFirstColumn = (colIndex == 0); + boolean inLastColumn = (colIndex == table.getNumberOfColumns() - 1); + + //determine the block area's size + int ipd = col.getColumnWidth().getValue(tableLM); + ipd -= (borderStart.getRetainedWidth() + borderEnd.getRetainedWidth()) / 2; + int bpd = actualRowHeight; + bpd -= (borderBefore.getRetainedWidth() + borderAfter.getRetainedWidth()) / 2; + + //generate the block area + Block block = new Block(); + block.setPositioning(Block.ABSOLUTE); + block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); + block.setIPD(ipd); + block.setBPD(bpd); + block.setXOffset(tclm.getXOffsetOfGridUnit(colIndex) + + (borderStart.getRetainedWidth() / 2)); + block.setYOffset(getRowOffset(rowIndex) + - (borderBefore.getRetainedWidth() / 2)); + boolean[] outer = new boolean[] {firstOnPage, lastOnPage, inFirstColumn, + inLastColumn}; + TraitSetter.addCollapsingBorders(block, + borderBefore, + borderAfter, + borderStart, + borderEnd, outer); + tableLM.addChildArea(block); + } /** * Registers the given area, that will be used to render the part of diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index ad8bec715..2ff97a6a7 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -305,13 +305,21 @@ public class TableContentLayoutManager implements PercentBaseContext { } /** - * Retuns the X offset of the given grid unit. + * Returns the X offset of the given grid unit. * @param gu the grid unit * @return the requested X offset */ protected int getXOffsetOfGridUnit(PrimaryGridUnit gu) { - int col = gu.getColIndex(); - return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM()); + return getXOffsetOfGridUnit(gu.getColIndex()); + } + + /** + * Returns the X offset of the grid unit in the given column. + * @param colIndex the column index (zero-based) + * @return the requested X offset + */ + protected int getXOffsetOfGridUnit(int colIndex) { + return startXOffset + getTableLM().getColumns().getXOffset(colIndex + 1, getTableLM()); } /** |