Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

MIFFile.java 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * $Id$
  3. * ============================================================================
  4. * The Apache Software License, Version 1.1
  5. * ============================================================================
  6. *
  7. * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modifica-
  10. * tion, are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if any, must
  20. * include the following acknowledgment: "This product includes software
  21. * developed by the Apache Software Foundation (http://www.apache.org/)."
  22. * Alternately, this acknowledgment may appear in the software itself, if
  23. * and wherever such third-party acknowledgments normally appear.
  24. *
  25. * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  26. * endorse or promote products derived from this software without prior
  27. * written permission. For written permission, please contact
  28. * apache@apache.org.
  29. *
  30. * 5. Products derived from this software may not be called "Apache", nor may
  31. * "Apache" appear in their name, without prior written permission of the
  32. * Apache Software Foundation.
  33. *
  34. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  35. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  36. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  37. * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  38. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  39. * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  40. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  41. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  43. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. * ============================================================================
  45. *
  46. * This software consists of voluntary contributions made by many individuals
  47. * on behalf of the Apache Software Foundation and was originally created by
  48. * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  49. * Software Foundation, please see <http://www.apache.org/>.
  50. */
  51. package org.apache.fop.render.mif;
  52. // Java
  53. import java.io.IOException;
  54. import java.io.OutputStream;
  55. import java.util.Iterator;
  56. import java.util.List;
  57. /**
  58. * The MIF File.
  59. * This organises the MIF File and the corresponding elements.
  60. * The catalog elements are used to setup the resources that
  61. * are referenced.
  62. */
  63. public class MIFFile extends MIFElement {
  64. protected MIFElement colorCatalog = null;
  65. protected PGFElement pgfCatalog = null;
  66. protected MIFElement fontCatalog = null;
  67. protected RulingElement rulingCatalog = null;
  68. protected MIFElement tblCatalog = null;
  69. protected MIFElement views = null;
  70. protected MIFElement variableFormats = null;
  71. protected MIFElement xRefFormats = null;
  72. protected MIFElement document = null;
  73. protected MIFElement bookComponent = null;
  74. protected MIFElement initialAutoNums = null;
  75. protected MIFElement aFrames = null;
  76. protected MIFElement tbls = null;
  77. protected List pages = new java.util.ArrayList();
  78. protected List textFlows = null;
  79. public MIFFile() {
  80. super("");
  81. valueElements = new java.util.ArrayList();
  82. setup();
  83. }
  84. /**
  85. * Do some setup.
  86. * Currently adds some dummy values to the resources.
  87. */
  88. protected void setup() {
  89. MIFElement unit = new MIFElement("Units");
  90. unit.setValue("Ucm");
  91. addElement(unit);
  92. colorCatalog = new MIFElement("ColorCatalog");
  93. MIFElement color = new MIFElement("Color");
  94. MIFElement prop = new MIFElement("ColorTag");
  95. prop.setValue("`Black'");
  96. color.addElement(prop);
  97. prop = new MIFElement("ColorCyan");
  98. prop.setValue("0.000000");
  99. color.addElement(prop);
  100. prop = new MIFElement("ColorMagenta");
  101. prop.setValue("0.000000");
  102. color.addElement(prop);
  103. prop = new MIFElement("ColorYellow");
  104. prop.setValue("0.000000");
  105. color.addElement(prop);
  106. prop = new MIFElement("ColorBlack");
  107. prop.setValue("100.000000");
  108. color.addElement(prop);
  109. prop = new MIFElement("ColorAttribute");
  110. prop.setValue("ColorIsBlack");
  111. color.addElement(prop);
  112. prop = new MIFElement("ColorAttribute");
  113. prop.setValue("ColorIsReserved");
  114. color.addElement(prop);
  115. color.finish(true);
  116. colorCatalog.addElement(color);
  117. addElement(colorCatalog);
  118. pgfCatalog = new PGFElement();
  119. pgfCatalog.lookupElement(null);
  120. addElement(pgfCatalog);
  121. rulingCatalog = new RulingElement();
  122. rulingCatalog.lookupElement(null);
  123. addElement(rulingCatalog);
  124. }
  125. public void output(OutputStream os) throws IOException {
  126. if (finished) {
  127. return;
  128. }
  129. if (!started) {
  130. os.write(("<MIFFile 5.00> # Generated by FOP\n"/* + getVersion()*/).getBytes());
  131. started = true;
  132. }
  133. boolean done = true;
  134. for (Iterator iter = valueElements.iterator(); iter.hasNext();) {
  135. MIFElement el = (MIFElement)iter.next();
  136. boolean d = el.output(os, 0);
  137. if (d) {
  138. iter.remove();
  139. } else {
  140. done = false;
  141. break;
  142. }
  143. }
  144. if (done && finish) {
  145. os.write(("# end of MIFFile").getBytes());
  146. }
  147. }
  148. public void addPage(MIFElement p) {
  149. pages.add(p);
  150. addElement(p);
  151. }
  152. }