User: tobias  
  Date: 01/03/11 17:00:56

  Modified:    lib      Fop.class Fop.java fop.jar
  Log:
  updated to newest version (cvs checkout from 2001/03/11) for better PDF support
  
  Revision  Changes    Path
  1.2       +39 -52    manual/lib/Fop.class
  
        <<Binary file>>
  
  
  1.2       +32 -99    manual/lib/Fop.java
  
  Index: Fop.java
  ===================================================================
  RCS file: /products/cvs/ejboss/manual/lib/Fop.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Fop.java  2001/02/11 00:04:47     1.1
  +++ Fop.java  2001/03/12 01:00:54     1.2
  @@ -67,7 +67,9 @@
   // FOP
   import org.apache.fop.messaging.MessageHandler;
   import org.apache.fop.apps.*;
  +import org.apache.fop.configuration.Configuration;
   
  +
   /**
    * extension to Ant which allows usage of Fop in the
    * same way as org.apache.fop.apps.CommandLine (the code is adapted from this class)
  @@ -76,7 +78,7 @@
    * containing org.w3c.dom.svg etc. for svg support
    */
   
  -public class Fop {
  +public class Fop extends Starter {
       String fofile, pdffile;
   
       /**
  @@ -95,110 +97,33 @@
           this.pdffile = pdffile;
       }
   
  -
  -    /**
  -      * creates a SAX parser, using the value of org.xml.sax.parser
  -      * defaulting to org.apache.xerces.parsers.SAXParser
  -      *
  -      * @return the created SAX parser
  -      */
  -    static XMLReader createParser() {
  -        String parserClassName = System.getProperty("org.xml.sax.parser");
  -        if (parserClassName == null) {
  -            parserClassName = "org.apache.xerces.parsers.SAXParser";
  -        }
  -        MessageHandler.logln("using SAX parser " + parserClassName);
  -
  -        try {
  -            return (XMLReader) Class.forName(
  -                     parserClassName).newInstance();
  -        } catch (ClassNotFoundException e) {
  -            MessageHandler.errorln("Could not find " + parserClassName);
  -        }
  -        catch (InstantiationException e) {
  -            MessageHandler.errorln("Could not instantiate " +
  -                                   parserClassName);
  -        }
  -        catch (IllegalAccessException e) {
  -            MessageHandler.errorln("Could not access " + parserClassName);
  -        }
  -        catch (ClassCastException e) {
  -            MessageHandler.errorln(parserClassName + " is not a SAX driver");
  -        }
  -        return null;
  -    } // end: createParser
  -
  -    /**
  -     * create an InputSource from a file name
  -     *
  -     * @param filename the name of the file
  -     * @return the InputSource created
  -     */
  -    protected static InputSource fileInputSource(String filename) {
  -
  -        /* this code adapted from James Clark's in XT */
  -        File file = new File(filename);
  -        String path = file.getAbsolutePath();
  -        String fSep = System.getProperty("file.separator");
  -        if (fSep != null && fSep.length() == 1)
  -            path = path.replace(fSep.charAt(0), '/');
  -        if (path.length() > 0 && path.charAt(0) != '/')
  -            path = '/' + path;
  -        try {
  -            return new InputSource(new URL("file", null, path).toString());
  -        } catch (java.net.MalformedURLException e) {
  -            throw new Error("unexpected MalformedURLException");
  -        }
  -    } // end: fileInputSource
   
  -    /**
  -     * main method, starts execution of this task
  -     *
  -     */
  -    public void execute () throws BuildException {
  -        Driver driver = new Driver();
  -        driver.setBaseDir(fofile);
  -        boolean errors = false;
  +    public void run () {
  +     Options options = new Options();
  +     boolean errors = false;
           String version = Version.getVersion();
  -        MessageHandler.logln("=======================\nTask " +
  -                             version + "\nconverting file " + fofile + " to " + 
pdffile);
  -
  -        if (!(new File(fofile).exists())) {
  -            errors = true;
  -            MessageHandler.errorln(
  -              "Task Fop - ERROR: Formatting objects file " +
  -              fofile + " missing.");
  -        }
  -
  -        XMLReader parser = createParser();
  -
  -        if (parser == null) {
  -            MessageHandler.errorln("Task Fop - ERROR: Unable to create SAX parser");
  +     
  +     File fofileF = new File (fofile);
  +     Configuration.put("baseDir",new File(fofileF.getAbsolutePath()).getParent());
  +     if (!fofileF.exists()) {
               errors = true;
  -        }
  -
  -        // setting the parser features
  -        try {
  -            parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
  -                              true);
  -        } catch (SAXException e) {
  -            MessageHandler.errorln("Error in setting up parser feature 
namespace-prefixes");
  -            MessageHandler.errorln("You need a parser which supports SAX version 
2");
  -            System.exit(1);
  +            MessageHandler.errorln("Task Fop - ERROR: Formatting objects file " +
  +                                fofile + " missing.");
           }
  -
  +     
  +     InputHandler inputHandler = new FOInputHandler(fofileF);
  +        XMLReader parser = inputHandler.getParser();
  +     super.setParserFeatures(parser);
  +     
  +        MessageHandler.logln("=======================\nTask " +
  +                             version + "\nconverting file " + fofile + " to " + 
pdffile);
  +     
           if (!errors) {
               try {
  -                driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
  -                                   version);
  -                
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
  -                driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
  -                
driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
  -                driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
  -                driver.setOutputStream(new FileOutputStream(pdffile));
  -                driver.buildFOTree(parser, fileInputSource(fofile));
  -                driver.format();
  -                driver.render();
  +             Driver driver = new Driver(inputHandler.fileInputSource(fofileF), new 
FileOutputStream(pdffile));
  +                driver.setRenderer(Driver.RENDER_PDF);
  +             driver.setXMLReader(parser);
  +             driver.run();
               } catch (Exception e) {
                   MessageHandler.errorln("Task Fop - FATAL ERROR: " +
                                          e.getMessage());
  @@ -206,6 +131,14 @@
               }
           }
           MessageHandler.logln("=======================\n");
  +    }
  +
  +    /**
  +     * main method, starts execution of this task
  +     *
  +     */
  +    public void execute () throws BuildException {
  +             run();
       } // end: execute
   }
   
  
  
  
  1.3       +3023 -2423manual/lib/fop.jar
  
        <<Binary file>>
  
  

Reply via email to