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

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