You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2014/01/30 16:51:11 UTC
svn commit: r1562866 [9/13] - in
/xmlgraphics/fop/branches/Temp_FopFontsForSVG: ./ examples/fo/basic/ lib/
src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/
src/documentation/intermediate-format-ng/ src/java/META-INF/services/
src/java/org/a...
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java Thu Jan 30 15:51:03 2014
@@ -19,26 +19,50 @@
package org.apache.fop.render.ps;
+import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.imageio.ImageIO;
import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.batik.transcoder.SVGAbstractTranscoder;
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.image.PNGTranscoder;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+import org.apache.xmlgraphics.ps.ImageEncoder;
+import org.apache.xmlgraphics.ps.ImageEncodingHelper;
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.fop.image.loader.batik.BatikImageFlavors;
import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.RenderingContext;
+import org.apache.fop.render.ps.svg.PSSVGGraphics2D;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
import org.apache.fop.svg.font.FOPFontFamilyResolverImpl;
@@ -48,6 +72,9 @@ import org.apache.fop.svg.font.FOPFontFa
*/
public class PSImageHandlerSVG implements ImageHandler {
+ private static final Color FALLBACK_COLOR = new Color(255, 33, 117);
+ private HashMap<String, String> gradientsFound = new HashMap<String, String>();
+
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
BatikImageFlavors.SVG_DOM
};
@@ -59,78 +86,262 @@ public class PSImageHandlerSVG implement
PSGenerator gen = psContext.getGenerator();
ImageXMLDOM imageSVG = (ImageXMLDOM)image;
- //Controls whether text painted by Batik is generated using text or path operations
- boolean strokeText = false;
- //TODO Configure text stroking
-
- SVGUserAgent ua = new SVGUserAgent(context.getUserAgent(),
- new FOPFontFamilyResolverImpl(psContext.getFontInfo()), new AffineTransform());
-
- PSGraphics2D graphics = new PSGraphics2D(strokeText, gen);
- graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
-
- BridgeContext ctx = new PSBridgeContext(ua,
- (strokeText ? null : psContext.getFontInfo()),
- context.getUserAgent().getImageManager(),
- context.getUserAgent().getImageSessionContext());
-
- //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
- //to it.
- Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument());
+ if (shouldRaster(imageSVG)) {
+ InputStream is = renderSVGToInputStream(context, imageSVG);
- GraphicsNode root;
+ float x = (float) pos.getX() / 1000f;
+ float y = (float) pos.getY() / 1000f;
+ float w = (float) pos.getWidth() / 1000f;
+ float h = (float) pos.getHeight() / 1000f;
+ Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h);
+
+ MaskedImage mi = convertToRGB(ImageIO.read(is));
+ BufferedImage ri = mi.getImage();
+ ImageEncoder encoder = ImageEncodingHelper.createRenderedImageEncoder(ri);
+ Dimension imgDim = new Dimension(ri.getWidth(), ri.getHeight());
+ String imgDescription = ri.getClass().getName();
+ ImageEncodingHelper helper = new ImageEncodingHelper(ri);
+ ColorModel cm = helper.getEncodedColorModel();
+ PSImageUtils.writeImage(encoder, imgDim, imgDescription, targetRect, cm, gen, ri, mi.getMaskColor());
+ } else {
+ //Controls whether text painted by Batik is generated using text or path operations
+ boolean strokeText = false;
+ //TODO Configure text stroking
+
+ SVGUserAgent ua = new SVGUserAgent(context.getUserAgent(),
+ new FOPFontFamilyResolverImpl(psContext.getFontInfo()), new AffineTransform());
+
+ PSSVGGraphics2D graphics = new PSSVGGraphics2D(strokeText, gen);
+ graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
+
+ BridgeContext ctx = new PSBridgeContext(ua,
+ (strokeText ? null : psContext.getFontInfo()),
+ context.getUserAgent().getImageManager(),
+ context.getUserAgent().getImageSessionContext());
+
+ //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
+ //to it.
+ Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument());
+
+ GraphicsNode root;
+ try {
+ GVTBuilder builder = new GVTBuilder();
+ root = builder.build(ctx, clonedDoc);
+ } catch (Exception e) {
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgNotBuilt(this, e, image.getInfo().getOriginalURI());
+ return;
+ }
+ // get the 'width' and 'height' attributes of the SVG document
+ float w = (float)ctx.getDocumentSize().getWidth() * 1000f;
+ float h = (float)ctx.getDocumentSize().getHeight() * 1000f;
+
+ float sx = pos.width / w;
+ float sy = pos.height / h;
+
+ ctx = null;
+
+ gen.commentln("%FOPBeginSVG");
+ gen.saveGraphicsState();
+ final boolean clip = false;
+ if (clip) {
+ /*
+ * Clip to the svg area.
+ * Note: To have the svg overlay (under) a text area then use
+ * an fo:block-container
+ */
+ gen.writeln("newpath");
+ gen.defineRect(pos.getMinX() / 1000f, pos.getMinY() / 1000f,
+ pos.width / 1000f, pos.height / 1000f);
+ gen.writeln("clip");
+ }
+
+ // transform so that the coordinates (0,0) is from the top left
+ // and positive is down and to the right. (0,0) is where the
+ // viewBox puts it.
+ gen.concatMatrix(sx, 0, 0, sy, pos.getMinX() / 1000f, pos.getMinY() / 1000f);
+
+ AffineTransform transform = new AffineTransform();
+ // scale to viewbox
+ transform.translate(pos.getMinX(), pos.getMinY());
+ gen.getCurrentState().concatMatrix(transform);
+ try {
+ root.paint(graphics);
+ } catch (Exception e) {
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.svgRenderingError(this, e, image.getInfo().getOriginalURI());
+ }
+
+ gen.restoreGraphicsState();
+ gen.commentln("%FOPEndSVG");
+ }
+ }
+
+ private InputStream renderSVGToInputStream(RenderingContext context, ImageXMLDOM imageSVG) throws IOException {
+ PNGTranscoder png = new PNGTranscoder();
+ Float width = getDimension(imageSVG.getDocument(), "width") * 8;
+ png.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, width);
+ Float height = getDimension(imageSVG.getDocument(), "height") * 8;
+ png.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, height);
+ TranscoderInput input = new TranscoderInput(imageSVG.getDocument());
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ TranscoderOutput output = new TranscoderOutput(os);
try {
- GVTBuilder builder = new GVTBuilder();
- root = builder.build(ctx, clonedDoc);
- } catch (Exception e) {
+ png.transcode(input, output);
+ } catch (TranscoderException ex) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
context.getUserAgent().getEventBroadcaster());
- eventProducer.svgNotBuilt(this, e, image.getInfo().getOriginalURI());
- return;
+ eventProducer.svgRenderingError(this, ex, imageSVG.getInfo().getOriginalURI());
+ } finally {
+ os.flush();
+ os.close();
+ }
+ return new ByteArrayInputStream(os.toByteArray());
+ }
+
+ private MaskedImage convertToRGB(BufferedImage alphaImage) {
+ int[] red = new int[256];
+ int[] green = new int[256];
+ int[] blue = new int[256];
+ BufferedImage rgbImage = new BufferedImage(alphaImage.getWidth(),
+ alphaImage.getHeight(), BufferedImage.TYPE_INT_RGB);
+ //Count occurances of each colour in image
+ for (int cx = 0; cx < alphaImage.getWidth(); cx++) {
+ for (int cy = 0; cy < alphaImage.getHeight(); cy++) {
+ int pixelValue = alphaImage.getRGB(cx, cy);
+ Color pixelColor = new Color(pixelValue);
+ red[pixelColor.getRed()]++;
+ green[pixelColor.getGreen()]++;
+ blue[pixelColor.getBlue()]++;
+ }
+ }
+ //Find colour not in image
+ Color alphaSwap = null;
+ for (int i = 0; i < 256; i++) {
+ if (red[i] == 0) {
+ alphaSwap = new Color(i, 0, 0);
+ break;
+ } else if (green[i] == 0) {
+ alphaSwap = new Color(0, i, 0);
+ break;
+ } else if (blue[i] == 0) {
+ alphaSwap = new Color(0, 0, i);
+ break;
+ }
+ }
+ //Check if all variations are used in all three colours
+ if (alphaSwap == null) {
+ //Fallback colour is no unique colour channel can be found
+ alphaSwap = FALLBACK_COLOR;
+ }
+ //Replace alpha channel with the new mask colour
+ for (int cx = 0; cx < alphaImage.getWidth(); cx++) {
+ for (int cy = 0; cy < alphaImage.getHeight(); cy++) {
+ int pixelValue = alphaImage.getRGB(cx, cy);
+ if (pixelValue == 0) {
+ rgbImage.setRGB(cx, cy, alphaSwap.getRGB());
+ } else {
+ rgbImage.setRGB(cx, cy, alphaImage.getRGB(cx, cy));
+ }
+ }
+ }
+ return new MaskedImage(rgbImage, alphaSwap);
+ }
+
+ private static class MaskedImage {
+ private Color maskColor = new Color(0, 0, 0);
+ private BufferedImage image;
+
+ public MaskedImage(BufferedImage image, Color maskColor) {
+ this.image = image;
+ this.maskColor = maskColor;
+ }
+
+ public Color getMaskColor() {
+ return maskColor;
+ }
+
+ public BufferedImage getImage() {
+ return image;
+ }
+ }
+
+ private Float getDimension(Document document, String dimension) {
+ if (document.getFirstChild().getAttributes().getNamedItem(dimension) != null) {
+ String width = document.getFirstChild().getAttributes().getNamedItem(dimension).getNodeValue();
+ width = width.replaceAll("[^\\d.]", "");
+ return Float.parseFloat(width);
}
- // get the 'width' and 'height' attributes of the SVG document
- float w = (float)ctx.getDocumentSize().getWidth() * 1000f;
- float h = (float)ctx.getDocumentSize().getHeight() * 1000f;
-
- float sx = pos.width / w;
- float sy = pos.height / h;
-
- ctx = null;
-
- gen.commentln("%FOPBeginSVG");
- gen.saveGraphicsState();
- final boolean clip = false;
- if (clip) {
- /*
- * Clip to the svg area.
- * Note: To have the svg overlay (under) a text area then use
- * an fo:block-container
- */
- gen.writeln("newpath");
- gen.defineRect(pos.getMinX() / 1000f, pos.getMinY() / 1000f,
- pos.width / 1000f, pos.height / 1000f);
- gen.writeln("clip");
- }
-
- // transform so that the coordinates (0,0) is from the top left
- // and positive is down and to the right. (0,0) is where the
- // viewBox puts it.
- gen.concatMatrix(sx, 0, 0, sy, pos.getMinX() / 1000f, pos.getMinY() / 1000f);
-
- AffineTransform transform = new AffineTransform();
- // scale to viewbox
- transform.translate(pos.getMinX(), pos.getMinY());
- gen.getCurrentState().concatMatrix(transform);
+ return null;
+ }
+
+ private boolean shouldRaster(ImageXMLDOM image) {
+ //A list of objects on which to check opacity
try {
- root.paint(graphics);
- } catch (Exception e) {
- SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
- context.getUserAgent().getEventBroadcaster());
- eventProducer.svgRenderingError(this, e, image.getInfo().getOriginalURI());
+ List<String> gradMatches = new ArrayList<String>();
+ gradMatches.add("radialGradient");
+ gradMatches.add("linearGradient");
+ return recurseSVGElements(image.getDocument().getChildNodes(), gradMatches, false);
+ } finally {
+ gradientsFound.clear();
}
+ }
- gen.restoreGraphicsState();
- gen.commentln("%FOPEndSVG");
+ private boolean recurseSVGElements(NodeList childNodes, List<String> gradMatches, boolean isMatched) {
+ boolean opacityFound = false;
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node curNode = childNodes.item(i);
+ if (isMatched && curNode.getLocalName() != null && curNode.getLocalName().equals("stop")) {
+ if (curNode.getAttributes().getNamedItem("style") != null) {
+ String[] stylePairs = curNode.getAttributes().getNamedItem("style").getNodeValue()
+ .split(";");
+ for (int styleAtt = 0; styleAtt < stylePairs.length; styleAtt++) {
+ String[] style = stylePairs[styleAtt].split(":");
+ if (style[0].equalsIgnoreCase("stop-opacity")) {
+ if (Double.parseDouble(style[1]) < 1) {
+ return true;
+ }
+ }
+ }
+ }
+ if (curNode.getAttributes().getNamedItem("stop-opacity") != null) {
+ String opacityValue = curNode.getAttributes().getNamedItem("stop-opacity").getNodeValue();
+ if (Double.parseDouble(opacityValue) < 1) {
+ return true;
+ }
+ }
+ }
+ String nodeName = curNode.getLocalName();
+ //Special case where rasterization needed for radial gradients
+ if (nodeName != null && nodeName.equals("ellipse")) {
+ String found = "";
+ String ellipseFill = curNode.getAttributes().getNamedItem("fill").getNodeValue();
+ Pattern pattern = Pattern.compile("#(.*?)\\)");
+ Matcher matcher = pattern.matcher(ellipseFill);
+ if (matcher.find()) {
+ found = matcher.group(1);
+ }
+ if (gradientsFound.get(found) != null) {
+ return true;
+ }
+ }
+ boolean inMatch = false;
+ if (!isMatched) {
+ inMatch = nodeName != null && gradMatches.contains(nodeName);
+ if (inMatch) {
+ gradientsFound.put(curNode.getAttributes().getNamedItem("id").getNodeValue(), nodeName);
+ }
+ } else {
+ inMatch = true;
+ }
+ opacityFound = recurseSVGElements(curNode.getChildNodes(), gradMatches, inMatch);
+ if (opacityFound) {
+ return true;
+ }
+ }
+ return opacityFound;
}
/** {@inheritDoc} */
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/ps/PSPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/ps/PSPainter.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/ps/PSPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/ps/PSPainter.java Thu Jan 30 15:51:03 2014
@@ -40,6 +40,7 @@ import org.apache.xmlgraphics.image.load
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.xmlgraphics.ps.PSResource;
+import org.apache.fop.fonts.EmbeddingMode;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.fonts.LazyFont;
@@ -115,7 +116,7 @@ public class PSPainter extends AbstractI
}
/** {@inheritDoc} */
- public void startGroup(AffineTransform transform) throws IFException {
+ public void startGroup(AffineTransform transform, String layer) throws IFException {
try {
PSGenerator generator = getGenerator();
saveGraphicsState();
@@ -375,7 +376,13 @@ public class PSPainter extends AbstractI
}
Font font = getFontInfo().getFontInstance(triplet, sizeMillipoints);
- useFont(fontKey, sizeMillipoints);
+ PSFontResource res = getDocumentHandler().getPSResourceForFontKey(fontKey);
+ if (tf instanceof MultiByteFont && ((MultiByteFont)tf).isOTFFile()) {
+ generator.writeln("/" + res.getName() + ".0 "
+ + generator.formatDouble(sizeMillipoints / 1000f) + " F");
+ } else {
+ useFont(fontKey, sizeMillipoints);
+ }
if (dp != null && dp[0] != null) {
x += dp[0][0];
@@ -408,7 +415,30 @@ public class PSPainter extends AbstractI
}
}
} else {
- useFont(fontKey, sizeMillipoints);
+ if (tf instanceof MultiByteFont && ((MultiByteFont)tf).isOTFFile()) {
+ //Analyze string and split up in order to paint in different sub-fonts/encodings
+ int curEncoding = 0;
+ for (int i = start; i < textLen; i++) {
+ char orgChar = text.charAt(i);
+
+ MultiByteFont mbFont = (MultiByteFont)tf;
+ int origGlyphIdx = mbFont.findGlyphIndex(orgChar);
+ int newGlyphIdx = mbFont.getUsedGlyphs().get(origGlyphIdx);
+ int encoding = newGlyphIdx / 256;
+ if (encoding != curEncoding) {
+ if (i != 0) {
+ writeText(text, start, i - start, letterSpacing, wordSpacing, dp, font, tf,
+ true);
+ start = i;
+ }
+ generator.writeln("/" + res.getName() + "." + encoding + " "
+ + generator.formatDouble(sizeMillipoints / 1000f) + " F");
+ curEncoding = encoding;
+ }
+ }
+ } else {
+ useFont(fontKey, sizeMillipoints);
+ }
}
writeText(text, start, textLen - start, letterSpacing, wordSpacing, dp, font, tf,
tf instanceof MultiByteFont);
@@ -431,12 +461,14 @@ public class PSPainter extends AbstractI
int lineStart = 0;
StringBuffer accText = new StringBuffer(initialSize);
StringBuffer sb = new StringBuffer(initialSize);
+ boolean isOTF = multiByte && ((MultiByteFont)tf).isOTFFile();
for (int i = start; i < end; i++) {
char orgChar = text.charAt(i);
char ch;
int cw;
int xGlyphAdjust = 0;
int yGlyphAdjust = 0;
+
if (CharUtilities.isFixedWidthSpace(orgChar)) {
//Fixed width space are rendered as spaces so copy/paste works in a reader
ch = font.mapChar(CharUtilities.SPACE);
@@ -460,11 +492,16 @@ public class PSPainter extends AbstractI
xGlyphAdjust -= dp[i + 1][0];
yGlyphAdjust += dp[i + 1][1];
}
- if (multiByte) {
- accText.append(HexEncoder.encode(ch));
- } else {
+ if (!multiByte || isOTF) {
char codepoint = (char)(ch % 256);
- PSGenerator.escapeChar(codepoint, accText); //add character to accumulated text
+ if (isOTF) {
+ codepoint -= (((MultiByteFont)tf).getEmbeddingMode() == EmbeddingMode.FULL) ? 0 : 1;
+ accText.append(HexEncoder.encode(codepoint, 2));
+ } else {
+ PSGenerator.escapeChar(codepoint, accText); //add character to accumulated text
+ }
+ } else {
+ accText.append(HexEncoder.encode(ch));
}
if (xGlyphAdjust != 0 || yGlyphAdjust != 0) {
needTJ = true;
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/rtf/RTFHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/rtf/RTFHandler.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/rtf/RTFHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/rtf/RTFHandler.java Thu Jan 30 15:51:03 2014
@@ -157,6 +157,7 @@ public class RTFHandler extends FOEventH
private PercentContext percentManager = new PercentContext();
+
/**
* Creates a new RTF structure handler.
* @param userAgent the FOUserAgent for this process
@@ -270,7 +271,7 @@ public class RTFHandler extends FOEventH
return;
} else {
- builderContext.popContainer();
+ builderContext.popContainer(RtfSection.class, this);
this.pagemaster = null;
}
}
@@ -377,10 +378,10 @@ public class RTFHandler extends FOEventH
//just do nothing
} else if (regionBefore != null
&& fl.getFlowName().equals(regionBefore.getRegionName())) {
- builderContext.popContainer();
+ builderContext.popContainer(RtfBefore.class, this);
} else if (regionAfter != null
&& fl.getFlowName().equals(regionAfter.getRegionName())) {
- builderContext.popContainer();
+ builderContext.popContainer(RtfAfter.class, this);
}
} catch (Exception e) {
log.error("endFlow: " + e.getMessage());
@@ -571,7 +572,7 @@ public class RTFHandler extends FOEventH
nestedTableDepth--;
builderContext.popTableContext();
- builderContext.popContainer();
+ builderContext.popContainer(RtfTable.class, this);
}
/** {@inheritDoc} */
@@ -605,21 +606,25 @@ public class RTFHandler extends FOEventH
/** {@inheritDoc} */
public void startHeader(TableHeader header) {
+ builderContext.pushPart(header);
startPart(header);
}
/** {@inheritDoc} */
public void endHeader(TableHeader header) {
+ builderContext.popPart(header.getClass(), this);
endPart(header);
}
/** {@inheritDoc} */
public void startFooter(TableFooter footer) {
+ builderContext.pushPart(footer);
startPart(footer);
}
/** {@inheritDoc} */
public void endFooter(TableFooter footer) {
+ builderContext.popPart(footer.getClass(), this);
endPart(footer);
}
@@ -711,11 +716,13 @@ public class RTFHandler extends FOEventH
* {@inheritDoc}
*/
public void startBody(TableBody body) {
+ builderContext.pushPart(body);
startPart(body);
}
/** {@inheritDoc} */
public void endBody(TableBody body) {
+ builderContext.popPart(TableBody.class, this);
endPart(body);
}
@@ -784,7 +791,7 @@ public class RTFHandler extends FOEventH
}
- builderContext.popContainer();
+ builderContext.popContainer(RtfTableRow.class, this);
builderContext.getTableContext().decreaseRowSpannings();
}
@@ -893,7 +900,7 @@ public class RTFHandler extends FOEventH
throw new RuntimeException(e.getMessage());
}
- builderContext.popContainer();
+ builderContext.popContainer(RtfTableCell.class, this);
builderContext.getTableContext().selectNextColumn();
}
@@ -929,7 +936,7 @@ public class RTFHandler extends FOEventH
return;
}
- builderContext.popContainer();
+ builderContext.popContainer(RtfList.class, this);
}
/** {@inheritDoc} */
@@ -976,7 +983,7 @@ public class RTFHandler extends FOEventH
return;
}
- builderContext.popContainer();
+ builderContext.popContainer(RtfListItem.class, this);
}
/** {@inheritDoc} */
@@ -1005,7 +1012,7 @@ public class RTFHandler extends FOEventH
return;
}
- builderContext.popContainer();
+ builderContext.popContainer(RtfListItemLabel.class, this);
}
/** {@inheritDoc} */
@@ -1070,7 +1077,7 @@ public class RTFHandler extends FOEventH
return;
}
- builderContext.popContainer();
+ builderContext.popContainer(RtfHyperLink.class, this);
}
/** {@inheritDoc} */
@@ -1306,7 +1313,7 @@ public class RTFHandler extends FOEventH
return;
}
- builderContext.popContainer();
+ builderContext.popContainer(RtfFootnote.class, this);
}
/** {@inheritDoc} */
@@ -1688,6 +1695,19 @@ public class RTFHandler extends FOEventH
}
/**
+ * Closes any mismatched tags that are detected in the RTF structure.
+ * @param containerClass The class representing the tag to close.
+ * @return Determines whether the tag mismatch has been handled.
+ */
+ public boolean endContainer(Class containerClass) {
+ if (containerClass == RtfTableRow.class) {
+ endRow(null);
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Calls the event handlers for the passed FONode and all its elements.
*
* @param foNode FONode object which shall be recursed
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java Thu Jan 30 15:51:03 2014
@@ -21,6 +21,12 @@ package org.apache.fop.render.rtf.rtflib
import java.util.Stack;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.fo.FObj;
+import org.apache.fop.render.rtf.RTFHandler;
+import org.apache.fop.render.rtf.RTFPlaceHolderHelper;
import org.apache.fop.render.rtf.rtflib.exceptions.RtfException;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfOptions;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer;
@@ -38,6 +44,10 @@ import org.apache.fop.render.rtf.rtflib.
*/
public class BuilderContext {
+
+ /** Static logging instance */
+ protected static final Log LOG = LogFactory.getLog(BuilderContext.class.getName());
+
/** stack of RtfContainers */
private final Stack containers = new Stack();
@@ -96,17 +106,22 @@ public class BuilderContext {
* @throws RtfException if not caught
*/
public RtfContainer getContainer(Class containerClass, boolean required,
- Object /*IBuilder*/ forWhichBuilder) throws RtfException {
+ Object forWhichBuilder) throws RtfException {
// TODO what to do if the desired container is not at the top of the stack?
// close top-of-stack container?
- final RtfContainer result = (RtfContainer)getObjectFromStack(containers,
+ RtfContainer result = (RtfContainer)getObjectFromStack(containers,
containerClass);
if (result == null && required) {
- throw new RtfException(
- "No RtfContainer of class '" + containerClass.getName()
- + "' available for '" + forWhichBuilder.getClass().getName() + "' builder"
- );
+ RTFPlaceHolderHelper placeHolderHelper = new RTFPlaceHolderHelper(this);
+ placeHolderHelper.createRTFPlaceholder(containerClass);
+ result = getContainer(containerClass, required, forWhichBuilder);
+ if (result == null) {
+ throw new RtfException(
+ "No RtfContainer of class '" + containerClass.getName()
+ + "' available for '" + forWhichBuilder.getClass().getName() + "' builder"
+ );
+ }
}
return result;
@@ -121,6 +136,14 @@ public class BuilderContext {
}
/**
+ * Push a Class representing a non-writeable section of the FO tree
+ * @param part the part
+ */
+ public void pushPart(FObj part) {
+ containers.push(part);
+ }
+
+ /**
* In some cases an RtfContainer must be replaced by another one on the
* stack. This happens when handling nested fo:blocks for example: after
* handling a nested block the enclosing block must switch to a new
@@ -142,8 +165,40 @@ public class BuilderContext {
}
/** pop the topmost RtfContainer from our stack */
- public void popContainer() {
- containers.pop();
+ public void popContainer(Class containerClass, RTFHandler handler) {
+ handlePop(containerClass, handler);
+ }
+
+ /** pop the topmost part class from our stack */
+ public void popPart(Class part, RTFHandler handler) {
+ handlePop(part, handler);
+ }
+
+ /**
+ * This method checks for any tag mismatches between what is being closed
+ * and what exists on the stack. If a mismatch is found, then it will push
+ * the object back onto the stack and attempt to close the given section
+ * before retrying with the current pop task.
+ * @param aClass The class to be popped from the stack
+ * @param handler The RTF handler class to fix any mismatches
+ */
+ private void handlePop(Class aClass, RTFHandler handler) {
+ Object object = containers.pop();
+ if (object.getClass() != aClass) {
+ pushAndClose(aClass, object, handler);
+ }
+ }
+
+ private void pushAndClose(Class aClass, Object object, RTFHandler handler) {
+ containers.push(object);
+ if (handler.endContainer(object.getClass())) {
+ popContainer(aClass, handler);
+ } else {
+ /* This should never happen unless a placeholder is not catered for
+ * in the RTFHandler.endContainer method. */
+ LOG.warn("Unhandled RTF structure tag mismatch detected between "
+ + aClass.getSimpleName() + " and " + object.getClass().getSimpleName());
+ }
}
/* push an IBuilder to our stack /
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/txt/TXTRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/txt/TXTRenderer.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/txt/TXTRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/txt/TXTRenderer.java Thu Jan 30 15:51:03 2014
@@ -583,6 +583,14 @@ public class TXTRenderer extends Abstrac
}
/** {@inheritDoc} */
+ protected void startLayer(String layer) {
+ }
+
+ /** {@inheritDoc} */
+ protected void endLayer() {
+ }
+
+ /** {@inheritDoc} */
protected void concatenateTransformationMatrix(AffineTransform at) {
currentState.push(new CTM(UnitConv.ptToMpt(at)));
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/render/xml/XMLRenderer.java Thu Jan 30 15:51:03 2014
@@ -545,6 +545,16 @@ public class XMLRenderer extends Abstrac
//only necessary for graphical output
}
+ /** {@inheritDoc} */
+ protected void startLayer(String layer) {
+ //only necessary for graphical output
+ }
+
+ /** {@inheritDoc} */
+ protected void endLayer() {
+ //only necessary for graphical output
+ }
+
/**
* {@inheritDoc}
* org.apache.fop.area.inline.InlineArea)
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java Thu Jan 30 15:51:03 2014
@@ -278,7 +278,6 @@ public class PDFDocumentGraphics2D exten
PDFStream pdfStream = this.pdfDoc.getFactory().makeStream(
PDFFilterList.CONTENT_FILTER, false);
pdfStream.add(getString());
- currentStream = null;
this.pdfDoc.registerObject(pdfStream);
pdfContext.getCurrentPage().setContents(pdfStream);
PDFAnnotList annots = pdfContext.getCurrentPage().getAnnotations();
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Thu Jan 30 15:51:03 2014
@@ -88,7 +88,8 @@ public class PDFDocumentGraphics2DConfig
final boolean strict = false;
if (cfg != null) {
URI thisUri = new File(".").getAbsoluteFile().toURI();
- InternalResourceResolver resourceResolver = ResourceResolverFactory.createDefaultInternalResourceResolver(thisUri);
+ InternalResourceResolver resourceResolver
+ = ResourceResolverFactory.createDefaultInternalResourceResolver(thisUri);
//TODO The following could be optimized by retaining the FontManager somewhere
FontManager fontManager = new FontManager(resourceResolver, FontDetectorFactory.createDefault(),
FontCacheManagerFactory.createDefault());
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/PDFGraphics2D.java Thu Jan 30 15:51:03 2014
@@ -80,6 +80,7 @@ import org.apache.fop.pdf.PDFColorHandle
import org.apache.fop.pdf.PDFConformanceException;
import org.apache.fop.pdf.PDFDeviceColorSpace;
import org.apache.fop.pdf.PDFDocument;
+import org.apache.fop.pdf.PDFFunction;
import org.apache.fop.pdf.PDFGState;
import org.apache.fop.pdf.PDFImage;
import org.apache.fop.pdf.PDFImageXObject;
@@ -89,11 +90,18 @@ import org.apache.fop.pdf.PDFPaintingSta
import org.apache.fop.pdf.PDFPattern;
import org.apache.fop.pdf.PDFResourceContext;
import org.apache.fop.pdf.PDFResources;
+import org.apache.fop.pdf.PDFShading;
import org.apache.fop.pdf.PDFText;
import org.apache.fop.pdf.PDFXObject;
import org.apache.fop.render.pdf.ImageRawCCITTFaxAdapter;
import org.apache.fop.render.pdf.ImageRawJPEGAdapter;
import org.apache.fop.render.pdf.ImageRenderedAdapter;
+import org.apache.fop.render.shading.Function;
+import org.apache.fop.render.shading.GradientFactory;
+import org.apache.fop.render.shading.GradientRegistrar;
+import org.apache.fop.render.shading.PDFGradientFactory;
+import org.apache.fop.render.shading.Pattern;
+import org.apache.fop.render.shading.Shading;
/**
* <p>PDF Graphics 2D.
@@ -104,7 +112,7 @@ import org.apache.fop.render.pdf.ImageRe
*
* @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D
*/
-public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHandler {
+public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHandler, GradientRegistrar {
private static final AffineTransform IDENTITY_TRANSFORM = new AffineTransform();
/** The number of decimal places. */
@@ -868,11 +876,10 @@ public class PDFGraphics2D extends Abstr
}
//Gradients are currently restricted to sRGB
- PDFDeviceColorSpace aColorSpace;
- aColorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
- PDFPattern myPat = pdfDoc.getFactory().makeGradient(
- resourceContext, false, aColorSpace,
- someColors, theBounds, theCoords, theMatrix);
+ PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
+ PDFGradientFactory gradientFactory = (PDFGradientFactory)GradientFactory.newInstance(this);
+ PDFPattern myPat = gradientFactory.createGradient(false, colSpace, someColors, theBounds,
+ theCoords, theMatrix);
currentStream.write(myPat.getColorSpaceOut(fill));
return true;
@@ -944,13 +951,10 @@ public class PDFGraphics2D extends Abstr
float offset = fractions[count];
theBounds.add(new Double(offset));
}
- PDFDeviceColorSpace colSpace;
- colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
-
- PDFPattern myPat = pdfDoc.getFactory().makeGradient(
- resourceContext, true, colSpace,
- someColors, theBounds, theCoords, theMatrix);
-
+ PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
+ PDFGradientFactory gradientFactory = (PDFGradientFactory) GradientFactory.newInstance(this);
+ PDFPattern myPat = gradientFactory.createGradient(true, colSpace, someColors, theBounds,
+ theCoords, theMatrix);
currentStream.write(myPat.getColorSpaceOut(fill));
return true;
@@ -1691,11 +1695,15 @@ public class PDFGraphics2D extends Abstr
* @param iter PathIterator to process
*/
public void processPathIterator(PathIterator iter) {
+ double lastX = 0.0;
+ double lastY = 0.0;
while (!iter.isDone()) {
double[] vals = new double[6];
int type = iter.currentSegment(vals);
switch (type) {
case PathIterator.SEG_CUBICTO:
+ lastX = vals[4];
+ lastY = vals[5];
currentStream.write(PDFNumber.doubleOut(vals[0], DEC) + " "
+ PDFNumber.doubleOut(vals[1], DEC) + " "
+ PDFNumber.doubleOut(vals[2], DEC) + " "
@@ -1704,18 +1712,30 @@ public class PDFGraphics2D extends Abstr
+ PDFNumber.doubleOut(vals[5], DEC) + " c\n");
break;
case PathIterator.SEG_LINETO:
+ lastX = vals[0];
+ lastY = vals[1];
currentStream.write(PDFNumber.doubleOut(vals[0], DEC) + " "
+ PDFNumber.doubleOut(vals[1], DEC) + " l\n");
break;
case PathIterator.SEG_MOVETO:
+ lastX = vals[0];
+ lastY = vals[1];
currentStream.write(PDFNumber.doubleOut(vals[0], DEC) + " "
+ PDFNumber.doubleOut(vals[1], DEC) + " m\n");
break;
case PathIterator.SEG_QUADTO:
- currentStream.write(PDFNumber.doubleOut(vals[0], DEC) + " "
- + PDFNumber.doubleOut(vals[1], DEC) + " "
- + PDFNumber.doubleOut(vals[2], DEC) + " "
- + PDFNumber.doubleOut(vals[3], DEC) + " y\n");
+ double controlPointAX = lastX + ((2.0 / 3.0) * (vals[0] - lastX));
+ double controlPointAY = lastY + ((2.0 / 3.0) * (vals[1] - lastY));
+ double controlPointBX = vals[2] + ((2.0 / 3.0) * (vals[0] - vals[2]));
+ double controlPointBY = vals[3] + ((2.0 / 3.0) * (vals[1] - vals[3]));
+ currentStream.write(PDFNumber.doubleOut(controlPointAX, DEC) + " "
+ + PDFNumber.doubleOut(controlPointAY, DEC) + " "
+ + PDFNumber.doubleOut(controlPointBX, DEC) + " "
+ + PDFNumber.doubleOut(controlPointBY, DEC) + " "
+ + PDFNumber.doubleOut(vals[2], DEC) + " "
+ + PDFNumber.doubleOut(vals[3], DEC) + " c\n");
+ lastX = vals[2];
+ lastY = vals[3];
break;
case PathIterator.SEG_CLOSE:
currentStream.write("h\n");
@@ -1840,4 +1860,36 @@ public class PDFGraphics2D extends Abstr
//NYI
}
+ /**
+ * Registers a function object against the output format document
+ * @param function The function object to register
+ * @return Returns either the function which has already been registered
+ * or the current new registered object.
+ */
+ public Function registerFunction(Function function) {
+ return pdfDoc.getFactory().registerFunction((PDFFunction)function);
+ }
+
+ /**
+ * Registers a shading object against the otuput format document
+ * @param shading The shading object to register
+ * @return Returs either the shading which has already been registered
+ * or the current new registered object
+ */
+ public Shading registerShading(Shading shading) {
+ assert shading instanceof PDFShading;
+ return pdfDoc.getFactory().registerShading(resourceContext, (PDFShading)shading);
+ }
+
+ /**
+ * Registers a pattern object against the output format document
+ * @param pattern The pattern object to register
+ * @return Returns either the pattern which has already been registered
+ * or the current new registered object
+ */
+ public Pattern registerPattern(Pattern pattern) {
+ assert pattern instanceof PDFPattern;
+ return pdfDoc.getFactory().registerPattern(resourceContext, (PDFPattern)pattern);
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java Thu Jan 30 15:51:03 2014
@@ -23,8 +23,11 @@ import java.awt.Dimension;
import java.awt.geom.AffineTransform;
import java.awt.geom.Dimension2D;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.SAXException;
+
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.gvt.font.FontFamilyResolver;
@@ -84,17 +87,28 @@ public class SimpleSVGUserAgent extends
return null; // userStyleSheetURI;
}
+
+ private static final String XML_PARSER_CLASS_NAME;
+
+ static {
+ String result;
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ result = factory.newSAXParser().getXMLReader().getClass().getName();
+ } catch (SAXException e) {
+ result = null;
+ } catch (ParserConfigurationException e) {
+ result = null;
+ }
+ XML_PARSER_CLASS_NAME = result;
+ }
+
/**
* Returns the class name of the XML parser.
* @return the XML parser class name
*/
public String getXMLParserClassName() {
- try {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- return factory.newSAXParser().getXMLReader().getClass().getName();
- } catch (Exception e) {
- return null;
- }
+ return XML_PARSER_CLASS_NAME;
}
/**
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java Thu Jan 30 15:51:03 2014
@@ -29,7 +29,6 @@ package org.apache.fop.text.linebreak;
* - commit BOTH changed files
*/
-// CSOFF: WhitespaceAfterCheck
// CSOFF: LineLengthCheck
/** Line breaking utilities. */
@@ -694,11 +693,11 @@ public final class LineBreakUtils {
"CP", "CR", "EX", "GL", "H2", "H3", "HY", "ID", "IN", "IS", "JL", "JT", "JV", "LF", "NL", "NS", "NU", "OP",
"PO", "PR", "QU", "SA", "SG", "SP", "SY", "WJ", "XX", "ZW"};
- private static String[] lineBreakPropertyLongNames = {"Ambiguous","Alphabetic","Break_Both","Break_After","Break_Before",
- "Mandatory_Break","Contingent_Break","Close_Punctuation","Combining_Mark","Close_Parenthesis","Carriage_Return",
- "Exclamation","Glue","H2","H3","Hyphen","Ideographic","Inseparable","Infix_Numeric","JL","JT","JV","Line_Feed",
- "Next_Line","Nonstarter","Numeric","Open_Punctuation","Postfix_Numeric","Prefix_Numeric","Quotation","Complex_Context",
- "Surrogate","Space","Break_Symbols","Word_Joiner","Unknown","ZWSpace"};
+ private static String[] lineBreakPropertyLongNames = {"Ambiguous", "Alphabetic", "Break_Both", "Break_After", "Break_Before",
+ "Mandatory_Break", "Contingent_Break", "Close_Punctuation", "Combining_Mark", "Close_Parenthesis", "Carriage_Return",
+ "Exclamation", "Glue", "H2", "H3", "Hyphen", "Ideographic", "Inseparable", "Infix_Numeric", "JL", "JT", "JV", "Line_Feed",
+ "Next_Line", "Nonstarter", "Numeric", "Open_Punctuation", "Postfix_Numeric", "Prefix_Numeric", "Quotation", "Complex_Context",
+ "Surrogate", "Space", "Break_Symbols", "Word_Joiner", "Unknown", "ZWSpace"};
/**
* Return the short name for the linebreak property corresponding
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/tools/fontlist/FontListMain.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/tools/fontlist/FontListMain.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/tools/fontlist/FontListMain.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/tools/fontlist/FontListMain.java Thu Jan 30 15:51:03 2014
@@ -117,7 +117,7 @@ public final class FontListMain {
}
try {
GenerationHelperContentHandler helper = new GenerationHelperContentHandler(
- handler, null);
+ handler, null, null);
FontListSerializer serializer = new FontListSerializer();
serializer.generateSAX(fontFamilies, singleFamily, helper);
} finally {
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingMode.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingMode.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingMode.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingMode.java Thu Jan 30 15:51:03 2014
@@ -54,8 +54,9 @@ public final class WritingMode extends T
* Assign writing mode traits from this trait to the specified
* writing mode traits setter.
* @param wms a writing mode traits setter
+ * @param explicit true if writing mode property explicitly specified
*/
- public void assignWritingModeTraits(WritingModeTraitsSetter wms) {
+ public void assignWritingModeTraits(WritingModeTraitsSetter wms, boolean explicit) {
Direction inlineProgressionDirection;
Direction blockProgressionDirection;
Direction columnProgressionDirection;
@@ -97,7 +98,7 @@ public final class WritingMode extends T
wms.setColumnProgressionDirection(columnProgressionDirection);
wms.setRowProgressionDirection(rowProgressionDirection);
wms.setShiftDirection(shiftDirection);
- wms.setWritingMode(this);
+ wms.setWritingMode(this, explicit);
}
/**
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraits.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraits.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraits.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraits.java Thu Jan 30 15:51:03 2014
@@ -31,20 +31,21 @@ public class WritingModeTraits implement
private Direction rowProgressionDirection;
private Direction shiftDirection;
private WritingMode writingMode;
+ private boolean explicit;
/**
* Default writing mode traits constructor.
*/
public WritingModeTraits() {
- this (WritingMode.LR_TB);
+ this (WritingMode.LR_TB, false);
}
/**
* Construct writing mode traits using the specified writing mode.
* @param writingMode a writing mode traits object
*/
- public WritingModeTraits(WritingMode writingMode) {
- assignWritingModeTraits(writingMode);
+ public WritingModeTraits(WritingMode writingMode, boolean explicit) {
+ assignWritingModeTraits(writingMode, explicit);
}
/**
@@ -125,17 +126,25 @@ public class WritingModeTraits implement
}
/**
+ * @return the "explicit-writing-mode" trait.
+ */
+ public boolean getExplicitWritingMode() {
+ return explicit;
+ }
+
+ /**
* @param writingMode the "writing-mode" trait.
*/
- public void setWritingMode(WritingMode writingMode) {
+ public void setWritingMode(WritingMode writingMode, boolean explicit) {
this.writingMode = writingMode;
+ this.explicit = explicit;
}
/**
* @param writingMode the "writing-mode" trait.
*/
- public void assignWritingModeTraits(WritingMode writingMode) {
- writingMode.assignWritingModeTraits(this);
+ public void assignWritingModeTraits(WritingMode writingMode, boolean explicit) {
+ writingMode.assignWritingModeTraits(this, explicit);
}
/**
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraitsGetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraitsGetter.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraitsGetter.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraitsGetter.java Thu Jan 30 15:51:03 2014
@@ -55,4 +55,9 @@ public interface WritingModeTraitsGetter
*/
WritingMode getWritingMode();
+ /**
+ * @return the "explicit-writing-mode" trait
+ */
+ boolean getExplicitWritingMode();
+
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraitsSetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraitsSetter.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraitsSetter.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/traits/WritingModeTraitsSetter.java Thu Jan 30 15:51:03 2014
@@ -58,13 +58,14 @@ public interface WritingModeTraitsSetter
* Set value of writing-mode trait.
* @param writingMode the "writing-mode" trait
*/
- void setWritingMode(WritingMode writingMode);
+ void setWritingMode(WritingMode writingMode, boolean explicit);
/**
* Collectivelly assign values to all writing mode traits based upon a specific
* writing mode.
* @param writingMode the "writing-mode" trait
+ * @param explicit true if writing mode explicitly specified
*/
- void assignWritingModeTraits(WritingMode writingMode);
+ void assignWritingModeTraits(WritingMode writingMode, boolean explicit);
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/AbstractPaintingState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/AbstractPaintingState.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/AbstractPaintingState.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/AbstractPaintingState.java Thu Jan 30 15:51:03 2014
@@ -24,7 +24,6 @@ import java.awt.geom.AffineTransform;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Stack;
@@ -36,10 +35,10 @@ public abstract class AbstractPaintingSt
private static final long serialVersionUID = 5998356138437094188L;
/** current state data */
- private AbstractData data = null;
+ private AbstractData data;
/** the state stack */
- private StateStack/*<AbstractData>*/ stateStack = new StateStack/*<AbstractData>*/();
+ private StateStack<AbstractData> stateStack = new StateStack<AbstractData>();
/**
* Instantiates a new state data object
@@ -216,8 +215,7 @@ public abstract class AbstractPaintingSt
*/
public AffineTransform getTransform() {
AffineTransform at = new AffineTransform();
- for (Iterator iter = stateStack.iterator(); iter.hasNext();) {
- AbstractData data = (AbstractData)iter.next();
+ for (AbstractData data : stateStack) {
AffineTransform stackTrans = data.getTransform();
at.concatenate(stackTrans);
}
@@ -249,7 +247,7 @@ public abstract class AbstractPaintingSt
if (stateStack.isEmpty()) {
return null;
} else {
- AbstractData baseData = (AbstractData)stateStack.get(0);
+ AbstractData baseData = stateStack.get(0);
return (AffineTransform) baseData.getTransform().clone();
}
}
@@ -297,7 +295,7 @@ public abstract class AbstractPaintingSt
*/
public AbstractData restore() {
if (!stateStack.isEmpty()) {
- setData((AbstractData)stateStack.pop());
+ setData(stateStack.pop());
return this.data;
} else {
return null;
@@ -310,12 +308,11 @@ public abstract class AbstractPaintingSt
*
* @param dataList a state data list
*/
- public void saveAll(List/*<AbstractData>*/ dataList) {
- Iterator it = dataList.iterator();
- while (it.hasNext()) {
+ public void saveAll(List<AbstractData> dataList) {
+ for (AbstractData data : dataList) {
// save current data on stack
save();
- setData((AbstractData)it.next());
+ setData(data);
}
}
@@ -325,8 +322,8 @@ public abstract class AbstractPaintingSt
*
* @return a list of state data popped from the stack
*/
- public List/*<AbstractData>*/ restoreAll() {
- List/*<AbstractData>*/ dataList = new java.util.ArrayList/*<AbstractData>*/();
+ public List<AbstractData> restoreAll() {
+ List<AbstractData> dataList = new java.util.ArrayList<AbstractData>();
AbstractData data;
while (true) {
data = getData();
@@ -361,7 +358,7 @@ public abstract class AbstractPaintingSt
*
* @return the state stack
*/
- protected Stack/*<AbstractData>*/ getStateStack() {
+ protected Stack<AbstractData> getStateStack() {
return this.stateStack;
}
@@ -369,8 +366,10 @@ public abstract class AbstractPaintingSt
@Override
public Object clone() {
AbstractPaintingState state = instantiate();
- state.stateStack = new StateStack(this.stateStack);
- state.data = (AbstractData)this.data.clone();
+ state.stateStack = new StateStack<AbstractData>(this.stateStack);
+ if (this.data != null) {
+ state.data = (AbstractData)this.data.clone();
+ }
return state;
}
@@ -385,7 +384,7 @@ public abstract class AbstractPaintingSt
/**
* A stack implementation which holds state objects
*/
- public class StateStack extends java.util.Stack {
+ public class StateStack<E> extends java.util.Stack<E> {
private static final long serialVersionUID = 4897178211223823041L;
@@ -393,7 +392,6 @@ public abstract class AbstractPaintingSt
* Default constructor
*/
public StateStack() {
- super();
}
/**
@@ -419,25 +417,28 @@ public abstract class AbstractPaintingSt
private static final long serialVersionUID = 5208418041189828624L;
/** The current color */
- protected Color color = null;
+ protected Color color;
/** The current background color */
- protected Color backColor = null;
+ protected Color backColor;
/** The current font name */
- protected String fontName = null;
+ protected String fontName;
/** The current font size */
- protected int fontSize = 0;
+ protected int fontSize;
/** The current line width */
- protected float lineWidth = 0;
+ protected float lineWidth;
/** The dash array for the current basic stroke (line type) */
- protected float[] dashArray = null;
+ protected float[] dashArray;
/** The current transform */
- protected AffineTransform transform = null;
+ protected AffineTransform transform;
+
+ /** The current (optional content group) layer. */
+ protected String layer;
/**
* Returns a newly create data object
@@ -485,6 +486,18 @@ public abstract class AbstractPaintingSt
transform = new AffineTransform();
}
+ public void setLayer(String layer) {
+ if (layer != null) {
+ this.layer = layer;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public String getLayer() {
+ return this.layer;
+ }
+
/**
* Returns the derived rotation from the current transform
*
@@ -523,6 +536,7 @@ public abstract class AbstractPaintingSt
this.transform = new AffineTransform();
}
data.transform = new AffineTransform(this.transform);
+ data.layer = this.layer;
return data;
}
@@ -535,7 +549,8 @@ public abstract class AbstractPaintingSt
+ ", fontSize=" + fontSize
+ ", lineWidth=" + lineWidth
+ ", dashArray=" + dashArray
- + ", transform=" + transform;
+ + ", transform=" + transform
+ + ", layer=" + layer;
}
}
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/GenerationHelperContentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/GenerationHelperContentHandler.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/GenerationHelperContentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/GenerationHelperContentHandler.java Thu Jan 30 15:51:03 2014
@@ -35,6 +35,7 @@ public class GenerationHelperContentHand
private static final Attributes EMPTY_ATTS = new AttributesImpl();
private String mainNamespace;
+ private Object contentHandlerContext;
/**
* Main constructor. If the given handler also implements any of the EntityResolver,
@@ -42,10 +43,12 @@ public class GenerationHelperContentHand
* @param handler the SAX content handler to delegate all calls to
* @param mainNamespace the main namespace used for generated XML content when abbreviated
* ContentHandler calls are used.
+ * @param contentHandlerContext additional content handler context state
*/
- public GenerationHelperContentHandler(ContentHandler handler, String mainNamespace) {
+ public GenerationHelperContentHandler(ContentHandler handler, String mainNamespace, Object contentHandlerContext) {
super(handler);
this.mainNamespace = mainNamespace;
+ this.contentHandlerContext = contentHandlerContext;
}
/**
@@ -66,6 +69,14 @@ public class GenerationHelperContentHand
}
/**
+ * Returns the context object (may be null).
+ * @return the context object
+ */
+ public Object getContentHandlerContext() {
+ return this.contentHandlerContext;
+ }
+
+ /**
* Convenience method to generate a startElement SAX event.
* @param localName the local name of the element
* @param atts the attributes
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/XMLUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/XMLUtil.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/XMLUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/java/org/apache/fop/util/XMLUtil.java Thu Jan 30 15:51:03 2014
@@ -300,4 +300,35 @@ public final class XMLUtil implements XM
}
}
+ /**
+ * Escape '<', '>' and '&' using NCRs.
+ * @param unescaped string
+ * @return escaped string
+ */
+ public static String escape(String unescaped) {
+ int needsEscape = 0;
+ for (int i = 0, n = unescaped.length(); i < n; ++i) {
+ char c = unescaped.charAt(i);
+ if ((c == '<') || (c == '>') || (c == '&')) {
+ ++needsEscape;
+ }
+ }
+ if (needsEscape > 0) {
+ StringBuffer sb = new StringBuffer(unescaped.length() + 6 * needsEscape);
+ for (int i = 0, n = unescaped.length(); i < n; ++i) {
+ char c = unescaped.charAt(i);
+ if ((c == '<') || (c == '>') || (c == '&')) {
+ sb.append("&#x");
+ sb.append(Integer.toString(c, 16));
+ sb.append(';');
+ } else {
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ } else {
+ return unescaped;
+ }
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java Thu Jan 30 15:51:03 2014
@@ -229,7 +229,7 @@ public class SVGDocumentHandler extends
}
private GenerationHelperContentHandler decorate(ContentHandler contentHandler) {
- return new GenerationHelperContentHandler(contentHandler, getMainNamespace());
+ return new GenerationHelperContentHandler(contentHandler, getMainNamespace(), getContext());
}
private void closeCurrentStream() {
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/sandbox/org/apache/fop/render/svg/SVGPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/sandbox/org/apache/fop/render/svg/SVGPainter.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/sandbox/org/apache/fop/render/svg/SVGPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/src/sandbox/org/apache/fop/render/svg/SVGPainter.java Thu Jan 30 15:51:03 2014
@@ -146,16 +146,16 @@ public class SVGPainter extends Abstract
}
/** {@inheritDoc} */
- public void startGroup(AffineTransform[] transforms) throws IFException {
- startGroup(SVGUtil.formatAffineTransformsMptToPt(transforms));
+ public void startGroup(AffineTransform[] transforms, String layer) throws IFException {
+ startGroup(SVGUtil.formatAffineTransformsMptToPt(transforms), layer);
}
/** {@inheritDoc} */
- public void startGroup(AffineTransform transform) throws IFException {
- startGroup(SVGUtil.formatAffineTransformMptToPt(transform));
+ public void startGroup(AffineTransform transform, String layer) throws IFException {
+ startGroup(SVGUtil.formatAffineTransformMptToPt(transform), layer);
}
- private void startGroup(String transform) throws IFException {
+ private void startGroup(String transform, String layer) throws IFException {
try {
AttributesImpl atts = new AttributesImpl();
if (transform != null && transform.length() > 0) {
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/status.xml?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/status.xml Thu Jan 30 15:51:03 2014
@@ -58,7 +58,19 @@
users, i.e. when the behaviour changes and could affect the layout of existing
documents. Example: the fix of marks layering will be such a case when it's done.
-->
- <release version="FOP Trunk" date="TBD">
+ <release version="FOP Trunk" date="01 November 2013">
+ <action context="Code" dev="GA" type="fix" fixes-bug="FOP-2311">
+ Eliminate regression to shorthand properties from Bugzilla 37114 (FOP-1069).
+ </action>
+ <action context="Renderers" dev="GA" type="add" fixes-bug="FOP-2301">
+ Enable support for PDF sub-page transitions.
+ </action>
+ <action context="Layout" dev="GA" type="fix" fixes-bug="FOP-2310">
+ Fix misplaced table cell border in WM RTL context.
+ </action>
+ <action context="Renderers" dev="GA" type="add" fixes-bug="FOP-2298">
+ Enable support for PDF page transitions.
+ </action>
<action context="Code" dev="PH" type="fix" fixes-bug="FOP-2211" due-to="Alexios Giotis, PH">
Fix and improve the handling of temporary files using the new URI resource resolvers
</action>
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/AbstractBasicTranscoderTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/AbstractBasicTranscoderTest.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/AbstractBasicTranscoderTest.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/AbstractBasicTranscoderTest.java Thu Jan 30 15:51:03 2014
@@ -24,13 +24,15 @@ import java.io.InputStream;
import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.io.output.ByteArrayOutputStream;
+
import org.apache.batik.transcoder.Transcoder;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
-import org.apache.commons.io.output.ByteArrayOutputStream;
import static org.apache.fop.FOPTestUtils.getBaseDir;
-import static org.junit.Assert.assertTrue;
/**
* Basic runtime test for FOP's transcoders. It is used to verify that
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicDriverTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicDriverTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicDriverTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicDriverTestCase.java Thu Jan 30 15:51:03 2014
@@ -28,11 +28,13 @@ import javax.xml.transform.TransformerFa
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
-import org.apache.fop.apps.FOPException;
import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+
import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
@@ -40,7 +42,6 @@ import org.apache.fop.apps.MimeConstants
import org.apache.fop.cli.InputHandler;
import static org.apache.fop.FOPTestUtils.getBaseDir;
-import static org.junit.Assert.assertTrue;
/**
* Basic runtime test for the old Fop class. It is used to verify that
@@ -136,7 +137,7 @@ public class BasicDriverTestCase {
InputHandler handler = new InputHandler(xmlFile, xsltFile, null);
try {
handler.renderTo(foUserAgent, MimeConstants.MIME_PDF, baout);
- } catch (FOPException e) {}
+ } catch (FOPException e) { /* NOP */ }
}
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicDriverTestSuite.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicDriverTestSuite.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicDriverTestSuite.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicDriverTestSuite.java Thu Jan 30 15:51:03 2014
@@ -27,6 +27,6 @@ import org.junit.runners.Suite.SuiteClas
* Test suite for basic functionality of FOP's Driver API.
*/
@RunWith(Suite.class)
-@SuiteClasses({ BasicDriverTestCase.class })
+@SuiteClasses(BasicDriverTestCase.class)
public class BasicDriverTestSuite {
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicPSTranscoderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicPSTranscoderTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicPSTranscoderTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/BasicPSTranscoderTestCase.java Thu Jan 30 15:51:03 2014
@@ -20,6 +20,7 @@
package org.apache.fop;
import org.apache.batik.transcoder.Transcoder;
+
import org.apache.fop.render.ps.PSTranscoder;
/**
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/DebugHelper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/DebugHelper.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/DebugHelper.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/DebugHelper.java Thu Jan 30 15:51:03 2014
@@ -25,7 +25,10 @@ import org.apache.fop.logging.LoggingEle
/**
* Handles some standard tasks for debugging.
*/
-public class DebugHelper {
+public final class DebugHelper {
+
+ private DebugHelper() {
+ }
private static boolean elObserversRegistered = false;
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/DigestFilterTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/DigestFilterTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/DigestFilterTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/DigestFilterTestCase.java Thu Jan 30 15:51:03 2014
@@ -19,8 +19,6 @@
package org.apache.fop;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.io.StringReader;
import java.security.NoSuchAlgorithmException;
@@ -28,13 +26,16 @@ import java.security.NoSuchAlgorithmExce
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
-import org.apache.fop.util.DigestFilter;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.fop.util.DigestFilter;
+
/**
* Test case for digesting SAX filter.
*
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/KnuthAlgorithmTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/KnuthAlgorithmTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/KnuthAlgorithmTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/KnuthAlgorithmTestCase.java Thu Jan 30 15:51:03 2014
@@ -19,10 +19,13 @@
package org.apache.fop;
-import static org.junit.Assert.assertEquals;
-
import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
import org.apache.fop.layoutmgr.BlockKnuthSequence;
import org.apache.fop.layoutmgr.BreakingAlgorithm;
import org.apache.fop.layoutmgr.ElementListObserver;
@@ -30,8 +33,6 @@ import org.apache.fop.layoutmgr.KnuthBox
import org.apache.fop.layoutmgr.KnuthGlue;
import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.KnuthSequence;
-import org.junit.Before;
-import org.junit.Test;
/**
* Tests the Knuth algorithm implementation.
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/URIResolutionTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/URIResolutionTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/URIResolutionTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/URIResolutionTestCase.java Thu Jan 30 15:51:03 2014
@@ -41,6 +41,9 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.xpath.XPathAPI;
@@ -59,8 +62,6 @@ import org.apache.fop.apps.io.ResourceRe
import org.apache.fop.render.xml.XMLRenderer;
import static org.apache.fop.FOPTestUtils.getBaseDir;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
/**
* Tests URI resolution facilities.
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPObjectAreaInfoTestCase.java Thu Jan 30 15:51:03 2014
@@ -19,11 +19,11 @@
package org.apache.fop.afp;
-import static org.junit.Assert.assertEquals;
-
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
/**
* Test case for {@link AFPObjectAreaInfo}.
*/
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPPaintingStateTestCase.java Thu Jan 30 15:51:03 2014
@@ -19,11 +19,11 @@
package org.apache.fop.afp;
-import static org.junit.Assert.assertEquals;
-
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
/**
* Test case for {@link AFPPaintingState}.
*/
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPResourceManagerTestCase.java Thu Jan 30 15:51:03 2014
@@ -26,13 +26,13 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.apache.xmlgraphics.util.MimeConstants;
import org.apache.fop.apps.io.ResourceResolverFactory;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
/**
* Test case for {@link AFPResourceManager}.
*/
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/AFPResourceUtilTestCase.java Thu Jan 30 15:51:03 2014
@@ -19,8 +19,6 @@
package org.apache.fop.afp;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -29,11 +27,11 @@ import java.util.Arrays;
import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+
import org.apache.commons.io.IOUtils;
-import org.apache.fop.afp.util.AFPResourceUtil;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
+import org.apache.fop.afp.util.AFPResourceUtil;
/**
* Tests the {@link AFPResourceUtil} class.
@@ -133,7 +131,7 @@ public class AFPResourceUtilTestCase {
* names fails.
* @throws Exception -
*/
- @Test(expected=Exception.class)
+ @Test(expected = Exception.class)
public void testResourceNameMismatch() throws Exception {
testResource(RESOURCE_NAME_MISMATCH, PSEG_B);
}
@@ -156,6 +154,6 @@ public class AFPResourceUtilTestCase {
}
private interface ResourceCopier {
- public void copy(InputStream in, OutputStream out) throws IOException;
+ void copy(InputStream in, OutputStream out) throws IOException;
}
}
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java Thu Jan 30 15:51:03 2014
@@ -16,16 +16,17 @@
*/
package org.apache.fop.afp.goca;
-import static org.junit.Assert.assertEquals;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
import org.apache.fop.afp.fonts.CharacterSet;
import org.apache.fop.afp.fonts.CharacterSetBuilder;
import org.apache.fop.fonts.Typeface;
-import org.junit.Before;
-import org.junit.Test;
public class GraphicsCharacterStringTestCase {
private GraphicsCharacterString gcsCp500;
Modified: xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java?rev=1562866&r1=1562865&r2=1562866&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java (original)
+++ xmlgraphics/fop/branches/Temp_FopFontsForSVG/test/java/org/apache/fop/afp/modca/AbstractAFPObjectTest.java Thu Jan 30 15:51:03 2014
@@ -19,10 +19,6 @@
package org.apache.fop.afp.modca;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -30,9 +26,14 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.fop.afp.Streamable;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.fop.afp.Streamable;
+
/**
* Tests the {@link AbstractAFPObject} class.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org