[FOray-commit] SF.net SVN: foray: [9838] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-06-25 19:06:51
|
Revision: 9838
http://svn.sourceforge.net/foray/?rev=9838&view=rev
Author: victormote
Date: 2007-06-25 12:06:35 -0700 (Mon, 25 Jun 2007)
Log Message:
-----------
Conform to axsl changes throwing OutputException.
Modified Paths:
--------------
trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java
trunk/foray/foray-mif/.classpath
trunk/foray/foray-mif/src/java/org/foray/mif/MifBook.java
trunk/foray/foray-output/src/java/org/foray/output/MIFConverter.java
trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
Modified: trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java
===================================================================
--- trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -30,7 +30,6 @@
import org.foray.common.WKConstants;
-import org.axsl.areaR.AreaRException;
import org.axsl.areaW.AreaTreeEvent;
import org.axsl.areaW.AreaTreeFactory;
import org.axsl.areaW.AreaTreeListener;
@@ -43,6 +42,7 @@
import org.axsl.layout.Layout;
import org.axsl.layout.LayoutException;
import org.axsl.layout.LayoutFactory;
+import org.axsl.output.OutputException;
import org.axsl.output.OutputTarget;
import org.axsl.output.Renderer;
import org.axsl.text.TextServer;
@@ -51,7 +51,6 @@
import org.xml.sax.SAXException;
-import java.io.IOException;
import java.io.OutputStream;
/**
@@ -193,7 +192,7 @@
startTime = System.currentTimeMillis();
try {
outputTarget.startOutput();
- } catch (final IOException e) {
+ } catch (final OutputException e) {
throw new FOrayException(e);
}
}
@@ -205,7 +204,7 @@
public void stopRenderer() throws SAXException {
try {
outputTarget.stopOutput();
- } catch (final IOException e) {
+ } catch (final OutputException e) {
throw new SAXException(e);
}
@@ -303,10 +302,8 @@
final Renderer renderer = (Renderer) this.outputTarget;
try {
renderer.render(page);
- } catch (final IOException e) {
+ } catch (final OutputException e) {
this.getLogger().error("Rendering error", e);
- } catch (final AreaRException e) {
- this.getLogger().error("Rendering error", e);
}
pageCount++;
}
Modified: trunk/foray/foray-mif/.classpath
===================================================================
--- trunk/foray/foray-mif/.classpath 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-mif/.classpath 2007-06-25 19:06:35 UTC (rev 9838)
@@ -5,5 +5,6 @@
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/>
<classpathentry kind="lib" path="/FOray Lib/commons-logging-1.1.jar" sourcepath="/FOray Lib-Build/commons-logging/commons-logging-1.1-src.zip"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-mif/src/java/org/foray/mif/MifBook.java
===================================================================
--- trunk/foray/foray-mif/src/java/org/foray/mif/MifBook.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-mif/src/java/org/foray/mif/MifBook.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -28,6 +28,8 @@
package org.foray.mif;
+import org.axsl.output.OutputException;
+
import org.apache.commons.logging.Log;
import java.io.IOException;
@@ -145,11 +147,15 @@
/**
* Writes the content of this book to a given output stream.
* @param stream The stream to which the content should be written.
- * @throws IOException For I/O errors during writing.
+ * @throws OutputException For I/O errors during writing.
*/
- public void output(final OutputStream stream) throws IOException {
+ public void output(final OutputStream stream) throws OutputException {
// Output the contents of bookComponent
- stream.write(this.bookComponent.mifContent().getBytes());
+ try {
+ stream.write(this.bookComponent.mifContent().getBytes());
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
}
/**
Modified: trunk/foray/foray-output/src/java/org/foray/output/MIFConverter.java
===================================================================
--- trunk/foray/foray-output/src/java/org/foray/output/MIFConverter.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-output/src/java/org/foray/output/MIFConverter.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -38,6 +38,7 @@
import org.axsl.foR.fo.TableColumn;
import org.axsl.foR.fo.TableRow;
import org.axsl.fontR.FontConsumer;
+import org.axsl.output.OutputException;
import org.apache.commons.logging.Log;
@@ -241,7 +242,7 @@
/**
* {@inheritDoc}
*/
- public void startOutput() throws IOException {
+ public void startOutput() throws OutputException {
this.mifDoc = new MifBook(getLogger());
getLogger().info("rendering areas to MIF");
this.mifDoc.setDocumentHeightWidth(pageHeight, pageWidth);
@@ -250,10 +251,14 @@
/**
* {@inheritDoc}
*/
- public void stopOutput() throws IOException {
+ public void stopOutput() throws OutputException {
getLogger().info("writing out MIF");
this.mifDoc.output(this.getOutputStream());
- this.getOutputStream().flush();
+ try {
+ this.getOutputStream().flush();
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
}
/**
Modified: trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -40,7 +40,6 @@
import org.axsl.areaR.Area;
import org.axsl.areaR.AreaNode;
-import org.axsl.areaR.AreaRException;
import org.axsl.areaR.AreaTree;
import org.axsl.areaR.BackgroundArea;
import org.axsl.areaR.BeforeFloatArea;
@@ -70,13 +69,13 @@
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.SVGGraphic;
+import org.axsl.output.OutputException;
import org.apache.commons.logging.Log;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
-import java.io.IOException;
/**
* Abstract base class for all renderers.
@@ -118,13 +117,9 @@
}
/**
- * Renders the given page to the output stream for this renderer.
- * @param page The page to be rendered.
- * @throws IOException For I/O errors when writing to the output stream.
- * @throws AreaRException For inconsistencies in the AreaTree.
+ * {@inheritDoc}
*/
- public abstract void render(PageArea page) throws IOException,
- AreaRException;
+ public abstract void render(PageArea page) throws OutputException;
/**
* Marks the border, if any, for the given area.
Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -31,12 +31,12 @@
import org.foray.output.OutputConfig;
import org.axsl.areaR.PageArea;
+import org.axsl.output.OutputException;
import org.apache.commons.logging.Log;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -97,8 +97,7 @@
/**
* {@inheritDoc}
*/
- public void stopOutput()
- throws IOException {
+ public void stopOutput() throws OutputException {
super.stopOutput();
if (endNumber == -1) {
@@ -114,7 +113,7 @@
printerJob.print();
} catch (final PrinterException e) {
e.printStackTrace();
- throw new IOException(
+ throw new OutputException(
"Unable to print: " + e.getClass().getName() +
": " + e.getMessage());
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -59,6 +59,7 @@
import org.axsl.fontR.FontUse;
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.SVGGraphic;
+import org.axsl.output.OutputException;
import org.apache.commons.logging.Log;
@@ -79,7 +80,6 @@
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Vector;
@@ -389,7 +389,7 @@
try {
render(pageList.get(aPageNumber));
- } catch (final IOException e) {
+ } catch (final OutputException e) {
e.printStackTrace();
// This exception can't occur because we are not dealing with
// any files
@@ -400,7 +400,7 @@
/**
* {@inheritDoc}
*/
- public void render(final PageArea page) throws IOException {
+ public void render(final PageArea page) throws OutputException {
pageWidth = Math.round(toPoints(page.getWidth()));
pageHeight = Math.round(toPoints(page.getHeight()));
@@ -830,13 +830,13 @@
/**
* {@inheritDoc}
*/
- public void startOutput() throws IOException { }
+ public void startOutput() throws OutputException { }
/**
* {@inheritDoc}
*/
- public void stopOutput() throws IOException {
+ public void stopOutput() throws OutputException {
render(0);
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -53,6 +53,7 @@
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.SVGGraphic;
+import org.axsl.output.OutputException;
import org.apache.commons.logging.Log;
@@ -715,8 +716,7 @@
/**
* {@inheritDoc}
*/
- public void startOutput()
- throws IOException {
+ public void startOutput() throws OutputException {
getLogger().info("rendering areas to PCL");
currentStream = new PCLStream(this.getOutputStream());
@@ -727,16 +727,19 @@
/**
* {@inheritDoc}
*/
- public void stopOutput()
- throws IOException {
+ public void stopOutput() throws OutputException {
getLogger().info("writing out PCL");
- this.getOutputStream().flush();
+ try {
+ this.getOutputStream().flush();
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
}
/**
* {@inheritDoc}
*/
- public void render(final PageArea page) throws IOException {
+ public void render(final PageArea page) throws OutputException {
getLogger().debug("PCLRenderer.renderPage() page.Height() = "
+ page.getHeight());
Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -39,7 +39,6 @@
import org.axsl.areaR.Area;
import org.axsl.areaR.AreaNode;
-import org.axsl.areaR.AreaRException;
import org.axsl.areaR.AreaTree;
import org.axsl.areaR.BookmarkArea;
import org.axsl.areaR.BookmarkTitleArea;
@@ -56,6 +55,7 @@
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicLink;
import org.axsl.graphicR.SVGGraphic;
+import org.axsl.output.OutputException;
import org.axsl.pdfW.PDFColor;
import org.axsl.pdfW.PDFContentStream;
import org.axsl.pdfW.PDFDocument;
@@ -150,7 +150,7 @@
/**
* {@inheritDoc}
*/
- public void startOutput() throws IOException {
+ public void startOutput() throws OutputException {
final String pdfVersion = this.getOptions().optionPDFVersion();
if (pdfVersion != null) {
final PDFVersion pdfVersionConstant = PDFVersion.fromString(
@@ -168,20 +168,28 @@
final String filter = (String) filters.get(i);
pdfDoc.addDefaultFilter(filter);
}
- pdfDoc.writeHeader();
+ try {
+ pdfDoc.writeHeader();
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
}
/**
* {@inheritDoc}
*/
- public void stopOutput() throws IOException {
+ public void stopOutput() throws OutputException {
/*
* Render the nodes that are children of AreaTree instead of a
* PageCollection.
*/
renderDocumentNodes();
renderDocumentMetadata();
- pdfDoc.close();
+ try {
+ pdfDoc.close();
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
// this frees up memory and makes the renderer reusable
this.pdfDoc = null;
@@ -427,7 +435,7 @@
/**
* Render page to PDF. {@inheritDoc}
*/
- public void render(final PageArea page) throws AreaRException, IOException {
+ public void render(final PageArea page) throws OutputException {
getLogger().debug("Rendering single page to PDF.");
final float w = page.getWidth();
final float h = page.getHeight();
@@ -439,7 +447,11 @@
renderDestinations(page);
getLogger().debug("Writing out PDF.");
- this.pdfDoc.writeIndirectObjects();
+ try {
+ this.pdfDoc.writeIndirectObjects();
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
}
/**
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -58,6 +58,7 @@
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.SVGGraphic;
+import org.axsl.output.OutputException;
import org.axsl.psR.Encoding;
import org.axsl.psR.EncodingVector;
@@ -1088,7 +1089,7 @@
/**
* {@inheritDoc}
*/
- public void startOutput() throws IOException {
+ public void startOutput() {
getLogger().debug("rendering areas to PostScript");
this.pagecount = 0;
@@ -1168,11 +1169,15 @@
/**
* {@inheritDoc}
*/
- public void stopOutput() throws IOException {
+ public void stopOutput() throws OutputException {
write("%%Trailer");
write("%%Pages: " + this.pagecount);
write("%%EOF");
- this.out.flush();
+ try {
+ this.out.flush();
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
getLogger().debug("written out PostScript");
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -50,6 +50,7 @@
import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.GraphicServer;
import org.axsl.graphicR.SVGGraphic;
+import org.axsl.output.OutputException;
import org.apache.commons.logging.Log;
@@ -251,7 +252,7 @@
/**
* {@inheritDoc}
*/
- public void render(final PageArea page) throws IOException {
+ public void render(final PageArea page) {
this.pageNumber++;
final int lastWidth = this.pageWidth;
final int lastHeight = this.pageHeight;
@@ -613,11 +614,11 @@
/**
* {@inheritDoc}
*/
- public void startOutput() throws IOException {
+ public void startOutput() throws OutputException {
try {
this.svgDocument = this.graphicServer.makeSvgDocument();
} catch (final GraphicException e) {
- throw new IOException(e.getMessage());
+ throw new OutputException(e.getMessage());
}
final ProcessingInstruction pi =
this.svgDocument.createProcessingInstruction(
@@ -630,12 +631,16 @@
/**
* {@inheritDoc}
*/
- public void stopOutput() throws IOException {
+ public void stopOutput() throws OutputException {
this.svgRoot.setAttributeNS(null, "width", "" + this.totalWidth);
this.svgRoot.setAttributeNS(null, "height", "" + this.totalHeight);
- this.graphicServer.writeSvgDocument(this.svgDocument,
- this.getOutputStream());
- this.getOutputStream().flush();
+ try {
+ this.graphicServer.writeSvgDocument(this.svgDocument,
+ this.getOutputStream());
+ this.getOutputStream().flush();
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
this.svgDocument = null;
this.svgRoot = null;
Modified: trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -44,6 +44,7 @@
import org.axsl.graphicR.Graphic;
import org.axsl.graphicR.GraphicException;
import org.axsl.graphicR.SVGGraphic;
+import org.axsl.output.OutputException;
import org.apache.commons.logging.Log;
@@ -545,7 +546,7 @@
/**
* {@inheritDoc}
*/
- public void startOutput() throws IOException {
+ public void startOutput() {
getLogger().info("rendering areas to TEXT");
this.currentStream = new TXTStream(this.getOutputStream());
String encoding;
@@ -569,9 +570,13 @@
/**
* {@inheritDoc}
*/
- public void stopOutput() throws IOException {
+ public void stopOutput() throws OutputException {
getLogger().info("writing out TEXT");
- this.getOutputStream().flush();
+ try {
+ this.getOutputStream().flush();
+ } catch (final IOException e) {
+ throw new OutputException(e);
+ }
}
/**
Modified: trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2007-06-22 21:24:42 UTC (rev 9837)
+++ trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2007-06-25 19:06:35 UTC (rev 9838)
@@ -71,7 +71,6 @@
import java.awt.Color;
import java.awt.Rectangle;
-import java.io.IOException;
import java.io.PrintWriter;
/**
@@ -103,7 +102,7 @@
/**
* {@inheritDoc}
*/
- public void render(final PageArea page) throws IOException {
+ public void render(final PageArea page) {
final RegionBodyArea body = page.getRegionBody();
final RegionArea before = page.getRegionBefore();
final RegionArea after = page.getRegionAfter();
@@ -546,7 +545,7 @@
/**
* {@inheritDoc}
*/
- public void startOutput() throws IOException {
+ public void startOutput() {
getLogger().debug("rendering areas to XML");
this.writer = new PrintWriter(this.getOutputStream());
final StringBuilder buffer = new StringBuilder();
@@ -566,7 +565,7 @@
/**
* {@inheritDoc}
*/
- public void stopOutput() throws IOException {
+ public void stopOutput() {
this.writer.write("</area-tree>");
this.writer.flush();
getLogger().debug("written out XML");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|