Browse Source

PR:

Obtained from:
Submitted by:
Reviewed by:
Start of work to move FOText from extending FObj to extending FONode instead.

All work is done except for changing FObj's parent from FObj to
FONode.  The RTF library works fine with the switch, but simple.fo and
franklin_alt.fo (among others I guess) will not work properly when FOText's
parent is switched.  (Layout problems occur--lines don't break properly
with the switch.)

Switch to super() constructor (instead of super(fobj) one) within
within TextLayoutManager, as it is not needed for this subclass, also to
facilitate the change above.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198040 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Glen Mazza 19 years ago
parent
commit
7ed159fa02
28 changed files with 96 additions and 100 deletions
  1. 9
    7
      src/java/org/apache/fop/fo/FONode.java
  2. 7
    7
      src/java/org/apache/fop/fo/FOText.java
  3. 0
    9
      src/java/org/apache/fop/fo/FObj.java
  4. 1
    1
      src/java/org/apache/fop/fo/FObjMixed.java
  5. 1
    1
      src/java/org/apache/fop/fo/flow/BasicLink.java
  6. 1
    1
      src/java/org/apache/fop/fo/flow/BidiOverride.java
  7. 1
    1
      src/java/org/apache/fop/fo/flow/Block.java
  8. 1
    1
      src/java/org/apache/fop/fo/flow/BlockContainer.java
  9. 1
    1
      src/java/org/apache/fop/fo/flow/Character.java
  10. 1
    1
      src/java/org/apache/fop/fo/flow/ExternalGraphic.java
  11. 1
    1
      src/java/org/apache/fop/fo/flow/Footnote.java
  12. 1
    1
      src/java/org/apache/fop/fo/flow/InlineContainer.java
  13. 1
    1
      src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
  14. 1
    1
      src/java/org/apache/fop/fo/flow/Leader.java
  15. 1
    1
      src/java/org/apache/fop/fo/flow/ListBlock.java
  16. 1
    1
      src/java/org/apache/fop/fo/flow/ListItem.java
  17. 1
    1
      src/java/org/apache/fop/fo/flow/PageNumber.java
  18. 1
    1
      src/java/org/apache/fop/fo/flow/PageNumberCitation.java
  19. 1
    1
      src/java/org/apache/fop/fo/flow/RetrieveMarker.java
  20. 1
    1
      src/java/org/apache/fop/fo/flow/Table.java
  21. 1
    1
      src/java/org/apache/fop/fo/flow/TableBody.java
  22. 1
    1
      src/java/org/apache/fop/fo/flow/TableCell.java
  23. 1
    1
      src/java/org/apache/fop/fo/flow/TableRow.java
  24. 1
    1
      src/java/org/apache/fop/fo/flow/Wrapper.java
  25. 1
    1
      src/java/org/apache/fop/fo/pagination/Flow.java
  26. 4
    3
      src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
  27. 2
    1
      src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
  28. 52
    51
      src/java/org/apache/fop/render/rtf/RTFHandler.java

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

@@ -19,6 +19,7 @@
package org.apache.fop.fo;

// Java
import java.util.List;
import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -134,13 +135,6 @@ public abstract class FONode {
// ignore
}

/**
*
*/
protected void start() {
// do nothing by default
}

/**
*
*/
@@ -328,6 +322,14 @@ public abstract class FONode {
}
}

/**
* Return a LayoutManager responsible for laying out this FObj's content.
* Must override in subclasses if their content can be laid out.
* @param list the list to which the layout manager(s) should be added
*/
public void addLayoutManager(List list) {
}

