Sfoglia il codice sorgente

Tweak: allow control over usage of Locators

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@554091 13f79535-47bb-0310-9956-ffa450edef68
pull/36/head
Andreas L. Delmelle 17 anni fa
parent
commit
1d07e61786

+ 21
- 0
src/java/org/apache/fop/apps/FOUserAgent.java Vedi File

@@ -86,6 +86,7 @@ public class FOUserAgent {
private File outputFile = null;
private Renderer rendererOverride = null;
private FOEventHandler foEventHandlerOverride = null;
private boolean locatorEnabled = true; // true by default (for error messages).
/** Producer: Metadata element for the system/software that produces
* the document. (Some renderers can store this in the document.)
@@ -517,5 +518,25 @@ public class FOUserAgent {
public XMLHandlerRegistry getXMLHandlerRegistry() {
return getFactory().getXMLHandlerRegistry();
}
/**
* Controls the use of SAXLocators to provide location information in error
* messages.
*
* @param enableLocator <code>false</code> if SAX Locators should be disabled
* @return true if context information should be stored on each node in the FO tree.
*/
public void setLocatorEnabled(boolean enableLocator) {
locatorEnabled = enableLocator;
}

/**
* Checks if the use of Locators is enabled
* @return true if context information should be stored on each node in the FO tree.
*/
public boolean isLocatorEnabled() {
return locatorEnabled;
}

}


+ 3
- 4
src/java/org/apache/fop/fo/FOTreeBuilder.java Vedi File

@@ -110,11 +110,10 @@ public class FOTreeBuilder extends DefaultHandler {
* true no Locator is passed to the FO tree nodes which would copy the information into
* a SAX LocatorImpl instance.
* @return true if no context information should be stored on each node in the FO tree.
* @deprecated Use FOUserAgent.isLocatorEnabled() instead.
*/
protected boolean isLocatorDisabled() {
//TODO make this configurable through the FOUserAgent so people can optimize memory
//consumption.
return false;
return !userAgent.isLocatorEnabled();
}
/**
@@ -127,7 +126,7 @@ public class FOTreeBuilder extends DefaultHandler {
/** @return a Locator instance if it is available and not disabled */
protected Locator getEffectiveLocator() {
return (isLocatorDisabled() ? null : this.locator);
return (userAgent.isLocatorEnabled() ? this.locator : null);
}
/**

Loading…
Annulla
Salva