You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/08/12 14:36:35 UTC
svn commit: r685132 [2/3] - in
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign: ./ lib/
src/documentation/ src/documentation/content/
src/documentation/content/xdocs/ src/documentation/content/xdocs/0.95/
src/documentation/content/xdocs/dev/ src/docum...
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/PrintRendererConfigurator.java Tue Aug 12 05:36:18 2008
@@ -43,6 +43,8 @@
import org.apache.fop.apps.FopFactory;
import org.apache.fop.fonts.EmbedFontInfo;
import org.apache.fop.fonts.FontCache;
+import org.apache.fop.fonts.FontEventAdapter;
+import org.apache.fop.fonts.FontEventListener;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontManager;
import org.apache.fop.fonts.FontResolver;
@@ -107,8 +109,10 @@
boolean strict = factory.validateUserConfigStrictly();
FontCache fontCache = fontManager.getFontCache();
+ FontEventListener listener = new FontEventAdapter(
+ renderer.getUserAgent().getEventBroadcaster());
List/*<EmbedFontInfo>*/ embedFontInfoList = buildFontListFromConfiguration(cfg,
- fontResolver, strict, fontManager);
+ fontResolver, strict, fontManager, listener);
if (fontCache != null && fontCache.hasChanged()) {
fontCache.save();
@@ -123,12 +127,14 @@
* @param fontResolver the FontResolver to use
* @param strict true if an Exception should be thrown if an error is found.
* @param fontManager the font manager
+ * @param listener a font event listener
* @return a List of EmbedFontInfo objects.
* @throws FOPException If an error occurs while processing the configuration
*/
public static List/*<EmbedFontInfo>*/ buildFontListFromConfiguration(Configuration cfg,
FontResolver fontResolver,
- boolean strict, FontManager fontManager) throws FOPException {
+ boolean strict, FontManager fontManager,
+ FontEventListener listener) throws FOPException {
FontCache fontCache = fontManager.getFontCache();
String fontBaseURL = fontManager.getFontBaseURL();
List/*<EmbedFontInfo>*/ fontInfoList
@@ -157,7 +163,8 @@
fontFileFinder.find(fontBase.getAbsolutePath()),
fontInfoList,
fontResolver,
- fontCache
+ fontCache,
+ listener
);
}
} catch (IOException e) {
@@ -171,7 +178,8 @@
fontFileFinder.find(),
fontInfoList,
fontResolver,
- fontCache
+ fontCache,
+ listener
);
} catch (IOException e) {
LogUtil.handleException(log, e, strict);
@@ -180,12 +188,12 @@
// load fonts from classpath
addFontInfoListFromFileList(ClasspathResource.getInstance()
.listResourcesOfMimeType("application/x-font"),
- fontInfoList, fontResolver, fontCache);
+ fontInfoList, fontResolver, fontCache, listener);
addFontInfoListFromFileList(
ClasspathResource.getInstance()
.listResourcesOfMimeType(
"application/x-font-truetype"),
- fontInfoList, fontResolver, fontCache);
+ fontInfoList, fontResolver, fontCache, listener);
}
// directory (multiple font) configuration
@@ -210,7 +218,8 @@
fontFileFinder.find(directory),
fontInfoList,
fontResolver,
- fontCache
+ fontCache,
+ listener
);
} catch (IOException e) {
LogUtil.handleException(log, e, strict);
@@ -221,7 +230,7 @@
Configuration[] font = fonts.getChildren("font");
for (int i = 0; i < font.length; i++) {
EmbedFontInfo embedFontInfo = getFontInfoFromConfiguration(
- font[i], fontResolver, strict, fontCache);
+ font[i], fontResolver, strict, fontCache, listener);
if (embedFontInfo != null) {
fontInfoList.add(embedFontInfo);
}
@@ -265,11 +274,12 @@
*/
private static void addFontInfoListFromFileList(
List fontFileList, List/*<EmbedFontInfo>*/ embedFontInfoList,
- FontResolver resolver, FontCache fontCache) {
+ FontResolver resolver, FontCache fontCache, FontEventListener listener) {
for (Iterator iter = fontFileList.iterator(); iter.hasNext();) {
URL fontUrl = (URL)iter.next();
// parse font to ascertain font info
FontInfoFinder finder = new FontInfoFinder();
+ finder.setEventListener(listener);
//EmbedFontInfo fontInfo = finder.find(fontUrl, resolver, fontCache);
//List<EmbedFontInfo> embedFontInfoList = finder.find(fontUrl, resolver, fontCache);
@@ -345,7 +355,8 @@
* @throws FOPException if something's wrong with the config data
*/
private static EmbedFontInfo getFontInfoFromConfiguration(
- Configuration fontCfg, FontResolver fontResolver, boolean strict, FontCache fontCache)
+ Configuration fontCfg, FontResolver fontResolver, boolean strict,
+ FontCache fontCache, FontEventListener listener)
throws FOPException {
String metricsUrl = fontCfg.getAttribute("metrics-url", null);
String embedUrl = fontCfg.getAttribute("embed-url", null);
@@ -397,6 +408,7 @@
}
if (fontFile != null) {
FontInfoFinder finder = new FontInfoFinder();
+ finder.setEventListener(listener);
EmbedFontInfo[] infos = finder.find(fontUrl, fontResolver, fontCache);
return infos[0]; //When subFont is set, only one font is returned
} else {
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java Tue Aug 12 05:36:18 2008
@@ -38,7 +38,6 @@
import java.awt.event.WindowEvent;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
-
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
@@ -60,8 +59,8 @@
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
-import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.render.awt.AWTRenderer;
/**
@@ -76,6 +75,8 @@
protected AWTRenderer renderer;
/** The FOUserAgent associated with this window */
protected FOUserAgent foUserAgent;
+ /** The originally configured target resolution */
+ protected float configuredTargetResolution;
/**
* Renderable instance that can be used to reload and re-render a document after
* modifications.
@@ -107,6 +108,7 @@
public PreviewDialog(FOUserAgent foUserAgent, Renderable renderable) {
renderer = (AWTRenderer) foUserAgent.getRendererOverride();
this.foUserAgent = foUserAgent;
+ this.configuredTargetResolution = this.foUserAgent.getTargetResolution();
this.renderable = renderable;
translator = new Translator();
@@ -551,23 +553,23 @@
}
private void scaleActionPerformed(ActionEvent e) {
- try {
- int index = scale.getSelectedIndex();
- if (index == 0) {
- setScale(previewPanel.getScaleToFitWindow() * 100);
- } else if (index == 1) {
- setScale(previewPanel.getScaleToFitWidth() * 100);
- } else {
- String item = (String)scale.getSelectedItem();
- setScale(Double.parseDouble(item.substring(0, item.indexOf('%'))));
- }
- } catch (FOPException fopEx) {
- fopEx.printStackTrace();
+ int index = scale.getSelectedIndex();
+ if (index == 0) {
+ setScaleToFitWindow();
+ } else if (index == 1) {
+ setScaleToFitWidth();
+ } else {
+ String item = (String)scale.getSelectedItem();
+ setScale(Double.parseDouble(item.substring(0, item.indexOf('%'))));
}
}
/** Prints the document */
public void startPrinterJob(boolean showDialog) {
+ //Restore originally configured target resolution
+ float saveResolution = foUserAgent.getTargetResolution();
+ foUserAgent.setTargetResolution(this.configuredTargetResolution);
+
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPageable(renderer);
if (!showDialog || pj.printDialog()) {
@@ -577,6 +579,8 @@
e.printStackTrace();
}
}
+
+ foUserAgent.setTargetResolution(saveResolution);
}
/**
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java Tue Aug 12 05:36:18 2008
@@ -23,6 +23,7 @@
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Point;
+import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
@@ -36,11 +37,12 @@
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
+import org.apache.xmlgraphics.util.UnitConv;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.PageViewport;
-
import org.apache.fop.render.awt.AWTRenderer;
@@ -155,6 +157,8 @@
this.renderable = renderable;
this.renderer = renderer;
this.foUserAgent = foUserAgent;
+ //Override target resolution for the computer screen
+ this.foUserAgent.setTargetResolution(Toolkit.getDefaultToolkit().getScreenResolution());
gridPanel = new JPanel();
gridPanel.setLayout(new GridLayout(0, 1)); // rows, cols
@@ -393,8 +397,10 @@
public double getScaleToFit(double viewWidth, double viewHeight) throws FOPException {
PageViewport pageViewport = renderer.getPageViewport(currentPage);
Rectangle2D pageSize = pageViewport.getViewArea();
- double widthScale = viewWidth / (pageSize.getWidth() / 1000f);
- double heightScale = viewHeight / (pageSize.getHeight() / 1000f);
+ float screenResolution = Toolkit.getDefaultToolkit().getScreenResolution();
+ float screenFactor = screenResolution / UnitConv.IN2PT;
+ double widthScale = viewWidth / (pageSize.getWidth() / 1000f) / screenFactor;
+ double heightScale = viewHeight / (pageSize.getHeight() / 1000f) / screenFactor;
return Math.min(displayMode == CONT_FACING ? widthScale / 2 : widthScale, heightScale);
}
Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFContentHandler.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 12 05:36:18 2008
@@ -0,0 +1 @@
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFContentHandler.java:680381-685126
Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFPainter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 12 05:36:18 2008
@@ -0,0 +1 @@
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFPainter.java:680381-685126
Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 12 05:36:18 2008
@@ -0,0 +1 @@
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java:680381-685126
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java Tue Aug 12 05:36:18 2008
@@ -75,10 +75,12 @@
// Add padding to corresponding space (space-before or space-after)
// if side == START or END, do nothing
- if (side == CommonBorderPaddingBackground.BEFORE) {
- attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE);
- } else if (side == CommonBorderPaddingBackground.AFTER) {
- attributes.addIntegerValue(padding, RtfText.SPACE_AFTER);
+ if (padding != 0) {
+ if (side == CommonBorderPaddingBackground.BEFORE) {
+ attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE);
+ } else if (side == CommonBorderPaddingBackground.AFTER) {
+ attributes.addIntegerValue(padding, RtfText.SPACE_AFTER);
+ }
}
}
}
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java Tue Aug 12 05:36:18 2008
@@ -19,10 +19,9 @@
package org.apache.fop.render.rtf;
-import java.util.Map;
import java.util.HashMap;
+import java.util.Map;
-//FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.FixedLength;
@@ -143,4 +142,8 @@
// RTF font size units are in half-points
return (int)(result * 2.0);
}
+
+ public float convertMptToTwips(int width) {
+ return width * POINT_TO_TWIPS / 1000;
+ }
}
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java Tue Aug 12 05:36:18 2008
@@ -21,6 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;
+
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.expr.NumericOp;
@@ -58,6 +59,8 @@
attrib.setTwips(RtfPage.PAGE_WIDTH, pagemaster.getPageWidth());
attrib.setTwips(RtfPage.PAGE_HEIGHT, pagemaster.getPageHeight());
+ //Sets the document level property
+ attrib.set(RtfPage.ITAP, "0");
Object widthRaw = attrib.getValue(RtfPage.PAGE_WIDTH);
Object heightRaw = attrib.getValue(RtfPage.PAGE_HEIGHT);
@@ -102,7 +105,7 @@
if (after != null) {
afterBottom = (Length) NumericOp.addition(pageBottom, after.getExtent());
}
- attrib.setTwips(RtfPage.FOOTERY, beforeTop);
+ attrib.setTwips(RtfPage.FOOTERY, afterBottom);
} catch (Exception e) {
log.error("Exception in convertPageAttributes: "
+ e.getMessage() + "- page attributes ignored");
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/RTFHandler.java Tue Aug 12 05:36:18 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);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startDocument() throws SAXException {
// TODO sections should be created
try {
@@ -187,9 +197,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endDocument() throws SAXException {
try {
rtfFile.flush();
@@ -199,9 +207,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
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 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endPageSequence(PageSequence pageSeq) {
if (bDefer) {
//If endBlock was called while SAX parsing, and the passed FO is Block
@@ -267,9 +279,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startFlow(Flow fl) {
if (bDefer) {
return;
@@ -357,9 +367,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endFlow(Flow fl) {
if (bDefer) {
return;
@@ -384,9 +392,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startBlock(Block bl) {
if (bDefer) {
return;
@@ -414,10 +420,7 @@
}
}
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endBlock(Block bl) {
if (bDefer) {
@@ -443,9 +446,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startBlockContainer(BlockContainer blc) {
if (bDefer) {
return;
@@ -472,9 +473,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endBlockContainer(BlockContainer bl) {
if (bDefer) {
return;
@@ -499,9 +498,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
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);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endTable(Table tbl) {
if (bDefer) {
return;
}
+ nestedTableDepth--;
builderContext.popTableContext();
builderContext.popContainer();
}
- /**
- *
- * @param tc TableColumn that is starting;
- */
-
+ /** {@inheritDoc} */
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;
- */
-
+ /** {@inheritDoc} */
public void endColumn(TableColumn tc) {
if (bDefer) {
return;
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startHeader(TableHeader header) {
startPart(header);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endHeader(TableHeader header) {
endPart(header);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startFooter(TableFooter footer) {
startPart(footer);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endFooter(TableFooter footer) {
endPart(footer);
}
- /**
- *
- * @param inl Inline that is starting.
- */
+ /** {@inheritDoc} */
public void startInline(Inline inl) {
if (bDefer) {
return;
@@ -669,10 +632,7 @@
}
}
- /**
- *
- * @param inl Inline that is ending.
- */
+ /** {@inheritDoc} */
public void endInline(Inline inl) {
if (bDefer) {
return;
@@ -735,10 +695,7 @@
startPart(body);
}
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endBody(TableBody body) {
endPart(body);
}
@@ -775,9 +732,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endRow(TableRow tr) {
if (bDefer) {
return;
@@ -814,9 +769,7 @@
builderContext.getTableContext().decreaseRowSpannings();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
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 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endCell(TableCell tc) {
if (bDefer) {
return;
@@ -917,9 +871,7 @@
}
// Lists
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startList(ListBlock lb) {
if (bDefer) {
return;
@@ -944,9 +896,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endList(ListBlock lb) {
if (bDefer) {
return;
@@ -955,9 +905,7 @@
builderContext.popContainer();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startListItem(ListItem li) {
if (bDefer) {
return;
@@ -995,9 +943,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endListItem(ListItem li) {
if (bDefer) {
return;
@@ -1006,9 +952,7 @@
builderContext.popContainer();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startListLabel() {
if (bDefer) {
return;
@@ -1028,9 +972,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endListLabel() {
if (bDefer) {
return;
@@ -1039,46 +981,32 @@
builderContext.popContainer();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startListBody() {
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endListBody() {
}
// Static Regions
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startStatic() {
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endStatic() {
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startMarkup() {
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endMarkup() {
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startLink(BasicLink basicLink) {
if (bDefer) {
return;
@@ -1109,9 +1037,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endLink() {
if (bDefer) {
return;
@@ -1120,9 +1046,7 @@
builderContext.popContainer();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void image(ExternalGraphic eg) {
if (bDefer) {
return;
@@ -1153,16 +1077,14 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
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 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void pageRef() {
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startFootnote(Footnote footnote) {
if (bDefer) {
return;
@@ -1375,9 +1273,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endFootnote(Footnote footnote) {
if (bDefer) {
return;
@@ -1386,9 +1282,7 @@
builderContext.popContainer();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void startFootnoteBody(FootnoteBody body) {
if (bDefer) {
return;
@@ -1409,9 +1303,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void endFootnoteBody(FootnoteBody body) {
if (bDefer) {
return;
@@ -1432,10 +1324,28 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
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.
- */
+ /** {@inheritDoc} */
public void startPageNumber(PageNumber pagenum) {
if (bDefer) {
return;
@@ -1497,16 +1404,64 @@
}
}
- /**
- *
- * @param pagenum PageNumber that is ending.
- */
+ /** {@inheritDoc} */
public void endPageNumber(PageNumber pagenum) {
if (bDefer) {
return;
}
}
+ /** {@inheritDoc} */
+ 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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Tue Aug 12 05:36:18 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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java Tue Aug 12 05:36:18 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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java Tue Aug 12 05:36:18 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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java Tue Aug 12 05:36:18 2008
@@ -144,21 +144,22 @@
}
header.newLine();
- header.writeGroupMark (true);
- header.writeControlWord ("fonttbl;");
+ header.writeGroupMark(true);
+ header.writeControlWord("fonttbl");
int len = fontTable.size ();
for (int i = 0; i < len; i++) {
- header.writeGroupMark (true);
+ header.writeGroupMark(true);
header.newLine();
- header.write ("\\f" + i);
- header.write (" " + (String) fontTable.elementAt (i));
- header.writeGroupMark (false);
+ header.write("\\f" + i);
+ header.write(" " + (String) fontTable.elementAt (i));
+ header.write(";");
+ header.writeGroupMark(false);
}
header.newLine();
- header.writeGroupMark (false);
+ header.writeGroupMark(false);
}
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java Tue Aug 12 05:36:18 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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java Tue Aug 12 05:36:18 2008
@@ -26,8 +26,8 @@
* the FOP project.
*/
-import java.io.Writer;
import java.io.IOException;
+import java.io.Writer;
/**
* @author Christopher Scott, scottc@westinghouse.com
@@ -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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java Tue Aug 12 05:36:18 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 bdelacretaz@codeconsult.ch
@@ -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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java Tue Aug 12 05:36:18 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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java Tue Aug 12 05:36:18 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/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Tue Aug 12 05:36:18 2008
@@ -63,7 +63,8 @@
List/*<EmbedFontInfo>*/ embedFontInfoList
= PrintRendererConfigurator.buildFontListFromConfiguration(
- cfg, fontResolver, false, fontManager);
+ cfg, fontResolver, false, fontManager, null);
+ //TODO Wire in the FontEventListener
if (fontManager.useCache()) {
fontManager.getFontCache().save();
}
Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/BreakUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/BreakUtil.java?rev=685132&r1=685131&r2=685132&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/BreakUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/BreakUtil.java Tue Aug 12 05:36:18 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);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org