Author: acumiskey
Date: Wed Oct 15 07:55:25 2008
New Revision: 704935
URL: http://svn.apache.org/viewvc?rev=704935&view=rev
Log:
Merged revisions 704008,704907,704909 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r704008 | vhennebert | 2008-10-13 11:34:32 +0100 (Mon, 13 Oct 2008) | 6 lines
Bugzilla #45971: improved the behaviour of the command line interface:
- display 'fop' instead of 'Fop' in help messages
- do not throw exception when running fop without argument or with -v or -h
- return more meaningful error codes
Patch submitted with some modifications by Tom Browder
(tom_dot.browder.at_gmail.dot_com)
........
r704907 | acumiskey | 2008-10-15 14:27:06 +0100 (Wed, 15 Oct 2008) | 1 line
More readable.
........
r704909 | acumiskey | 2008-10-15 14:28:25 +0100 (Wed, 15 Oct 2008) | 1 line
Fix for ps:ps-page-setup-code.
........
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/ (props changed)
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/CommandLineOptions.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/Main.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 15 07:55:25 2008
@@ -1,2 +1,2 @@
/xmlgraphics/fop/branches/fop-0_95:684572,688085,688696
-/xmlgraphics/fop/trunk:693433-698670,699739
+/xmlgraphics/fop/trunk:693433-698670,699739,704008-704909
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Oct 15 07:55:25 2008
@@ -1 +1 @@
-/xmlgraphics/fop/trunk:1-703363
+/xmlgraphics/fop/trunk:1-704933
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/CommandLineOptions.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/CommandLineOptions.java?rev=704935&r1=704934&r2=704935&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/CommandLineOptions.java
(original)
+++
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/CommandLineOptions.java
Wed Oct 15 07:55:25 2008
@@ -23,17 +23,15 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.PrintStream;
import java.util.Locale;
import java.util.Map;
import java.util.Vector;
import javax.swing.UIManager;
-import org.xml.sax.SAXException;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.Version;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
@@ -50,6 +48,7 @@
import org.apache.fop.render.print.PrintRenderer;
import org.apache.fop.render.xml.XMLRenderer;
import org.apache.fop.util.CommandLineLogger;
+import org.xml.sax.SAXException;
/**
* Options parses the commandline arguments
@@ -134,7 +133,8 @@
}
/**
- * Parse the command line arguments.
+ * Parses the command line arguments.
+ *
* @param args the command line arguments.
* @throws FOPException for general errors
* @throws IOException if the the configuration file could not be loaded
@@ -165,10 +165,10 @@
return false;
}
} catch (FOPException e) {
- printUsage();
+ printUsage(System.err);
throw e;
} catch (java.io.FileNotFoundException e) {
- printUsage();
+ printUsage(System.err);
throw e;
}
@@ -228,12 +228,18 @@
}
/**
- * parses the commandline arguments
- * @return true if parse was successful and processing can continue, false
- * if processing should stop
+ * Parses the command line arguments.
+ *
+ * @return true if processing can continue, false if it should stop
(nothing to do)
* @exception FOPException if there was an error in the format of the
options
*/
private boolean parseOptions(String[] args) throws FOPException {
+ // do not throw an exception for no args
+ if (args.length == 0) {
+ printVersion();
+ printUsage(System.out);
+ return false;
+ }
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-x")
|| args[i].equals("--dump-config")) {
@@ -304,7 +310,8 @@
} else if (args[i].equals("-at")) {
i = i + parseAreaTreeOption(args, i);
} else if (args[i].equals("-v")) {
- System.out.println("FOP Version " + Version.getVersion());
+ printVersion();
+ return false;
} else if (args[i].equals("-param")) {
if (i + 2 < args.length) {
String name = args[++i];
@@ -330,8 +337,8 @@
} else if (!isOption(args[i])) {
i = i + parseUnknownOption(args, i);
} else {
- printUsage();
- return false;
+ printUsage(System.err);
+ System.exit(1);
}
}
return true;
@@ -1029,12 +1036,19 @@
}
}
+ private static void printVersion() {
+ System.out.println("FOP Version " + Version.getVersion());
+ }
+
/**
- * shows the commandline syntax including a summary of all available
options and some examples
+ * Shows the command line syntax including a summary of all available
options and some
+ * examples.
+ *
+ * @param out the stream to which the message must be printed
*/
- public static void printUsage() {
- System.err.println(
- "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] "
+ public static void printUsage(PrintStream out) {
+ out.println(
+ "\nUSAGE\nfop [options] [-fo|-xml] infile [-xsl file] "
+ "[-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at
[mime]|-print] <outfile>\n"
+ " [OPTIONS] \n"
+ " -d debug mode \n"
@@ -1095,15 +1109,15 @@
+ " XSL-FO file is saved and no rendering is
performed. \n"
+ " (Only available if you use -xml and -xsl
parameters)\n\n"
+ "\n"
- + " [Examples]\n" + " Fop foo.fo foo.pdf \n"
- + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous
line)\n"
- + " Fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n"
- + " Fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n"
- + " Fop -xml - -xsl foo.xsl -pdf -\n"
- + " Fop foo.fo -mif foo.mif\n"
- + " Fop foo.fo -rtf foo.rtf\n"
- + " Fop foo.fo -print\n"
- + " Fop foo.fo -awt\n");
+ + " [Examples]\n" + " fop foo.fo foo.pdf \n"
+ + " fop -fo foo.fo -pdf foo.pdf (does the same as the previous
line)\n"
+ + " fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n"
+ + " fop -xml foo.xml -xsl foo.xsl -foout foo.fo\n"
+ + " fop -xml - -xsl foo.xsl -pdf -\n"
+ + " fop foo.fo -mif foo.mif\n"
+ + " fop foo.fo -rtf foo.rtf\n"
+ + " fop foo.fo -print\n"
+ + " fop foo.fo -awt\n");
}
/**
@@ -1112,11 +1126,11 @@
private void printUsagePrintOutput() {
System.err.println("USAGE: -print [from[-to][,even|odd]] [-copies
numCopies]\n\n"
+ "Example:\n"
- + "all pages: Fop infile.fo -print\n"
- + "all pages with two copies: Fop infile.fo -print -copies
2\n"
- + "all pages starting with page 7: Fop infile.fo -print 7\n"
- + "pages 2 to 3: Fop infile.fo -print 2-3\n"
- + "only even page between 10 and 20: Fop infile.fo -print
10-20,even\n");
+ + "all pages: fop infile.fo -print\n"
+ + "all pages with two copies: fop infile.fo -print -copies
2\n"
+ + "all pages starting with page 7: fop infile.fo -print 7\n"
+ + "pages 2 to 3: fop infile.fo -print 2-3\n"
+ + "only even page between 10 and 20: fop infile.fo -print
10-20,even\n");
}
/**
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/Main.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/Main.java?rev=704935&r1=704934&r2=704935&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/Main.java
(original)
+++
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/cli/Main.java
Wed Oct 15 07:55:25 2008
@@ -139,7 +139,10 @@
}
/**
- * Executes FOP with the given ClassLoader setup.
+ * Executes FOP with the given arguments. If no argument is provided,
returns its
+ * version number as well as a short usage statement; if '-v' is provided,
returns its
+ * version number alone; if '-h' is provided, returns its short help
message.
+ *
* @param args command-line arguments
*/
public static void startFOP(String[] args) {
@@ -153,7 +156,7 @@
try {
options = new CommandLineOptions();
if (!options.parse(args)) {
- System.exit(1);
+ System.exit(0);
}
foUserAgent = options.getFOUserAgent();
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java?rev=704935&r1=704934&r2=704935&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java
(original)
+++
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/PSRenderer.java
Wed Oct 15 07:55:25 2008
@@ -40,36 +40,6 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.image.loader.ImageException;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
-import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
-import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
-import org.apache.xmlgraphics.image.loader.pipeline.ImageProviderPipeline;
-import org.apache.xmlgraphics.image.loader.util.ImageUtil;
-import org.apache.xmlgraphics.ps.DSCConstants;
-import org.apache.xmlgraphics.ps.ImageEncoder;
-import org.apache.xmlgraphics.ps.PSDictionary;
-import org.apache.xmlgraphics.ps.PSPageDeviceDictionary;
-import org.apache.xmlgraphics.ps.PSDictionaryFormatException;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.xmlgraphics.ps.PSImageUtils;
-import org.apache.xmlgraphics.ps.PSProcSets;
-import org.apache.xmlgraphics.ps.PSResource;
-import org.apache.xmlgraphics.ps.PSState;
-import org.apache.xmlgraphics.ps.dsc.DSCException;
-import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
-import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
-import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
-
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.Area;
@@ -107,6 +77,34 @@
import org.apache.fop.render.ps.extensions.PSSetupCode;
import org.apache.fop.util.CharUtilities;
import org.apache.fop.util.ColorUtil;
+import org.apache.xmlgraphics.image.loader.ImageException;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
+import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
+import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
+import org.apache.xmlgraphics.image.loader.pipeline.ImageProviderPipeline;
+import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.ps.DSCConstants;
+import org.apache.xmlgraphics.ps.ImageEncoder;
+import org.apache.xmlgraphics.ps.PSDictionary;
+import org.apache.xmlgraphics.ps.PSDictionaryFormatException;
+import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.xmlgraphics.ps.PSImageUtils;
+import org.apache.xmlgraphics.ps.PSPageDeviceDictionary;
+import org.apache.xmlgraphics.ps.PSProcSets;
+import org.apache.xmlgraphics.ps.PSResource;
+import org.apache.xmlgraphics.ps.PSState;
+import org.apache.xmlgraphics.ps.dsc.DSCException;
+import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
+import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
+import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
/**
* Renderer that renders to PostScript.
@@ -143,7 +141,7 @@
/** The application producing the PostScript */
private int currentPageNumber = 0;
- private boolean enableComments = true;
+ private final boolean enableComments = true;
private boolean autoRotateLandscape = false;
private int languageLevel = PSGenerator.DEFAULT_LANGUAGE_LEVEL;
@@ -589,12 +587,12 @@
/** [EMAIL PROTECTED] */
public void paintImage(RenderedImage image, RendererContext context,
int x, int y, int width, int height) throws IOException {
- float fx = (float)x / 1000f;
+ float fx = x / 1000f;
x += currentIPPosition / 1000f;
- float fy = (float)y / 1000f;
+ float fy = y / 1000f;
y += currentBPPosition / 1000f;
- float fw = (float)width / 1000f;
- float fh = (float)height / 1000f;
+ float fw = width / 1000f;
+ float fh = height / 1000f;
PSImageUtils.renderBitmapImage(image, fx, fy, fw, fh, gen);
}
@@ -1235,6 +1233,8 @@
PSExtensionAttachment attachment =
(PSExtensionAttachment)attObj;
if (attachment instanceof PSCommentBefore) {
gen.commentln("%" + attachment.getContent());
+ } else if (attachment instanceof PSSetupCode) {
+ gen.writeln(attachment.getContent());
}
}
}
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java?rev=704935&r1=704934&r2=704935&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
(original)
+++
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java
Wed Oct 15 07:55:25 2008
@@ -20,21 +20,20 @@
package org.apache.fop.render.ps.extensions;
// FOP
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.extensions.ExtensionAttachment;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
/**
* Base class for the PostScript-specific extension elements.
*/
public abstract class AbstractPSExtensionObject extends FONode {
- private PSSetupCode setupCode = new PSSetupCode();
+ private final PSSetupCode setupCode = new PSSetupCode();
/**
* Main constructor.
@@ -56,9 +55,10 @@
/** [EMAIL PROTECTED] */
protected void characters(char[] data, int start, int length,
PropertyList pList, Locator locator) {
- if (setupCode.getContent() != null) {
- StringBuffer sb = new StringBuffer(setupCode.getContent());
- sb.append(data, start, length - start);
+ String content = setupCode.getContent();
+ if (content != null) {
+ StringBuffer sb = new StringBuffer(content);
+ sb.append(data, start, length);
setupCode.setContent(sb.toString());
} else {
setupCode.setContent(new String(data, start, length));
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]