aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo/flow
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/apache/fop/fo/flow')
-rw-r--r--src/org/apache/fop/fo/flow/BasicLink.java6
-rw-r--r--src/org/apache/fop/fo/flow/BidiOverride.java66
-rw-r--r--src/org/apache/fop/fo/flow/Block.java392
-rw-r--r--src/org/apache/fop/fo/flow/Character.java26
-rw-r--r--src/org/apache/fop/fo/flow/ExternalGraphic.java5
-rw-r--r--src/org/apache/fop/fo/flow/Flow.java62
-rw-r--r--src/org/apache/fop/fo/flow/Footnote.java12
-rw-r--r--src/org/apache/fop/fo/flow/Inline.java2
-rw-r--r--src/org/apache/fop/fo/flow/InlineContainer.java33
-rw-r--r--src/org/apache/fop/fo/flow/InstreamForeignObject.java9
-rw-r--r--src/org/apache/fop/fo/flow/Leader.java23
-rw-r--r--src/org/apache/fop/fo/flow/PageNumber.java24
-rw-r--r--src/org/apache/fop/fo/flow/PageNumberCitation.java79
13 files changed, 458 insertions, 281 deletions
diff --git a/src/org/apache/fop/fo/flow/BasicLink.java b/src/org/apache/fop/fo/flow/BasicLink.java
index 5b8344341..938c43dcc 100644
--- a/src/org/apache/fop/fo/flow/BasicLink.java
+++ b/src/org/apache/fop/fo/flow/BasicLink.java
@@ -17,6 +17,7 @@ import org.apache.fop.datatypes.ColorType;
// Java
import java.util.Enumeration;
import java.awt.Rectangle;
+import java.util.List;
public class BasicLink extends Inline {
@@ -24,6 +25,11 @@ public class BasicLink extends Inline {
super(parent);
}
+ // add start and end properties for the link
+ public void addLayoutManager(List lms) {
+ super.addLayoutManager(lms);
+ }
+
public Status layout(Area area) throws FOPException {
String destination;
int linkType;
diff --git a/src/org/apache/fop/fo/flow/BidiOverride.java b/src/org/apache/fop/fo/flow/BidiOverride.java
index 208f2ae0f..d7123ed39 100644
--- a/src/org/apache/fop/fo/flow/BidiOverride.java
+++ b/src/org/apache/fop/fo/flow/BidiOverride.java
@@ -9,21 +9,48 @@ package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
-import org.apache.fop.layout.*;
+import org.apache.fop.layout.AuralProps;
+import org.apache.fop.layout.RelativePositionProps;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.Word;
+
+import java.util.List;
+import java.util.ArrayList;
+
/**
*/
-public class BidiOverride extends ToBeImplementedElement {
+public class BidiOverride extends FObjMixed {
public BidiOverride(FONode parent) {
super(parent);
}
- public Status layout(Area area) throws FOPException {
+ public void addLayoutManager(List list) {
+ if (false) {
+ super.addLayoutManager(list);
+ } else {
+ ArrayList childList = new ArrayList();
+ super.addLayoutManager(childList);
+ for (int count = childList.size() - 1; count >= 0; count--) {
+ LayoutManager lm = (LayoutManager) childList.get(count);
+ if (lm.generatesInlineAreas()) {
+ list.add( new BidiLayoutManager(this,
+ (LeafNodeLayoutManager) lm));
+ } else {
+ list.add(lm);
+ }
+ }
+ }
+ }
+
+ public void setup() {
// Common Aural Properties
AuralProps mAurProps = propMgr.getAuralProps();
@@ -46,6 +73,37 @@ public class BidiOverride extends ToBeImplementedElement {
// this.properties.get("unicode-bidi");
// this.properties.get("word-spacing");
- return super.layout(area);
+ }
+
+ /**
+ * If this bidi has a different writing mode direction
+ * ltr or rtl than its parent writing mode then this
+ * reverses the inline areas (at the character level).
+ */
+ class BidiLayoutManager extends LeafNodeLayoutManager {
+ List childs;
+
+ BidiLayoutManager(FObj obj, LeafNodeLayoutManager cLM) {
+ super(obj);
+ childs = new ArrayList();
+ for (int count = cLM.size() - 1; count >= 0; count--) {
+ InlineArea ia = cLM.get(count);
+ if (ia instanceof Word) {
+ // reverse word
+ Word word = (Word) ia;
+ StringBuffer sb = new StringBuffer(word.getWord());
+ word.setWord(sb.reverse().toString());
+ }
+ childs.add(ia);
+ }
+ }
+
+ public int size() {
+ return childs.size();
+ }
+
+ public InlineArea get(int index) {
+ return (InlineArea) childs.get(index);
+ }
}
}
diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java
index d234cc159..1bf604eb8 100644
--- a/src/org/apache/fop/fo/flow/Block.java
+++ b/src/org/apache/fop/fo/flow/Block.java
@@ -20,6 +20,8 @@ import org.apache.fop.apps.StreamRenderer;
import org.xml.sax.Attributes;
+import java.util.List;
+
/*
Modified by Mark Lillywhite mark-fop@inomial.com. The changes
here are based on memory profiling and do not change functionality.
@@ -31,9 +33,9 @@ import org.xml.sax.Attributes;
the reference to BlockArea was made local, the required information
is now stored (instead of a reference to the complex BlockArea object)
and it appears that there are a lot of changes in this file, in fact
- there are only a few sematic changes; mostly I just got rid of
+ there are only a few sematic changes; mostly I just got rid of
"this." from blockArea since BlockArea is now local.
- */
+ */
public class Block extends FObjMixed {
@@ -76,10 +78,13 @@ public class Block extends FObjMixed {
public void handleAttrs(Attributes attlist) throws FOPException {
super.handleAttrs(attlist);
this.span = this.properties.get("span").getEnum();
- this.wsTreatment = this.properties.get("white-space-treatment").getEnum();
- this.bWScollapse = (this.properties.get("white-space-collapse").getEnum() ==
- Constants.TRUE);
- this.lfTreatment = this.properties.get("linefeed-treatment").getEnum();
+ this.wsTreatment =
+ this.properties.get("white-space-treatment").getEnum();
+ this.bWScollapse =
+ (this.properties.get("white-space-collapse").getEnum()
+ == Constants.TRUE);
+ this.lfTreatment =
+ this.properties.get("linefeed-treatment").getEnum();
}
public Status layout(Area area) throws FOPException {
@@ -114,7 +119,8 @@ public class Block extends FObjMixed {
MarginProps mProps = propMgr.getMarginProps();
// Common Relative Position Properties
- RelativePositionProps mRelProps = propMgr.getRelativePositionProps();
+ RelativePositionProps mRelProps =
+ propMgr.getRelativePositionProps();
// this.properties.get("break-after");
// this.properties.get("break-before");
@@ -145,29 +151,30 @@ public class Block extends FObjMixed {
// this.properties.get("z-index");
this.align = this.properties.get("text-align").getEnum();
- this.alignLast = this.properties.get("text-align-last").getEnum();
+ this.alignLast =
+ this.properties.get("text-align-last").getEnum();
this.breakAfter = this.properties.get("break-after").getEnum();
- this.lineHeight =
- this.properties.get("line-height").getLength().mvalue();
- this.startIndent =
- this.properties.get("start-indent").getLength().mvalue();
- this.endIndent =
- this.properties.get("end-indent").getLength().mvalue();
- this.spaceBefore =
- this.properties.get("space-before.optimum").getLength().mvalue();
- this.spaceAfter =
- this.properties.get("space-after.optimum").getLength().mvalue();
- this.textIndent =
- this.properties.get("text-indent").getLength().mvalue();
+ this.lineHeight = this.properties.get(
+ "line-height").getLength().mvalue();
+ this.startIndent = this.properties.get(
+ "start-indent").getLength().mvalue();
+ this.endIndent = this.properties.get(
+ "end-indent").getLength().mvalue();
+ this.spaceBefore = this.properties.get(
+ "space-before.optimum").getLength().mvalue();
+ this.spaceAfter = this.properties.get(
+ "space-after.optimum").getLength().mvalue();
+ this.textIndent = this.properties.get(
+ "text-indent").getLength().mvalue();
this.keepWithNext =
- this.properties.get("keep-with-next").getEnum();
- this.backgroundColor =
- this.properties.get("background-color").getColorType();
+ this.properties.get("keep-with-next").getEnum();
+ this.backgroundColor = this.properties.get(
+ "background-color").getColorType();
this.blockWidows =
- this.properties.get("widows").getNumber().intValue();
+ this.properties.get("widows").getNumber().intValue();
this.blockOrphans =
- this.properties.get("orphans").getNumber().intValue();
+ this.properties.get("orphans").getNumber().intValue();
this.id = this.properties.get("id").getString();
@@ -189,9 +196,9 @@ public class Block extends FObjMixed {
int numChildren = this.children.size();
for (int i = 0; i < numChildren; i++) {
- FONode fo = (FONode)children.get(i);
+ FONode fo = (FONode) children.get(i);
if (fo instanceof FOText) {
- if (((FOText)fo).willCreateArea()) {
+ if (((FOText) fo).willCreateArea()) {
//fo.setWidows(blockWidows);
break;
} else {
@@ -206,9 +213,9 @@ public class Block extends FObjMixed {
}
for (int i = numChildren - 1; i >= 0; i--) {
- FONode fo = (FONode)children.get(i);
+ FONode fo = (FONode) children.get(i);
if (fo instanceof FOText) {
- if (((FOText)fo).willCreateArea()) {
+ if (((FOText) fo).willCreateArea()) {
//fo.setOrphans(blockOrphans);
break;
}
@@ -232,11 +239,10 @@ public class Block extends FObjMixed {
}
int spaceLeft = area.spaceLeft();
- blockArea =
- new BlockArea(propMgr.getFontState(area.getFontInfo()),
- area.getAllocationWidth(), area.spaceLeft(),
- startIndent, endIndent, textIndent, align,
- alignLast, lineHeight);
+ blockArea = new BlockArea( propMgr.getFontState(area.getFontInfo()),
+ area.getAllocationWidth(), area.spaceLeft(),
+ startIndent, endIndent, textIndent, align, alignLast,
+ lineHeight);
blockArea.setGeneratedBy(this);
this.areasGenerated++;
if (this.areasGenerated == 1)
@@ -246,9 +252,9 @@ public class Block extends FObjMixed {
// markers
//if (this.hasMarkers())
- //blockArea.addMarkers(this.getMarkers());
+ //blockArea.addMarkers(this.getMarkers());
- blockArea.setParent(area); // BasicLink needs it
+ blockArea.setParent(area); // BasicLink needs it
blockArea.setPage(area.getPage());
blockArea.setBackgroundColor(backgroundColor);
blockArea.setBorderAndPadding(propMgr.getBorderAndPadding());
@@ -262,7 +268,7 @@ public class Block extends FObjMixed {
int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
- FONode fo = (FONode)children.get(i);
+ FONode fo = (FONode) children.get(i);
Status status;
if ((status = fo.layout(blockArea)).isIncomplete()) {
this.marker = i;
@@ -280,14 +286,15 @@ public class Block extends FObjMixed {
if ((i != 0)) {
status = new Status(Status.AREA_FULL_SOME);
area.addChild(blockArea);
- area.setMaxHeight(area.getMaxHeight() - spaceLeft
- + blockArea.getMaxHeight());
+ area.setMaxHeight(area.getMaxHeight() -
+ spaceLeft + blockArea.getMaxHeight());
area.increaseHeight(blockArea.getHeight());
- area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
+ area.setAbsoluteHeight(
+ blockArea.getAbsoluteHeight());
anythingLaidOut = true;
return status;
- } else // i == 0 nothing was laid out..
+ } else // i == 0 nothing was laid out..
{
anythingLaidOut = false;
return status;
@@ -296,8 +303,8 @@ public class Block extends FObjMixed {
// blockArea.end();
area.addChild(blockArea);
- area.setMaxHeight(area.getMaxHeight() - spaceLeft
- + blockArea.getMaxHeight());
+ area.setMaxHeight(area.getMaxHeight() - spaceLeft +
+ blockArea.getMaxHeight());
area.increaseHeight(blockArea.getHeight());
area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
anythingLaidOut = true;
@@ -308,8 +315,8 @@ public class Block extends FObjMixed {
blockArea.end();
- area.setMaxHeight(area.getMaxHeight() - spaceLeft
- + blockArea.getMaxHeight());
+ area.setMaxHeight(area.getMaxHeight() - spaceLeft +
+ blockArea.getMaxHeight());
area.addChild(blockArea);
@@ -327,8 +334,8 @@ public class Block extends FObjMixed {
}
// This is not needed any more and it consumes a LOT
// of memory. So we release it for the GC.
- areaHeight= blockArea.getHeight();
- contentWidth= blockArea.getContentWidth();
+ areaHeight = blockArea.getHeight();
+ contentWidth = blockArea.getContentWidth();
// no break if last in area tree, or trailing in context
// area
@@ -359,7 +366,7 @@ public class Block extends FObjMixed {
* Return the content width of the boxes generated by this FO.
*/
public int getContentWidth() {
- return contentWidth; // getAllocationWidth()??
+ return contentWidth; // getAllocationWidth()??
}
@@ -367,26 +374,25 @@ public class Block extends FObjMixed {
return this.span;
}
- public LayoutManager getLayoutManager() {
-BlockLayoutManager blm = new BlockLayoutManager(this);
-TextInfo ti = new TextInfo();
+ public void addLayoutManager(List list) {
+ BlockLayoutManager blm = new BlockLayoutManager(this);
+ TextInfo ti = new TextInfo();
- try {
- ti.fs = propMgr.getFontState(fontInfo);
- } catch (FOPException fopex) {
- log.error("Error setting FontState for characters: " +
- fopex.getMessage());
- }
- ti.lineHeight = this.lineHeight;
+ try {
+ ti.fs = propMgr.getFontState(fontInfo);
+ } catch (FOPException fopex) {
+ log.error("Error setting FontState for characters: " +
+ fopex.getMessage());
+ }
+ ti.lineHeight = this.lineHeight;
- ColorType c = getProperty("color").getColorType();
- ti.color = c;
+ ColorType c = getProperty("color").getColorType();
+ ti.color = c;
- ti.verticalAlign =
- getProperty("vertical-align").getEnum();
+ ti.verticalAlign = getProperty("vertical-align").getEnum();
-blm.setBlockTextInfo(ti);
- return blm;
+ blm.setBlockTextInfo(ti);
+ list.add(blm);
}
public boolean generatesInlineAreas() {
@@ -394,144 +400,142 @@ blm.setBlockTextInfo(ti);
}
public void addChild(FONode child) {
- // Handle whitespace based on values of properties
- // Handle a sequence of inline-producing children in
- // one pass
- if (((FObj)child).generatesInlineAreas()) {
- if (firstInlineChild == null) {
- firstInlineChild = child;
- }
- // lastInlineChild = children.size();
- }
- else {
- // Handle whitespace in preceeding inline areas if any
- handleWhiteSpace();
- }
- super.addChild(child);
+ // Handle whitespace based on values of properties
+ // Handle a sequence of inline-producing children in
+ // one pass
+ if (((FObj) child).generatesInlineAreas()) {
+ if (firstInlineChild == null) {
+ firstInlineChild = child;
+ }
+ // lastInlineChild = children.size();
+ } else {
+ // Handle whitespace in preceeding inline areas if any
+ handleWhiteSpace();
+ }
+ super.addChild(child);
}
public void end() {
- handleWhiteSpace();
+ handleWhiteSpace();
}
private void handleWhiteSpace() {
- log.debug("fo:block: handleWhiteSpace");
- if (firstInlineChild != null) {
- boolean bInWS=false;
- boolean bPrevWasLF=false;
- RecursiveCharIterator charIter =
- new RecursiveCharIterator(this, firstInlineChild);
- LFchecker lfCheck = new LFchecker(charIter);
-
- while (charIter.hasNext()) {
- switch (CharUtilities.classOf(charIter.nextChar())) {
- case CharUtilities.XMLWHITESPACE:
- /* Some kind of whitespace character, except linefeed. */
- boolean bIgnore=false;
-
- switch (wsTreatment) {
- case Constants.IGNORE:
- bIgnore=true;
- break;
- case Constants.IGNORE_IF_BEFORE_LINEFEED:
- bIgnore = lfCheck.nextIsLF();
- break;
- case Constants.IGNORE_IF_SURROUNDING_LINEFEED:
- bIgnore = (bPrevWasLF || lfCheck.nextIsLF());
- break;
- case Constants.IGNORE_IF_AFTER_LINEFEED:
- bIgnore = bPrevWasLF;
- break;
- }
- // Handle ignore
- if (bIgnore) {
- charIter.remove();
- }
- else if (bWScollapse) {
- if (bInWS || (lfTreatment == Constants.PRESERVE &&
- (bPrevWasLF || lfCheck.nextIsLF()))) {
- charIter.remove();
- }
- else {
- bInWS = true;
- }
- }
- break;
-
- case CharUtilities.LINEFEED:
- /* A linefeed */
- lfCheck.reset();
- bPrevWasLF=true; // for following whitespace
-
- switch (lfTreatment) {
- case Constants.IGNORE:
- charIter.remove();
- break;
- case Constants.TREAT_AS_SPACE:
- if (bInWS) {
- // only if bWScollapse=true
- charIter.remove();
- }
- else {
- if (bWScollapse) bInWS=true;
- charIter.replaceChar('\u0020');
- }
- break;
- case Constants.TREAT_AS_ZERO_WIDTH_SPACE:
- charIter.replaceChar('\u200b');
- // Fall through: this isn't XML whitespace
- case Constants.PRESERVE:
- bInWS=false;
- break;
- }
- break;
-
- case CharUtilities.EOT:
- // A "boundary" objects such as non-character inline
- // or nested block object was encountered.
- // If any whitespace run in progress, finish it.
- // FALL THROUGH
-
- case CharUtilities.UCWHITESPACE: // Non XML-whitespace
- case CharUtilities.NONWHITESPACE:
- /* Any other character */
- bInWS = bPrevWasLF=false;
- lfCheck.reset();
- break;
- }
- }
- firstInlineChild = null;
- }
+ log.debug("fo:block: handleWhiteSpace");
+ if (firstInlineChild != null) {
+ boolean bInWS = false;
+ boolean bPrevWasLF = false;
+ RecursiveCharIterator charIter =
+ new RecursiveCharIterator(this, firstInlineChild);
+ LFchecker lfCheck = new LFchecker(charIter);
+
+ while (charIter.hasNext()) {
+ switch (CharUtilities.classOf(charIter.nextChar())) {
+ case CharUtilities.XMLWHITESPACE:
+ /* Some kind of whitespace character, except linefeed. */
+ boolean bIgnore = false;
+
+ switch (wsTreatment) {
+ case Constants.IGNORE:
+ bIgnore = true;
+ break;
+ case Constants.IGNORE_IF_BEFORE_LINEFEED:
+ bIgnore = lfCheck.nextIsLF();
+ break;
+ case Constants.IGNORE_IF_SURROUNDING_LINEFEED:
+ bIgnore = (bPrevWasLF ||
+ lfCheck.nextIsLF());
+ break;
+ case Constants.IGNORE_IF_AFTER_LINEFEED:
+ bIgnore = bPrevWasLF;
+ break;
+ }
+ // Handle ignore
+ if (bIgnore) {
+ charIter.remove();
+ } else if (bWScollapse) {
+ if (bInWS || (lfTreatment ==
+ Constants.PRESERVE &&
+ (bPrevWasLF || lfCheck.nextIsLF()))) {
+ charIter.remove();
+ } else {
+ bInWS = true;
+ }
+ }
+ break;
+
+ case CharUtilities.LINEFEED:
+ /* A linefeed */
+ lfCheck.reset();
+ bPrevWasLF = true; // for following whitespace
+
+ switch (lfTreatment) {
+ case Constants.IGNORE:
+ charIter.remove();
+ break;
+ case Constants.TREAT_AS_SPACE:
+ if (bInWS) {
+ // only if bWScollapse=true
+ charIter.remove();
+ } else {
+ if (bWScollapse)
+ bInWS = true;
+ charIter.replaceChar('\u0020');
+ }
+ break;
+ case Constants.TREAT_AS_ZERO_WIDTH_SPACE:
+ charIter.replaceChar('\u200b');
+ // Fall through: this isn't XML whitespace
+ case Constants.PRESERVE:
+ bInWS = false;
+ break;
+ }
+ break;
+
+ case CharUtilities.EOT:
+ // A "boundary" objects such as non-character inline
+ // or nested block object was encountered.
+ // If any whitespace run in progress, finish it.
+ // FALL THROUGH
+
+ case CharUtilities.UCWHITESPACE: // Non XML-whitespace
+ case CharUtilities.NONWHITESPACE:
+ /* Any other character */
+ bInWS = bPrevWasLF = false;
+ lfCheck.reset();
+ break;
+ }
+ }
+ firstInlineChild = null;
+ }
}
private static class LFchecker {
- private boolean bNextIsLF=false;
- private RecursiveCharIterator charIter;
-
- LFchecker(RecursiveCharIterator charIter) {
- this.charIter = charIter;
- }
-
- boolean nextIsLF() {
- if (bNextIsLF==false) {
- CharIterator lfIter = charIter.mark();
- while (lfIter.hasNext()) {
- char c = lfIter.nextChar();
- if (c == '\n') {
- bNextIsLF=true;
- break;
- }
- else if (CharUtilities.classOf(c) !=
- CharUtilities.XMLWHITESPACE) {
- break;
- }
- }
- }
- return bNextIsLF;
- }
-
- void reset() {
- bNextIsLF=false;
- }
+ private boolean bNextIsLF = false;
+ private RecursiveCharIterator charIter;
+
+ LFchecker(RecursiveCharIterator charIter) {
+ this.charIter = charIter;
+ }
+
+ boolean nextIsLF() {
+ if (bNextIsLF == false) {
+ CharIterator lfIter = charIter.mark();
+ while (lfIter.hasNext()) {
+ char c = lfIter.nextChar();
+ if (c == '\n') {
+ bNextIsLF = true;
+ break;
+ } else if (CharUtilities.classOf(c) !=
+ CharUtilities.XMLWHITESPACE) {
+ break;
+ }
+ }
+ }
+ return bNextIsLF;
+ }
+
+ void reset() {
+ bNextIsLF = false;
+ }
}
}
diff --git a/src/org/apache/fop/fo/flow/Character.java b/src/org/apache/fop/fo/flow/Character.java
index 9f22c7c30..17243d949 100644
--- a/src/org/apache/fop/fo/flow/Character.java
+++ b/src/org/apache/fop/fo/flow/Character.java
@@ -24,6 +24,7 @@ import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+import java.util.List;
/**
* this class represents the flow object 'fo:character'. Its use is defined by
@@ -48,13 +49,23 @@ public class Character extends FObj {
super(parent);
}
- public LayoutManager getLayoutManager() {
- LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this);
- lm.setCurrentArea(getInlineArea());
- return lm;
+ public void addLayoutManager(List list) {
+ InlineArea inline = getInlineArea();
+ if (inline != null) {
+ LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this);
+ lm.setCurrentArea(inline);
+ list.add(lm);
+ }
}
protected InlineArea getInlineArea() {
+ String str = this.properties.get("character").getString();
+ if (str.length() == 1) {
+ org.apache.fop.area.inline.Character ch =
+ new org.apache.fop.area.inline.Character(
+ str.charAt(0));
+ return ch;
+ }
return null;
}
@@ -77,7 +88,8 @@ public class Character extends FObj {
MarginInlineProps mProps = propMgr.getMarginInlineProps();
// Common Relative Position Properties
- RelativePositionProps mRelProps = propMgr.getRelativePositionProps();
+ RelativePositionProps mRelProps =
+ propMgr.getRelativePositionProps();
// this.properties.get("alignment-adjust");
// this.properties.get("treat-as-word-space");
@@ -105,8 +117,8 @@ public class Character extends FObj {
}
public CharIterator charIterator() {
- return new OneCharIterator(characterValue);
- // But what it the character is ignored due to white space handling?
+ return new OneCharIterator(characterValue);
+ // But what it the character is ignored due to white space handling?
}
diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java
index 1183afdea..96689b8c4 100644
--- a/src/org/apache/fop/fo/flow/ExternalGraphic.java
+++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java
@@ -22,6 +22,7 @@ import org.apache.fop.area.inline.Viewport;
// Java
import java.net.URL;
import java.net.MalformedURLException;
+import java.util.List;
public class ExternalGraphic extends FObj {
String url;
@@ -41,10 +42,10 @@ public class ExternalGraphic extends FObj {
super(parent);
}
- public LayoutManager getLayoutManager() {
+ public void addLayoutManager(List list) {
LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this);
lm.setCurrentArea(getInlineArea());
- return lm;
+ list.add(lm);
}
protected InlineArea getInlineArea() {
diff --git a/src/org/apache/fop/fo/flow/Flow.java b/src/org/apache/fop/fo/flow/Flow.java
index f0828f426..bdeb21db8 100644
--- a/src/org/apache/fop/fo/flow/Flow.java
+++ b/src/org/apache/fop/fo/flow/Flow.java
@@ -19,6 +19,7 @@ import org.apache.fop.layoutmgr.FlowLayoutManager;
// Java
import java.util.ArrayList;
+import java.util.List;
import org.xml.sax.Attributes;
@@ -59,36 +60,35 @@ public class Flow extends FObj {
public void handleAttrs(Attributes attlist) throws FOPException {
super.handleAttrs(attlist);
if (parent.getName().equals("fo:page-sequence")) {
- this.pageSequence = (PageSequence)parent;
+ this.pageSequence = (PageSequence) parent;
} else {
- throw new FOPException("flow must be child of "
- + "page-sequence, not "
- + parent.getName());
+ throw new FOPException("flow must be child of " +
+ "page-sequence, not " + parent.getName());
}
// according to communication from Paul Grosso (XSL-List,
// 001228, Number 406), confusion in spec section 6.4.5 about
// multiplicity of fo:flow in XSL 1.0 is cleared up - one (1)
// fo:flow per fo:page-sequence only.
-/* if (pageSequence.isFlowSet()) {
- if (this.name.equals("fo:flow")) {
- throw new FOPException("Only a single fo:flow permitted"
- + " per fo:page-sequence");
- } else {
- throw new FOPException(this.name
- + " not allowed after fo:flow");
- }
- }
-*/
+ /* if (pageSequence.isFlowSet()) {
+ if (this.name.equals("fo:flow")) {
+ throw new FOPException("Only a single fo:flow permitted"
+ + " per fo:page-sequence");
+ } else {
+ throw new FOPException(this.name
+ + " not allowed after fo:flow");
+ }
+ }
+ */
setFlowName(getProperty("flow-name").getString());
- // Now done in addChild of page-sequence
+ // Now done in addChild of page-sequence
//pageSequence.addFlow(this);
}
protected void setFlowName(String name) throws FOPException {
if (name == null || name.equals("")) {
- throw new FOPException("A 'flow-name' is required for "
- + getName());
+ throw new FOPException("A 'flow-name' is required for " +
+ getName());
} else {
_flowName = name;
}
@@ -109,7 +109,7 @@ public class Flow extends FObj {
}
// flow is *always* laid out into a BodyAreaContainer
- BodyAreaContainer bac = (BodyAreaContainer)area;
+ BodyAreaContainer bac = (BodyAreaContainer) area;
boolean prevChildMustKeepWithNext = false;
ArrayList pageMarker = this.getMarkerSnapshot(new ArrayList());
@@ -119,7 +119,7 @@ public class Flow extends FObj {
throw new FOPException("fo:flow must contain block-level children");
}
for (int i = this.marker; i < numChildren; i++) {
- FObj fo = (FObj)children.get(i);
+ FObj fo = (FObj) children.get(i);
if (bac.isBalancingRequired(fo)) {
// reset the the just-done span area in preparation
@@ -139,8 +139,8 @@ public class Flow extends FObj {
this.marker = i;
markerSnapshot = this.getMarkerSnapshot(new ArrayList());
}
- // Set current content width for percent-based lengths in children
- setContentWidth(currentArea.getContentWidth());
+ // Set current content width for percent-based lengths in children
+ setContentWidth(currentArea.getContentWidth());
_status = fo.layout(currentArea);
@@ -155,9 +155,10 @@ public class Flow extends FObj {
* }
*/
if (_status.isIncomplete()) {
- if ((prevChildMustKeepWithNext) && (_status.laidOutNone())) {
+ if ((prevChildMustKeepWithNext) &&
+ (_status.laidOutNone())) {
this.marker = i - 1;
- FObj prevChild = (FObj)children.get(this.marker);
+ FObj prevChild = (FObj) children.get(this.marker);
prevChild.removeAreas();
prevChild.resetMarker();
prevChild.removeID(area.getIDReferences());
@@ -169,8 +170,8 @@ public class Flow extends FObj {
if (bac.isLastColumn())
if (_status.getCode() == Status.FORCE_COLUMN_BREAK) {
this.marker = i;
- _status =
- new Status(Status.FORCE_PAGE_BREAK); // same thing
+ _status = new Status(Status.FORCE_PAGE_BREAK);
+ // same thing
return _status;
} else {
this.marker = i;
@@ -183,7 +184,8 @@ public class Flow extends FObj {
return _status;
}
// I don't much like exposing this. (AHS 001217)
- ((org.apache.fop.layout.ColumnArea)currentArea).incrementSpanIndex();
+ ((org.apache.fop.layout.ColumnArea) currentArea).
+ incrementSpanIndex();
i--;
}
}
@@ -197,14 +199,14 @@ public class Flow extends FObj {
}
protected void setContentWidth(int contentWidth) {
- this.contentWidth = contentWidth;
+ this.contentWidth = contentWidth;
}
/**
* Return the content width of this flow (really of the region
* in which it is flowing).
*/
public int getContentWidth() {
- return this.contentWidth;
+ return this.contentWidth;
}
public Status getStatus() {
@@ -215,8 +217,8 @@ public class Flow extends FObj {
return true;
}
- public LayoutManager getLayoutManager() {
- return new FlowLayoutManager(this);
+ public void addLayoutManager(List list) {
+ list.add(new FlowLayoutManager(this));
}
}
diff --git a/src/org/apache/fop/fo/flow/Footnote.java b/src/org/apache/fop/fo/flow/Footnote.java
index 0374e0400..103e6665c 100644
--- a/src/org/apache/fop/fo/flow/Footnote.java
+++ b/src/org/apache/fop/fo/flow/Footnote.java
@@ -12,6 +12,11 @@ import org.apache.fop.fo.*;
import org.apache.fop.layout.*;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.*;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+
+import java.util.List;
// Java
import java.util.ArrayList;
@@ -22,6 +27,13 @@ public class Footnote extends FObj {
super(parent);
}
+ public void addLayoutManager(List lms) {
+ // add inlines layout manager
+ //inline.addLayoutManager(lms);
+ // set start and end footnote reference
+ }
+
+
public Status layout(Area area) throws FOPException {
FONode inline = null;
FONode fbody = null;
diff --git a/src/org/apache/fop/fo/flow/Inline.java b/src/org/apache/fop/fo/flow/Inline.java
index c6f78e8d0..c25104ac3 100644
--- a/src/org/apache/fop/fo/flow/Inline.java
+++ b/src/org/apache/fop/fo/flow/Inline.java
@@ -89,7 +89,7 @@ public class Inline extends FObjMixed {
public CharIterator charIterator() {
- return new InlineCharIterator(this, propMgr.getBorderAndPadding());
+ return new InlineCharIterator(this, propMgr.getBorderAndPadding());
}
}
diff --git a/src/org/apache/fop/fo/flow/InlineContainer.java b/src/org/apache/fop/fo/flow/InlineContainer.java
index 78bbbce04..d3a46f016 100644
--- a/src/org/apache/fop/fo/flow/InlineContainer.java
+++ b/src/org/apache/fop/fo/flow/InlineContainer.java
@@ -13,17 +13,28 @@ import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+import org.apache.fop.area.inline.InlineArea;
import org.xml.sax.Attributes;
+import java.util.List;
+import java.util.ArrayList;
+
/**
*/
-public class InlineContainer extends ToBeImplementedElement {
+public class InlineContainer extends FObj {
public InlineContainer(FONode parent) {
super(parent);
}
+ public void addLayoutManager(List lms) {
+ ArrayList childList = new ArrayList();
+ super.addLayoutManager(childList);
+ lms.add(new ICLayoutManager(this, childList));
+ }
+
public void handleAttrs(Attributes attlist) throws FOPException {
super.handleAttrs(attlist);
// Common Border, Padding, and Background Properties
@@ -34,7 +45,8 @@ public class InlineContainer extends ToBeImplementedElement {
MarginInlineProps mProps = propMgr.getMarginInlineProps();
// Common Relative Position Properties
- RelativePositionProps mRelProps = propMgr.getRelativePositionProps();
+ RelativePositionProps mRelProps =
+ propMgr.getRelativePositionProps();
// this.properties.get("alignment-adjust");
// this.properties.get("alignment-baseline");
@@ -57,4 +69,21 @@ public class InlineContainer extends ToBeImplementedElement {
// this.properties.get("writing-mode");
}
+ /**
+ * This creates a single inline container area after
+ * laying out the child block areas. All footnotes, floats
+ * and id areas are maintained for later retrieval.
+ */
+ class ICLayoutManager extends LeafNodeLayoutManager {
+ List childrenLM;
+
+ ICLayoutManager(FObj obj, List childLM) {
+ super(obj);
+ childrenLM = childLM;
+ }
+
+ public InlineArea get(int index) {
+ return null;
+ }
+ }
}
diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java
index 9dc8682b6..df30fccaf 100644
--- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java
+++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java
@@ -29,6 +29,7 @@ import org.apache.fop.layoutmgr.LayoutInfo;
import org.w3c.dom.Document;
import java.awt.geom.Point2D;
+import java.util.List;
public class InstreamForeignObject extends FObj {
@@ -60,10 +61,10 @@ public class InstreamForeignObject extends FObj {
super(parent);
}
- public LayoutManager getLayoutManager() {
+ public void addLayoutManager(List list) {
LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this);
lm.setCurrentArea(getInlineArea());
- return lm;
+ list.add(lm);
}
/**
@@ -144,6 +145,10 @@ public class InstreamForeignObject extends FObj {
return areaCurrent;
}
+ public boolean generatesInlineAreas() {
+ return true;
+ }
+
/**
* layout this formatting object.
*
diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java
index 7089ce78a..92cbf999a 100644
--- a/src/org/apache/fop/fo/flow/Leader.java
+++ b/src/org/apache/fop/fo/flow/Leader.java
@@ -20,6 +20,9 @@ import org.apache.fop.layout.FontState;
import org.apache.fop.apps.FOPException;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+import org.apache.fop.area.MinOptMax;
+
+import java.util.List;
/**
* Implements fo:leader; main property of leader leader-pattern.
@@ -32,14 +35,22 @@ public class Leader extends FObjMixed {
super(parent);
}
- public LayoutManager getLayoutManager() {
- LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this);
- lm.setCurrentArea(getInlineArea());
- return lm;
+ public void addLayoutManager(List list) {
+ list.add(new LeafNodeLayoutManager(this) {
+ public InlineArea get(int index) {
+ if(index > 0)
+ return null;
+ int contentIPD = parentLM.getContentIPD();
+ return getInlineArea(contentIPD);
+ }
+ });
}
- protected InlineArea getInlineArea() {
- return null;
+ protected InlineArea getInlineArea(int maxIPD) {
+ org.apache.fop.area.inline.Leader leader = new org.apache.fop.area.inline.Leader();
+ leader.setWidth(maxIPD / 2);
+ leader.setAllocationIPD(new MinOptMax(0, maxIPD / 2, maxIPD));
+ return leader;
}
public Status layout(Area area) throws FOPException {
diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java
index b1eb6a696..a1dfb10ce 100644
--- a/src/org/apache/fop/fo/flow/PageNumber.java
+++ b/src/org/apache/fop/fo/flow/PageNumber.java
@@ -15,8 +15,12 @@ import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.Word;
+
// Java
-import java.util.Enumeration;
+import java.util.List;
public class PageNumber extends FObj {
@@ -31,6 +35,24 @@ public class PageNumber extends FObj {
super(parent);
}
+ public void addLayoutManager(List lms) {
+ lms.add(new LeafNodeLayoutManager(this) {
+ public InlineArea get(int index) {
+ if(index > 0)
+ return null;
+ // get page string from parent, build area
+ Word inline = new Word();
+ //String parentLM.getCurrentPageNumber();
+ inline.setWord("01");
+ return inline;
+ }
+
+ public boolean resolved() {
+ return true;
+ }
+ });
+ }
+
public Status layout(Area area) throws FOPException {
if (!(area instanceof BlockArea)) {
log.warn("page-number outside block area");
diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java
index af9d1eeaf..0c705a8af 100644
--- a/src/org/apache/fop/fo/flow/PageNumberCitation.java
+++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java
@@ -14,7 +14,11 @@ import org.apache.fop.datatypes.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+import org.apache.fop.area.inline.InlineArea;
+import java.util.List;
+import java.util.ArrayList;
/**
* 6.6.11 fo:page-number-citation
@@ -88,6 +92,18 @@ public class PageNumberCitation extends FObj {
super(parent);
}
+ public void addLayoutManager(List lms) {
+ LeafNodeLayoutManager lnlm = new LeafNodeLayoutManager(this);
+ lnlm.setCurrentArea(getInlineArea());
+ lms.add(lnlm);
+ }
+
+ // is id can be resolved then simply return a word, otherwise
+ // return a resolveable area
+ private InlineArea getInlineArea() {
+ return null;
+ }
+
public Status layout(Area area) throws FOPException {
if (!(area instanceof BlockArea)) {
log.warn("page-number-citation outside block area");
@@ -98,37 +114,38 @@ public class PageNumberCitation extends FObj {
this.area = area;
if (this.marker == START) {
- // Common Accessibility Properties
+ // Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
- // Common Aural Properties
- AuralProps mAurProps = propMgr.getAuralProps();
+ // Common Aural Properties
+ AuralProps mAurProps = propMgr.getAuralProps();
- // Common Border, Padding, and Background Properties
- BorderAndPadding bap = propMgr.getBorderAndPadding();
- BackgroundProps bProps = propMgr.getBackgroundProps();
+ // Common Border, Padding, and Background Properties
+ BorderAndPadding bap = propMgr.getBorderAndPadding();
+ BackgroundProps bProps = propMgr.getBackgroundProps();
- // Common Font Properties
- //this.fontState = propMgr.getFontState(area.getFontInfo());
+ // Common Font Properties
+ //this.fontState = propMgr.getFontState(area.getFontInfo());
- // Common Margin Properties-Inline
- MarginInlineProps mProps = propMgr.getMarginInlineProps();
+ // Common Margin Properties-Inline
+ MarginInlineProps mProps = propMgr.getMarginInlineProps();
- // Common Relative Position Properties
- RelativePositionProps mRelProps = propMgr.getRelativePositionProps();
+ // Common Relative Position Properties
+ RelativePositionProps mRelProps =
+ propMgr.getRelativePositionProps();
- // this.properties.get("alignment-adjust");
- // this.properties.get("alignment-baseline");
- // this.properties.get("baseline-shift");
- // this.properties.get("dominant-baseline");
- // this.properties.get("id");
- // this.properties.get("keep-with-next");
+ // this.properties.get("alignment-adjust");
+ // this.properties.get("alignment-baseline");
+ // this.properties.get("baseline-shift");
+ // this.properties.get("dominant-baseline");
+ // this.properties.get("id");
+ // this.properties.get("keep-with-next");
// this.properties.get("keep-with-previous");
// this.properties.get("letter-spacing");
// this.properties.get("line-height");
- // this.properties.get("line-height-shift-adjustment");
- // this.properties.get("ref-id");
- // this.properties.get("score-spaces");
+ // this.properties.get("line-height-shift-adjustment");
+ // this.properties.get("ref-id");
+ // this.properties.get("score-spaces");
// this.properties.get("text-decoration");
// this.properties.get("text-shadow");
// this.properties.get("text-transform");
@@ -141,7 +158,7 @@ public class PageNumberCitation extends FObj {
this.wrapOption = this.properties.get("wrap-option").getEnum();
this.whiteSpaceCollapse =
- this.properties.get("white-space-collapse").getEnum();
+ this.properties.get("white-space-collapse").getEnum();
this.refId = this.properties.get("ref-id").getString();
@@ -164,16 +181,14 @@ public class PageNumberCitation extends FObj {
pageNumber = idReferences.getPageNumber(refId);
- if (pageNumber != null) { // if we already know the page number
- this.marker =
- FOText.addText((BlockArea)area,
- propMgr.getFontState(area.getFontInfo()), red,
- green, blue, wrapOption, null,
- whiteSpaceCollapse, pageNumber.toCharArray(),
- 0, pageNumber.length(), ts,
- VerticalAlign.BASELINE);
- } else { // add pageNumberCitation to area to be resolved during rendering
- BlockArea blockArea = (BlockArea)area;
+ if (pageNumber != null) { // if we already know the page number
+ this.marker = FOText.addText((BlockArea) area,
+ propMgr.getFontState(area.getFontInfo()), red,
+ green, blue, wrapOption, null, whiteSpaceCollapse,
+ pageNumber.toCharArray(), 0, pageNumber.length(),
+ ts, VerticalAlign.BASELINE);
+ } else { // add pageNumberCitation to area to be resolved during rendering
+ BlockArea blockArea = (BlockArea) area;
LineArea la = blockArea.getCurrentLineArea();
if (la == null) {
return new Status(Status.AREA_FULL_NONE);