/**
* Returns the name of the node
* @return the name of this node

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

@@ -131,7 +131,7 @@ public class FOText extends FObj {
* @return true if this will create an area in the output
*/
public boolean willCreateArea() {
if (textInfo.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE
if (textInfo.whiteSpaceCollapse == Constants.WhiteSpaceCollapse.FALSE
&& endIndex - startIndex > 0) {
return true;
}
@@ -194,7 +194,7 @@ public class FOText extends FObj {
* text-transform property.
*/
private void textTransform() {
if (textInfo.textTransform == TextTransform.NONE) {
if (textInfo.textTransform == Constants.TextTransform.NONE) {
return;
}
for (int i = 0; i < endIndex; i++) {
@@ -323,13 +323,13 @@ public class FOText extends FObj {
private char charTransform(int i) {
switch (textInfo.textTransform) {
/* put NONE first, as this is probably the common case */
case TextTransform.NONE:
case Constants.TextTransform.NONE:
return ca[i];
case TextTransform.UPPERCASE:
case Constants.TextTransform.UPPERCASE:
return Character.toUpperCase(ca[i]);
case TextTransform.LOWERCASE:
case Constants.TextTransform.LOWERCASE:
return Character.toLowerCase(ca[i]);
case TextTransform.CAPITALIZE:
case Constants.TextTransform.CAPITALIZE:
if (isStartOfWord(i)) {
/*
Use toTitleCase here. Apparently, some languages use
@@ -497,7 +497,7 @@ public class FOText extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
if (endIndex - startIndex > 0) {

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

@@ -21,7 +21,6 @@ package org.apache.fop.fo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
@@ -459,14 +458,6 @@ public class FObj extends FONode implements Constants {
return markers;
}

/**
* Return a LayoutManager responsible for laying out this FObj's content.
* Must override in subclasses if their content can be laid out.
* @param list the list to which the layout manager(s) should be added
*/
public void addLayoutManager(List list) {
}

/*
* Return a string representation of the fo element.
* Deactivated in order to see precise ID of each fo element created

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

@@ -69,7 +69,7 @@ public class FObjMixed extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
if (getChildNodes() != null) {

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

@@ -106,7 +106,7 @@ public class BasicLink extends Inline {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
BasicLinkLayoutManager lm = new BasicLinkLayoutManager(this);

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

@@ -109,7 +109,7 @@ public class BidiOverride extends FObjMixed {
}
/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
* @todo see if can/should move the child iteration logic
* to BidiLayoutManager
*/

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

@@ -342,7 +342,7 @@ public class Block extends FObjMixed {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
BlockLayoutManager blm = new BlockLayoutManager(this);

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

@@ -91,7 +91,7 @@ public class BlockContainer extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
BlockContainerLayoutManager blm = new BlockContainerLayoutManager(this);

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

@@ -89,7 +89,7 @@ public class Character extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
String str = getPropString(PR_CHARACTER);

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

@@ -66,7 +66,7 @@ public class ExternalGraphic extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
if (getPropString(PR_SRC) != null) {

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

@@ -112,7 +112,7 @@ public class Footnote extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
if (getInlineFO() == null) {

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

@@ -53,7 +53,7 @@ public class InlineContainer extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
ArrayList childList = new ArrayList();

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

@@ -109,7 +109,7 @@ public class InstreamForeignObject extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
InstreamForeignObjectLM lm = new InstreamForeignObjectLM(this);

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

@@ -125,7 +125,7 @@ public class Leader extends FObjMixed {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
setup();

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

@@ -84,7 +84,7 @@ public class ListBlock extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
ListBlockLayoutManager lm = new ListBlockLayoutManager(this);

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

@@ -109,7 +109,7 @@ public class ListItem extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
ListItemLayoutManager blm = new ListItemLayoutManager(this);

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

@@ -91,7 +91,7 @@ public class PageNumber extends FObj {
}
/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
PageNumberLayoutManager lm = new PageNumberLayoutManager(this);

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

@@ -67,7 +67,7 @@ public class PageNumberCitation extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
PageNumberCitationLayoutManager lm =

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

@@ -84,7 +84,7 @@ public class RetrieveMarker extends FObjMixed {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
RetrieveMarkerLayoutManager lm = new RetrieveMarkerLayoutManager(this);

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

@@ -132,7 +132,7 @@ public class Table extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
* @todo see if can/should move much of this logic into TableLayoutManager
* and/or TableBody and TableColumn FO subclasses.
*/

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

@@ -65,7 +65,7 @@ public class TableBody extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
Body blm = new Body(this);

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

@@ -325,7 +325,7 @@ public class TableCell extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
Cell clm = new Cell(this);

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

@@ -128,7 +128,7 @@ public class TableRow extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
Row rlm = new Row(this);

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

@@ -46,7 +46,7 @@ public class Wrapper extends FObjMixed {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
* @todo remove null check when vCN() & endOfNode() implemented
*/
public void addLayoutManager(List list) {

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

@@ -126,7 +126,7 @@ public class Flow extends FObj {
}

/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @see org.apache.fop.fo.FONode#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
FlowLayoutManager lm = new FlowLayoutManager(this);

+ 4
- 3
src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java View File

@@ -19,6 +19,7 @@
package org.apache.fop.layoutmgr;

import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FONode;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.Area;
import org.apache.fop.area.Resolveable;
@@ -413,9 +414,9 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
List newLMs = new ArrayList(size);
while (fobjIter.hasNext() && newLMs.size() < size ) {
Object theobj = fobjIter.next();
if (theobj instanceof FObj) {
FObj fobj = (FObj) theobj;
fobj.addLayoutManager(newLMs);
if (theobj instanceof FONode) {
FONode foNode = (FONode) theobj;
foNode.addLayoutManager(newLMs);
}
}
return newLMs;

+ 2
- 1
src/java/org/apache/fop/layoutmgr/TextLayoutManager.java View File

@@ -121,7 +121,8 @@ public class TextLayoutManager extends AbstractLayoutManager {
* @param node The FOText object to be rendered
*/
public TextLayoutManager(FOText node) {
super(node);
super();

foText = node;
textArray = new char[node.endIndex - node.startIndex];
System.arraycopy(node.ca, node.startIndex, textArray, 0,

+ 52
- 51
src/java/org/apache/fop/render/rtf/RTFHandler.java View File

@@ -30,6 +30,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.BlockContainer;
@@ -367,7 +368,7 @@ public class RTFHandler extends FOEventHandler {
bDefer = false;
bDeferredExecution=true;
recurseFObj(bl);
recurseFONode(bl);
bDeferredExecution=false;
//exit function, because the code has already beed executed while
@@ -1225,115 +1226,115 @@ public class RTFHandler extends FOEventHandler {
/**
* Calls the appropriate event handler for the passed FObj.
*
* @param fobj FO-object whose event is to be called
* @param foNode FO node whose event is to be called
* @param bStart TRUE calls the start handler, FALSE the end handler
*/
private void invokeDeferredEvent(FObj fobj, boolean bStart) {
if (fobj instanceof Block) {
private void invokeDeferredEvent(FONode foNode, boolean bStart) {
if (foNode instanceof Block) {
if (bStart) {
startBlock( (Block) fobj);
startBlock( (Block) foNode);
} else {
endBlock( (Block) fobj);
endBlock( (Block) foNode);
}
} else if (fobj instanceof Inline) {
} else if (foNode instanceof Inline) {
if (bStart) {
startInline( (Inline) fobj);
startInline( (Inline) foNode);
} else {
endInline( (Inline) fobj);
endInline( (Inline) foNode);
}
} else if (fobj instanceof FOText) {
} else if (foNode instanceof FOText) {
if (bStart) {
FOText text = (FOText) fobj;
FOText text = (FOText) foNode;
characters(text.ca, text.startIndex, text.endIndex);
}
} else if (fobj instanceof Character) {
} else if (foNode instanceof Character) {
if (bStart) {
Character c = (Character) fobj;
Character c = (Character) foNode;
character(c);
}
} else if (fobj instanceof BasicLink) {
} else if (foNode instanceof BasicLink) {
if (bStart) {
startLink( (BasicLink) fobj);
startLink( (BasicLink) foNode);
} else {
endLink();
}
} else if (fobj instanceof PageNumber) {
} else if (foNode instanceof PageNumber) {
if (bStart) {
startPageNumber( (PageNumber) fobj);
startPageNumber( (PageNumber) foNode);
} else {
endPageNumber( (PageNumber) fobj);
endPageNumber( (PageNumber) foNode);
}
} else if (fobj instanceof Footnote) {
} else if (foNode instanceof Footnote) {
if (bStart) {
startFootnote( (Footnote) fobj);
startFootnote( (Footnote) foNode);
} else {
endFootnote( (Footnote) fobj);
endFootnote( (Footnote) foNode);
}
} else if (fobj instanceof FootnoteBody) {
} else if (foNode instanceof FootnoteBody) {
if (bStart) {
startFootnoteBody( (FootnoteBody) fobj);
startFootnoteBody( (FootnoteBody) foNode);
} else {
endFootnoteBody( (FootnoteBody) fobj);
endFootnoteBody( (FootnoteBody) foNode);
}
} else if (fobj instanceof ListBlock) {
} else if (foNode instanceof ListBlock) {
if (bStart) {
startList( (ListBlock) fobj);
startList( (ListBlock) foNode);
} else {
endList( (ListBlock) fobj);
endList( (ListBlock) foNode);
}
} else if (fobj instanceof ListItem) {
} else if (foNode instanceof ListItem) {
if (bStart) {
startListItem( (ListItem) fobj);
startListItem( (ListItem) foNode);
} else {
endListItem( (ListItem) fobj);
endListItem( (ListItem) foNode);
}
} else if (fobj instanceof ListItemLabel) {
} else if (foNode instanceof ListItemLabel) {
if (bStart) {
startListLabel();
} else {
endListLabel();
}
} else if (fobj instanceof Table) {
} else if (foNode instanceof Table) {
if (bStart) {
startTable( (Table) fobj);
startTable( (Table) foNode);
} else {
endTable( (Table) fobj);
endTable( (Table) foNode);
}
} else if (fobj instanceof TableColumn) {
} else if (foNode instanceof TableColumn) {
if (bStart) {
startColumn( (TableColumn) fobj);
startColumn( (TableColumn) foNode);
} else {
endColumn( (TableColumn) fobj);
endColumn( (TableColumn) foNode);
}
} else if (fobj instanceof TableRow) {
} else if (foNode instanceof TableRow) {
if (bStart) {
startRow( (TableRow) fobj);
startRow( (TableRow) foNode);
} else {
endRow( (TableRow) fobj);
endRow( (TableRow) foNode);
}
} else if (fobj instanceof TableCell) {
} else if (foNode instanceof TableCell) {
if (bStart) {
startCell( (TableCell) fobj);
startCell( (TableCell) foNode);
} else {
endCell( (TableCell) fobj);
endCell( (TableCell) foNode);
}
}
}
/**
* Calls the event handlers for the passed FObj and all its elements.
* Calls the event handlers for the passed FONode and all its elements.
*
* @param fobj FO-object which shall be recursed
* @param foNode FONode object which shall be recursed
*/
private void recurseFObj(FObj fobj) {
invokeDeferredEvent(fobj, true);
private void recurseFONode(FONode foNode) {
invokeDeferredEvent(foNode, true);
if (fobj.childNodes != null) {
for(Iterator it=fobj.childNodes.iterator();it.hasNext();) {
recurseFObj( (FObj) it.next() );
if (foNode.getChildNodes() != null) {
for(Iterator it = foNode.getChildNodes(); it.hasNext() ; ) {
recurseFONode( (FONode) it.next() );
}
}
invokeDeferredEvent(fobj, false);
invokeDeferredEvent(foNode, false);
}
}

Loading…
Cancel
Save