Browse Source

Remove all storage of fo/FOInputHandler from within the FO Tree itself, in favor of storing it one time in apps/Document and getting it from there when needed. Makes everything cleaner, and uses less memory, at the probable expense of some processing time (to go up the tree to get to Document).


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196887 13f79535-47bb-0310-9956-ffa450edef68
pull/30/head
William Victor Mote 21 years ago
parent
commit
fa38778ac0

+ 14
- 1
src/java/org/apache/fop/apps/Document.java View File

@@ -62,6 +62,7 @@ import org.apache.fop.area.AreaTree;
import org.apache.fop.area.AreaTreeModel;

import org.apache.fop.fo.extensions.Bookmarks;
import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.fo.FOTreeEvent;
import org.apache.fop.fo.FOTreeListener;
@@ -111,6 +112,12 @@ public class Document implements FOTreeControl, FOTreeListener {
*/
private Set idReferences = new HashSet();

/**
* Structure handler used to notify structure events
* such as start end element.
*/
public FOInputHandler foInputHandler;

/**
* Main constructor
* @param driver the Driver object that is the "parent" of this Document
@@ -383,5 +390,11 @@ public class Document implements FOTreeControl, FOTreeListener {
return idReferences;
}

}
/**
* @return the FOInputHandler for parsing this FO Tree
*/
public FOInputHandler getFOInputHandler() {
return foInputHandler;
}

}

+ 1
- 0
src/java/org/apache/fop/apps/Driver.java View File

@@ -576,6 +576,7 @@ public class Driver implements LogEnabled {
currentDocument = new Document(this);
}
parser.setContentHandler(getContentHandler());
currentDocument.foInputHandler = foInputHandler;
/** LayoutStrategy is hard-wired for now, but needs to be made
accessible through the API and/or configuration */
if (foInputHandler instanceof FOTreeHandler) {

+ 0
- 7
src/java/org/apache/fop/fo/FONode.java View File

@@ -117,13 +117,6 @@ public abstract class FONode {
return userAgent;
}

/**
* Sets the structure handler to send events to.
* @param foih FOInputHandler instance
*/
public void setFOInputHandler(FOInputHandler foih) {
}

/**
* Do something with the attributes for this element
* @param attlist Collection of attributes passed to us from the parser.

+ 1
- 6
src/java/org/apache/fop/fo/FOText.java View File

@@ -76,7 +76,7 @@ public class FOText extends FObj {
* the character array containing the text
*/
public char[] ca;
private int start;
public int start;

/**
* the length of the character array containing the text
@@ -139,11 +139,6 @@ public class FOText extends FObj {
textTransform();
}

public void setFOInputHandler(FOInputHandler foih) {
super.setFOInputHandler(foih);
foInputHandler.characters(ca, start, length);
}

/**
* Check if this text node will create an area.
* This means either there is non-whitespace or it is

+ 0
- 1
src/java/org/apache/fop/fo/FOTreeBuilder.java View File

@@ -282,7 +282,6 @@ public class FOTreeBuilder extends DefaultHandler {
fobj.setUserAgent(userAgent);
// set the structure handler so that appropriate
// elements can signal structure events
fobj.setFOInputHandler(foInputHandler);

fobj.handleAttrs(attlist);
} catch (FOPException e) {

+ 4
- 0
src/java/org/apache/fop/fo/FOTreeControl.java View File

@@ -114,4 +114,8 @@ public interface FOTreeControl {
*/
Set getIDReferences();

/**
* @return the FOInputHandler for parsing this FO Tree
*/
FOInputHandler getFOInputHandler();
}

+ 0
- 19
src/java/org/apache/fop/fo/FObj.java View File

@@ -78,12 +78,6 @@ public class FObj extends FONode {
*/
protected static PropertyListBuilder plb = null;

/**
* Structure handler used to notify structure events
* such as start end element.
*/
protected FOInputHandler foInputHandler;

/**
* Formatting properties for this fo element.
*/
@@ -251,19 +245,6 @@ public class FObj extends FONode {
}
}

/**
* Set the structure handler for handling structure events.
*
* @param st the structure handler
*/
public void setFOInputHandler(FOInputHandler foih) {
foInputHandler = foih;
}

public FOInputHandler getFOInputHandler() {
return foInputHandler;
}

/**
* lets outside sources access the property list
* first used by PageNumberCitation to find the "id" property

+ 1
- 11
src/java/org/apache/fop/fo/FObjMixed.java View File

@@ -57,8 +57,6 @@ package org.apache.fop.fo;
public class FObjMixed extends FObj {
/** TextInfo for this object */
protected TextInfo textInfo = null;
/** FontInfo for this object */
protected FOTreeControl fontInfo = null;

/**
* @param parent FONode that is the parent of this object
@@ -67,14 +65,6 @@ public class FObjMixed extends FObj {
super(parent);
}

/**
* @param foih FOInputHandler to set
*/
public void setFOInputHandler(FOInputHandler foih) {
super.setFOInputHandler(foih);
fontInfo = foih.getFontInfo();
}

/**
* @param data array of characters containing text to be added
* @param start starting array element to add
@@ -90,7 +80,7 @@ public class FObjMixed extends FObj {

FOText ft = new FOText(data, start, length, textInfo, this);
ft.setUserAgent(userAgent);
ft.setFOInputHandler(foInputHandler);
getFOTreeControl().getFOInputHandler().characters(ft.ca, ft.start, ft.length);
addChild(ft);
}


+ 2
- 2
src/java/org/apache/fop/fo/flow/Block.java View File

@@ -143,7 +143,7 @@ public class Block extends FObjMixed {

setupID();

foInputHandler.startBlock(this);
getFOTreeControl().getFOInputHandler().startBlock(this);
}

private void setup() {
@@ -270,7 +270,7 @@ public class Block extends FObjMixed {
*/
public void end() {
handleWhiteSpace();
foInputHandler.endBlock(this);
getFOTreeControl().getFOInputHandler().endBlock(this);
}

