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 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.apps;
  19. // Java
  20. import java.io.File;
  21. import java.io.IOException;
  22. import java.io.OutputStream;
  23. import java.net.URISyntaxException;
  24. import java.util.Date;
  25. import java.util.Map;
  26. import javax.xml.transform.Source;
  27. import javax.xml.transform.stream.StreamSource;
  28. import org.apache.commons.logging.Log;
  29. import org.apache.commons.logging.LogFactory;
  30. import org.apache.xmlgraphics.image.loader.ImageContext;
  31. import org.apache.xmlgraphics.image.loader.ImageManager;
  32. import org.apache.xmlgraphics.image.loader.ImageSessionContext;
  33. import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext;
  34. import org.apache.xmlgraphics.image.loader.util.SoftMapCache;
  35. import org.apache.xmlgraphics.util.UnitConv;
  36. import org.apache.fop.Version;
  37. import org.apache.fop.accessibility.Accessibility;
  38. import org.apache.fop.accessibility.DummyStructureTreeEventHandler;
  39. import org.apache.fop.accessibility.StructureTreeEventHandler;
  40. import org.apache.fop.apps.io.InternalResourceResolver;
  41. import org.apache.fop.configuration.Configuration;
  42. import org.apache.fop.configuration.ConfigurationException;
  43. import org.apache.fop.events.DefaultEventBroadcaster;
  44. import org.apache.fop.events.Event;
  45. import org.apache.fop.events.EventBroadcaster;
  46. import org.apache.fop.events.EventListener;
  47. import org.apache.fop.events.FOPEventListenerProxy;
  48. import org.apache.fop.events.LoggingEventListener;
  49. import org.apache.fop.fo.ElementMappingRegistry;
  50. import org.apache.fop.fo.FOEventHandler;
  51. import org.apache.fop.fonts.FontManager;
  52. import org.apache.fop.layoutmgr.LayoutManagerMaker;
  53. import org.apache.fop.render.ImageHandlerRegistry;
  54. import org.apache.fop.render.Renderer;
  55. import org.apache.fop.render.RendererConfig;
  56. import org.apache.fop.render.RendererConfig.RendererConfigParser;
  57. import org.apache.fop.render.RendererConfigOption;
  58. import org.apache.fop.render.RendererFactory;
  59. import org.apache.fop.render.XMLHandlerRegistry;
  60. import org.apache.fop.render.intermediate.IFDocumentHandler;
  61. import org.apache.fop.util.ColorSpaceCache;
  62. import org.apache.fop.util.ContentHandlerFactoryRegistry;
  63. /**
  64. * This is the user agent for FOP.
  65. * It is the entity through which you can interact with the XSL-FO processing and is
  66. * used by the processing to obtain user configurable options.
  67. * <p>
  68. * Renderer specific extensions (that do not produce normal areas on
  69. * the output) will be done like so:
  70. * <br>
  71. * The extension will create an area, custom if necessary
  72. * <br>
  73. * this area will be added to the user agent with a key
  74. * <br>
  75. * the renderer will know keys for particular extensions
  76. * <br>
  77. * eg. bookmarks will be held in a special hierarchical area representing
  78. * the title and bookmark structure
  79. * <br>
  80. * These areas may contain resolvable areas that will be processed
  81. * with other resolvable areas
  82. */
  83. public class FOUserAgent {
  84. private static Log log = LogFactory.getLog("FOP");
  85. private final FopFactory factory;
  86. private final InternalResourceResolver resourceResolver;
  87. private float targetResolution = FopFactoryConfig.DEFAULT_TARGET_RESOLUTION;
  88. private Map rendererOptions = new java.util.HashMap();
  89. private File outputFile;
  90. private IFDocumentHandler documentHandlerOverride;
  91. private Renderer rendererOverride;
  92. private FOEventHandler foEventHandlerOverride;
  93. private boolean locatorEnabled = true; // true by default (for error messages).
  94. private boolean conserveMemoryPolicy;
  95. private EventBroadcaster eventBroadcaster = new FOPEventBroadcaster();
  96. private StructureTreeEventHandler structureTreeEventHandler
  97. = DummyStructureTreeEventHandler.INSTANCE;
  98. private boolean pdfUAEnabled;
  99. /** Producer: Metadata element for the system/software that produces
  100. * the document. (Some renderers can store this in the document.)
  101. */
  102. protected String producer = "Apache FOP Version " + Version.getVersion();
  103. /** Creator: Metadata element for the user that created the
  104. * document. (Some renderers can store this in the document.)
  105. */
  106. protected String creator;
  107. /** Creation Date: Override of the date the document was created.
  108. * (Some renderers can store this in the document.)
  109. */
  110. protected Date creationDate;
  111. /** Author of the content of the document. */
  112. protected String author;
  113. /** Title of the document. */
  114. protected String title;
  115. /** Subject of the document. */
  116. protected String subject;
  117. /** Set of keywords applicable to this document. */
  118. protected String keywords;
  119. private final ImageSessionContext imageSessionContext;
  120. private final SoftMapCache pdfObjectCache = new SoftMapCache(true);
  121. /**
  122. * Main constructor. <b>This constructor should not be called directly. Please use the
  123. * methods from FopFactory to construct FOUserAgent instances!</b>
  124. * @param factory the factory that provides environment-level information
  125. * @param resourceResolver the resolver used to acquire resources
  126. * @see org.apache.fop.apps.FopFactory
  127. */
  128. FOUserAgent(final FopFactory factory, InternalResourceResolver resourceResolver) {
  129. this.factory = factory;
  130. this.resourceResolver = resourceResolver;
  131. setTargetResolution(factory.getTargetResolution());
  132. setAccessibility(factory.isAccessibilityEnabled());
  133. imageSessionContext = new AbstractImageSessionContext(factory.getFallbackResolver()) {
  134. public ImageContext getParentContext() {
  135. return factory;
  136. }
  137. public float getTargetResolution() {
  138. return FOUserAgent.this.getTargetResolution();
  139. }
  140. public Source resolveURI(String uri) {
  141. return FOUserAgent.this.resolveURI(uri);
  142. }
  143. };
  144. }
  145. /**
  146. * Returns a new {@link Fop} instance. Use this factory method if your output type
  147. * requires an output stream and you want to configure this very rendering run,
  148. * i.e. if you want to set some metadata like the title and author of the document
  149. * you want to render. In that case, create a new {@link FOUserAgent} instance
  150. * using {@link org.apache.fop.apps.FopFactory#newFOUserAgent() newFOUserAgent()}.
  151. * <p>
  152. * MIME types are used to select the output format (ex. "application/pdf" for PDF). You can
  153. * use the constants defined in {@link MimeConstants}.
  154. * @param outputFormat the MIME type of the output format to use (ex. "application/pdf").
  155. * @param stream the output stream
  156. * @return the new Fop instance
  157. * @throws FOPException when the constructor fails
  158. */
  159. public Fop newFop(String outputFormat, OutputStream stream) throws FOPException {
  160. return new Fop(outputFormat, this, stream);
  161. }
  162. /**
  163. * Returns a new {@link Fop} instance. Use this factory method if you want to configure this
  164. * very rendering run, i.e. if you want to set some metadata like the title and author of the
  165. * document you want to render. In that case, create a new {@link FOUserAgent}
  166. * instance using {@link org.apache.fop.apps.FopFactory#newFOUserAgent() newFOUserAgent()}.
  167. * <p>
  168. * MIME types are used to select the output format (ex. "application/pdf" for PDF). You can
  169. * use the constants defined in {@link MimeConstants}.
  170. * @param outputFormat the MIME type of the output format to use (ex. "application/pdf").
  171. * @return the new Fop instance
  172. * @throws FOPException when the constructor fails
  173. */
  174. public Fop newFop(String outputFormat) throws FOPException {
  175. return newFop(outputFormat, null);
  176. }
  177. /**
  178. * Returns the resource resolver.
  179. *
  180. * @return the resource resolver
  181. */
  182. public InternalResourceResolver getResourceResolver() {
  183. return resourceResolver;
  184. }
  185. // ---------------------------------------------- rendering-run dependent stuff
  186. /**
  187. * Sets an explicit document handler to use which overrides the one that would be
  188. * selected by default.
  189. * @param documentHandler the document handler instance to use
  190. */
  191. public void setDocumentHandlerOverride(IFDocumentHandler documentHandler) {
  192. if (isAccessibilityEnabled()) {
  193. setStructureTreeEventHandler(documentHandler.getStructureTreeEventHandler());
  194. }
  195. this.documentHandlerOverride = documentHandler;
  196. }
  197. /**
  198. * Returns the overriding {@link IFDocumentHandler} instance, if any.
  199. * @return the overriding document handler or null
  200. */
  201. public IFDocumentHandler getDocumentHandlerOverride() {
  202. return this.documentHandlerOverride;
  203. }
  204. /**
  205. * Sets an explicit renderer to use which overrides the one defined by the
  206. * render type setting.
  207. * @param renderer the Renderer instance to use
  208. */
  209. public void setRendererOverride(Renderer renderer) {
  210. this.rendererOverride = renderer;
  211. }
  212. /**
  213. * Returns the overriding Renderer instance, if any.
  214. * @return the overriding Renderer or null
  215. */
  216. public Renderer getRendererOverride() {
  217. return rendererOverride;
  218. }
  219. /**
  220. * Sets an explicit FOEventHandler instance which overrides the one
  221. * defined by the render type setting.
  222. * @param handler the FOEventHandler instance
  223. */
  224. public void setFOEventHandlerOverride(FOEventHandler handler) {
  225. this.foEventHandlerOverride = handler;
  226. }
  227. /**
  228. * Returns the overriding FOEventHandler instance, if any.
  229. * @return the overriding FOEventHandler or null
  230. */
  231. public FOEventHandler getFOEventHandlerOverride() {
  232. return this.foEventHandlerOverride;
  233. }
  234. /**
  235. * Sets the producer of the document.
  236. * @param producer source of document
  237. */
  238. public void setProducer(String producer) {
  239. this.producer = producer;
  240. }
  241. /**
  242. * Returns the producer of the document
  243. * @return producer name
  244. */
  245. public String getProducer() {
  246. return producer;
  247. }
  248. /**
  249. * Sets the creator of the document.
  250. * @param creator of document
  251. */
  252. public void setCreator(String creator) {
  253. this.creator = creator;
  254. }
  255. /**
  256. * Returns the creator of the document
  257. * @return creator name
  258. */
  259. public String getCreator() {
  260. return creator;
  261. }
  262. /**
  263. * Sets the creation date of the document.
  264. * @param creationDate date of document
  265. */
  266. public void setCreationDate(Date creationDate) {
  267. this.creationDate = creationDate;
  268. }
  269. /**
  270. * Returns the creation date of the document
  271. * @return creation date of document
  272. */
  273. public Date getCreationDate() {
  274. return creationDate;
  275. }
  276. /**
  277. * Sets the author of the document.
  278. * @param author of document
  279. */
  280. public void setAuthor(String author) {
  281. this.author = author;
  282. }
  283. /**
  284. * Returns the author of the document
  285. * @return author name
  286. */
  287. public String getAuthor() {
  288. return author;
  289. }
  290. /**
  291. * Sets the title of the document. This will override any title coming from
  292. * an fo:title element.
  293. * @param title of document
  294. */
  295. public void setTitle(String title) {
  296. this.title = title;
  297. }
  298. /**
  299. * Returns the title of the document
  300. * @return title name
  301. */
  302. public String getTitle() {
  303. return title;
  304. }
  305. /**
  306. * Sets the subject of the document.
  307. * @param subject of document
  308. */
  309. public void setSubject(String subject) {
  310. this.subject = subject;
  311. }
  312. /**
  313. * Returns the subject of the document
  314. * @return the subject
  315. */
  316. public String getSubject() {
  317. return subject;
  318. }
  319. /**
  320. * Sets the keywords for the document.
  321. * @param keywords for the document
  322. */
  323. public void setKeywords(String keywords) {
  324. this.keywords = keywords;
  325. }
  326. /**
  327. * Returns the keywords for the document
  328. * @return the keywords
  329. */
  330. public String getKeywords() {
  331. return keywords;
  332. }
  333. /**
  334. * Returns the renderer options
  335. * @return renderer options
  336. */
  337. public Map getRendererOptions() {
  338. return rendererOptions;
  339. }
  340. /**
  341. * Gets the renderer options given an interface representing renderer configuration options.
  342. *
  343. * @param option the renderer option
  344. * @return the value
  345. */
  346. public Object getRendererOption(RendererConfigOption option) {
  347. return rendererOptions.get(option.getName());
  348. }
  349. /**
  350. * Attempts to resolve the given URI.
  351. * Will use the configured resolver and if not successful fall back
  352. * to the default resolver.
  353. * @param uri URI to access
  354. * @return A {@link javax.xml.transform.Source} object, or null if the URI
  355. * cannot be resolved.
  356. */
  357. public StreamSource resolveURI(String uri) {
  358. // TODO: What do we want to do when resources aren't found??? We also need to remove this
  359. // method entirely
  360. try {
  361. // Have to do this so we can resolve data URIs
  362. StreamSource src = new StreamSource(resourceResolver.getResource(uri));
  363. src.setSystemId(uri);
  364. return src;
  365. } catch (URISyntaxException use) {
  366. return null;
  367. } catch (IOException ioe) {
  368. return null;
  369. }
  370. }
  371. /**
  372. * Sets the output File.
  373. * @param f the output File
  374. */
  375. public void setOutputFile(File f) {
  376. this.outputFile = f;
  377. }
  378. /**
  379. * Gets the output File.
  380. * @return the output File
  381. */
  382. public File getOutputFile() {
  383. return outputFile;
  384. }
  385. /**
  386. * Returns the conversion factor from pixel units to millimeters. This
  387. * depends on the desired target resolution.
  388. * @return float conversion factor
  389. * @see #getTargetResolution()
  390. */
  391. public float getTargetPixelUnitToMillimeter() {
  392. return UnitConv.IN2MM / this.targetResolution;
  393. }
  394. /** @return the resolution for resolution-dependant output */
  395. public float getTargetResolution() {
  396. return this.targetResolution;
  397. }
  398. /**
  399. * Sets the target resolution in dpi. This value defines the target resolution of
  400. * bitmap images generated by the bitmap renderers (such as the TIFF renderer) and of
  401. * bitmap images generated by filter effects in Apache Batik.
  402. * @param dpi resolution in dpi
  403. */
  404. public void setTargetResolution(float dpi) {
  405. this.targetResolution = dpi;
  406. if (log.isDebugEnabled()) {
  407. log.debug("target-resolution set to: " + targetResolution
  408. + "dpi (px2mm=" + getTargetPixelUnitToMillimeter() + ")");
  409. }
  410. }
  411. /**
  412. * Sets the target resolution in dpi. This value defines the target resolution of
  413. * bitmap images generated by the bitmap renderers (such as the TIFF renderer) and of
  414. * bitmap images generated by filter effects in Apache Batik.
  415. * @param dpi resolution in dpi
  416. */
  417. public void setTargetResolution(int dpi) {
  418. setTargetResolution((float)dpi);
  419. }
  420. /**
  421. * Returns the image session context for the image package.
  422. * @return the ImageSessionContext instance for this rendering run
  423. */
  424. public ImageSessionContext getImageSessionContext() {
  425. return this.imageSessionContext;
  426. }
  427. // ---------------------------------------------- environment-level stuff
  428. // (convenience access to FopFactory methods)
  429. /**
  430. * Returns the conversion factor from pixel units to millimeters. This
  431. * depends on the desired source resolution.
  432. * @return float conversion factor
  433. * @see #getSourceResolution()
  434. */
  435. public float getSourcePixelUnitToMillimeter() {
  436. return factory.getSourcePixelUnitToMillimeter();
  437. }
  438. /** @return the resolution for resolution-dependant input */
  439. public float getSourceResolution() {
  440. return factory.getSourceResolution();
  441. }
  442. /**
  443. * Gets the default page-height to use as fallback,
  444. * in case page-height="auto"
  445. *
  446. * @return the page-height, as a String
  447. * @see FopFactory#getPageHeight()
  448. */
  449. public String getPageHeight() {
  450. return factory.getPageHeight();
  451. }
  452. /**
  453. * Gets the default page-width to use as fallback,
  454. * in case page-width="auto"
  455. *
  456. * @return the page-width, as a String
  457. * @see FopFactory#getPageWidth()
  458. */
  459. public String getPageWidth() {
  460. return factory.getPageWidth();
  461. }
  462. /**
  463. * Returns whether FOP is strictly validating input XSL
  464. * @return true of strict validation turned on, false otherwise
  465. * @see FopFactory#validateStrictly()
  466. */
  467. public boolean validateStrictly() {
  468. return factory.validateStrictly();
  469. }
  470. /**
  471. * @return true if the indent inheritance should be broken when crossing reference area
  472. * boundaries (for more info, see the javadoc for the relative member variable)
  473. * @see FopFactory#isBreakIndentInheritanceOnReferenceAreaBoundary()
  474. */
  475. public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() {
  476. return factory.isBreakIndentInheritanceOnReferenceAreaBoundary();
  477. }
  478. /**
  479. * @return the RendererFactory
  480. */
  481. public RendererFactory getRendererFactory() {
  482. return factory.getRendererFactory();
  483. }
  484. /**
  485. * @return the XML handler registry
  486. */
  487. public XMLHandlerRegistry getXMLHandlerRegistry() {
  488. return factory.getXMLHandlerRegistry();
  489. }
  490. /**
  491. * Controls the use of SAXLocators to provide location information in error
  492. * messages.
  493. *
  494. * @param enableLocator <code>false</code> if SAX Locators should be disabled
  495. */
  496. public void setLocatorEnabled(boolean enableLocator) {
  497. locatorEnabled = enableLocator;
  498. }
  499. /**
  500. * Checks if the use of Locators is enabled
  501. * @return true if context information should be stored on each node in the FO tree.
  502. */
  503. public boolean isLocatorEnabled() {
  504. return locatorEnabled;
  505. }
  506. /**
  507. * Returns the event broadcaster that control events sent inside a processing run. Clients
  508. * can register event listeners with the event broadcaster to listen for events that occur
  509. * while a document is being processed.
  510. * @return the event broadcaster.
  511. */
  512. public EventBroadcaster getEventBroadcaster() {
  513. return this.eventBroadcaster;
  514. }
  515. public boolean isPdfUAEnabled() {
  516. return pdfUAEnabled;
  517. }
  518. public void setPdfUAEnabled(boolean pdfUAEnabled) {
  519. this.pdfUAEnabled = pdfUAEnabled;
  520. }
  521. private class FOPEventBroadcaster extends DefaultEventBroadcaster {
  522. private EventListener rootListener;
  523. public FOPEventBroadcaster() {
  524. //Install a temporary event listener that catches the first event to
  525. //do some initialization.
  526. this.rootListener = new EventListener() {
  527. public void processEvent(Event event) {
  528. if (!listeners.hasEventListeners()) {
  529. //Backwards-compatibility: Make sure at least the LoggingEventListener is
  530. //plugged in so no events are just silently swallowed.
  531. addEventListener(
  532. new LoggingEventListener(LogFactory.getLog(FOUserAgent.class)));
  533. }
  534. //Replace with final event listener
  535. rootListener = new FOPEventListenerProxy(
  536. listeners, FOUserAgent.this);
  537. rootListener.processEvent(event);
  538. }
  539. };
  540. }
  541. /** {@inheritDoc} */
  542. public void broadcastEvent(Event event) {
  543. rootListener.processEvent(event);
  544. }
  545. }
  546. /**
  547. * Check whether memory-conservation is enabled.
  548. *
  549. * @return true if FOP is to conserve as much as possible
  550. */
  551. public boolean isConserveMemoryPolicyEnabled() {
  552. return this.conserveMemoryPolicy;
  553. }
  554. /**
  555. * Control whether memory-conservation should be enabled
  556. *
  557. * @param conserveMemoryPolicy the cachingEnabled to set
  558. */
  559. public void setConserveMemoryPolicy(boolean conserveMemoryPolicy) {
  560. this.conserveMemoryPolicy = conserveMemoryPolicy;
  561. }
  562. /**
  563. * Check whether complex script features are enabled.
  564. *
  565. * @return true if FOP is to use complex script features
  566. */
  567. public boolean isComplexScriptFeaturesEnabled() {
  568. return factory.isComplexScriptFeaturesEnabled();
  569. }
  570. /**
  571. * Returns the renderer configuration object for a particular MIME type.
  572. *
  573. * @param mimeType the config MIME type
  574. * @param configCreator the parser for creating the config for the first run of parsing.
  575. * @return the renderer configuration object
  576. * @throws FOPException if an error occurs when creating the config object
  577. */
  578. public RendererConfig getRendererConfig(String mimeType, RendererConfigParser configCreator)
  579. throws FOPException {
  580. return factory.getRendererConfig(this, getRendererConfiguration(mimeType), configCreator);
  581. }
  582. /**
  583. * Returns a {@link Configuration} object for which contains renderer configuration for a given
  584. * MIME type.
  585. *
  586. * @param mimeType the renderer configuration MIME type
  587. * @return the configuration object
  588. */
  589. public Configuration getRendererConfiguration(String mimeType) {
  590. Configuration cfg = getUserConfig();
  591. String type = "renderer";
  592. String mime = "mime";
  593. if (cfg == null) {
  594. if (log.isDebugEnabled()) {
  595. log.debug("userconfig is null");
  596. }
  597. return null;
  598. }
  599. Configuration userConfig = null;
  600. Configuration[] cfgs = cfg.getChild(type + "s").getChildren(type);
  601. for (Configuration child : cfgs) {
  602. try {
  603. if (child.getAttribute(mime).equals(mimeType)) {
  604. userConfig = child;
  605. break;
  606. }
  607. } catch (ConfigurationException e) {
  608. // silently pass over configurations without mime type
  609. }
  610. }
  611. log.debug((userConfig == null ? "No u" : "U")
  612. + "ser configuration found for MIME type " + mimeType);
  613. return userConfig;
  614. }
  615. /**
  616. * Activates accessibility (for output formats that support it).
  617. *
  618. * @param accessibility <code>true</code> to enable accessibility support
  619. */
  620. public void setAccessibility(boolean accessibility) {
  621. if (accessibility) {
  622. getRendererOptions().put(Accessibility.ACCESSIBILITY, Boolean.TRUE);
  623. }
  624. }
  625. /**
  626. * Check if accessibility is enabled.
  627. * @return true if accessibility is enabled
  628. */
  629. public boolean isAccessibilityEnabled() {
  630. Boolean enabled = (Boolean)this.getRendererOptions().get(Accessibility.ACCESSIBILITY);
  631. if (enabled != null) {
  632. return enabled;
  633. } else {
  634. return false;
  635. }
  636. }
  637. /**
  638. * Sets the document's structure tree event handler, for use by accessible
  639. * output formats.
  640. *
  641. * @param structureTreeEventHandler The structure tree event handler to set
  642. */
  643. public void setStructureTreeEventHandler(StructureTreeEventHandler structureTreeEventHandler) {
  644. this.structureTreeEventHandler = structureTreeEventHandler;
  645. }
  646. /**
  647. * Returns the document's structure tree event handler, for use by
  648. * accessible output formats.
  649. *
  650. * @return The structure tree event handler
  651. */
  652. public StructureTreeEventHandler getStructureTreeEventHandler() {
  653. return this.structureTreeEventHandler;
  654. }
  655. /** @see FopFactory#getLayoutManagerMakerOverride() */
  656. public LayoutManagerMaker getLayoutManagerMakerOverride() {
  657. return factory.getLayoutManagerMakerOverride();
  658. }
  659. /** @see FopFactory#getContentHandlerFactoryRegistry() */
  660. public ContentHandlerFactoryRegistry getContentHandlerFactoryRegistry() {
  661. return factory.getContentHandlerFactoryRegistry();
  662. }
  663. /** @see FopFactory#getImageManager() */
  664. public ImageManager getImageManager() {
  665. return factory.getImageManager();
  666. }
  667. /** @see FopFactory#getElementMappingRegistry() */
  668. public ElementMappingRegistry getElementMappingRegistry() {
  669. return factory.getElementMappingRegistry();
  670. }
  671. /** @see FopFactory#getFontManager() */
  672. public FontManager getFontManager() {
  673. return factory.getFontManager();
  674. }
  675. /**
  676. * Indicates whether a namespace URI is on the ignored list.
  677. * @param namespaceURI the namespace URI
  678. * @return true if the namespace is ignored by FOP
  679. */
  680. public boolean isNamespaceIgnored(String namespaceURI) {
  681. return factory.isNamespaceIgnored(namespaceURI);
  682. }
  683. /**
  684. * Is the user configuration to be validated?
  685. * @return if the user configuration should be validated
  686. */
  687. public boolean validateUserConfigStrictly() {
  688. return factory.validateUserConfigStrictly();
  689. }
  690. /**
  691. * Get the user configuration.
  692. * @return the user configuration
  693. */
  694. public Configuration getUserConfig() {
  695. return factory.getUserConfig();
  696. }
  697. /** @return the image handler registry */
  698. public ImageHandlerRegistry getImageHandlerRegistry() {
  699. return factory.getImageHandlerRegistry();
  700. }
  701. /** @return the color space cache */
  702. public ColorSpaceCache getColorSpaceCache() {
  703. return factory.getColorSpaceCache();
  704. }
  705. /** @see FopFactory#getHyphenationPatternNames() */
  706. public Map<String, String> getHyphenationPatternNames() {
  707. return factory.getHyphenationPatternNames();
  708. }
  709. public InternalResourceResolver getHyphenationResourceResolver() {
  710. return factory.getHyphenationResourceResolver();
  711. }
  712. public SoftMapCache getPDFObjectCache() {
  713. return pdfObjectCache;
  714. }
  715. }