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

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