Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

AreaTreeInputHandler.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright 2006 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.cli;
  18. import java.io.File;
  19. import java.io.OutputStream;
  20. import java.util.Vector;
  21. import javax.xml.transform.Result;
  22. import javax.xml.transform.sax.SAXResult;
  23. import org.apache.fop.apps.FOPException;
  24. import org.apache.fop.apps.FOUserAgent;
  25. import org.apache.fop.area.AreaTreeModel;
  26. import org.apache.fop.area.AreaTreeParser;
  27. import org.apache.fop.area.RenderPagesModel;
  28. import org.apache.fop.fonts.FontInfo;
  29. import org.xml.sax.SAXException;
  30. /**
  31. * InputHandler for the area tree XML (intermediate format) as input.
  32. */
  33. public class AreaTreeInputHandler extends InputHandler {
  34. /**
  35. * Constructor for XML->XSLT->area tree XML input
  36. * @param xmlfile XML file
  37. * @param xsltfile XSLT file
  38. * @param params Vector of command-line parameters (name, value,
  39. * name, value, ...) for XSL stylesheet, null if none
  40. */
  41. public AreaTreeInputHandler(File xmlfile, File xsltfile, Vector params) {
  42. super(xmlfile, xsltfile, params);
  43. }
  44. /**
  45. * Constructor for area tree XML input
  46. * @param atfile the file to read the area tree document.
  47. */
  48. public AreaTreeInputHandler(File atfile) {
  49. super(atfile);
  50. }
  51. /** @see org.apache.fop.cli.InputHandler */
  52. public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out)
  53. throws FOPException {
  54. FontInfo fontInfo = new FontInfo();
  55. AreaTreeModel treeModel = new RenderPagesModel(userAgent,
  56. outputFormat, fontInfo, out);
  57. //Iterate over all intermediate files
  58. AreaTreeParser parser = new AreaTreeParser();
  59. // Resulting SAX events (the generated FO) must be piped through to FOP
  60. Result res = new SAXResult(parser.getContentHandler(treeModel, userAgent));
  61. transformTo(res);
  62. try {
  63. treeModel.endDocument();
  64. } catch (SAXException e) {
  65. throw new FOPException(e);
  66. }
  67. }
  68. }