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 = 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 org.apache.fop.apps.FopFactory#newFOUserAgent() 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 org.apache.fop.apps.FopFactory#newFOUserAgent() 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(RendererConfigOption 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 StreamSource resolveURI(String uri) {
  354. // TODO: What do we want to do when resources aren't found??? We also need to remove this
  355. // method entirely
  356. try {
  357. // Have to do this so we can resolve data URIs
  358. StreamSource src = new StreamSource(resourceResolver.getResource(uri));
  359. src.setSystemId(uri);
  360. return src;
  361. } catch (URISyntaxException use) {
  362. return null;
  363. } catch (IOException ioe) {
  364. return null;
  365. }
  366. }
  367. /**
  368. * Sets the output File.
  369. * @param f the output File
  370. */
  371. public void setOutputFile(File f) {
  372. this.outputFile = f;
  373. }
  374. /**
  375. * Gets the output File.
  376. * @return the output File
  377. */
  378. public File getOutputFile() {
  379. return outputFile;
  380. }
  381. /**
  382. * Returns the conversion factor from pixel units to millimeters. This
  383. * depends on the desired target resolution.
  384. * @return float conversion factor
  385. * @see #getTargetResolution()
  386. */
  387. public float getTargetPixelUnitToMillimeter() {
  388. return UnitConv.IN2MM / this.targetResolution;
  389. }
  390. /** @return the resolution for resolution-dependant output */
  391. public float getTargetResolution() {
  392. return this.targetResolution;
  393. }
  394. /**
  395. * Sets the target resolution in dpi. This value defines the target resolution of
  396. * bitmap images generated by the bitmap renderers (such as the TIFF renderer) and of
  397. * bitmap images generated by filter effects in Apache Batik.
  398. * @param dpi resolution in dpi
  399. */
  400. public void setTargetResolution(float dpi) {
  401. this.targetResolution = dpi;
  402. if (log.isDebugEnabled()) {
  403. log.debug("target-resolution set to: " + targetResolution
  404. + "dpi (px2mm=" + getTargetPixelUnitToMillimeter() + ")");
  405. }
  406. }
  407. /**
  408. * Sets the target resolution in dpi. This value defines the target resolution of
  409. * bitmap images generated by the bitmap renderers (such as the TIFF renderer) and of
  410. * bitmap images generated by filter effects in Apache Batik.
  411. * @param dpi resolution in dpi
  412. */
  413. public void setTargetResolution(int dpi) {
  414. setTargetResolution((float)dpi);
  415. }
  416. /**
  417. * Returns the image session context for the image package.
  418. * @return the ImageSessionContext instance for this rendering run
  419. */
  420. public ImageSessionContext getImageSessionContext() {
  421. return this.imageSessionContext;
  422. }
  423. // ---------------------------------------------- environment-level stuff
  424. // (convenience access to FopFactory methods)
  425. /**
  426. * Returns the conversion factor from pixel units to millimeters. This
  427. * depends on the desired source resolution.
  428. * @return float conversion factor
  429. * @see #getSourceResolution()
  430. */
  431. public float getSourcePixelUnitToMillimeter() {
  432. return factory.getSourcePixelUnitToMillimeter();
  433. }
  434. /** @return the resolution for resolution-dependant input */
  435. public float getSourceResolution() {
  436. return factory.getSourceResolution();
  437. }
  438. /**
  439. * Gets the default page-height to use as fallback,
  440. * in case page-height="auto"
  441. *
  442. * @return the page-height, as a String
  443. * @see FopFactory#getPageHeight()
  444. */
  445. public String getPageHeight() {
  446. return factory.getPageHeight();
  447. }
  448. /**
  449. * Gets the default page-width to use as fallback,
  450. * in case page-width="auto"
  451. *
  452. * @return the page-width, as a String
  453. * @see FopFactory#getPageWidth()
  454. */
  455. public String getPageWidth() {
  456. return factory.getPageWidth();
  457. }
  458. /**
  459. * Returns whether FOP is strictly validating input XSL
  460. * @return true of strict validation turned on, false otherwise
  461. * @see FopFactory#validateStrictly()
  462. */
  463. public boolean validateStrictly() {
  464. return factory.validateStrictly();
  465. }
  466. /**
  467. * @return true if the indent inheritance should be broken when crossing reference area
  468. * boundaries (for more info, see the javadoc for the relative member variable)
  469. * @see FopFactory#isBreakIndentInheritanceOnReferenceAreaBoundary()
  470. */
  471. public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() {
  472. return factory.isBreakIndentInheritanceOnReferenceAreaBoundary();
  473. }
  474. /**
  475. * @return the RendererFactory
  476. */
  477. public RendererFactory getRendererFactory() {
  478. return factory.getRendererFactory();
  479. }
  480. /**
  481. * @return the XML handler registry
  482. */
  483. public XMLHandlerRegistry getXMLHandlerRegistry() {
  484. return factory.getXMLHandlerRegistry();
  485. }
  486. /**
  487. * Controls the use of SAXLocators to provide location information in error
  488. * messages.
  489. *
  490. * @param enableLocator <code>false</code> if SAX Locators should be disabled
  491. */
  492. public void setLocatorEnabled(boolean enableLocator) {
  493. locatorEnabled = enableLocator;
  494. }
  495. /**
  496. * Checks if the use of Locators is enabled
  497. * @return true if context information should be stored on each node in the FO tree.
  498. */
  499. public boolean isLocatorEnabled() {
  500. return locatorEnabled;
  501. }
  502. /**
  503. * Returns the event broadcaster that control events sent inside a processing run. Clients
  504. * can register event listeners with the event broadcaster to listen for events that occur
  505. * while a document is being processed.
  506. * @return the event broadcaster.
  507. */
  508. public EventBroadcaster getEventBroadcaster() {
  509. return this.eventBroadcaster;
  510. }
  511. private class FOPEventBroadcaster extends DefaultEventBroadcaster {
  512. private EventListener rootListener;
  513. public FOPEventBroadcaster() {
  514. //Install a temporary event listener that catches the first event to
  515. //do some initialization.
  516. this.rootListener = new EventListener() {
  517. public void processEvent(Event event) {
  518. if (!listeners.hasEventListeners()) {
  519. //Backwards-compatibility: Make sure at least the LoggingEventListener is
  520. //plugged in so no events are just silently swallowed.
  521. addEventListener(
  522. new LoggingEventListener(LogFactory.getLog(FOUserAgent.class)));
  523. }
  524. //Replace with final event listener
  525. rootListener = new FOPEventListenerProxy(
  526. listeners, FOUserAgent.this);
  527. rootListener.processEvent(event);
  528. }
  529. };
  530. }
  531. /** {@inheritDoc} */
  532. public void broadcastEvent(Event event) {
  533. rootListener.processEvent(event);
  534. }
  535. }
  536. /**
  537. * Check whether memory-conservation is enabled.
  538. *
  539. * @return true if FOP is to conserve as much as possible
  540. */
  541. public boolean isConserveMemoryPolicyEnabled() {
  542. return this.conserveMemoryPolicy;
  543. }
  544. /**
  545. * Control whether memory-conservation should be enabled
  546. *
  547. * @param conserveMemoryPolicy the cachingEnabled to set
  548. */
  549. public void setConserveMemoryPolicy(boolean conserveMemoryPolicy) {
  550. this.conserveMemoryPolicy = conserveMemoryPolicy;
  551. }
  552. /**
  553. * Check whether complex script features are enabled.
  554. *
  555. * @return true if FOP is to use complex script features
  556. */
  557. public boolean isComplexScriptFeaturesEnabled() {
  558. return factory.isComplexScriptFeaturesEnabled();
  559. }
  560. /**
  561. * Returns the renderer configuration object for a particular MIME type.
  562. *
  563. * @param mimeType the config MIME type
  564. * @param configCreator the parser for creating the config for the first run of parsing.
  565. * @return the renderer configuration object
  566. * @throws FOPException if an error occurs when creating the config object
  567. */
  568. public RendererConfig getRendererConfig(String mimeType, RendererConfigParser configCreator)
  569. throws FOPException {
  570. return factory.getRendererConfig(this, getRendererConfiguration(mimeType), configCreator);
  571. }
  572. /**
  573. * Returns a {@link Configuration} object for which contains renderer configuration for a given
  574. * MIME type.
  575. *
  576. * @param mimeType the renderer configuration MIME type
  577. * @return the configuration object
  578. */
  579. public Configuration getRendererConfiguration(String mimeType) {
  580. Configuration cfg = getUserConfig();
  581. String type = "renderer";
  582. String mime = "mime";
  583. if (cfg == null) {
  584. if (log.isDebugEnabled()) {
  585. log.debug("userconfig is null");
  586. }
  587. return null;
  588. }
  589. Configuration userConfig = null;
  590. Configuration[] cfgs = cfg.getChild(type + "s").getChildren(type);
  591. for (int i = 0; i < cfgs.length; ++i) {
  592. Configuration child = cfgs[i];
  593. try {
  594. if (child.getAttribute(mime).equals(mimeType)) {
  595. userConfig = child;
  596. break;
  597. }
  598. } catch (ConfigurationException e) {
  599. // silently pass over configurations without mime type
  600. }
  601. }
  602. log.debug((userConfig == null ? "No u" : "U")
  603. + "ser configuration found for MIME type " + mimeType);
  604. return userConfig;
  605. }
  606. /**
  607. * Activates accessibility (for output formats that support it).
  608. *
  609. * @param accessibility <code>true</code> to enable accessibility support
  610. */
  611. public void setAccessibility(boolean accessibility) {
  612. if (accessibility) {
  613. getRendererOptions().put(Accessibility.ACCESSIBILITY, Boolean.TRUE);
  614. }
  615. }
  616. /**
  617. * Check if accessibility is enabled.
  618. * @return true if accessibility is enabled
  619. */
  620. public boolean isAccessibilityEnabled() {
  621. Boolean enabled = (Boolean)this.getRendererOptions().get(Accessibility.ACCESSIBILITY);
  622. if (enabled != null) {
  623. return enabled.booleanValue();
  624. } else {
  625. return false;
  626. }
  627. }
  628. /**
  629. * Sets the document's structure tree event handler, for use by accessible
  630. * output formats.
  631. *
  632. * @param structureTreeEventHandler The structure tree event handler to set
  633. */
  634. public void setStructureTreeEventHandler(StructureTreeEventHandler structureTreeEventHandler) {
  635. this.structureTreeEventHandler = structureTreeEventHandler;
  636. }
  637. /**
  638. * Returns the document's structure tree event handler, for use by
  639. * accessible output formats.
  640. *
  641. * @return The structure tree event handler
  642. */
  643. public StructureTreeEventHandler getStructureTreeEventHandler() {
  644. return this.structureTreeEventHandler;
  645. }
  646. /** @see FopFactory#getLayoutManagerMakerOverride() */
  647. public LayoutManagerMaker getLayoutManagerMakerOverride() {
  648. return factory.getLayoutManagerMakerOverride();
  649. }
  650. /** @see FopFactory#getContentHandlerFactoryRegistry() */
  651. public ContentHandlerFactoryRegistry getContentHandlerFactoryRegistry() {
  652. return factory.getContentHandlerFactoryRegistry();
  653. }
  654. /** @see FopFactory#getImageManager() */
  655. public ImageManager getImageManager() {
  656. return factory.getImageManager();
  657. }
  658. /** @see FopFactory#getElementMappingRegistry() */
  659. public ElementMappingRegistry getElementMappingRegistry() {
  660. return factory.getElementMappingRegistry();
  661. }
  662. /** @see FopFactory#getFontManager() */
  663. public FontManager getFontManager() {
  664. return factory.getFontManager();
  665. }
  666. /**
  667. * Indicates whether a namespace URI is on the ignored list.
  668. * @param namespaceURI the namespace URI
  669. * @return true if the namespace is ignored by FOP
  670. */
  671. public boolean isNamespaceIgnored(String namespaceURI) {
  672. return factory.isNamespaceIgnored(namespaceURI);
  673. }
  674. /**
  675. * Is the user configuration to be validated?
  676. * @return if the user configuration should be validated
  677. */
  678. public boolean validateUserConfigStrictly() {
  679. return factory.validateUserConfigStrictly();
  680. }
  681. /**
  682. * Get the user configuration.
  683. * @return the user configuration
  684. */
  685. public Configuration getUserConfig() {
  686. return factory.getUserConfig();
  687. }
  688. /** @return the image handler registry */
  689. public ImageHandlerRegistry getImageHandlerRegistry() {
  690. return factory.getImageHandlerRegistry();
  691. }
  692. /** @return the color space cache */
  693. public ColorSpaceCache getColorSpaceCache() {
  694. return factory.getColorSpaceCache();
  695. }
  696. /** @see FopFactory#getHyphenationPatternNames() */
  697. public Map<String, String> getHyphenationPatternNames() {
  698. return factory.getHyphenationPatternNames();
  699. }
  700. }