You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FOUserAgent.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright 1999-2004 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.apps;
  18. // Java
  19. import java.util.HashMap;
  20. import java.util.Map;
  21. import java.io.IOException;
  22. import java.io.InputStream;
  23. // FOP
  24. import org.apache.fop.pdf.PDFEncryptionParams;
  25. /**
  26. * The User Agent for fo.
  27. * This user agent is used by the processing to obtain user configurable
  28. * options.
  29. * <p>
  30. * Renderer specific extensions (that do not produce normal areas on
  31. * the output) will be done like so:
  32. * <br>
  33. * The extension will create an area, custom if necessary
  34. * <br>
  35. * this area will be added to the user agent with a key
  36. * <br>
  37. * the renderer will know keys for particular extensions
  38. * <br>
  39. * eg. bookmarks will be held in a special hierarchical area representing
  40. * the title and bookmark structure
  41. * <br>
  42. * These areas may contain resolveable areas that will be processed
  43. * with other resolveable areas
  44. */
  45. public class FOUserAgent {
  46. /** Map containing various default values */
  47. public Map defaults = new java.util.HashMap();
  48. /** Map containing XML handlers for various document types */
  49. public Map handlers = new java.util.HashMap();
  50. private String baseURL;
  51. private PDFEncryptionParams pdfEncryptionParams;
  52. private float px2mm = 0.35277777777777777778f; //72dpi (=25.4/dpi)
  53. private HashMap rendererOptions = new java.util.HashMap();
  54. /**
  55. * Returns the renderer options
  56. * @return renderer options
  57. */
  58. public HashMap getRendererOptions() {
  59. return rendererOptions;
  60. }
  61. /**
  62. * Sets the base URL.
  63. * @param baseURL base URL
  64. */
  65. public void setBaseURL(String baseURL) {
  66. this.baseURL = baseURL;
  67. }
  68. /**
  69. * Returns the base URL.
  70. * @return the base URL
  71. */
  72. public String getBaseURL() {
  73. if ((this.baseURL == null) || (this.baseURL.trim().equals(""))) {
  74. return "file:.";
  75. } else {
  76. return this.baseURL;
  77. }
  78. }
  79. /**
  80. * Returns the parameters for PDF encryption.
  81. * @return the PDF encryption parameters, null if not applicable
  82. */
  83. public PDFEncryptionParams getPDFEncryptionParams() {
  84. return pdfEncryptionParams;
  85. }
  86. /**
  87. * Sets the parameters for PDF encryption.
  88. * @param pdfEncryptionParams the PDF encryption parameters, null to
  89. * disable PDF encryption
  90. */
  91. public void setPDFEncryptionParams(PDFEncryptionParams pdfEncryptionParams) {
  92. this.pdfEncryptionParams = pdfEncryptionParams;
  93. }
  94. /**
  95. * Get an input stream for a reference.
  96. * Temporary solution until API better.
  97. * @param uri URI to access
  98. * @return InputStream for accessing the resource.
  99. * @throws IOException in case of an I/O problem
  100. */
  101. public InputStream getStream(String uri) throws IOException {
  102. return null;
  103. }
  104. /**
  105. * Returns the conversion factor from pixel units to millimeters. This
  106. * depends on the desired reolution.
  107. * @return float conversion factor
  108. */
  109. public float getPixelUnitToMillimeter() {
  110. return this.px2mm;
  111. }
  112. /**
  113. * Sets the resolution in dpi.
  114. * @param dpi resolution in dpi
  115. */
  116. public void setResolution(int dpi) {
  117. this.px2mm = (float)(25.4 / dpi);
  118. }
  119. /**
  120. * If to create hot links to footnotes and before floats.
  121. * @return True if hot links dhould be created
  122. */
  123. public boolean linkToFootnotes() {
  124. return true;
  125. }
  126. }