import org.apache.fop.layout.inline.InlineArea;
import org.apache.fop.fo.FObj;
import org.apache.fop.layout.FontState;
+import org.apache.fop.layout.LineArea;
import org.apache.fop.apps.FOPException;
import org.apache.fop.messaging.MessageHandler;
public final static int OK = 0;
public final static int DOESNOT_FIT = 1;
-
public Character(FObj parent, PropertyList propertyList) {
super(parent, propertyList);
this.name = "fo:character";
// initialize id
String id = this.properties.get("id").getString();
blockArea.getIDReferences().initializeID(id, blockArea);
- blockArea.addCharacter(fontstate,red,green,blue,wrapOption,this.getLinkSet(),
- whiteSpaceCollapse,characterValue,textDecoration);
- return new Status(Status.OK);
+ LineArea la = blockArea.getCurrentLineArea();
+ la.changeFont(fontstate);
+ la.changeColor(red, green, blue);
+ la.changeWrapOption(wrapOption);
+ la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
+ blockArea.setupLinkSet(this.getLinkSet());
+ int result = la.addCharacter(characterValue, this.getLinkSet(), textDecoration);
+ if (result == Character.DOESNOT_FIT) {
+ la = blockArea.createNextLineArea();
+ if(la == null) {
+ return new Status(Status.AREA_FULL_NONE);
+ }
+ la.changeFont(fontstate);
+ la.changeColor(red, green, blue);
+ la.changeWrapOption(wrapOption);
+ la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
+ blockArea.setupLinkSet(this.getLinkSet());
+ la.addCharacter(characterValue, this.getLinkSet(), textDecoration);
+ }
+ return new Status(Status.OK);
}
pageNumber.toCharArray(), 0, pageNumber.length(),
false);
} else { // add pageNumberCitation to area to be resolved during rendering
- this.marker = ((BlockArea) area).addPageNumberCitation(fs, red,
- green, blue, wrapOption, null, whiteSpaceCollapse,
- refId);
+ BlockArea blockArea = (BlockArea)area;
+ LineArea la = blockArea.getCurrentLineArea();
+ la.changeFont(fs);
+ la.changeColor(red, green, blue);
+ la.changeWrapOption(wrapOption);
+ la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
+/* la.changeHyphenation(language, country, hyphenate,
+ hyphenationChar, hyphenationPushCharacterCount,
+ hyphenationRemainCharacterCount);*/
+
+// blockArea.setupLinkSet(null);
+ la.addPageNumberCitation(refId, null);
+ this.marker = -1;
}
import java.util.Enumeration;
import org.apache.fop.messaging.MessageHandler;
+/**
+ * This class represents a Block Area.
+ * A block area is made up of a sequence of Line Areas.
+ *
+ * This class is used to organise the sequence of line areas as
+ * inline areas are added to this block it creates and ands line areas
+ * to hold the inline areas.
+ * This uses the line-height and line-stacking-strategy to work
+ * out how to stack the lines.
+ */
public class BlockArea extends Area {
/* relative to area container */
}
}
- public int addPageNumberCitation(FontState fontState, float red,
- float green, float blue, int wrapOption, LinkSet ls,
- int whiteSpaceCollapse, String refid) {
-
- this.currentLineArea.changeFont(fontState);
- this.currentLineArea.changeColor(red, green, blue);
- this.currentLineArea.changeWrapOption(wrapOption);
- this.currentLineArea.changeWhiteSpaceCollapse(whiteSpaceCollapse);
- this.currentLineArea.changeHyphenation(language, country, hyphenate,
- hyphenationChar, hyphenationPushCharacterCount,
- hyphenationRemainCharacterCount);
-
-
- if (ls != null) {
- this.currentLinkSet = ls;
- ls.setYOffset(currentHeight);
- }
-
- this.currentLineArea.addPageNumberCitation(refid, ls);
- this.hasLines = true;
-
- return -1;
-
- }
-
// font-variant support : addText is a wrapper for addRealText
// added by Eric SCHAEFFER
public int addText(FontState fontState, float red, float green,
return 1;
}
- public void addCharacter(FontState fontState, float red, float green,
- float blue, int wrapOption, LinkSet ls,
- int whiteSpaceCollapse, char data, boolean ul) {
+ public LineArea getCurrentLineArea()
+ {
+ return this.currentLineArea;
+ }
- this.currentLineArea.changeFont(fontState);
- this.currentLineArea.changeColor(red, green, blue);
- this.currentLineArea.changeWrapOption(wrapOption);
- this.currentLineArea.changeWhiteSpaceCollapse(whiteSpaceCollapse);
-
- if (ls != null) {
- this.currentLinkSet = ls;
- ls.setYOffset(currentHeight);
- }
-
- int marker = this.currentLineArea.addCharacter(data, ls, ul);
- //if character didn't fit into line, open a new one
- if (marker == org.apache.fop.fo.flow.Character.DOESNOT_FIT) {
+ public LineArea createNextLineArea()
+ {
+ if (this.hasLines) {
+ this.currentLineArea.addPending();
this.currentLineArea.align(this.align);
+// this.currentLineArea.verticalAlign();
this.addLineArea(this.currentLineArea);
-
+ }
this.currentLineArea =
new LineArea(fontState, lineHeight, halfLeading,
allocationWidth, startIndent, endIndent,
currentLineArea);
- this.currentLineArea.changeFont(fontState);
- this.currentLineArea.changeColor(red, green, blue);
- this.currentLineArea.changeWrapOption(wrapOption);
- this.currentLineArea.changeWhiteSpaceCollapse(
- whiteSpaceCollapse);
+ if (currentHeight + lineHeight > maxHeight) {
+ return null;
+ }
+ return this.currentLineArea;
+ }
+
+ public void setupLinkSet(LinkSet ls)
+ {
if (ls != null) {
this.currentLinkSet = ls;
ls.setYOffset(currentHeight);
}
-
- this.currentLineArea.addCharacter(data, ls, ul);
- }
- this.hasLines = true;
- }
-
+ }
public void end() {
if (this.hasLines) {