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.

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