git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196887 13f79535-47bb-0310-9956-ffa450edef68tags/Root_Temp_KnuthStylePageBreaking
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; | |||||
} | |||||
} |
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) { |
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. |
* 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 |
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) { |
*/ | */ | ||||
Set getIDReferences(); | Set getIDReferences(); | ||||
/** | |||||
* @return the FOInputHandler for parsing this FO Tree | |||||
*/ | |||||
FOInputHandler getFOInputHandler(); | |||||
} | } |
*/ | */ | ||||
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 |
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); | ||||
} | } | ||||
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() { |
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(); |
* 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(); |
* 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(); |
// 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); | |||||
} | } | ||||
/** | /** |
*/ | */ | ||||
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); |
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(); |