private void handleWhiteSpace() {

+ 1
- 12
src/java/org/apache/fop/fo/flow/Leader.java View File

@@ -79,8 +79,6 @@ public class Leader extends FObjMixed {
private int ruleThickness;
private int leaderPattern;
private int patternWidth;
/** FontInfo for this object */
protected FOTreeControl fontInfo = null;
/** FontState for this object */
protected Font fontState;

@@ -91,15 +89,6 @@ public class Leader extends FObjMixed {
super(parent);
}


/**
* @param foih FOInputHandler to set
*/
public void setFOInputHandler(FOInputHandler foih) {
super.setFOInputHandler(foih);
fontInfo = foih.getFontInfo();
}

public void setup() {

// Common Accessibility Properties
@@ -113,7 +102,7 @@ public class Leader extends FObjMixed {
CommonBackground bProps = propMgr.getBackgroundProps();

// Common Font Properties
this.fontState = propMgr.getFontState(fontInfo);
this.fontState = propMgr.getFontState(getFOTreeControl());

// Common Margin Properties-Inline
CommonMarginInline mProps = propMgr.getMarginInlineProps();

+ 1
- 11
src/java/org/apache/fop/fo/flow/PageNumber.java View File

@@ -71,8 +71,6 @@ import org.apache.fop.fo.FOInputHandler;
* Standard.
*/
public class PageNumber extends FObj {
/** FontInfo for this object */
protected FOTreeControl fontInfo = null;
/** FontState for this object */
protected Font fontState;

@@ -88,14 +86,6 @@ public class PageNumber extends FObj {
super(parent);
}

/**
* @param foih FOInputHandler to be set
*/
public void setFOInputHandler(FOInputHandler foih) {
super.setFOInputHandler(foih);
fontInfo = foih.getFontInfo();
}

public void setup() {

// Common Accessibility Properties
@@ -109,7 +99,7 @@ public class PageNumber extends FObj {
CommonBackground bProps = propMgr.getBackgroundProps();

// Common Font Properties
this.fontState = propMgr.getFontState(fontInfo);
this.fontState = propMgr.getFontState(getFOTreeControl());

// Common Margin Properties-Inline
CommonMarginInline mProps = propMgr.getMarginInlineProps();

+ 1
- 11
src/java/org/apache/fop/fo/flow/PageNumberCitation.java View File

@@ -74,8 +74,6 @@ import org.apache.fop.util.CharUtilities;
* block referenced with the ref-id attribute.
*/
public class PageNumberCitation extends FObj {
/** FontInfo for this object **/
protected FOTreeControl fontInfo = null;
/** Fontstate for this object **/
protected Font fontState;

@@ -94,14 +92,6 @@ public class PageNumberCitation extends FObj {
super(parent);
}

/**
* @param foih the FOInputHandler object to set
*/
public void setFOInputHandler(FOInputHandler foih) {
super.setFOInputHandler(foih);
fontInfo = foih.getFontInfo();
}

/**
* @param str string to be measured
* @return width (in millipoints ??) of the string
@@ -128,7 +118,7 @@ public class PageNumberCitation extends FObj {
CommonBackground bProps = propMgr.getBackgroundProps();

// Common Font Properties
this.fontState = propMgr.getFontState(fontInfo);
this.fontState = propMgr.getFontState(getFOTreeControl());

// Common Margin Properties-Inline
CommonMarginInline mProps = propMgr.getMarginInlineProps();

+ 2
- 2
src/java/org/apache/fop/fo/pagination/Flow.java View File

@@ -126,14 +126,14 @@ public class Flow extends FObj {
// Now done in addChild of page-sequence
//pageSequence.addFlow(this);

foInputHandler.startFlow(this);
getFOTreeControl().getFOInputHandler().startFlow(this);
}

/**
* Tell the StructureRenderer that we are at the end of the flow.
*/
public void end() {
foInputHandler.endFlow(this);
getFOTreeControl().getFOInputHandler().endFlow(this);
}

/**

+ 2
- 2
src/java/org/apache/fop/fo/pagination/PageSequence.java View File

@@ -331,7 +331,7 @@ public class PageSequence extends FObj {
*/
private void startStructuredPageSequence() {
if (!sequenceStarted) {
foInputHandler.startPageSequence(this);
getFOTreeControl().getFOInputHandler().startPageSequence(this);
sequenceStarted = true;
}
}
@@ -343,7 +343,7 @@ public class PageSequence extends FObj {
*/
public void end() {
try {
this.foInputHandler.endPageSequence(this);
this.getFOTreeControl().getFOInputHandler().endPageSequence(this);
} catch (FOPException fopex) {
getLogger().error("Error in PageSequence.end(): "
+ fopex.getMessage(), fopex);

+ 1
- 1
src/java/org/apache/fop/fo/pagination/Title.java View File

@@ -91,7 +91,7 @@ public class Title extends FObjMixed {
CommonBackground bProps = propMgr.getBackgroundProps();

// Common Font Properties
Font fontState = propMgr.getFontState(foInputHandler.getFontInfo());
Font fontState = propMgr.getFontState(getFOTreeControl().getFOInputHandler().getFontInfo());

// Common Margin Properties-Inline
CommonMarginInline mProps = propMgr.getMarginInlineProps();

Loading…
Cancel
Save