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
tags/Root_Temp_KnuthStylePageBreaking
William Victor Mote 21 years ago
parent
commit
b35e94b1df

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

import org.apache.fop.area.AreaTreeModel; import org.apache.fop.area.AreaTreeModel;


import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fo.extensions.Bookmarks;
import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.fo.FOTreeControl; import org.apache.fop.fo.FOTreeControl;
import org.apache.fop.fo.FOTreeEvent; import org.apache.fop.fo.FOTreeEvent;
import org.apache.fop.fo.FOTreeListener; import org.apache.fop.fo.FOTreeListener;
*/ */
private Set idReferences = new HashSet(); private Set idReferences = new HashSet();


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

/** /**
* Main constructor * Main constructor
* @param driver the Driver object that is the "parent" of this Document * @param driver the Driver object that is the "parent" of this Document
return idReferences; 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

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

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

return userAgent; 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 * Do something with the attributes for this element
* @param attlist Collection of attributes passed to us from the parser. * @param attlist Collection of attributes passed to us from the parser.

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

* the character array containing the text * the character array containing the text
*/ */
public char[] ca; public char[] ca;
private int start;
public int start;


/** /**
* the length of the character array containing the text * the length of the character array containing the text
textTransform(); textTransform();
} }


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

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

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

fobj.setUserAgent(userAgent); fobj.setUserAgent(userAgent);
// set the structure handler so that appropriate // set the structure handler so that appropriate
// elements can signal structure events // elements can signal structure events
fobj.setFOInputHandler(foInputHandler);


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

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

*/ */
Set getIDReferences(); Set getIDReferences();


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

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

*/ */
protected static PropertyListBuilder plb = null; 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. * Formatting properties for this fo element.
*/ */
} }
} }


/**
* 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 * lets outside sources access the property list
* first used by PageNumberCitation to find the "id" property * first used by PageNumberCitation to find the "id" property

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

public class FObjMixed extends FObj { public class FObjMixed extends FObj {
/** TextInfo for this object */ /** TextInfo for this object */
protected TextInfo textInfo = null; protected TextInfo textInfo = null;
/** FontInfo for this object */
protected FOTreeControl fontInfo = null;


/** /**
* @param parent FONode that is the parent of this object * @param parent FONode that is the parent of this object
super(parent); 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 data array of characters containing text to be added
* @param start starting array element to add * @param start starting array element to add


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



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



setupID(); setupID();


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


private void setup() { private void setup() {
*/ */
public void end() { public void end() {
handleWhiteSpace(); handleWhiteSpace();
foInputHandler.endBlock(this);
getFOTreeControl().getFOInputHandler().endBlock(this);
} }


private void handleWhiteSpace() { private void handleWhiteSpace() {

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

private int ruleThickness; private int ruleThickness;
private int leaderPattern; private int leaderPattern;
private int patternWidth; private int patternWidth;
/** FontInfo for this object */
protected FOTreeControl fontInfo = null;
/** FontState for this object */ /** FontState for this object */
protected Font fontState; protected Font fontState;


super(parent); super(parent);
} }



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

public void setup() { public void setup() {


// Common Accessibility Properties // Common Accessibility Properties
CommonBackground bProps = propMgr.getBackgroundProps(); CommonBackground bProps = propMgr.getBackgroundProps();


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


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

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

* Standard. * Standard.
*/ */
public class PageNumber extends FObj { public class PageNumber extends FObj {
/** FontInfo for this object */
protected FOTreeControl fontInfo = null;
/** FontState for this object */ /** FontState for this object */
protected Font fontState; protected Font fontState;


super(parent); super(parent);
} }


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

public void setup() { public void setup() {


// Common Accessibility Properties // Common Accessibility Properties
CommonBackground bProps = propMgr.getBackgroundProps(); CommonBackground bProps = propMgr.getBackgroundProps();


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


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

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

* block referenced with the ref-id attribute. * block referenced with the ref-id attribute.
*/ */
public class PageNumberCitation extends FObj { public class PageNumberCitation extends FObj {
/** FontInfo for this object **/
protected FOTreeControl fontInfo = null;
/** Fontstate for this object **/ /** Fontstate for this object **/
protected Font fontState; protected Font fontState;


super(parent); 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 * @param str string to be measured
* @return width (in millipoints ??) of the string * @return width (in millipoints ??) of the string
CommonBackground bProps = propMgr.getBackgroundProps(); CommonBackground bProps = propMgr.getBackgroundProps();


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


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

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

// Now done in addChild of page-sequence // Now done in addChild of page-sequence
//pageSequence.addFlow(this); //pageSequence.addFlow(this);


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


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


/** /**

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

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

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

CommonBackground bProps = propMgr.getBackgroundProps(); CommonBackground bProps = propMgr.getBackgroundProps();


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


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

Loading…
Cancel
Save