Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/RTFHandler.java Thu Jul 31 02:06:10 2008 @@ -20,6 +20,8 @@ package org.apache.fop.render.rtf; // Java +import java.awt.Dimension; +import java.awt.Rectangle; import java.awt.geom.Point2D; import java.io.FileNotFoundException; import java.io.IOException; @@ -51,12 +53,13 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.datatypes.LengthBase; -import org.apache.fop.datatypes.SimplePercentBaseContext; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.events.ResourceEventProducer; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOText; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.XMLObj; import org.apache.fop.fo.flow.AbstractGraphics; import org.apache.fop.fo.flow.BasicLink; @@ -74,6 +77,7 @@ import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.PageNumber; +import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; import org.apache.fop.fo.flow.table.TableFooter; @@ -89,8 +93,10 @@ import org.apache.fop.fo.pagination.SimplePageMaster; import org.apache.fop.fo.pagination.StaticContent; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.fo.properties.FixedLength; +import org.apache.fop.fo.properties.EnumLength; import org.apache.fop.fonts.FontSetup; +import org.apache.fop.layoutmgr.inline.ImageLayout; +import org.apache.fop.layoutmgr.table.ColumnSetup; import org.apache.fop.render.DefaultFontResolver; import org.apache.fop.render.RendererEventProducer; import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer; @@ -110,6 +116,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfHyperLink; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfPage; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; @@ -117,6 +124,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem.RtfListItemLabel; import org.apache.fop.render.rtf.rtflib.tools.BuilderContext; +import org.apache.fop.render.rtf.rtflib.tools.PercentContext; import org.apache.fop.render.rtf.rtflib.tools.TableContext; /** @@ -150,6 +158,10 @@ private SimplePageMaster pagemaster; + private int nestedTableDepth = 1; + + private PercentContext percentManager = new PercentContext(); + /** * Creates a new RTF structure handler. * @param userAgent the FOUserAgent for this process @@ -173,9 +185,7 @@ eventProducer.ioError(this, ioe); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startDocument() throws SAXException { // TODO sections should be created try { @@ -187,9 +197,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endDocument() throws SAXException { try { rtfFile.flush(); @@ -199,9 +207,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startPageSequence(PageSequence pageSeq) { try { //This is needed for region handling @@ -240,6 +246,14 @@ builderContext.pushContainer(sect); + //Calculate usable page width for this flow + int useAblePageWidth = pagemaster.getPageWidth().getValue() + - pagemaster.getCommonMarginBlock().marginLeft.getValue() + - pagemaster.getCommonMarginBlock().marginRight.getValue() + - sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_LEFT).intValue() + - sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_RIGHT).intValue(); + percentManager.setDimension(pageSeq, useAblePageWidth); + bHeaderSpecified = false; bFooterSpecified = false; } catch (IOException ioe) { @@ -247,9 +261,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endPageSequence(PageSequence pageSeq) { if (bDefer) { //If endBlock was called while SAX parsing, and the passed FO is Block @@ -267,9 +279,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startFlow(Flow fl) { if (bDefer) { return; @@ -357,9 +367,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endFlow(Flow fl) { if (bDefer) { return; @@ -384,9 +392,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startBlock(Block bl) { if (bDefer) { return; @@ -414,10 +420,7 @@ } } - - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endBlock(Block bl) { if (bDefer) { @@ -443,9 +446,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startBlockContainer(BlockContainer blc) { if (bDefer) { return; @@ -472,9 +473,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endBlockContainer(BlockContainer bl) { if (bDefer) { return; @@ -499,9 +498,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startTable(Table tbl) { if (bDefer) { return; @@ -519,6 +516,8 @@ = TableAttributesConverter.convertTableAttributes(tbl); RtfTable table = tc.newTable(atts, tableContext); + table.setNestedTableDepth(nestedTableDepth); + nestedTableDepth++; CommonBorderPaddingBackground border = tbl.getCommonBorderPaddingBackground(); RtfAttributes borderAttributes = new RtfAttributes(); @@ -545,53 +544,32 @@ builderContext.pushTableContext(tableContext); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endTable(Table tbl) { if (bDefer) { return; } + nestedTableDepth--; builderContext.popTableContext(); builderContext.popContainer(); } - /** - * - * @param tc TableColumn that is starting; - */ - + /** [EMAIL PROTECTED] */ public void startColumn(TableColumn tc) { if (bDefer) { return; } try { - /** - * Pass a SimplePercentBaseContext to getValue in order to - * avoid a NullPointerException, which occurs when you use - * proportional-column-width function in column-width attribute. - * Of course the results won't be correct, but at least the - * rest of the document will be rendered. Usage of the - * TableLayoutManager is not welcome due to design reasons and - * it also does not provide the correct values. - * TODO: Make proportional-column-width working for rtf output - */ - SimplePercentBaseContext context - = new SimplePercentBaseContext(null, - LengthBase.TABLE_UNITS, - 100000); - - Integer iWidth - = new Integer(tc.getColumnWidth().getValue(context) / 1000); - - String strWidth = iWidth.toString() + FixedLength.POINT; - Float width = new Float( - FoUnitsConverter.getInstance().convertToTwips(strWidth)); + int iWidth = tc.getColumnWidth().getValue(percentManager); + percentManager.setDimension(tc, iWidth); + + //convert to twips + Float width = new Float(FoUnitsConverter.getInstance().convertMptToTwips(iWidth)); builderContext.getTableContext().setNextColumnWidth(width); builderContext.getTableContext().setNextColumnRowSpanning( - new Integer(0), null); + new Integer(0), null); builderContext.getTableContext().setNextFirstSpanningCol(false); } catch (Exception e) { log.error("startColumn: " + e.getMessage()); @@ -599,49 +577,34 @@ } } - /** - * - * @param tc TableColumn that is ending; - */ - + /** [EMAIL PROTECTED] */ public void endColumn(TableColumn tc) { if (bDefer) { return; } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startHeader(TableHeader header) { startPart(header); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endHeader(TableHeader header) { endPart(header); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startFooter(TableFooter footer) { startPart(footer); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endFooter(TableFooter footer) { endPart(footer); } - /** - * - * @param inl Inline that is starting. - */ + /** [EMAIL PROTECTED] */ public void startInline(Inline inl) { if (bDefer) { return; @@ -669,10 +632,7 @@ } } - /** - * - * @param inl Inline that is ending. - */ + /** [EMAIL PROTECTED] */ public void endInline(Inline inl) { if (bDefer) { return; @@ -735,10 +695,7 @@ startPart(body); } - - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endBody(TableBody body) { endPart(body); } @@ -775,9 +732,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endRow(TableRow tr) { if (bDefer) { return; @@ -814,9 +769,7 @@ builderContext.getTableContext().decreaseRowSpannings(); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startCell(TableCell tc) { if (bDefer) { return; @@ -868,7 +821,6 @@ //process number-columns-spanned attribute if (numberColumnsSpanned > 0) { // Get the number of columns spanned - RtfTable table = row.getTable(); tctx.setCurrentFirstSpanningCol(true); // We widthdraw one cell because the first cell is already created @@ -876,6 +828,8 @@ for (int i = 0; i < numberColumnsSpanned - 1; ++i) { tctx.selectNextColumn(); + //aggregate width for further elements + width += tctx.getColumnWidth(); tctx.setCurrentFirstSpanningCol(false); RtfTableCell hCell = row.newTableCellMergedHorizontally( 0, null); @@ -890,10 +844,12 @@ cell.getRtfAttributes()); } else { tctx.setCurrentColumnRowSpanning( - new Integer(numberRowsSpanned), null); + new Integer(numberRowsSpanned), cell.getRtfAttributes()); } } } + //save width of the cell, convert from twips to mpt + percentManager.setDimension(tc, (int)width * 50); builderContext.pushContainer(cell); } catch (IOException ioe) { @@ -904,9 +860,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endCell(TableCell tc) { if (bDefer) { return; @@ -917,9 +871,7 @@ } // Lists - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startList(ListBlock lb) { if (bDefer) { return; @@ -944,9 +896,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endList(ListBlock lb) { if (bDefer) { return; @@ -955,9 +905,7 @@ builderContext.popContainer(); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startListItem(ListItem li) { if (bDefer) { return; @@ -995,9 +943,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endListItem(ListItem li) { if (bDefer) { return; @@ -1006,9 +952,7 @@ builderContext.popContainer(); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startListLabel() { if (bDefer) { return; @@ -1028,9 +972,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endListLabel() { if (bDefer) { return; @@ -1039,46 +981,32 @@ builderContext.popContainer(); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startListBody() { } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endListBody() { } // Static Regions - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startStatic() { } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endStatic() { } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startMarkup() { } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endMarkup() { } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startLink(BasicLink basicLink) { if (bDefer) { return; @@ -1109,9 +1037,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endLink() { if (bDefer) { return; @@ -1120,9 +1046,7 @@ builderContext.popContainer(); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void image(ExternalGraphic eg) { if (bDefer) { return; @@ -1153,16 +1077,14 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void foreignObject(InstreamForeignObject ifo) { if (bDefer) { return; } try { - XMLObj child = (XMLObj) ifo.getChildXMLObj(); + XMLObj child = ifo.getChildXMLObj(); Document doc = child.getDOMDocument(); String ns = child.getNamespaceURI(); @@ -1191,7 +1113,8 @@ FOUserAgent userAgent = ifo.getUserAgent(); ImageManager manager = userAgent.getFactory().getImageManager(); - Image converted = manager.convertImage(image, FLAVORS); + Map hints = ImageUtil.getDefaultHints(ua.getImageSessionContext()); + Image converted = manager.convertImage(image, FLAVORS, hints); putGraphic(ifo, converted); } catch (ImageException ie) { @@ -1242,7 +1165,7 @@ throws IOException { byte[] rawData = null; - ImageInfo info = image.getInfo(); + final ImageInfo info = image.getInfo(); if (image instanceof ImageRawStream) { ImageRawStream rawImage = (ImageRawStream)image; @@ -1261,6 +1184,25 @@ return; } + //Set up percentage calculations + this.percentManager.setDimension(abstractGraphic); + PercentBaseContext pContext = new PercentBaseContext() { + + public int getBaseLength(int lengthBase, FObj fobj) { + switch (lengthBase) { + case LengthBase.IMAGE_INTRINSIC_WIDTH: + return info.getSize().getWidthMpt(); + case LengthBase.IMAGE_INTRINSIC_HEIGHT: + return info.getSize().getHeightMpt(); + default: + return percentManager.getBaseLength(lengthBase, fobj); + } + } + + }; + ImageLayout layout = new ImageLayout(abstractGraphic, pContext, + image.getInfo().getSize().getDimensionMpt()); + final IRtfTextrunContainer c = (IRtfTextrunContainer)builderContext.getContainer( IRtfTextrunContainer.class, true, this); @@ -1273,63 +1215,23 @@ } rtfGraphic.setImageData(rawData); - //set scaling - if (abstractGraphic.getScaling() == Constants.EN_UNIFORM) { - rtfGraphic.setScaling ("uniform"); - } - - //get width - int width = 0; - if (abstractGraphic.getWidth().getEnum() == Constants.EN_AUTO) { - width = info.getSize().getWidthMpt(); - } else { - width = abstractGraphic.getWidth().getValue(); - } - - //get height - int height = 0; - if (abstractGraphic.getWidth().getEnum() == Constants.EN_AUTO) { - height = info.getSize().getHeightMpt(); - } else { - height = abstractGraphic.getHeight().getValue(); - } - - //get content-width - int contentwidth = 0; - if (abstractGraphic.getContentWidth().getEnum() - == Constants.EN_AUTO) { - contentwidth = info.getSize().getWidthMpt(); - } else if (abstractGraphic.getContentWidth().getEnum() - == Constants.EN_SCALE_TO_FIT) { - contentwidth = width; - } else { - //TODO: check, if the value is a percent value - contentwidth = abstractGraphic.getContentWidth().getValue(); - } - - //get content-width - int contentheight = 0; - if (abstractGraphic.getContentHeight().getEnum() - == Constants.EN_AUTO) { - - contentheight = info.getSize().getHeightMpt(); - - } else if (abstractGraphic.getContentHeight().getEnum() - == Constants.EN_SCALE_TO_FIT) { - - contentheight = height; - } else { - //TODO: check, if the value is a percent value - contentheight = abstractGraphic.getContentHeight().getValue(); - } - - //set width in rtf - //newGraphic.setWidth((long) (contentwidth / 1000f) + FixedLength.POINT); - rtfGraphic.setWidth((long) (contentwidth / 50f) + "twips"); - - //set height in rtf - //newGraphic.setHeight((long) (contentheight / 1000f) + FixedLength.POINT); - rtfGraphic.setHeight((long) (contentheight / 50f) + "twips"); + FoUnitsConverter converter = FoUnitsConverter.getInstance(); + Dimension viewport = layout.getViewportSize(); + Rectangle placement = layout.getPlacement(); + int cropLeft = Math.round(converter.convertMptToTwips(-placement.x)); + int cropTop = Math.round(converter.convertMptToTwips(-placement.y)); + int cropRight = Math.round(converter.convertMptToTwips( + -1 * (viewport.width - placement.x - placement.width))); + int cropBottom = Math.round(converter.convertMptToTwips( + -1 * (viewport.height - placement.y - placement.height))); + rtfGraphic.setCropping(cropLeft, cropTop, cropRight, cropBottom); + + int width = Math.round(converter.convertMptToTwips(viewport.width)); + int height = Math.round(converter.convertMptToTwips(viewport.height)); + width += cropLeft + cropRight; + height += cropTop + cropBottom; + rtfGraphic.setWidthTwips(width); + rtfGraphic.setHeightTwips(height); //TODO: make this configurable: // int compression = m_context.m_options.getRtfExternalGraphicCompressionRate (); @@ -1342,15 +1244,11 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void pageRef() { } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startFootnote(Footnote footnote) { if (bDefer) { return; @@ -1375,9 +1273,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endFootnote(Footnote footnote) { if (bDefer) { return; @@ -1386,9 +1282,7 @@ builderContext.popContainer(); } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void startFootnoteBody(FootnoteBody body) { if (bDefer) { return; @@ -1409,9 +1303,7 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void endFootnoteBody(FootnoteBody body) { if (bDefer) { return; @@ -1432,10 +1324,28 @@ } } - /** - * [EMAIL PROTECTED] - */ + /** [EMAIL PROTECTED] */ public void leader(Leader l) { + if (bDefer) { + return; + } + + try { + percentManager.setDimension(l); + RtfAttributes rtfAttr = TextAttributesConverter.convertLeaderAttributes( + l, percentManager); + + IRtfTextrunContainer container + = (IRtfTextrunContainer)builderContext.getContainer( + IRtfTextrunContainer.class, true, this); + RtfTextrun textrun = container.getTextrun(); + + textrun.addLeader(rtfAttr); + + } catch (Exception e) { + log.error("startLeader: " + e.getMessage()); + throw new RuntimeException(e.getMessage()); + } } /** @@ -1469,10 +1379,7 @@ } } - /** - * - * @param pagenum PageNumber that is starting. - */ + /** [EMAIL PROTECTED] */ public void startPageNumber(PageNumber pagenum) { if (bDefer) { return; @@ -1497,16 +1404,64 @@ } } - /** - * - * @param pagenum PageNumber that is ending. - */ + /** [EMAIL PROTECTED] */ public void endPageNumber(PageNumber pagenum) { if (bDefer) { return; } } + /** [EMAIL PROTECTED] */ + public void startPageNumberCitation(PageNumberCitation l) { + if (bDefer) { + return; + } + try { + + IRtfTextrunContainer container + = (IRtfTextrunContainer)builderContext.getContainer( + IRtfTextrunContainer.class, true, this); + RtfTextrun textrun = container.getTextrun(); + + textrun.addPageNumberCitation(l.getRefId()); + + } catch (Exception e) { + log.error("startPageNumberCitation: " + e.getMessage()); + throw new RuntimeException(e.getMessage()); + } + } + + private void prepareTable(Table tab) { + // Allows to receive the available width of the table + percentManager.setDimension(tab); + + // Table gets expanded by half of the border on each side inside Word + // When using wide borders the table gets cut off + int tabDiff = tab.getCommonBorderPaddingBackground().getBorderStartWidth(false) / 2 + + tab.getCommonBorderPaddingBackground().getBorderEndWidth(false); + + // check for "auto" value + if (!(tab.getInlineProgressionDimension().getMaximum(null).getLength() + instanceof EnumLength)) { + // value specified + percentManager.setDimension(tab, + tab.getInlineProgressionDimension().getMaximum(null) + .getLength().getValue(percentManager) + - tabDiff); + } else { + // set table width again without border width + percentManager.setDimension(tab, percentManager.getBaseLength( + LengthBase.CONTAINING_BLOCK_WIDTH, tab) - tabDiff); + } + + ColumnSetup columnSetup = new ColumnSetup(tab); + //int sumOfColumns = columnSetup.getSumOfColumnWidths(percentManager); + float tableWidth = percentManager.getBaseLength(LengthBase.CONTAINING_BLOCK_WIDTH, tab); + float tableUnit = columnSetup.computeTableUnit(percentManager, Math.round(tableWidth)); + percentManager.setTableUnit(tab, Math.round(tableUnit)); + + } + /** * Calls the appropriate event handler for the passed FObj. * @@ -1659,6 +1614,16 @@ } else { endCell( (TableCell) foNode); } + } else if (foNode instanceof Leader) { + if (bStart) { + leader((Leader) foNode); + } + } else if (foNode instanceof PageNumberCitation) { + if (bStart) { + startPageNumberCitation((PageNumberCitation) foNode); + } else { + endPageNumberCitation((PageNumberCitation) foNode); + } } else { RTFEventProducer eventProducer = RTFEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); @@ -1701,9 +1666,12 @@ //recurse all table-columns if (table.getColumns() != null) { - for (Iterator it = table.getColumns().iterator(); it.hasNext();) { - recurseFONode( (FONode) it.next() ); - } + //Calculation for column-widths which are not set + prepareTable(table); + + for (Iterator it = table.getColumns().iterator(); it.hasNext();) { + recurseFONode( (FONode) it.next() ); + } } else { //TODO Implement implicit column setup handling! RTFEventProducer eventProducer = RTFEventProducer.Provider.get(
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Thu Jul 31 02:06:10 2008 @@ -21,25 +21,30 @@ import java.awt.Color; -//FOP +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOText; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.BlockContainer; import org.apache.fop.fo.flow.Inline; +import org.apache.fop.fo.flow.Leader; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonTextDecoration; -import org.apache.fop.render.rtf.BorderAttributesConverter; +import org.apache.fop.fo.properties.PercentLength; import org.apache.fop.render.rtf.rtflib.rtfdoc.IBorderAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFontManager; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfLeader; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; /** Converts FO properties to RtfAttributes @@ -53,6 +58,8 @@ */ final class TextAttributesConverter { + private static Log log = LogFactory.getLog(TextAttributesConverter.class); + /** * Constructor is private, because it's just a utility class. */ @@ -137,6 +144,131 @@ return attrib; } + + /** + * Converts FO properties used by RtfLeader to RtfAttributes. + * @param fobj Leader + * @param context PercentBaseContext + * @return RtfAttributes + * @throws FOPException + */ + public static RtfAttributes convertLeaderAttributes(Leader fobj, PercentBaseContext context) + throws FOPException { + boolean tab = false; + FOPRtfAttributes attrib = new FOPRtfAttributes(); + attrib.set(RtfText.ATTR_FONT_FAMILY, + RtfFontManager.getInstance().getFontNumber(fobj.getCommonFont().getFirstFontFamily())); + + if (fobj.getLeaderLength() != null) { + attrib.set(RtfLeader.LEADER_WIDTH, convertMptToTwips(fobj.getLeaderLength().getMaximum( + context).getLength().getValue(context))); + + if (fobj.getLeaderLength().getMaximum(context) instanceof PercentLength) { + if (((PercentLength)fobj.getLeaderLength().getMaximum(context)).getString().equals( + "100.0%")) { + // Use Tab instead of white spaces + attrib.set(RtfLeader.LEADER_USETAB, 1); + tab = true; + } + } + } + + attrFontColor(fobj.getColor(), attrib); + + if (fobj.getLeaderPatternWidth() != null) { + //TODO calculate pattern width not possible for white spaces, because its using + //underlines for tab it would work with LEADER_PATTERN_WIDTH (expndtw) + } + + switch(fobj.getLeaderPattern()) { + case Constants.EN_DOTS: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_DOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_DOTTED); + } + break; + case Constants.EN_SPACE: + //nothing has to be set for spaces + break; + case Constants.EN_RULE: + //Things like start-indent, space-after, ... not supported? + //Leader class does not offer these properties + //TODO aggregate them with the leader width or + // create a second - blank leader - before + + if (fobj.getRuleThickness() != null) { + //TODO See inside RtfLeader, better calculation for + //white spaces would be necessary + //attrib.set(RtfLeader.LEADER_RULE_THICKNESS, + // fobj.getRuleThickness().getValue(context)); + log.warn("RTF: fo:leader rule-thickness not supported"); + } + + switch (fobj.getRuleStyle()) { + case Constants.EN_SOLID: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_THICK); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_THICK); + } + break; + case Constants.EN_DASHED: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_MIDDLEDOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_MIDDLEDOTTED); + } + break; + case Constants.EN_DOTTED: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_DOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_DOTTED); + } + break; + case Constants.EN_DOUBLE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_EQUAL); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_EQUAL); + } + break; + case Constants.EN_GROOVE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_HYPHENS); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_HYPHENS); + } + break; + case Constants.EN_RIDGE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_UNDERLINE); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_UNDERLINE); + } + break; + default: + break; + } + break; + case Constants.EN_USECONTENT: + log.warn("RTF: fo:leader use-content not supported"); + break; + default: + break; + } + + if (fobj.getLeaderAlignment() == Constants.EN_REFERENCE_AREA) { + log.warn("RTF: fo:leader reference-area not supported"); + } + return attrib; + } + + private static int convertMptToTwips(int mpt) { + return Math.round(FoUnitsConverter.getInstance().convertMptToTwips(mpt)); + } + private static void attrFont(CommonFont font, FOPRtfAttributes rtfAttr) { rtfAttr.set(RtfText.ATTR_FONT_FAMILY, RtfFontManager.getInstance().getFontNumber(font.getFirstFontFamily())); Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java Thu Jul 31 02:06:10 2008 @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.Iterator; + import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributesImpl; @@ -164,6 +165,15 @@ } /** + * Returns a value as an Integer. The value is simply cast to an Integer. + * @param name String containing attribute name + * @return the value of an attribute, null if not found + */ + public Integer getValueAsInteger(String name) { + return (Integer)values.get(name); + } + + /** * @param name String containing attribute name * @return true if given attribute is set */ Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java Thu Jul 31 02:06:10 2008 @@ -269,6 +269,9 @@ */ protected boolean scaleUniform = false; + /** cropping on left/top/right/bottom edges for \piccrop*N */ + private int[] cropValues = new int[4]; + /** * Graphic compression rate */ @@ -406,6 +409,7 @@ computeImageSize(); writeSizeInfo(); + writeAttributes(getRtfAttributes(), null); for (int i = 0; i < imagedata.length; i++) { int iData = imagedata [i]; @@ -519,6 +523,19 @@ writeControlWord("picscaley" + widthDesired * 100 / width); } } + + if (this.cropValues[0] != 0) { + writeOneAttribute("piccropl", new Integer(this.cropValues[0])); + } + if (this.cropValues[1] != 0) { + writeOneAttribute("piccropt", new Integer(this.cropValues[1])); + } + if (this.cropValues[2] != 0) { + writeOneAttribute("piccropr", new Integer(this.cropValues[2])); + } + if (this.cropValues[3] != 0) { + writeOneAttribute("piccropb", new Integer(this.cropValues[3])); + } } ////////////////////////////////////////////////// @@ -546,6 +563,24 @@ } /** + * Sets the desired width of the image. + * @param twips The desired image width (in twips) + */ + public void setWidthTwips(int twips) { + this.widthDesired = twips; + this.perCentW = false; + } + + /** + * Sets the desired height of the image. + * @param twips The desired image height (in twips) + */ + public void setHeightTwips(int twips) { + this.heightDesired = twips; + this.perCentH = false; + } + + /** * Sets the flag whether the image size shall be adjusted. * * @param value @@ -553,9 +588,34 @@ * false no adjustment */ public void setScaling(String value) { - if (value.equalsIgnoreCase("uniform")) { - this.scaleUniform = true; - } + setUniformScaling("uniform".equalsIgnoreCase(value)); + } + + /** + * Sets the flag whether the image size shall be adjusted. + * + * @param uniform + * true image width or height shall be adjusted automatically\n + * false no adjustment + */ + public void setUniformScaling(boolean uniform) { + this.scaleUniform = uniform; + } + + /** + * Sets cropping values for all four edges for the \piccrop*N commands. + * A positive value crops toward the center of the picture; + * a negative value crops away from the center, adding a space border around the picture + * @param left left cropping value (in twips) + * @param top top cropping value (in twips) + * @param right right cropping value (in twips) + * @param bottom bottom cropping value (in twips) + */ + public void setCropping(int left, int top, int right, int bottom) { + this.cropValues[0] = left; + this.cropValues[1] = top; + this.cropValues[2] = right; + this.cropValues[3] = bottom; } /** Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java Thu Jul 31 02:06:10 2008 @@ -60,11 +60,13 @@ public static final String HEADERY = "headery"; /** constant for footer position */ public static final String FOOTERY = "footery"; - + /** constant for itap level */ + public static final String ITAP = "itap"; + /** String array of RtfPage attributes */ public static final String[] PAGE_ATTR = new String[]{ PAGE_WIDTH, PAGE_HEIGHT, LANDSCAPE, MARGIN_TOP, MARGIN_BOTTOM, - MARGIN_LEFT, MARGIN_RIGHT, HEADERY, FOOTERY + MARGIN_LEFT, MARGIN_RIGHT, HEADERY, FOOTERY, ITAP }; /** RtfPage creates new page attributes with the parent container, the writer Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java Thu Jul 31 02:06:10 2008 @@ -26,8 +26,8 @@ * the FOP project. */ -import java.io.Writer; import java.io.IOException; +import java.io.Writer; /** * @author Christopher Scott, [EMAIL PROTECTED] @@ -50,9 +50,9 @@ private String id = null; /** Create an RTF page number citation as a child of given container with default attributes */ - RtfPageNumberCitation (IRtfPageNumberCitationContainer parent, Writer w, String id) + RtfPageNumberCitation (RtfContainer parent, Writer w, String id) throws IOException { - super((RtfContainer)parent, w); + super(parent, w); this.id = id; } @@ -92,7 +92,7 @@ writeStarControlWord(pageRef); writeGroupMark(false); writeGroupMark(true); - writeControlWord(RTF_FIELD_RESULT); + writeControlWord(RTF_FIELD_RESULT + '#'); //To see where the page-number would be writeGroupMark(false); writeGroupMark(false); } Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java Thu Jul 31 02:06:10 2008 @@ -26,8 +26,8 @@ * the FOP project. */ -import java.io.Writer; import java.io.IOException; +import java.io.Writer; /** Container for RtfRow elements * @author Bertrand Delacretaz [EMAIL PROTECTED] @@ -43,6 +43,9 @@ * number-columns-spanned attribute */ private ITableColumnsInfo tableContext; + /** Shows the table depth necessary for nested tables */ + private int nestedTableDepth = 0; + /** Create an RTF element as a child of given container */ RtfTable(IRtfTableContainer parent, Writer w, ITableColumnsInfo tc) throws IOException { @@ -213,6 +216,22 @@ } /** + * Sets the nested table depth. + * @param nestedTableDepth the nested table depth + */ + public void setNestedTableDepth(int nestedTableDepth) { + this.nestedTableDepth = nestedTableDepth; + } + + /** + * Returns the nested table depth. + * @return the nested table depth + */ + public int getNestedTableDepth() { + return this.nestedTableDepth; + } + + /** * Sets the RtfAttributes for the borders of the table. * @param attributes Border attributes of the table. */ Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java Thu Jul 31 02:06:10 2008 @@ -133,11 +133,11 @@ * @throws IOException for I/O problems */ protected void writeRtfContent() throws IOException { - if (getTable().isNestedTable()) { //nested table writeControlWord("intbl"); - writeControlWord("itap2"); + //itap is the depth (level) of the current nested table + writeControlWord("itap" + getTable().getNestedTableDepth()); } else { //normal (not nested) table writeRowAndCellsDefintions(); Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java Thu Jul 31 02:06:10 2008 @@ -22,8 +22,8 @@ // Java import java.io.IOException; import java.io.Writer; -import java.util.List; import java.util.Iterator; +import java.util.List; import java.util.ListIterator; // FOP @@ -176,6 +176,15 @@ } /** + * Inserts a page number citation. + * @param refId the identifier being referenced + * @throws IOException for I/O problems + */ + public void addPageNumberCitation(String refId) throws IOException { + RtfPageNumberCitation r = new RtfPageNumberCitation(this, writer, refId); + } + + /** * Pop inline attributes. * * @throws IOException for I/O problems @@ -243,6 +252,15 @@ } /** + * Inserts a leader. + * @param attrs Attributes for the leader + * @throws IOException for I/O problems + */ + public void addLeader(RtfAttributes attrs) throws IOException { + new RtfLeader(this, writer, attrs); + } + + /** * Inserts a page number. * @param attr Attributes for the page number to insert. * @throws IOException for I/O problems Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/BreakUtil.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/BreakUtil.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/util/BreakUtil.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/util/BreakUtil.java Thu Jul 31 02:06:10 2008 @@ -36,7 +36,8 @@ case Constants.EN_PAGE: return 2; case Constants.EN_EVEN_PAGE: return 3; case Constants.EN_ODD_PAGE: return 3; - default: throw new IllegalArgumentException(); + default: throw new IllegalArgumentException( + "Illegal value for breakClass: " + breakClass); } } Modified: xmlgraphics/fop/trunk/status.xml URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/status.xml (original) +++ xmlgraphics/fop/trunk/status.xml Thu Jul 31 02:06:10 2008 @@ -172,12 +172,117 @@ </action> </release> <release version="0.95" date="TBD"> + <notes> + <section> + <title>Notes</title> + <p> + Besides the important changes listed below, the most important areas with + improvements in this release are: + </p> + <ul> + <li> + Many bugfixes in tables, plus some new features (full support for keeps and + breaks, border conditionality, background on columns and header/footer/body) + </li> + <li> + Improvements and bugfixes for font handling and font + auto-detection/-registration. + </li> + <li> + Performance improvements and memory optimizations for the property handling + in the FO tree. + </li> + </ul> + <p> + Please note that with this release, we've dropped support for Java 1.3. + FOP will, from now on, <strong>require at least Java 1.4</strong>. + </p> + <p> + There have been a few changes in tables that make FOP both more strict and more + compliant to the Recommendation: + <ul> + <li>XSL-FO 1.1 explicitly states that a row-spanning fo:table-cell element is not + allowed to span further than its enclosing fo:table-header/footer/body element + (see bottom of <link href="http://www.w3.org/TR/xsl11/#fo_table">section + 6.7.3</link>). From now on FOP will give a validation error if a document + contains such an erroneous cell. + </li> + <li> + <p>If an fo:table element contains explicit fo:table-column children, then those + elements set the total number of columns in the table. This means that a + validation error will now occur if a row contains more cells than available + columns. This change allows to improve performance, since the rendering of the + table may start as soon as the table-column elements have been parsed.</p> + <p>If more flexibility is needed, then the fo:table-column elements may be just + omitted. The final number of columns will then be set by the row that has the + most cells.</p> + </li> + </ul> + </p> + <p> + The image libraries Jimi and JAI are no longer needed (and used) for image loading. + Instead we rely completely on the Image I/O API that has been introduced with + Java 1.4. If you still need support for bitmap image formats that do not work + out-of-the-box, we recommend adding + <link href="http://jai-imageio.dev.java.net/">JAI Image I/O Tools</link> + (an Image I/O compatible image codec package) to the classpath. JAI is still required + for building the FOP distribution but it is optional for normal builds and at run-time. + </p> + <note> + This final 0.95 release contains all the + <a href="changes_0.95beta.html">changes made for Apache FOP 0.95beta</a>. + </note> + </section> + </notes> <action context="Renderers" dev="JM" type="fix"> - Fixed positioning of absolutely positioned block-containers in multi-column documents. + Fixed a color selection problem which occurred after an image has been painted + through the Graphics2DAdapter in PDF output. + </action> + <action context="Renderers" dev="JM" type="fix" fixes-bug="41306"> + Fixed page ordering problem with AWTRenderer. + </action> + <action context="Renderers" dev="JM" type="fix" fixes-bug="39980"> + Fixed image scaling for RTF output. + </action> + <action context="API" dev="JM" type="fix"> + Fixed the -imagein command-line option. + </action> + <action context="Renderers" dev="JM" type="add" fixes-bug="43825" due-to="Maximilian Aster"> + Added support for fo:leader for RTF output (no full support!). Fixes problems with empty leaders + being used to force empty lines among other issues. + </action> + <action context="Renderers" dev="JM" type="add" fixes-bug="43824" due-to="Maximilian Aster"> + Added support for page-number-citation for RTF output. + </action> + <action context="Renderers" dev="JM" type="fix" fixes-bug="43606" due-to="Maximilian Aster"> + Fixed handling of proportional-column-width() and percentages for table column in RTF + output. + </action> + <action context="Layout" dev="AD" type="fix" fixes-bug="45295"> + Fixed NullPointerException when page-number-citations are used inside a marker. + </action> + <action context="Images" dev="JM" type="fix"> + Fixed two bugs concerning resolution handling with SVG images and their + conversion to bitmaps for RTF output. + </action> + <action context="Code" dev="JM" type="fix" fixes-bug="44887" importance="high"> + Fixed potential multi-threading problem concerning the use of DecimalFormat. + </action> + <action context="Layout" dev="JM" type="fix" fixes-bug="44412"> + Regression bugfix: Multiple collapsible breaks don't cause empty pages anymore. </action> <action context="Renderers" dev="JM" type="fix"> + Fixed resolution handling inside AWT preview dialog. + </action> + <action context="Renderers" dev="JM" type="fix" importance="high"> + Fixed positioning of absolutely positioned block-containers in multi-column documents. + </action> + <action context="Renderers" dev="JM" type="fix" importance="high"> Fixed rendering of fixed block-containers in AFP output. </action> + <action context="Layout" dev="VH" type="fix" fixes-bug="41621" importance="high"> + Various bugfixes for table layout. + </action> <action context="Renderers" dev="JM" type="fix"> Fixed regression causing bad positioning of block-containers if used as descendant of a table-cell. Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java (original) +++ xmlgraphics/fop/trunk/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java Thu Jul 31 02:06:10 2008 @@ -88,6 +88,51 @@ assertEquals(16000, info.getSize().getHeightMpt()); } + public void testSVGNoViewbox() throws Exception { + String uri = "test/resources/images/circles.svg"; + + FopFactory ff = FopFactory.newInstance(); + ff.setSourceResolution(96); + ff.setTargetResolution(300); + + FOUserAgent userAgent = ff.newFOUserAgent(); + + ImageManager manager = ff.getImageManager(); + ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); + assertNotNull("ImageInfo must not be null", info); + + Image img = manager.getImage(info, ImageFlavor.XML_DOM, + userAgent.getImageSessionContext()); + assertNotNull("Image must not be null", img); + assertEquals(ImageFlavor.XML_DOM, img.getFlavor()); + ImageXMLDOM imgDom = (ImageXMLDOM)img; + assertNotNull(imgDom.getDocument()); + assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); + info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image + assertEquals(96, info.getSize().getDpiHorizontal(), 0); + assertEquals(340158, info.getSize().getWidthMpt()); + assertEquals(340158, info.getSize().getHeightMpt()); + assertEquals(454, info.getSize().getWidthPx()); + assertEquals(454, info.getSize().getHeightPx()); + + img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, + userAgent.getImageSessionContext()); + assertNotNull("Image must not be null", img); + assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor()); + ImageRendered imgRed = (ImageRendered)img; + assertNotNull(imgRed.getRenderedImage()); + if (DEBUG_TARGET_DIR != null) { + ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(), + (int)userAgent.getTargetResolution(), + new File(DEBUG_TARGET_DIR, "circles.svg.png")); + } + assertEquals(1418, imgRed.getRenderedImage().getWidth()); + assertEquals(1418, imgRed.getRenderedImage().getHeight()); + info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image + assertEquals(340158, info.getSize().getWidthMpt()); + assertEquals(340158, info.getSize().getHeightMpt()); + } + public void testWMF() throws Exception { String uri = "test/resources/images/testChart.wmf"; Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug44412.xml URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug44412.xml?rev=681307&r1=681306&r2=681307&view=diff ============================================================================== --- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug44412.xml (original) +++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_break-before_bug44412.xml Thu Jul 31 02:06:10 2008 @@ -20,8 +20,7 @@ <info> <p> This test checks Bugzilla #44412 where a break-before on the first child of an otherwise - empty block is set. It is expected that the parent block creates two areas, the first with - only border-before on the first page and zero bpd. + empty block is set. </p> </info> <fo> @@ -44,20 +43,12 @@ </fo:root> </fo> <checks> - <eval expected="2" xpath="count(//[EMAIL PROTECTED] = 'b1'])"/> - <eval expected="4000 4000 4000 0" xpath="(//[EMAIL PROTECTED] = 'b1'])[1]/@bap"/> - <eval expected="4000 4000 0 4000" xpath="(//[EMAIL PROTECTED] = 'b1'])[2]/@bap"/> - <eval expected="0" xpath="(//[EMAIL PROTECTED] = 'b1'])[1]/@bpd"/> - <eval expected="43200" xpath="(//[EMAIL PROTECTED] = 'b1'])[2]/@bpd"/> + <eval expected="1" xpath="count(//[EMAIL PROTECTED] = 'b1'])"/> + <eval expected="4000 4000 4000 4000" xpath="(//[EMAIL PROTECTED] = 'b1'])[1]/@bap"/> + <eval expected="43200" xpath="(//[EMAIL PROTECTED] = 'b1'])[1]/@bpd"/> <element-list category="breaker" index="0"> <box w="14400"/> - <penalty w="0" p="0"/> - <box w="0" aux="true"/> - <penalty w="0" p="INF"/> - <glue w="4000"/> <!-- border-before --> - <box w="0"/> <!-- first block area of the "b1" block with zero bpd --> - <skip>3</skip> </element-list> </checks> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
