Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java Wed Nov 21 12:50:23 2007 @@ -20,18 +20,14 @@ package org.apache.fop.layoutmgr.table; 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.fo.flow.Marker; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FONode.FONodeIterator; +import org.apache.fop.fo.flow.table.EffRow; 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; /** @@ -48,82 +44,41 @@ /** Selects the table-footer elements for iteration. */ public static final int FOOTER = 2; - /** Logger **/ - private static Log log = LogFactory.getLog(TableRowIterator.class); - /** The table on which this instance operates. */ protected Table table; - /** Column setup of the operated table. */ - private ColumnSetup columns; /** Part of the table over which to iterate. One of BODY, HEADER or FOOTER. */ private int tablePart; - /** Holds the currently fetched row (TableCell instances). */ - private List currentRow = new java.util.ArrayList(); - - /** - * Holds the grid units of cells from the previous row which will span over the - * current row. Should be read "previous row's spanning cells". List of GridUnit - * instances. - */ - private List previousRowsSpanningCells = new java.util.ArrayList(); - - /** Index of the row currently being fetched. */ - private int fetchIndex = -1; - - /** - * Number of spans found on the current row which will also span over the next row. - */ - private int pendingRowSpans; + private Iterator rowGroupsIter; - //TODO rows should later be a Jakarta Commons LinkedList so concurrent modifications while - //using a ListIterator are possible - /** List of cached rows. This is a list of EffRow elements. */ - private List fetchedRows = new java.util.ArrayList(); - - /** - * Index of the row that will be returned at the next iteration step. Note that there - * is no direct relation between this field and [EMAIL PROTECTED] - * TableRowIterator#fetchIndex}. The fetching of rows and the iterating over them are - * two different processes. Hence the two indices. */ - private int iteratorIndex = 0; - - //prefetch state - /** - * Iterator over the requested table's part(s) (header, footer, body). Note that - * a table may have several table-body children, hence the iterator. - */ - private ListIterator tablePartIterator = null; - /** Iterator over a part's child elements (either table-rows or table-cells). */ - private ListIterator tablePartChildIterator = null; + private int rowIndex = 0; /** * Creates a new TableRowIterator. * @param table the table to iterate over - * @param columns the column setup for the table * @param tablePart indicates what part of the table to iterate over (HEADER, FOOTER, BODY) */ - public TableRowIterator(Table table, ColumnSetup columns, int tablePart) { + public TableRowIterator(Table table, int tablePart) { this.table = table; - this.columns = columns; this.tablePart = tablePart; switch(tablePart) { - case HEADER: { - List bodyList = new java.util.ArrayList(); - bodyList.add(table.getTableHeader()); - this.tablePartIterator = bodyList.listIterator(); + case HEADER: + rowGroupsIter = table.getTableHeader().getRowGroups().iterator(); break; - } - case FOOTER: { - List bodyList = new java.util.ArrayList(); - bodyList.add(table.getTableFooter()); - this.tablePartIterator = bodyList.listIterator(); + case FOOTER: + rowGroupsIter = table.getTableFooter().getRowGroups().iterator(); break; - } - default: { - this.tablePartIterator = table.getChildNodes(); - } + default: + List rowGroupsList = new LinkedList(); + // TODO this is ugly + for (FONodeIterator iter = table.getChildNodes(); iter.hasNext();) { + FONode node = iter.nextNode(); + if (node instanceof TableBody) { + rowGroupsList.addAll(((TableBody) node).getRowGroups()); + } + } + rowGroupsIter = rowGroupsList.iterator(); } } @@ -132,429 +87,18 @@ * consecutive rows which contains all spanned grid units of its cells. * @return the next row group, or null */ - public EffRow[] getNextRowGroup() { - EffRow firstRowInGroup = getNextRow(); - if (firstRowInGroup == null) { - return null; - } - EffRow lastRowInGroup = firstRowInGroup; - int lastIndex = lastRowInGroup.getIndex(); - boolean allFinished; - do { - allFinished = true; - Iterator iter = lastRowInGroup.getGridUnits().iterator(); - while (iter.hasNext()) { - GridUnit gu = (GridUnit)iter.next(); - if (!gu.isLastGridUnitRowSpan()) { - allFinished = false; - break; - } - } - lastIndex = lastRowInGroup.getIndex(); - if (!allFinished) { - lastRowInGroup = getNextRow(); - if (lastRowInGroup == null) { - allFinished = true; - } - } - } while (!allFinished); - int rowCount = lastIndex - firstRowInGroup.getIndex() + 1; - EffRow[] rowGroup = new EffRow[rowCount]; - for (int i = 0; i < rowCount; i++) { - rowGroup[i] = getCachedRow(i + firstRowInGroup.getIndex()); - } - return rowGroup; - } - - /** - * Returns the row at the given index, fetching rows up to the requested one if - * necessary. - * - * @return the requested row, or null if there is no row at the given index (index - * < 0 or end of table-part reached) - */ - private EffRow getRow(int index) { - boolean moreRows = true; - while (moreRows && fetchedRows.size() <= index) { - moreRows = prefetchNext(); - } - // Whatever the value of index, getCachedRow will handle it nicely - return getCachedRow(index); - } - - /** - * Returns the next effective row. - * @return the requested effective row or null if there is no more row. - */ - private EffRow getNextRow() { - return getRow(iteratorIndex++); - } - - /** - * Returns the row preceding the given row, without moving the iterator. - * - * @param row a row in the iterated table part - * @return the preceding row, or null if there is no such row (the given row is the - * first one in the table part) - */ - public EffRow getPrecedingRow(EffRow row) { - return getRow(row.getIndex() - 1); - } - - /** - * Returns the row following the given row, without moving the iterator. - * - * @param row a row in the iterated table part - * @return the following row, or null if there is no more row - */ - public EffRow getFollowingRow(EffRow row) { - return getRow(row.getIndex() + 1); - } - - /** - * Returns the first effective row. - * @return the requested effective row. - */ - public EffRow getFirstRow() { - if (fetchedRows.size() == 0) { - prefetchNext(); - } - return getCachedRow(0); - } - - /** - * Returns the last effective row. - * <p>Note:This is inefficient for large tables because the whole table - * if preloaded.</p> - * @return the requested effective row. - */ - public EffRow getLastRow() { - while (prefetchNext()) { - //nop - } - return getCachedRow(fetchedRows.size() - 1); - } - - /** - * Returns a cached effective row. If the given index points outside the range of rows - * (negative or greater than the number of already fetched rows), this methods - * terminates nicely by returning null. - * - * @param index index of the row (zero-based) - * @return the requested effective row or null if (index < 0 || index >= the - * number of already fetched rows) - */ - private EffRow getCachedRow(int index) { - if (index < 0 || index >= fetchedRows.size()) { - return null; - } else { - return (EffRow)fetchedRows.get(index); - } - } - - /** - * Fetches the next row. - * - * @return true if there was a row to fetch; otherwise, false (the end of the - * table-part has been reached) - */ - private boolean prefetchNext() { - boolean firstInTable = false; - boolean firstInTablePart = false; - // If we are at the end of the current table part - if (tablePartChildIterator != null && !tablePartChildIterator.hasNext()) { - //force skip on to next component - if (pendingRowSpans > 0) { - this.currentRow.clear(); - this.fetchIndex++; - EffRow gridUnits = buildGridRow(this.currentRow, null); - log.debug(gridUnits); - fetchedRows.add(gridUnits); - return true; - } - tablePartChildIterator = null; - if (fetchedRows.size() > 0) { - getCachedRow(fetchedRows.size() - 1).setFlagForAllGridUnits( - GridUnit.LAST_IN_PART, true); - } - } - // If the iterating over the current table-part has not started yet - if (tablePartChildIterator == null) { - if (tablePartIterator.hasNext()) { - tablePartChildIterator = ((TableBody)tablePartIterator.next()).getChildNodes(); - if (fetchedRows.size() == 0) { - firstInTable = true; - } - firstInTablePart = true; - } else { - //no more rows in that part of the table - if (fetchedRows.size() > 0) { - getCachedRow(fetchedRows.size() - 1).setFlagForAllGridUnits( - GridUnit.LAST_IN_PART, true); - // If the last row is the last of the table - if (tablePart == FOOTER - || (tablePart == BODY && table.getTableFooter() == null)) { - getCachedRow(fetchedRows.size() - 1).setFlagForAllGridUnits( - GridUnit.LAST_IN_TABLE, true); - } - } - return false; - } - } - Object node = tablePartChildIterator.next(); - while (node instanceof Marker) { - node = tablePartChildIterator.next(); - } - this.currentRow.clear(); - this.fetchIndex++; - TableRow rowFO = null; - if (node instanceof TableRow) { - rowFO = (TableRow)node; - ListIterator cellIterator = rowFO.getChildNodes(); - while (cellIterator.hasNext()) { - this.currentRow.add(cellIterator.next()); - } - } else if (node instanceof TableCell) { - this.currentRow.add(node); - if (!((TableCell)node).endsRow()) { - while (tablePartChildIterator.hasNext()) { - TableCell cell = (TableCell)tablePartChildIterator.next(); - if (cell.startsRow()) { - //next row already starts here, one step back - tablePartChildIterator.previous(); - break; - } - this.currentRow.add(cell); - if (cell.endsRow()) { - break; - } - } - } - } else { - throw new IllegalStateException("Illegal class found: " + node.getClass().getName()); - } - EffRow gridUnits = buildGridRow(this.currentRow, rowFO); - if (firstInTablePart) { - gridUnits.setFlagForAllGridUnits(GridUnit.FIRST_IN_PART, true); - } - if (firstInTable && (tablePart == HEADER || table.getTableHeader() == null) - && tablePart != FOOTER) { - gridUnits.setFlagForAllGridUnits(GridUnit.FIRST_IN_TABLE, true); - } - log.debug(gridUnits); - fetchedRows.add(gridUnits); - return true; - } - - /** - * Places the given object at the given position in the list, first extending it if - * necessary with null objects to reach the position. - * - * @param list the list in which to place the object - * @param position index at which the object must be placed (0-based) - * @param obj the object to place - */ - private void safelySetListItem(List list, int position, Object obj) { - while (position >= list.size()) { - list.add(null); - } - list.set(position, obj); - } - - private Object safelyGetListItem(List list, int position) { - if (position >= list.size()) { + EffRow[] getNextRowGroup() { + if (!rowGroupsIter.hasNext()) { return null; - } else { - return list.get(position); - } - } - - /** - * Builds the list of grid units corresponding to the given table row. - * - * @param cells list of cells starting at the current row - * @param rowFO the fo:table-row object containing the row, possibly null - * @return the list of grid units - */ - private EffRow buildGridRow(List cells, TableRow rowFO) { - EffRow row = new EffRow(this.fetchIndex, tablePart); - List gridUnits = row.getGridUnits(); - - TableBody bodyFO = null; - - //Create all row-spanned grid units based on information from the previous row - int colnum = 1; - GridUnit[] horzSpan = null; // Grid units horizontally spanned by a single cell - if (pendingRowSpans > 0) { - ListIterator spanIter = previousRowsSpanningCells.listIterator(); - while (spanIter.hasNext()) { - GridUnit gu = (GridUnit)spanIter.next(); - if (gu != null) { - if (gu.getColSpanIndex() == 0) { - horzSpan = new GridUnit[gu.getCell().getNumberColumnsSpanned()]; - } - GridUnit newGU = gu.createNextRowSpanningGridUnit(); - newGU.setRow(rowFO); - safelySetListItem(gridUnits, colnum - 1, newGU); - horzSpan[newGU.getColSpanIndex()] = newGU; - if (newGU.isLastGridUnitColSpan()) { - //Add the array of row-spanned grid units to the primary grid unit - newGU.getPrimary().addRow(horzSpan); - horzSpan = null; - } - if (newGU.isLastGridUnitRowSpan()) { - spanIter.set(null); - pendingRowSpans--; - } else { - spanIter.set(newGU); - } - } - colnum++; - } } - if (pendingRowSpans < 0) { - throw new IllegalStateException("pendingRowSpans must not become negative!"); - } - - //Transfer available cells to their slots - colnum = 1; - ListIterator iter = cells.listIterator(); - while (iter.hasNext()) { - TableCell cell = (TableCell)iter.next(); - - colnum = cell.getColumnNumber(); - - //TODO: remove the check below??? - //shouldn't happen here, since - //overlapping cells already caught in - //fo.flow.TableCell.bind()... - GridUnit other = (GridUnit)safelyGetListItem(gridUnits, colnum - 1); - if (other != null) { - String err = "A table-cell (" - + cell.getContextInfo() - + ") is overlapping with another (" - + other.getCell().getContextInfo() - + ") in column " + colnum; - throw new IllegalStateException(err - + " (this should have been catched by FO tree validation)"); - } - TableColumn col = columns.getColumn(colnum); - - //Add grid unit for primary grid unit - PrimaryGridUnit gu = new PrimaryGridUnit(cell, col, colnum - 1, this.fetchIndex); - safelySetListItem(gridUnits, colnum - 1, gu); - boolean hasRowSpanningLeft = !gu.isLastGridUnitRowSpan(); - if (hasRowSpanningLeft) { - pendingRowSpans++; - safelySetListItem(previousRowsSpanningCells, colnum - 1, gu); - } - - if (gu.hasSpanning()) { - //Add grid units on spanned slots if any - horzSpan = new GridUnit[cell.getNumberColumnsSpanned()]; - horzSpan[0] = gu; - for (int j = 1; j < cell.getNumberColumnsSpanned(); j++) { - colnum++; - GridUnit guSpan = new GridUnit(gu, columns.getColumn(colnum), colnum - 1, j); - //TODO: remove the check below??? - other = (GridUnit)safelyGetListItem(gridUnits, colnum - 1); - if (other != null) { - String err = "A table-cell (" - + cell.getContextInfo() - + ") is overlapping with another (" - + other.getCell().getContextInfo() - + ") in column " + colnum; - throw new IllegalStateException(err - + " (this should have been catched by FO tree validation)"); - } - safelySetListItem(gridUnits, colnum - 1, guSpan); - if (hasRowSpanningLeft) { - pendingRowSpans++; - safelySetListItem(previousRowsSpanningCells, colnum - 1, guSpan); - } - horzSpan[j] = guSpan; - } - gu.addRow(horzSpan); - } - - //Gather info for empty grid units (used later) - if (bodyFO == null) { - bodyFO = gu.getBody(); - } - - colnum++; - } - - //Post-processing the list (looking for gaps and resolve start and end borders) - fillEmptyGridUnits(gridUnits, rowFO, bodyFO); - resolveStartEndBorders(gridUnits); - - return row; - } - - private void fillEmptyGridUnits(List gridUnits, TableRow row, TableBody body) { - for (int pos = 1; pos <= gridUnits.size(); pos++) { - GridUnit gu = (GridUnit)gridUnits.get(pos - 1); - - //Empty grid units - if (gu == null) { - //Add grid unit - gu = new EmptyGridUnit(row, columns.getColumn(pos), body, - pos - 1); - gridUnits.set(pos - 1, gu); - } - - //Set flags - gu.setFlag(GridUnit.IN_FIRST_COLUMN, (pos == 1)); - gu.setFlag(GridUnit.IN_LAST_COLUMN, (pos == gridUnits.size())); - } - } - - private void resolveStartEndBorders(List gridUnits) { - for (int pos = 1; pos <= gridUnits.size(); pos++) { - GridUnit starting = (GridUnit)gridUnits.get(pos - 1); - - //Border resolution - if (table.isSeparateBorderModel()) { - starting.assignBorderForSeparateBorderModel(); - } else { - //Neighbouring grid unit at start edge - GridUnit start = null; - int find = pos - 1; - while (find >= 1) { - GridUnit candidate = (GridUnit)gridUnits.get(find - 1); - if (candidate.isLastGridUnitColSpan()) { - start = candidate; - break; - } - find--; - } - - //Ending grid unit for current cell - GridUnit ending = null; - if (starting.getCell() != null) { - pos += starting.getCell().getNumberColumnsSpanned() - 1; - } - ending = (GridUnit)gridUnits.get(pos - 1); - - //Neighbouring grid unit at end edge - GridUnit end = null; - find = pos + 1; - while (find <= gridUnits.size()) { - GridUnit candidate = (GridUnit)gridUnits.get(find - 1); - if (candidate.isPrimary()) { - end = candidate; - break; - } - find++; - } - starting.resolveBorder(start, - CommonBorderPaddingBackground.START); - ending.resolveBorder(end, - CommonBorderPaddingBackground.END); - //Only start and end borders here, before and after during layout - } + List rowGroup = (List) rowGroupsIter.next(); + EffRow[] effRowGroup = new EffRow[rowGroup.size()]; + int i = 0; + for (Iterator rowIter = rowGroup.iterator(); rowIter.hasNext();) { + List gridUnits = (List) rowIter.next(); + effRowGroup[i++] = new EffRow(rowIndex++, tablePart, gridUnits); } + return effRowGroup; } }
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableStepper.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableStepper.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableStepper.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/table/TableStepper.java Wed Nov 21 12:50:23 2007 @@ -27,6 +27,9 @@ 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.TableRow; import org.apache.fop.layoutmgr.BreakElement; import org.apache.fop.layoutmgr.KnuthBox; @@ -153,15 +156,15 @@ boolean signalKeepWithNext = false; int laststep = 0; int step; - int addedBoxLen = 0; + int cumulateLength = 0; // Length of the content accumulated before the break TableContentPosition lastTCPos = null; LinkedList returnList = new LinkedList(); while ((step = getNextStep()) >= 0) { int normalRow = activeRowIndex; int increase = step - laststep; int penaltyOrGlueLen = step + getMaxRemainingHeight() - totalHeight; - int boxLen = step - addedBoxLen - Math.max(0, penaltyOrGlueLen); - addedBoxLen += boxLen; + int boxLen = step - cumulateLength - Math.max(0, penaltyOrGlueLen)/* the penalty, if any */; + cumulateLength += boxLen + Math.max(0, -penaltyOrGlueLen)/* the glue, if any */; boolean forcedBreak = false; int breakClass = -1; Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java Wed Nov 21 12:50:23 2007 @@ -53,14 +53,6 @@ * @return the requested configuration subtree, null if there's no configuration */ protected Configuration getRendererConfig(Renderer renderer) { - Configuration cfg = userAgent.getFactory().getUserConfig(); - if (cfg == null) { - if (log.isDebugEnabled()) { - log.debug("userconfig is null"); - } - return null; - } - String mimeType = renderer.getMimeType(); if (mimeType == null) { if (log.isInfoEnabled()) { @@ -69,6 +61,24 @@ return null; } + return getRendererConfig(userAgent, mimeType); + } + + /** + * Returns the configuration subtree for a specific renderer. + * @param userAgent the user agent containing the user configuration + * @param mimeType the MIME type of the renderer + * @return the requested configuration subtree, null if there's no configuration + */ + public static Configuration getRendererConfig(FOUserAgent userAgent, String mimeType) { + Configuration cfg = userAgent.getFactory().getUserConfig(); + if (cfg == null) { + if (log.isDebugEnabled()) { + log.debug("userconfig is null"); + } + return null; + } + Configuration userRendererConfig = null; Configuration[] cfgs Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java Wed Nov 21 12:50:23 2007 @@ -27,12 +27,15 @@ import java.util.List; import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; @@ -222,7 +225,15 @@ } } } - + + private static void closeSource(Source src) { + if (src instanceof StreamSource) { + StreamSource streamSource = (StreamSource)src; + IOUtils.closeQuietly(streamSource.getInputStream()); + IOUtils.closeQuietly(streamSource.getReader()); + } + } + /** * Returns a font info from a font node Configuration definition * @@ -243,23 +254,27 @@ LogUtil.handleError(log, "Font configuration without metric-url or embed-url", strict); return null; } - if (embedUrl != null) { - Source source = fontResolver.resolve(embedUrl); - if (source == null) { - LogUtil.handleError(log, - "Failed to resolve font with embed-url '" + embedUrl + "'", strict); - return null; - } - embedUrl = source.getSystemId(); // absolute path/url - } - if (metricsUrl != null) { - Source source = fontResolver.resolve(metricsUrl); - if (source == null) { - LogUtil.handleError(log, - "Failed to resolve font with metric-url '" + metricsUrl + "'", strict); - return null; + if (strict) { + //This section just checks early whether the URIs can be resolved + //Stream are immediately closed again since they will never be used anyway + if (embedUrl != null) { + Source source = fontResolver.resolve(embedUrl); + closeSource(source); + if (source == null) { + LogUtil.handleError(log, + "Failed to resolve font with embed-url '" + embedUrl + "'", strict); + return null; + } + } + if (metricsUrl != null) { + Source source = fontResolver.resolve(metricsUrl); + closeSource(source); + if (source == null) { + LogUtil.handleError(log, + "Failed to resolve font with metric-url '" + metricsUrl + "'", strict); + return null; + } } - metricsUrl = source.getSystemId(); // absolute path/url } boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true); Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/java2d/FontSetup.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/java2d/FontSetup.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/java2d/FontSetup.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/java2d/FontSetup.java Wed Nov 21 12:50:23 2007 @@ -218,7 +218,7 @@ java.awt.Font[] fonts = env.getAllFonts(); for (int i = 0; i < fonts.length; i++) { java.awt.Font f = fonts[i]; - if (HARDCODED_FONT_NAMES.contains(f.getFontName())) { + if (HARDCODED_FONT_NAMES.contains(f.getName())) { continue; //skip } @@ -231,20 +231,20 @@ + ", Style: " + f.getStyle()); } - String searchName = FontUtil.stripWhiteSpace(f.getFontName()).toLowerCase(); + String searchName = FontUtil.stripWhiteSpace(f.getName()).toLowerCase(); String guessedStyle = FontUtil.guessStyle(searchName); int guessedWeight = FontUtil.guessWeight(searchName); num++; String fontKey = "F" + num; int style = convertToAWTFontStyle(guessedStyle, guessedWeight); - addFontMetricsMapper(fontInfo, f.getFontName(), fontKey, graphics, style); + addFontMetricsMapper(fontInfo, f.getName(), fontKey, graphics, style); //Register appropriate font triplets matching the font. Two different strategies: //Example: "Arial Bold", normal, normal - addFontTriplet(fontInfo, f.getFontName(), + addFontTriplet(fontInfo, f.getName(), Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, fontKey); - if (!f.getFontName().equals(f.getFamily())) { + if (!f.getName().equals(f.getFamily())) { //Example: "Arial", bold, normal addFontTriplet(fontInfo, f.getFamily(), guessedStyle, guessedWeight, fontKey); Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java Wed Nov 21 12:50:23 2007 @@ -21,7 +21,12 @@ import java.awt.Color; +import java.io.BufferedOutputStream; import java.io.IOException; +import java.io.OutputStream; + +import org.w3c.dom.Document; +import org.w3c.dom.svg.SVGLength; import org.apache.avalon.framework.configuration.Configuration; import org.apache.batik.bridge.BridgeContext; @@ -29,13 +34,12 @@ import org.apache.batik.transcoder.TranscoderException; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.transcoder.image.ImageTranscoder; +import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D; +import org.apache.xmlgraphics.java2d.ps.TextHandler; + import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontSetup; import org.apache.fop.svg.AbstractFOPTranscoder; -import org.apache.xmlgraphics.java2d.ps.AbstractPSDocumentGraphics2D; -import org.apache.xmlgraphics.java2d.ps.TextHandler; -import org.w3c.dom.Document; -import org.w3c.dom.svg.SVGLength; /** * This class enables to transcode an input to a PostScript document. @@ -114,7 +118,11 @@ getLogger().trace("document size: " + w + "pt x " + h + "pt"); try { - graphics.setupDocument(output.getOutputStream(), w, h); + OutputStream out = output.getOutputStream(); + if (!(out instanceof BufferedOutputStream)) { + out = new BufferedOutputStream(out); + } + graphics.setupDocument(out, w, h); graphics.setViewportDimension(width, height); if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) { Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSFontUtils.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSFontUtils.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSFontUtils.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ps/PSFontUtils.java Wed Nov 21 12:50:23 2007 @@ -100,8 +100,11 @@ if (fm instanceof LazyFont && ((LazyFont)fm).getRealFont() == null) { continue; } else if (null == fm.getEncoding()) { - //ignore (ZapfDingbats and Symbol run through here - //TODO: ZapfDingbats and Symbol should get getEncoding() fixed! + //ignore (ZapfDingbats and Symbol used to run through here, kept for safety reasons) + } else if ("SymbolEncoding".equals(fm.getEncoding())) { + //ignore (no encoding redefinition) + } else if ("ZapfDingbatsEncoding".equals(fm.getEncoding())) { + //ignore (no encoding redefinition) } else if ("WinAnsiEncoding".equals(fm.getEncoding())) { redefineFontEncoding(gen, fm.getFontName(), fm.getEncoding()); } else { Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/svg/PDFTranscoder.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/svg/PDFTranscoder.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/svg/PDFTranscoder.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/svg/PDFTranscoder.java Wed Nov 21 12:50:23 2007 @@ -20,7 +20,12 @@ package org.apache.fop.svg; import java.awt.Color; +import java.io.BufferedOutputStream; import java.io.IOException; +import java.io.OutputStream; + +import org.w3c.dom.Document; +import org.w3c.dom.svg.SVGLength; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; @@ -36,10 +41,9 @@ import org.apache.batik.transcoder.image.ImageTranscoder; import org.apache.batik.transcoder.keys.BooleanKey; import org.apache.batik.transcoder.keys.FloatKey; + import org.apache.fop.Version; import org.apache.fop.fonts.FontInfo; -import org.w3c.dom.Document; -import org.w3c.dom.svg.SVGLength; /** * This class enables to transcode an input to a pdf document. @@ -195,7 +199,11 @@ if (hints.containsKey(KEY_DEVICE_RESOLUTION)) { graphics.setDeviceDPI(((Float)hints.get(KEY_DEVICE_RESOLUTION)).floatValue()); } - graphics.setupDocument(output.getOutputStream(), w, h); + OutputStream out = output.getOutputStream(); + if (!(out instanceof BufferedOutputStream)) { + out = new BufferedOutputStream(out); + } + graphics.setupDocument(out, w, h); graphics.setSVGDimension(width, height); if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) { Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/status.xml URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/status.xml?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/status.xml (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/status.xml Wed Nov 21 12:50:23 2007 @@ -28,6 +28,51 @@ <changes> <release version="FOP Trunk"> + <action context="Code" dev="VH" type="fix" fixes-bug="43803"> + Restored proper handling of fo:table-cell having no children, which is allowed in relaxed + validation mode. + </action> + <action context="Code" dev="JM" type="fix"> + Memory Leak fixed in the Property Cache. Fixed by Jeremias Maerki. Reported and Tested By + Chris Bowditch. + </action> + <action context="Code" dev="VH" type="fix"> + Bugfix in tables: wrong element generation by the merging algorithm when glues must be + produced to cope with conditional spaces. The corresponding length was added twice: one in + the glue itself and one in the following box. + </action> + <action context="Code" dev="JM" type="fix"> + Bugfix for URI resolution: Make StreamSources without system identifier work again. + </action> + <action context="Code" dev="JM" type="fix" fixes-bug="43910" due-to="David Delbecq"> + Avoid a NullPointerException in AreaTreeHandler.endDocument(). + </action> + <action context="Code" dev="VH" type="fix" fixes-bug="43766"> + Bugfix: breaks generated by the merging algorithm for a table-row containing empty cells + had always a penalty of 900. + </action> + <action context="Code" dev="JM" type="add" fixes-bug="43605" due-to="V. Schappert"> + Added methods for fo:page-number-citation(-last) in FOEventHandler. + </action> + <action context="Code" dev="VH" type="add"> + Step towards performance: the collapsing-border resolution algorithm no longer triggers the + retrieving of the whole table, when possible. + </action> + <action context="Code" dev="VH" type="fix"> + In case of missing cells the border-end of the table was applied to an inner cell, instead + of the (empty) cell in the last column. + </action> + <action context="Code" dev="VH" type="fix"> + Fixed the resolution of borders with table-columns (border-before/after was wrongly applied + to every cell of the column). + </action> + <action context="Code" dev="VH" type="fix"> + Fixed the resolution of border-end on cells spanning several rows. + </action> + <action context="Code" dev="JM" type="fix" fixes-bug="43835" due-to="David Churavy"> + Bugfix: Use Font.getName() (logical font name) instead of Font.getFontName() + (localized) when registering fonts from AWT. + </action> <action context="Code" dev="JM" type="fix"> Made the way TrueType fonts are embedded in PDF compliant to the specification so viewers correctly identify subset fonts. Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/java/org/apache/fop/logging/LoggingElementListObserver.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/java/org/apache/fop/logging/LoggingElementListObserver.java?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/java/org/apache/fop/logging/LoggingElementListObserver.java (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/java/org/apache/fop/logging/LoggingElementListObserver.java Wed Nov 21 12:50:23 2007 @@ -24,6 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.ListElement; import org.apache.fop.layoutmgr.ElementListObserver.Observer; @@ -44,7 +45,8 @@ return; } log.debug(" "); - log.debug("ElementList: category=" + category + ", id=" + id); + int len = (elementList != null ? ElementListUtils.calcContentLength(elementList) : 0); + log.debug("ElementList: category=" + category + ", id=" + id + ", len=" + len + "mpt"); if (elementList == null) { log.debug("<<empty list>>"); return; Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml Wed Nov 21 12:50:23 2007 @@ -144,5 +144,16 @@ <eval expected="31800" xpath="//pageViewport[8]//flow/block[2]/block/@bpd"/> <eval expected="16800" xpath="//pageViewport[9]//flow/block/@bpd"/> <eval expected="16800" xpath="//pageViewport[9]//flow/block/block/@bpd"/> + + <element-list category="breaker"> + <skip>3</skip> <!-- The block before the table --> + <penalty p="INF" w="0"/> + <glue w="4000"/> <!-- The border before --> + <box w="16800"/> <!-- Line 1 --> + <penalty p="0" w="0"/> + <glue w="25000"/> <!-- The space between lines --> + <box w="16800"/> <!-- Line 2 --> + <skip>3</skip> <!-- glue for end of page TODO missing element for border-after!! --> + </element-list> </checks> </testcase> Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/table_border-collapse_collapse_spans_2.xml URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/table_border-collapse_collapse_spans_2.xml?rev=597205&r1=597204&r2=597205&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/table_border-collapse_collapse_spans_2.xml (original) +++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/table_border-collapse_collapse_spans_2.xml Wed Nov 21 12:50:23 2007 @@ -329,10 +329,8 @@ <eval expected="63500" xpath="//flow/block[2]/block[7]/@bpda"/> <eval expected="307500" xpath="//flow/block[2]/block[7]/@left-offset"/> <eval expected="7500" xpath="//flow/block[2]/block[7]/@top-offset"/> - <!-- <eval expected="80000" xpath="//flow/block[2]/block[8]/@ipd"/> <eval expected="120000" xpath="//flow/block[2]/block[8]/@ipda"/> - --> <eval expected="43400" xpath="//flow/block[2]/block[8]/@bpd"/> <eval expected="55400" xpath="//flow/block[2]/block[8]/@bpda"/> <eval expected="15000" xpath="//flow/block[2]/block[8]/@left-offset"/> @@ -340,9 +338,7 @@ <eval expected="(double,#ff00ff,6000,collapse-inner)" xpath="//flow/block[2]/block[8]/@border-before"/> <eval expected="(inset,#ff00ff,6000,collapse-inner)" xpath="//flow/block[2]/block[8]/@border-after"/> <eval expected="(solid,#ff00ff,30000,collapse-outer)" xpath="//flow/block[2]/block[8]/@border-start"/> - <!-- <eval expected="(dashed,#ff0000,10000,collapse-inner)" xpath="//flow/block[2]/block[8]/@border-end"/> - --> <eval expected="95000" xpath="//flow/block[2]/block[9]/@ipd"/> <eval expected="105000" xpath="//flow/block[2]/block[9]/@ipda"/> <eval expected="52200" xpath="//flow/block[2]/block[9]/@bpd"/> @@ -350,18 +346,14 @@ <eval expected="105000" xpath="//flow/block[2]/block[9]/@left-offset"/> <eval expected="33800" xpath="//flow/block[2]/block[9]/@top-offset"/> <eval expected="(dashed,#ff0000,10000,collapse-inner)" xpath="//flow/block[2]/block[9]/@border-start"/> - <!-- <eval expected="92500" xpath="//flow/block[2]/block[10]/@ipd"/> <eval expected="107500" xpath="//flow/block[2]/block[10]/@ipda"/> - --> <eval expected="49700" xpath="//flow/block[2]/block[10]/@bpd"/> <eval expected="54700" xpath="//flow/block[2]/block[10]/@bpda"/> <eval expected="200000" xpath="//flow/block[2]/block[10]/@left-offset"/> <eval expected="31300" xpath="//flow/block[2]/block[10]/@top-offset"/> <eval expected="(solid,#008000,5000,collapse-inner)" xpath="//flow/block[2]/block[10]/@border-before"/> - <!-- <eval expected="(solid,#000080,15000,collapse-inner)" xpath="//flow/block[2]/block[10]/@border-end"/> - --> <eval expected="95000" xpath="//flow/block[2]/block[11]/@ipd"/> <eval expected="105000" xpath="//flow/block[2]/block[11]/@ipda"/> <eval expected="46900" xpath="//flow/block[2]/block[11]/@bpd"/> @@ -378,10 +370,8 @@ <eval expected="86000" xpath="//flow/block[2]/block[12]/@top-offset"/> <eval expected="(double,#008000,40000,collapse-inner)" xpath="//flow/block[2]/block[12]/@border-after"/> <eval expected="(double,#ff0000,4000,collapse-inner)" xpath="//flow/block[2]/block[12]/@border-end"/> - <!-- <eval expected="187500" xpath="//flow/block[2]/block[13]/@ipd"/> <eval expected="187500" xpath="//flow/block[2]/block[13]/@ipda"/> - --> <eval expected="79100" xpath="//flow/block[2]/block[13]/@bpd"/> <eval expected="79100" xpath="//flow/block[2]/block[13]/@bpda"/> <eval expected="105000" xpath="//flow/block[2]/block[13]/@left-offset"/> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
