Esempio n. 1
0
  /* Stylesheet is useless and just kept to keep the consistency with
   * builddoc V1 */
  public String process(String sourceDoc, String styleSheet) throws Throwable {
    String fileToExec = null;

    if (!new File(sourceDoc).isFile()) {
      System.err.println("Could not find master document: " + sourceDoc);
      return null;
    }

    try {
      Converter converter = null;
      ImageConverter imgConvert = new ImageConverter();

      switch (format) {
        case JAVAHELP:
          if (!isToolbox) {
            imgConvert.loadMD5s(ScilabConstants.SCI.getPath() + "/modules/helptools/etc");
          }
          converter = new JavaHelpDocbookTagConverter(sourceDoc, this, imgConvert);
          break;
        case HTML:
          converter = new HTMLDocbookTagConverter(sourceDoc, this, imgConvert);
          break;
        case WEB:
          if (!isToolbox) {
            imgConvert.loadMD5s(ScilabConstants.SCI.getPath() + "/modules/helptools/etc");
          }
          converter = new HTMLDocbookTagConverter(sourceDoc, this, imgConvert);
          break;
        case CHM:
          if (!isToolbox) {
            imgConvert.loadMD5s(ScilabConstants.SCI.getPath() + "/modules/helptools/etc");
          }
          converter = new CHMDocbookTagConverter(sourceDoc, this, imgConvert);
          break;
        case FO:
          converter = new FODocbookTagConverter(sourceDoc, this, imgConvert);
          break;
        case JAR_ONLY:
          converter = new JarOnlyConverter(this);
          break;
        case PDF:
        case PS:
          converter = new FopConverter(this);
          break;
        default:
          System.err.printf("%s is not a supported format.\n", format);
          return null;
      }

      converter.registerAllExternalXMLHandlers();

      converter.convert();

      converter.install();

      if (imgConvert.getScilabImageConverter() != null) {
        fileToExec = imgConvert.getScilabImageConverter().getFileWithScilabCode();
      }

    } catch (SAXException e) {
      System.err.println("An error occurred during the conversion:");
      System.err.println(e.toString());
    } catch (Throwable e) {
      System.err.println("An error occurred during the conversion:\n");
      e.printStackTrace();
      throw e;
    }

    return fileToExec;
  }