From 85469d276ba93487b8b66af42f3fcb56ffbe6786 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Sat, 22 Nov 2003 19:48:21 +0000 Subject: [PATCH] New feature for the Ant task: relativebase="true" uses the directory of each FO-file in a fileset as basedir. This is in contrast to the general basedir parameter. Submitted by: Joe DeVivo git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197021 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/tools/anttasks/Fop.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java index 9cd1d4fb5..9622c1fad 100644 --- a/src/java/org/apache/fop/tools/anttasks/Fop.java +++ b/src/java/org/apache/fop/tools/anttasks/Fop.java @@ -85,6 +85,8 @@ import org.apache.avalon.framework.logger.Logger; *
  • format -> MIME type of the format to generate ex. "application/pdf"
  • *
  • outfile -> output filename
  • *
  • baseDir -> directory to work from
  • + *
  • relativebase -> (true | false) control whether to use each FO's + * directory as base directory. false uses the baseDir parameter.
  • *
  • userconfig -> file with user configuration (same as the "-c" command * line option)
  • *
  • messagelevel -> (error | warn | info | verbose | debug) level to output @@ -105,6 +107,7 @@ public class Fop extends Task { private int messageType = Project.MSG_VERBOSE; private boolean logFiles = true; private boolean force = false; + private boolean relativebase = false; /** * Sets the filename for the userconfig.xml. @@ -154,6 +157,25 @@ public class Fop extends Task { return this.filesets; } + /** + * Set whether to include files (external-grpahics, instream-foreign-object) + * from a path relative to the .fo file (true) or the working directory (false, default) + * only useful for filesets + * + * @param relbase true if paths are relative to file. + */ + public void setRelativebase(boolean relbase) { + this.relativebase = relbase; + } + + /** + * Gets the relative base attribute + * @return the relative base attribute + */ + public boolean getRelativebase() { + return relativebase; + } + /** * Set whether to check dependencies, or to always generate; * optional, default is false. @@ -429,7 +451,6 @@ class FOPTaskStarter extends AbstractLogEnabled { if (task.getOutdir() != null) { outf = new File(task.getOutdir(), outf.getName()); } - // Render if "force" flag is set OR // OR output file doesn't exist OR // output file is older than input file @@ -437,7 +458,8 @@ class FOPTaskStarter extends AbstractLogEnabled { || (task.getFofile().lastModified() > outf.lastModified() )) { render(task.getFofile(), outf, rint); actioncount++; - } else if (outf.exists() && (task.getFofile().lastModified() <= outf.lastModified() )) { + } else if (outf.exists() + && (task.getFofile().lastModified() <= outf.lastModified() )) { skippedcount++; } } @@ -468,6 +490,10 @@ class FOPTaskStarter extends AbstractLogEnabled { } try { + if (task.getRelativebase()) { + this.baseURL = f.getParentFile().toURL(). + toExternalForm(); + } if (this.baseURL == null) { this.baseURL = fs.getDir(task.getProject()).toURL(). toExternalForm(); -- 2.39.5