Browse Source

removed old area tree


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194902 13f79535-47bb-0310-9956-ffa450edef68
pull/30/head
Keiron Liddle 22 years ago
parent
commit
dd0b2a8e07
83 changed files with 72 additions and 6517 deletions
  1. 0
    7
      src/org/apache/fop/apps/Driver.java
  2. 2
    4
      src/org/apache/fop/apps/PrintStarter.java
  3. 0
    34
      src/org/apache/fop/datatypes/IDReferences.java
  4. 0
    13
      src/org/apache/fop/fo/FONode.java
  5. 0
    12
      src/org/apache/fop/fo/FOText.java
  6. 0
    1
      src/org/apache/fop/fo/FOTreeBuilder.java
  7. 0
    21
      src/org/apache/fop/fo/FObj.java
  8. 1
    25
      src/org/apache/fop/fo/FObjMixed.java
  9. 2
    4
      src/org/apache/fop/fo/PropertyManager.java
  10. 2
    4
      src/org/apache/fop/fo/Title.java
  11. 1
    3
      src/org/apache/fop/fo/ToBeImplementedElement.java
  12. 1
    3
      src/org/apache/fop/fo/Unknown.java
  13. 0
    11
      src/org/apache/fop/fo/UnknownXMLObj.java
  14. 0
    20
      src/org/apache/fop/fo/XMLElement.java
  15. 0
    15
      src/org/apache/fop/fo/XMLObj.java
  16. 1
    51
      src/org/apache/fop/fo/flow/BasicLink.java
  17. 0
    1
      src/org/apache/fop/fo/flow/BidiOverride.java
  18. 2
    191
      src/org/apache/fop/fo/flow/Block.java
  19. 2
    77
      src/org/apache/fop/fo/flow/BlockContainer.java
  20. 17
    7
      src/org/apache/fop/fo/flow/ExternalGraphic.java
  21. 1
    2
      src/org/apache/fop/fo/flow/Float.java
  22. 0
    112
      src/org/apache/fop/fo/flow/Flow.java
  23. 1
    83
      src/org/apache/fop/fo/flow/Footnote.java
  24. 0
    37
      src/org/apache/fop/fo/flow/FootnoteBody.java
  25. 1
    3
      src/org/apache/fop/fo/flow/InitialPropertySet.java
  26. 1
    144
      src/org/apache/fop/fo/flow/InstreamForeignObject.java
  27. 3
    90
      src/org/apache/fop/fo/flow/Leader.java
  28. 1
    83
      src/org/apache/fop/fo/flow/ListBlock.java
  29. 1
    96
      src/org/apache/fop/fo/flow/ListItem.java
  30. 1
    22
      src/org/apache/fop/fo/flow/ListItemBody.java
  31. 1
    15
      src/org/apache/fop/fo/flow/ListItemLabel.java
  32. 0
    31
      src/org/apache/fop/fo/flow/Marker.java
  33. 1
    2
      src/org/apache/fop/fo/flow/MultiCase.java
  34. 1
    2
      src/org/apache/fop/fo/flow/MultiProperties.java
  35. 1
    2
      src/org/apache/fop/fo/flow/MultiPropertySet.java
  36. 1
    2
      src/org/apache/fop/fo/flow/MultiSwitch.java
  37. 1
    2
      src/org/apache/fop/fo/flow/MultiToggle.java
  38. 3
    20
      src/org/apache/fop/fo/flow/PageNumber.java
  39. 2
    59
      src/org/apache/fop/fo/flow/PageNumberCitation.java
  40. 0
    111
      src/org/apache/fop/fo/flow/RetrieveMarker.java
  41. 0
    2
      src/org/apache/fop/fo/flow/RowSpanMgr.java
  42. 1
    52
      src/org/apache/fop/fo/flow/StaticContent.java
  43. 1
    485
      src/org/apache/fop/fo/flow/Table.java
  44. 1
    2
      src/org/apache/fop/fo/flow/TableAndCaption.java
  45. 2
    183
      src/org/apache/fop/fo/flow/TableBody.java
  46. 1
    2
      src/org/apache/fop/fo/flow/TableCaption.java
  47. 0
    171
      src/org/apache/fop/fo/flow/TableCell.java
  48. 1
    40
      src/org/apache/fop/fo/flow/TableColumn.java
  49. 0
    8
      src/org/apache/fop/fo/flow/TableFooter.java
  50. 1
    226
      src/org/apache/fop/fo/flow/TableRow.java
  51. 2
    2
      src/org/apache/fop/fo/pagination/PageSequence.java
  52. 0
    1
      src/org/apache/fop/fo/pagination/Root.java
  53. 0
    414
      src/org/apache/fop/layout/Area.java
  54. 0
    75
      src/org/apache/fop/layout/AreaContainer.java
  55. 0
    95
      src/org/apache/fop/layout/AreaTree.java
  56. 0
    228
      src/org/apache/fop/layout/BlockArea.java
  57. 0
    390
      src/org/apache/fop/layout/BodyAreaContainer.java
  58. 0
    49
      src/org/apache/fop/layout/BodyRegionArea.java
  59. 0
    15
      src/org/apache/fop/layout/Box.java
  60. 0
    53
      src/org/apache/fop/layout/ColumnArea.java
  61. 0
    23
      src/org/apache/fop/layout/DisplaySpace.java
  62. 0
    32
      src/org/apache/fop/layout/ExtensionArea.java
  63. 0
    1336
      src/org/apache/fop/layout/LineArea.java
  64. 0
    163
      src/org/apache/fop/layout/LinkSet.java
  65. 0
    107
      src/org/apache/fop/layout/LinkedRectangle.java
  66. 0
    221
      src/org/apache/fop/layout/Page.java
  67. 0
    46
      src/org/apache/fop/layout/RegionArea.java
  68. 0
    10
      src/org/apache/fop/layout/Space.java
  69. 0
    120
      src/org/apache/fop/layout/SpanArea.java
  70. 0
    206
      src/org/apache/fop/layout/inline/ForeignObjectArea.java
  71. 0
    115
      src/org/apache/fop/layout/inline/InlineArea.java
  72. 0
    90
      src/org/apache/fop/layout/inline/InlineSpace.java
  73. 0
    59
      src/org/apache/fop/layout/inline/LeaderArea.java
  74. 0
    23
      src/org/apache/fop/layout/inline/PageNumberInlineArea.java
  75. 0
    42
      src/org/apache/fop/layout/inline/WordArea.java
  76. 2
    3
      src/org/apache/fop/pdf/PDFDocument.java
  77. 2
    0
      src/org/apache/fop/pdf/PDFLink.java
  78. 1
    1
      src/org/apache/fop/render/awt/AWTRenderer.java
  79. 1
    1
      src/org/apache/fop/render/pdf/PDFRenderer.java
  80. 2
    2
      src/org/apache/fop/svg/PDFANode.java
  81. 1
    1
      src/org/apache/fop/svg/PDFGraphics2D.java
  82. 1
    0
      src/org/apache/fop/svg/PDFTextElementBridge.java
  83. 0
    1
      src/org/apache/fop/svg/SVGElement.java

+ 0
- 7
src/org/apache/fop/apps/Driver.java View File

@@ -11,7 +11,6 @@ package org.apache.fop.apps;
import org.apache.fop.fo.FOUserAgent;
import org.apache.fop.fo.FOTreeBuilder;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.render.Renderer;
import org.apache.fop.configuration.ConfigurationReader;
import org.apache.fop.configuration.Configuration;
@@ -138,11 +137,6 @@ public class Driver {
*/
private FOTreeBuilder _treeBuilder;

/**
* the area tree that is the result of formatting the FO tree
*/
private AreaTree _areaTree;

/**
* the renderer to use to output the area tree
*/
@@ -242,7 +236,6 @@ public class Driver {
* The output stream is cleared. The renderer is cleared.
*/
public synchronized void reset() {
_areaTree = null;
_source = null;
_stream = null;
_reader = null;

+ 2
- 4
src/org/apache/fop/apps/PrintStarter.java View File

@@ -31,8 +31,6 @@ import java.io.IOException;
import java.util.Vector;

import org.apache.fop.render.awt.AWTRenderer;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.layout.Page;

/**
* This class prints a xsl-fo dokument without interaction.
@@ -154,10 +152,10 @@ public class PrintStarter extends CommandLineStarter {
}
}

public void renderPage(Page page) {
/*public void renderPage(Page page) {
pageWidth = (int)((float)page.getWidth() / 1000f);
pageHeight = (int)((float)page.getHeight() / 1000f);
}
}*/

private Vector getInvalidPageNumbers() {


+ 0
- 34
src/org/apache/fop/datatypes/IDReferences.java View File

@@ -8,7 +8,6 @@
package org.apache.fop.datatypes;

import org.apache.fop.pdf.PDFGoTo;
import org.apache.fop.layout.AreaContainer;


// Java
@@ -16,7 +15,6 @@ import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;

/**
@@ -48,20 +46,6 @@ public class IDReferences {
idUnvalidated = new Hashtable();
}


/**
* Creates and configures the specified id.
*
* @param id The id to initialize
* @param area The area where this id was encountered
* @exception FOPException
*/
public void initializeID(String id, Area area) throws FOPException {
createID(id);
configureID(id, area);
}


/**
* Creates id entry
*
@@ -134,24 +118,6 @@ public class IDReferences {
return idUnvalidated.containsKey(id);
}

/**
* Configures this id
*
* @param id The id to configure
* @param area The area where the id was encountered
*/
public void configureID(String id, Area area) {
if (id != null &&!id.equals("")) {
setPosition(id,
area.getPage().getBody().getXPosition()
+ area.getTableCellXOffset() - ID_PADDING,
area.getPage().getBody().getYPosition()
- area.getAbsoluteHeight() + ID_PADDING);
setPageNumber(id, area.getPage().getNumber());
area.getPage().addToIDList(id);
}
}

/**
* Adds id to validation list to be validated . This should be used if it is unsure whether the id is valid
*

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

@@ -10,7 +10,6 @@ package org.apache.fop.fo;
// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.StructureHandler;
import org.apache.fop.layout.Area;
import org.apache.fop.util.CharUtilities;

// Avalon
@@ -72,18 +71,6 @@ abstract public class FONode {
// ignore
}

/**
* generates the area or areas for this formatting object
* and adds these to the area. This method should always be
* overridden by all sub classes
*
* @param area
*/
public Status layout(Area area) throws FOPException {
// should always be overridden
return new Status(Status.OK);
}

/**
*
*/

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

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

// FOP
import org.apache.fop.layout.Area;
import org.apache.fop.layout.BlockArea;
import org.apache.fop.layout.FontState;
import org.apache.fop.layout.*;
import org.apache.fop.datatypes.*;
@@ -70,16 +68,6 @@ public class FOText extends FObj {
return false;
}

// Just to keep PageNumber and PageNumber citation happy for now.
// The real code is moved to TextLayoutManager!

public static int addText(BlockArea ba, FontState fontState,
float red, float green, float blue, int wrapOption,
LinkSet ls, int whiteSpaceCollapse, char data[],
int start, int end, TextState textState, int vAlign) {
return 0;
}

public void addLayoutManager(List list) {
// if nothing left (length=0)?
if(length == 0) return;

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

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

// FOP
import org.apache.fop.layout.AreaTree;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.StructureHandler;
import org.apache.fop.fo.pagination.Root;

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

@@ -8,15 +8,11 @@
package org.apache.fop.fo;

// FOP
import org.apache.fop.layout.Area;
import org.apache.fop.layout.AreaClass;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.StructureHandler;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.fo.properties.FOPropertyMapping;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.AreaClass;
import org.apache.fop.layout.LinkSet;
import org.apache.fop.fo.flow.Marker;

// Java
@@ -67,8 +63,6 @@ public class FObj extends FONode {
protected int widows = 0;
protected int orphans = 0;

protected LinkSet linkSet;

// count of areas generated-by/returned-by
public int areasGenerated = 0;

@@ -295,21 +289,6 @@ public class FObj extends FONode {
// still to do
}

public void setLinkSet(LinkSet linkSet) {
this.linkSet = linkSet;
for (int i = 0; i < this.children.size(); i++) {
Object obj = this.children.get(i);
if (obj instanceof FObj) {
FObj child = (FObj) obj;
child.setLinkSet(linkSet);
}
}
}

public LinkSet getLinkSet() {
return this.linkSet;
}

/**
* At the start of a new span area layout may be partway through a
* nested FO, and balancing requires rollback to this known point.

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

@@ -7,7 +7,6 @@

package org.apache.fop.fo;

import org.apache.fop.layout.Area;
import org.apache.fop.layout.FontState;
import org.apache.fop.layout.FontInfo;
import org.apache.fop.apps.FOPException;
@@ -63,34 +62,11 @@ public class FObjMixed extends FObj {
addChild(ft);
}

public Status layout(Area area) throws FOPException {
public void setup() {

if (this.properties != null) {
setupID();
if (id != null) {
if (this.marker == START) {
if (area.getIDReferences() != null)
area.getIDReferences().createID(id);
this.marker = 0;
}

if (this.marker == 0) {
if (area.getIDReferences() != null)
area.getIDReferences().configureID(id, area);
}
}
}

int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FONode fo = (FONode) children.get(i);
Status status;
if ((status = fo.layout(area)).isIncomplete()) {
this.marker = i;
return status;
}
}
return new Status(Status.OK);
}

public CharIterator charIterator() {

+ 2
- 4
src/org/apache/fop/fo/PropertyManager.java View File

@@ -35,8 +35,6 @@ import org.apache.fop.layout.HyphenationProps;
import org.apache.fop.apps.FOPException;
import java.text.MessageFormat;
import java.text.FieldPosition;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.ColumnArea;

public class PropertyManager {

@@ -133,7 +131,7 @@ public class PropertyManager {
return hyphProps;
}

public int checkBreakBefore(Area area) {
/*public int checkBreakBefore(Area area) {
if (!(area instanceof ColumnArea)) {
switch (properties.get("break-before").getEnum()) {
case BreakBefore.PAGE:
@@ -197,7 +195,7 @@ public class PropertyManager {
default:
return Status.OK;
}
}
}*/


public MarginProps getMarginProps() {

+ 2
- 4
src/org/apache/fop/fo/Title.java View File

@@ -13,7 +13,6 @@ import org.apache.fop.datatypes.*;
import org.apache.fop.layout.*;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.apps.FOPException;

/**
@@ -24,7 +23,7 @@ public class Title extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -37,7 +36,7 @@ public class Title extends ToBeImplementedElement {
BackgroundProps bProps = propMgr.getBackgroundProps();

// Common Font Properties
FontState fontState = propMgr.getFontState(area.getFontInfo());
//FontState fontState = propMgr.getFontState(structHandler.getFontInfo());

// Common Margin Properties-Inline
MarginInlineProps mProps = propMgr.getMarginInlineProps();
@@ -56,6 +55,5 @@ public class Title extends ToBeImplementedElement {
int vis = this.properties.get("visibility").getEnum();
Length zIndex = this.properties.get("z-index").getLength();

return super.layout(area);
}
}

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

@@ -11,7 +11,6 @@ package org.apache.fop.fo;
import org.apache.fop.fo.*;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;

/**
@@ -22,10 +21,9 @@ public class ToBeImplementedElement extends FObj {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {
log.debug("This element \"" + this.name
+ "\" is not yet implemented.");
return new Status(Status.OK);
}

}

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

@@ -12,7 +12,6 @@ import org.apache.fop.fo.*;
import org.apache.fop.layout.*;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.apps.FOPException;

/**
@@ -33,8 +32,7 @@ public class Unknown extends FONode {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {
log.debug("Layout Unknown element");
return new Status(Status.OK);
}
}

+ 0
- 11
src/org/apache/fop/fo/UnknownXMLObj.java View File

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

import org.apache.fop.fo.*;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.FontState;
import org.apache.fop.layout.inline.*;
import org.apache.fop.apps.FOPException;
@@ -59,15 +58,5 @@ public class UnknownXMLObj extends XMLObj {
super.addCharacters(data, start, length);
}

public Status layout(Area area) throws FOPException {
if(!"".equals(this.namespace)) {
log.error("no handler defined for " + this.namespace + ":" + this.name + " foreign xml");
} else {
log.error("no handler defined for (none):" + this.name + " foreign xml");
}

/* return status */
return new Status(Status.OK);
}
}


+ 0
- 20
src/org/apache/fop/fo/XMLElement.java View File

@@ -9,8 +9,6 @@ package org.apache.fop.fo;

// FOP
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.inline.*;
import org.apache.fop.apps.FOPException;

import org.xml.sax.Attributes;
@@ -36,24 +34,6 @@ public class XMLElement extends XMLObj {
init();
}

/**
* layout this formatting object.
*
* @param area the area to layout the object into
*
* @return the status of the layout
*/
public Status layout(final Area area) throws FOPException {

if (!(area instanceof ForeignObjectArea)) {
// this is an error
throw new FOPException("XML not in fo:instream-foreign-object");
}

/* return status */
return new Status(Status.OK);
}

private void init() {
createBasicDocument();
}

+ 0
- 15
src/org/apache/fop/fo/XMLObj.java View File

@@ -9,10 +9,8 @@ package org.apache.fop.fo;

// FOP
import org.apache.fop.fo.*;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.FontState;
import org.apache.fop.apps.FOPException;
import org.apache.fop.layout.LinkSet;
import org.apache.fop.datatypes.IDReferences;

import org.w3c.dom.*;
@@ -151,18 +149,5 @@ public abstract class XMLObj extends FONode {
element.appendChild(text);
}

/**
* layout this formatting object.
*
* @param area the area to layout the object into
* @return the status of the layout
*/
public Status layout(Area area) throws FOPException {
/* generate a warning */
log.warn("" + this.name + " outside foreign xml");

/* return status */
return new Status(Status.OK);
}
}


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

@@ -30,7 +30,7 @@ public class BasicLink extends Inline {
super.addLayoutManager(lms);
}

public Status layout(Area area) throws FOPException {
public void setup() {
String destination;
int linkType;

@@ -69,56 +69,6 @@ public class BasicLink extends Inline {
// this.properties.get("target-presentation-context");
// this.properties.get("target-stylesheet");

if (!(destination =
this.properties.get("internal-destination").getString()).equals("")) {
linkType = LinkSet.INTERNAL;
} else if (!(destination =
this.properties.get("external-destination").getString()).equals("")) {
linkType = LinkSet.EXTERNAL;
} else {
throw new FOPException("internal-destination or external-destination must be specified in basic-link");
}

if (this.marker == START) {
// initialize id
area.getIDReferences().initializeID(id, area);
this.marker = 0;
}

// new LinkedArea to gather up inlines
LinkSet ls = new LinkSet(destination, area, linkType);

Page p = area.getPage();

AreaContainer ac = p.getBody().getCurrentColumnArea();
if (ac == null) {
throw new FOPException("Couldn't get ancestor AreaContainer when processing basic-link");
}

int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FONode fo = (FONode)children.get(i);
if(fo instanceof FObj)
((FObj)fo).setLinkSet(ls);

Status status;
if ((status = fo.layout(area)).isIncomplete()) {
this.marker = i;
return status;
}
}

ls.applyAreaContainerOffsets(ac, area);

// pass on command line
String mergeLinks = System.getProperty("links.merge");
if ((null != mergeLinks) &&!mergeLinks.equalsIgnoreCase("no")) {
ls.mergeLinks();
}

p.addLinkSet(ls);

return new Status(Status.OK);
}

}

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

@@ -13,7 +13,6 @@ 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;

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

@@ -90,17 +90,7 @@ public class Block extends FObjMixed {
structHandler.startBlock(this);
}

public Status layout(Area area) throws FOPException {
BlockArea blockArea;

// log.error(" b:LAY[" + marker + "] ");


if (this.marker == BREAK_AFTER) {
return new Status(Status.OK);
}

if (this.marker == START) {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -132,7 +122,7 @@ public class Block extends FObjMixed {
// this.properties.get("text-altitude");
// this.properties.get("hyphenation-keep");
// this.properties.get("hyphenation-ladder-count");
// this.properties.get("id");
setupID();
// this.properties.get("keep-together");
// this.properties.get("keep-with-next");
// this.properties.get("keep-with-previous");
@@ -179,185 +169,6 @@ public class Block extends FObjMixed {
this.blockOrphans =
this.properties.get("orphans").getNumber().intValue();

this.id = this.properties.get("id").getString();

if (area instanceof BlockArea) {
area.end();
}

if (area.getIDReferences() != null)
area.getIDReferences().createID(id);

this.marker = 0;

// no break if first in area tree, or leading in context
// area
int breakBeforeStatus = propMgr.checkBreakBefore(area);
if (breakBeforeStatus != Status.OK) {
return new Status(breakBeforeStatus);
}

int numChildren = this.children.size();
for (int i = 0; i < numChildren; i++) {
FONode fo = (FONode) children.get(i);
if (fo instanceof FOText) {
if (((FOText) fo).willCreateArea()) {
//fo.setWidows(blockWidows);
break;
} else {
children.remove(i);
numChildren = this.children.size();
i--;
}
} else {
//fo.setWidows(blockWidows);
break;
}
}

for (int i = numChildren - 1; i >= 0; i--) {
FONode fo = (FONode) children.get(i);
if (fo instanceof FOText) {
if (((FOText) fo).willCreateArea()) {
//fo.setOrphans(blockOrphans);
break;
}
} else {
//fo.setOrphans(blockOrphans);
break;
}
}
}

if ((spaceBefore != 0) && (this.marker == 0)) {
area.addDisplaySpace(spaceBefore);
}

if (anythingLaidOut) {
this.textIndent = 0;
}

if (marker == 0 && area.getIDReferences() != null) {
area.getIDReferences().configureID(id, area);
}

int spaceLeft = area.spaceLeft();
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)
blockArea.isFirst(true);
// for normal areas this should be the only pair
blockArea.addLineagePair(this, this.areasGenerated);

// markers
//if (this.hasMarkers())
//blockArea.addMarkers(this.getMarkers());

blockArea.setParent(area); // BasicLink needs it
blockArea.setPage(area.getPage());
blockArea.setBackgroundColor(backgroundColor);
blockArea.setBorderAndPadding(propMgr.getBorderAndPadding());
blockArea.setHyphenation(propMgr.getHyphenationProps());
blockArea.start();

blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
blockArea.setIDReferences(area.getIDReferences());

blockArea.setTableCellXOffset(area.getTableCellXOffset());

int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FONode fo = (FONode) children.get(i);
Status status;
if ((status = fo.layout(blockArea)).isIncomplete()) {
this.marker = i;
// this block was modified by
// Hani Elabed 11/27/2000
// if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE))
// {
// status = new Status(Status.AREA_FULL_SOME);
// }

// new block to replace the one above
// Hani Elabed 11/27/2000
if (status.getCode() == Status.AREA_FULL_NONE) {
// something has already been laid out
if ((i != 0)) {
status = new Status(Status.AREA_FULL_SOME);
area.addChild(blockArea);
area.setMaxHeight(area.getMaxHeight() -
spaceLeft + blockArea.getMaxHeight());
area.increaseHeight(blockArea.getHeight());
area.setAbsoluteHeight(
blockArea.getAbsoluteHeight());
anythingLaidOut = true;

return status;
} else // i == 0 nothing was laid out..
{
anythingLaidOut = false;
return status;
}
}

// blockArea.end();
area.addChild(blockArea);
area.setMaxHeight(area.getMaxHeight() - spaceLeft +
blockArea.getMaxHeight());
area.increaseHeight(blockArea.getHeight());
area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
anythingLaidOut = true;
return status;
}
anythingLaidOut = true;
}

blockArea.end();

area.setMaxHeight(area.getMaxHeight() - spaceLeft +
blockArea.getMaxHeight());

area.addChild(blockArea);

/* should this be combined into above? */
area.increaseHeight(blockArea.getHeight());

area.setAbsoluteHeight(blockArea.getAbsoluteHeight());

if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
}

if (area instanceof BlockArea) {
area.start();
}
// 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();

// no break if last in area tree, or trailing in context
// area
int breakAfterStatus = propMgr.checkBreakAfter(area);
if (breakAfterStatus != Status.OK) {
this.marker = BREAK_AFTER;
blockArea = null; //Faster GC - BlockArea is big
return new Status(breakAfterStatus);
}

if (keepWithNext != 0) {
blockArea = null; // Faster GC - BlockArea is big
return new Status(Status.KEEP_WITH_NEXT);
}

// log.error(" b:OK" + marker + " ");
blockArea.isLast(true);
blockArea = null; // Faster GC - BlockArea is big
return new Status(Status.OK);
}

public int getAreaHeight() {

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

@@ -32,10 +32,6 @@ public class BlockContainer extends FObj {

int span;

AreaContainer areaContainer;

PageSequence pageSequence;

public BlockContainer(FONode parent) {
super(parent);
}
@@ -46,8 +42,7 @@ public class BlockContainer extends FObj {
setupID();
}

public Status layout(Area area) throws FOPException {
if (this.marker == START) {
public void setup() {

// Common Accessibility Properties
AbsolutePositionProps mAbsProps = propMgr.getAbsolutePositionProps();
@@ -65,7 +60,7 @@ public class BlockContainer extends FObj {
// this.properties.get("clip");
// this.properties.get("display-align");
// this.properties.get("height");
// this.properties.get("id");
setupID();
// this.properties.get("keep-together");
// this.properties.get("keep-with-next");
// this.properties.get("keep-with-previous");
@@ -89,76 +84,6 @@ public class BlockContainer extends FObj {
this.height = this.properties.get("height").getLength().mvalue();
span = this.properties.get("span").getEnum();

// initialize id
String id = this.properties.get("id").getString();
area.getIDReferences().initializeID(id, area);
}

boolean prevChildMustKeepWithNext = false;

AreaContainer container = (AreaContainer)area;
if ((this.width == 0) && (this.height == 0)) {
width = right - left;
height = bottom - top;
}

this.areaContainer =
new AreaContainer(propMgr.getFontState(container.getFontInfo()),
container.getXPosition() + left,
container.getYPosition() - top, width, height,
position);

areaContainer.setPage(area.getPage());
areaContainer.setBackgroundColor(backgroundColor);
areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding());
areaContainer.start();

areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
areaContainer.setIDReferences(area.getIDReferences());

int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FObj fo = (FObj)children.get(i);
Status status;
if ((status = fo.layout(areaContainer)).isIncomplete()) {
/*
* if ((prevChildMustKeepWithNext) && (status.laidOutNone())) {
* this.marker = i - 1;
* FObj prevChild = (FObj) children.elementAt(this.marker);
* prevChild.removeAreas();
* prevChild.resetMarker();
* return new Status(Status.AREA_FULL_SOME);
* // should probably return AREA_FULL_NONE if first
* // or perhaps an entirely new status code
* } else {
* this.marker = i;
* return status;
* }
*/
}
if (status.getCode() == Status.KEEP_WITH_NEXT) {
prevChildMustKeepWithNext = true;
}
}
area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());

areaContainer.end();
if (position == Position.ABSOLUTE)
areaContainer.setHeight(height);
area.addChild(areaContainer);

return new Status(Status.OK);
}

/**
* Return the content width of the boxes generated by this block
* container FO.
*/
public int getContentWidth() {
if (areaContainer != null)
return areaContainer.getContentWidth(); // getAllocationWidth()??
else
return 0; // not laid out yet
}

public boolean generatesReferenceAreas() {

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

@@ -16,6 +16,7 @@ import org.apache.fop.image.*;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
import org.apache.fop.layoutmgr.LayoutInfo;
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.Viewport;

@@ -36,7 +37,6 @@ public class ExternalGraphic extends FObj {
String src;
int height;
int width;
String id;

public ExternalGraphic(FONode parent) {
super(parent);
@@ -57,14 +57,24 @@ public class ExternalGraphic extends FObj {
// if we need to load this image to get its size
ImageFactory fact = ImageFactory.getInstance();
FopImage fopimage = fact.getImage(url, userAgent);
// if(fopimage == null) {
// error
// }
// if(!fopimage.load(FopImage.DIMENSIONS)) {
// error
// }
if(fopimage == null) {
// error
return null;
}
// load dimensions
if(!fopimage.load(FopImage.DIMENSIONS, userAgent)) {
// error
return null;
}
Image imArea = new Image(url);
Viewport vp = new Viewport(imArea);
vp.setWidth((int)fopimage.getWidth() * 1000);
vp.setHeight((int)fopimage.getHeight() * 1000);
vp.setOffset(0);
vp.info = new LayoutInfo();
vp.info.alignment = properties.get("vertical-align").getEnum();
vp.info.lead = vp.getHeight();

return vp;
}


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

@@ -23,11 +23,10 @@ public class Float extends ToBeImplementedElement {
this.name = "fo:float";
}

public Status layout(Area area) throws FOPException {
public void setup() {

// this.properties.get("float");
// this.properties.get("clear");

return super.layout(area);
}
}

+ 0
- 112
src/org/apache/fop/fo/flow/Flow.java View File

@@ -11,8 +11,6 @@ package org.apache.fop.fo.flow;
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.fo.pagination.*;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.BodyAreaContainer;
import org.apache.fop.apps.FOPException;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.FlowLayoutManager;
@@ -30,11 +28,6 @@ public class Flow extends FObj {
*/
private PageSequence pageSequence;

/**
* Area in which we lay out our kids
*/
private Area area;

/**
* ArrayList to store snapshot
*/
@@ -50,8 +43,6 @@ public class Flow extends FObj {
*/
private int contentWidth;

private Status _status = new Status(Status.AREA_FULL_NONE);


public Flow(FONode parent) {
super(parent);
@@ -104,105 +95,6 @@ public class Flow extends FObj {
return _flowName;
}

public Status layout(Area area) throws FOPException {
return layout(area, null);

}

public Status layout(Area area, Region region) throws FOPException {
if (this.marker == START) {
this.marker = 0;
}

// flow is *always* laid out into a BodyAreaContainer
BodyAreaContainer bac = (BodyAreaContainer) area;

boolean prevChildMustKeepWithNext = false;
ArrayList pageMarker = this.getMarkerSnapshot(new ArrayList());

int numChildren = this.children.size();
if (numChildren == 0) {
throw new FOPException("fo:flow must contain block-level children");
}
for (int i = this.marker; i < numChildren; i++) {
FObj fo = (FObj) children.get(i);

if (bac.isBalancingRequired(fo)) {
// reset the the just-done span area in preparation
// for a backtrack for balancing
bac.resetSpanArea();

this.rollback(markerSnapshot);
// one less because of the "continue"
i = this.marker - 1;
continue;
}
// current column area
Area currentArea = bac.getNextArea(fo);
// temporary hack for IDReferences
currentArea.setIDReferences(bac.getIDReferences());
if (bac.isNewSpanArea()) {
this.marker = i;
markerSnapshot = this.getMarkerSnapshot(new ArrayList());
}
// Set current content width for percent-based lengths in children
setContentWidth(currentArea.getContentWidth());

_status = fo.layout(currentArea);

/*
* if((_status.isPageBreak() || i == numChildren - 1) && bac.needsFootnoteAdjusting()) {
* bac.adjustFootnoteArea();
* this.rollback(pageMarker);
* i = this.marker - 1;
* Area mainReferenceArea = bac.getMainReferenceArea();
* // remove areas
* continue;
* }
*/
if (_status.isIncomplete()) {
if ((prevChildMustKeepWithNext) &&
(_status.laidOutNone())) {
this.marker = i - 1;
FObj prevChild = (FObj) children.get(this.marker);
prevChild.removeAreas();
prevChild.resetMarker();
_status = new Status(Status.AREA_FULL_SOME);
return _status;
// should probably return AREA_FULL_NONE if first
// or perhaps an entirely new status code
}
if (bac.isLastColumn())
if (_status.getCode() == Status.FORCE_COLUMN_BREAK) {
this.marker = i;
_status = new Status(Status.FORCE_PAGE_BREAK);
// same thing
return _status;
} else {
this.marker = i;
return _status;
}
else {
// not the last column, but could be page breaks
if (_status.isPageBreak()) {
this.marker = i;
return _status;
}
// I don't much like exposing this. (AHS 001217)
((org.apache.fop.layout.ColumnArea) currentArea).
incrementSpanIndex();
i--;
}
}
if (_status.getCode() == Status.KEEP_WITH_NEXT) {
prevChildMustKeepWithNext = true;
} else {
prevChildMustKeepWithNext = false;
}
}
return _status;
}

protected void setContentWidth(int contentWidth) {
this.contentWidth = contentWidth;
}
@@ -214,10 +106,6 @@ public class Flow extends FObj {
return this.contentWidth;
}

public Status getStatus() {
return _status;
}

public boolean generatesReferenceAreas() {
return true;
}

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

@@ -33,87 +33,5 @@ public class Footnote extends FObj {
// set start and end footnote reference
}


public Status layout(Area area) throws FOPException {
FONode inline = null;
FONode fbody = null;
if (this.marker == START) {
this.marker = 0;
}
int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FONode fo = (FONode)children.get(i);
if (fo instanceof Inline) {
inline = fo;
Status status = fo.layout(area);
if (status.isIncomplete()) {
return status;
}
} else if (inline != null && fo instanceof FootnoteBody) {
// add footnote to current page or next if it can't fit
fbody = fo;
if (area instanceof BlockArea) {
((BlockArea)area).addFootnote((FootnoteBody)fbody);
} else {
Page page = area.getPage();
layoutFootnote(page, (FootnoteBody)fbody, area);
}
}
}
if (fbody == null) {
log.error("no footnote-body in footnote");
}
if (area instanceof BlockArea) {}
return new Status(Status.OK);
}

public static boolean layoutFootnote(Page p, FootnoteBody fb, Area area) {
try {
BodyAreaContainer bac = p.getBody();
AreaContainer footArea = bac.getFootnoteReferenceArea();
footArea.setIDReferences(bac.getIDReferences());
int basePos = footArea.getCurrentYPosition()
- footArea.getHeight();
int oldHeight = footArea.getHeight();
if (area != null) {
footArea.setMaxHeight(area.getMaxHeight() - area.getHeight()
+ footArea.getHeight());
} else {
footArea.setMaxHeight(bac.getMaxHeight()
+ footArea.getHeight());
}
Status status = fb.layout(footArea);
if (status.isIncomplete()) {
// add as a pending footnote
return false;
} else {
if (area != null) {
area.setMaxHeight(area.getMaxHeight()
- footArea.getHeight() + oldHeight);
}
// bac.setMaxHeight(bac.getMaxHeight() - footArea.getHeight() + oldHeight);
if (bac.getFootnoteState() == 0) {
Area ar = bac.getMainReferenceArea();
//decreaseMaxHeight(ar, footArea.getHeight() - oldHeight);
footArea.setYPosition(basePos + footArea.getHeight());
}
}
} catch (FOPException fope) {
return false;
}
return true;
}

/* protected static void decreaseMaxHeight(Area ar, int change) {
ar.setMaxHeight(ar.getMaxHeight() - change);
ArrayList childs = ar.getChildren();
for (Iterator en = childs.iterator(); en.hasNext(); ) {
Object obj = en.next();
if (obj instanceof Area) {
Area childArea = (Area)obj;
decreaseMaxHeight(childArea, change);
}
}
}
*/
}


+ 0
- 37
src/org/apache/fop/fo/flow/FootnoteBody.java View File

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

// FOP
import org.apache.fop.fo.*;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.AreaClass;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.*;
@@ -31,40 +30,4 @@ public class FootnoteBody extends FObj {
super(parent);
}

public Status layout(Area area) throws FOPException {
this.areaClass = AreaClass.setAreaClass(AreaClass.XSL_FOOTNOTE);
if (this.marker == START) {
this.marker = 0;
}
BlockArea blockArea =
new BlockArea(propMgr.getFontState(area.getFontInfo()),
area.getAllocationWidth(), area.spaceLeft(),
startIndent, endIndent, textIndent, align,
alignLast, lineHeight);
blockArea.setGeneratedBy(this);
blockArea.isFirst(true);
blockArea.setPage(area.getPage());
blockArea.start();

blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
blockArea.setIDReferences(area.getIDReferences());

blockArea.setTableCellXOffset(area.getTableCellXOffset());

int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FONode fo = (FONode)children.get(i);
Status status;
if ((status = fo.layout(blockArea)).isIncomplete()) {
this.resetMarker();
return status;
}
}
blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
blockArea.isLast(true);
return new Status(Status.OK);
}

}

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

@@ -12,7 +12,6 @@ import org.apache.fop.fo.*;
import org.apache.fop.layout.*;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.apps.FOPException;

/**
@@ -23,7 +22,7 @@ public class InitialPropertySet extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -52,6 +51,5 @@ public class InitialPropertySet extends ToBeImplementedElement {
// this.properties.get("text-transform");
// this.properties.get("word-spacing");

return super.layout(area);
}
}

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

@@ -149,20 +149,7 @@ public class InstreamForeignObject extends FObj {
return true;
}

/**
* layout this formatting object.
*
* @param area the area to layout the object into
*
* @return the status of the layout
*
public Status layout(Area area) throws FOPException {

if (this.marker == BREAK_AFTER) {
return new Status(Status.OK);
}

if (this.marker == START) {
/*

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -233,135 +220,5 @@ public class InstreamForeignObject extends FObj {

this.scaling = this.properties.get("scaling").getEnum();

area.getIDReferences().createID(id);
if (this.areaCurrent == null) {
this.areaCurrent =
new ForeignObjectArea(propMgr.getFontState(area.getFontInfo()),
area.getAllocationWidth());

this.areaCurrent.start();
areaCurrent.setWidth(this.width);
areaCurrent.setHeight(this.height);
areaCurrent.setContentWidth(this.contwidth);
areaCurrent.setContentHeight(this.contheight);
areaCurrent.setScaling(this.scaling);
areaCurrent.setAlign(align);
areaCurrent.setVerticalAlign(valign);
areaCurrent.setOverflow(overflow);
areaCurrent.setSizeAuto(wauto, hauto);
areaCurrent.setContentSizeAuto(cwauto, chauto);

// this means that children can get the fontstate
areaCurrent.setPage(area.getPage());

int numChildren = this.children.size();
if (numChildren > 1) {
throw new FOPException("Only one child element is allowed in an instream-foreign-object");
}
/* layout foreign object *
if (this.children.size() > 0) {
FONode fo = (FONode)children.get(0);
Status status;
if ((status =
fo.layout(this.areaCurrent)).isIncomplete()) {
return status;
}

/* finish off the foreign object area *
this.areaCurrent.end();
}
}

this.marker = 0;

if (breakBefore == BreakBefore.PAGE
|| ((spaceBefore + areaCurrent.getEffectiveHeight())
> area.spaceLeft())) {
return new Status(Status.FORCE_PAGE_BREAK);
}

if (breakBefore == BreakBefore.ODD_PAGE) {
return new Status(Status.FORCE_PAGE_BREAK_ODD);
}

if (breakBefore == BreakBefore.EVEN_PAGE) {
return new Status(Status.FORCE_PAGE_BREAK_EVEN);
}
}

if (this.areaCurrent == null) {
return new Status(Status.OK);
}

if (area instanceof BlockArea) {
BlockArea ba = (BlockArea)area;
LineArea la = ba.getCurrentLineArea();
if (la == null) {
return new Status(Status.AREA_FULL_NONE);
}
la.addPending();
if (areaCurrent.getEffectiveWidth() > la.getRemainingWidth()) {
la = ba.createNextLineArea();
if (la == null) {
return new Status(Status.AREA_FULL_NONE);
}
}
la.addInlineArea(areaCurrent);
} else {
area.addChild(areaCurrent);
area.increaseHeight(areaCurrent.getEffectiveHeight());
}

if (this.isInTableCell) {
startIndent += forcedStartOffset;
/*
* endIndent = areaCurrent.getEffectiveWidth() - forcedWidth -
* forcedStartOffset;
*
}

areaCurrent.setStartIndent(startIndent);
// areaCurrent.setEndIndent(endIndent);

/* if there is a space-before *
if (spaceBefore != 0) {
/* add a display space *
// area.addDisplaySpace(spaceBefore);
}

/* add the SVG area to the containing area *
// area.addChild(areaCurrent);

areaCurrent.setPage(area.getPage());

/* increase the height of the containing area accordingly *
// area.increaseHeight(areaCurrent.getEffectiveHeight());

/* if there is a space-after *
if (spaceAfter != 0) {
/* add a display space *
// area.addDisplaySpace(spaceAfter);
}


if (breakAfter == BreakAfter.PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK);
}

if (breakAfter == BreakAfter.ODD_PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK_ODD);
}

if (breakAfter == BreakAfter.EVEN_PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK_EVEN);
}

areaCurrent = null;
/* return status *
return new Status(Status.OK);
}
*/
}

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

@@ -13,9 +13,6 @@ import org.apache.fop.fo.properties.*;
import org.apache.fop.datatypes.*;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.layout.*;
import org.apache.fop.layout.BlockArea;
import org.apache.fop.layout.inline.LeaderArea;
import org.apache.fop.layout.LineArea;
import org.apache.fop.layout.FontState;
import org.apache.fop.apps.FOPException;
import org.apache.fop.layoutmgr.LayoutManager;
@@ -53,15 +50,7 @@ public class Leader extends FObjMixed {
return leader;
}

public Status layout(Area area) throws FOPException {
BlockArea blockArea;
// restriction in this version
if (!(area instanceof BlockArea)) {
log.warn("in this version of Fop fo:leader must be a direct child of fo:block ");
return new Status(Status.OK);
} else {
blockArea = (BlockArea)area;
}
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -121,8 +110,8 @@ public class Leader extends FObjMixed {
Length maxlength = this.properties.get("leader-length.maximum").getLength();
int leaderLengthMaximum;
if(maxlength instanceof PercentLength) {
leaderLengthMaximum = (int)(((PercentLength)maxlength).value()
* area.getAllocationWidth());
//leaderLengthMaximum = (int)(((PercentLength)maxlength).value()
// * area.getAllocationWidth());
} else {
leaderLengthMaximum = maxlength.mvalue();
}
@@ -136,23 +125,6 @@ public class Leader extends FObjMixed {
int leaderAlignment =
this.properties.get("leader-alignment").getEnum();

// initialize id
blockArea.getIDReferences().initializeID(id, blockArea);

// adds leader to blockarea, there the leaderArea is generated
int succeeded = addLeader(blockArea,
propMgr.getFontState(area.getFontInfo()),
red, green, blue, leaderPattern,
leaderLengthMinimum, leaderLengthOptimum,
leaderLengthMaximum, ruleThickness,
ruleStyle, leaderPatternWidth,
leaderAlignment);
if (succeeded == 1) {
return new Status(Status.OK);
} else {
// not sure that this is the correct Status here
return new Status(Status.AREA_FULL_SOME);
}
}

/*
@@ -164,64 +136,5 @@ public class Leader extends FObjMixed {
* }
*/


/**
* adds a leader to current line area of containing block area
* the actual leader area is created in the line area
*
* @return int +1 for success and -1 for none
*/
public int addLeader(BlockArea ba, FontState fontState, float red,
float green, float blue, int leaderPattern,
int leaderLengthMinimum, int leaderLengthOptimum,
int leaderLengthMaximum, int ruleThickness,
int ruleStyle, int leaderPatternWidth,
int leaderAlignment) {

LineArea la = ba.getCurrentLineArea();
// this should start a new page
if (la == null) {
return -1;
}

la.changeFont(fontState);
la.changeColor(red, green, blue);

// check whether leader fits into the (rest of the) line
// using length.optimum to determine where to break the line as defined
// in the xsl:fo spec: "User agents may choose to use the value of 'leader-length.optimum'
// to determine where to break the line" (7.20.4)
// if leader is longer then create a new LineArea and put leader there
if (leaderLengthOptimum <= (la.getRemainingWidth())) {
la.addLeader(leaderPattern, leaderLengthMinimum,
leaderLengthOptimum, leaderLengthMaximum, ruleStyle,
ruleThickness, leaderPatternWidth, leaderAlignment);
} else {
la = ba.createNextLineArea();
if (la == null) {
// not enough room
return -1;
}
la.changeFont(fontState);
la.changeColor(red, green, blue);

// check whether leader fits into LineArea at all, otherwise
// clip it (should honor the clip option of containing area)
if (leaderLengthMinimum <= la.getContentWidth()) {
la.addLeader(leaderPattern, leaderLengthMinimum,
leaderLengthOptimum, leaderLengthMaximum,
ruleStyle, ruleThickness, leaderPatternWidth,
leaderAlignment);
} else {
log.error("Leader doesn't fit into line, it will be clipped to fit.");
la.addLeader(leaderPattern, la.getRemainingWidth(),
leaderLengthOptimum, leaderLengthMaximum,
ruleStyle, ruleThickness, leaderPatternWidth,
leaderAlignment);
}
}
// this.hasLines = true;
return 1;
}
}


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

@@ -12,7 +12,6 @@ import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.datatypes.*;
import org.apache.fop.layout.*;
import org.apache.fop.layout.BlockArea;
import org.apache.fop.layout.FontState;
import org.apache.fop.apps.FOPException;

@@ -37,8 +36,7 @@ public class ListBlock extends FObj {
super(parent);
}

public Status layout(Area area) throws FOPException {
if (this.marker == START) {
public void setup() throws FOPException {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -81,86 +79,6 @@ public class ListBlock extends FObj {
this.backgroundColor =
this.properties.get("background-color").getColorType();

this.marker = 0;

if (area instanceof BlockArea) {
area.end();
}

if (spaceBefore != 0) {
area.addDisplaySpace(spaceBefore);
}

if (this.isInTableCell) {
startIndent += forcedStartOffset;
endIndent += area.getAllocationWidth() - forcedWidth
- forcedStartOffset;
}

// initialize id
area.getIDReferences().initializeID(id, area);
}

BlockArea blockArea =
new BlockArea(propMgr.getFontState(area.getFontInfo()),
area.getAllocationWidth(), area.spaceLeft(),
startIndent, endIndent, 0, align, alignLast,
lineHeight);
blockArea.setGeneratedBy(this);
this.areasGenerated++;
if (this.areasGenerated == 1)
blockArea.isFirst(true);
// for normal areas this should be the only pair
blockArea.addLineagePair(this, this.areasGenerated);

// markers
//if (this.hasMarkers())
//blockArea.addMarkers(this.getMarkers());


blockArea.setPage(area.getPage());
blockArea.setBackgroundColor(backgroundColor);
blockArea.start();

blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
blockArea.setIDReferences(area.getIDReferences());

int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
if (!(children.get(i) instanceof ListItem)) {
log.error("children of list-blocks must be list-items");
return new Status(Status.OK);
}
ListItem listItem = (ListItem)children.get(i);
Status status;
if ((status = listItem.layout(blockArea)).isIncomplete()) {
if (status.getCode() == Status.AREA_FULL_NONE && i > 0) {
status = new Status(Status.AREA_FULL_SOME);
}
this.marker = i;
blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
return status;
}
}

blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
area.setAbsoluteHeight(blockArea.getAbsoluteHeight());

if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
}

if (area instanceof BlockArea) {
area.start();
}

blockArea.isLast(true);
return new Status(Status.OK);
}

public boolean generatesInlineAreas() {

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

@@ -11,7 +11,6 @@ package org.apache.fop.fo.flow;
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.*;
import org.apache.fop.layout.BlockArea;
import org.apache.fop.layout.FontState;
import org.apache.fop.apps.FOPException;

@@ -29,14 +28,12 @@ public class ListItem extends FObj {
int endIndent;
int spaceBefore;
int spaceAfter;
BlockArea blockArea;

public ListItem(FONode parent) {
super(parent);
}

public Status layout(Area area) throws FOPException {
if (this.marker == START) {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -71,98 +68,6 @@ public class ListItem extends FObj {
this.spaceAfter =
this.properties.get("space-after.optimum").getLength().mvalue();

area.getIDReferences().createID(id);

this.marker = 0;
}

/* not sure this is needed given we know area is from list block */
if (area instanceof BlockArea) {
area.end();
}

if (spaceBefore != 0) {
area.addDisplaySpace(spaceBefore);
}

this.blockArea =
new BlockArea(propMgr.getFontState(area.getFontInfo()),
area.getAllocationWidth(), area.spaceLeft(), 0, 0,
0, align, alignLast, lineHeight);
this.blockArea.setGeneratedBy(this);
this.areasGenerated++;
if (this.areasGenerated == 1)
this.blockArea.isFirst(true);
// for normal areas this should be the only pair
this.blockArea.addLineagePair(this, this.areasGenerated);

// markers
//if (this.hasMarkers())
//this.blockArea.addMarkers(this.getMarkers());

blockArea.setPage(area.getPage());
blockArea.start();

blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
blockArea.setIDReferences(area.getIDReferences());

int numChildren = this.children.size();
if (numChildren != 2) {
throw new FOPException("list-item must have exactly two children");
}
ListItemLabel label = (ListItemLabel)children.get(0);
ListItemBody body = (ListItemBody)children.get(1);

Status status;

// what follows doesn't yet take into account whether the
// body failed completely or only got some text in

if (this.marker == 0) {
// configure id
area.getIDReferences().configureID(id, area);

status = label.layout(blockArea);
if (status.isIncomplete()) {
return status;
}
}

status = body.layout(blockArea);
if (status.isIncomplete()) {
blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
this.marker = 1;
return status;
}

blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
area.setAbsoluteHeight(blockArea.getAbsoluteHeight());

if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
}

/* not sure this is needed given we know area is from list block */
if (area instanceof BlockArea) {
area.start();
}
this.blockArea.isLast(true);
return new Status(Status.OK);
}

/**
* Return the content width of the boxes generated by this FO.
*/
public int getContentWidth() {
if (blockArea != null)
return blockArea.getContentWidth(); // getAllocationWidth()??
else
return 0; // not laid out yet
}

public boolean generatesInlineAreas() {

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

@@ -23,8 +23,7 @@ public class ListItemBody extends FObj {
super(parent);
}

public Status layout(Area area) throws FOPException {
if (this.marker == START) {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -32,11 +31,6 @@ public class ListItemBody extends FObj {
setupID();
// this.properties.get("keep-together");

this.marker = 0;
// initialize id
area.getIDReferences().initializeID(id, area);
}

/*
* For calculating the lineage - The fo:list-item-body formatting object
* does not generate any areas. The fo:list-item-body formatting object
@@ -44,21 +38,6 @@ public class ListItemBody extends FObj {
* of areas returned by each of the children of the fo:list-item-body.
*/

int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FObj fo = (FObj)children.get(i);

Status status;
if ((status = fo.layout(area)).isIncomplete()) {
this.marker = i;
if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
return new Status(Status.AREA_FULL_NONE);
} else {
return new Status(Status.AREA_FULL_SOME);
}
}
}
return new Status(Status.OK);
}

}

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

@@ -23,12 +23,7 @@ public class ListItemLabel extends FObj {
super(parent);
}

public Status layout(Area area) throws FOPException {
int numChildren = this.children.size();

if (numChildren != 1) {
throw new FOPException("list-item-label must have exactly one block in this version of FOP");
}
public void setup() throws FOPException {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -36,11 +31,6 @@ public class ListItemLabel extends FObj {
setupID();
// this.properties.get("keep-together");

// initialize id
area.getIDReferences().initializeID(id, area);

Block block = (Block)children.get(0);

/*
* For calculating the lineage - The fo:list-item-label formatting object
* does not generate any areas. The fo:list-item-label formatting object
@@ -48,10 +38,6 @@ public class ListItemLabel extends FObj {
* of areas returned by each of the children of the fo:list-item-label.
*/

Status status;
status = block.layout(area);
area.addDisplaySpace(-block.getAreaHeight());
return status;
}

}

+ 0
- 31
src/org/apache/fop/fo/flow/Marker.java View File

@@ -19,7 +19,6 @@ import org.xml.sax.Attributes;
public class Marker extends FObjMixed {

private String markerClassName;
private Area registryArea;

public Marker(FONode parent) {
super(parent);
@@ -42,39 +41,9 @@ public class Marker extends FObjMixed {
}
}

public Status layout(Area area) throws FOPException {
// no layout action desired
this.registryArea = area;
area.addMarker(this);
area.getPage().registerMarker(this);
// System.out.println("Marker being registered in area '" + area + "'");
return new Status(Status.OK);
}

public Status layoutMarker(Area area) throws FOPException {
if (this.marker == START)
this.marker = 0;

int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FONode fo = (FONode)children.get(i);

Status status;
if ((status = fo.layout(area)).isIncomplete()) {
this.marker = i;
return status;
}
}

return new Status(Status.OK);
}

public String getMarkerClassName() {
return markerClassName;
}

public Area getRegistryArea() {
return registryArea;
}

}

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

@@ -22,7 +22,7 @@ public class MultiCase extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -32,6 +32,5 @@ public class MultiCase extends ToBeImplementedElement {
// this.properties.get("case-name");
// this.properties.get("case-title");

return super.layout(area);
}
}

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

@@ -22,13 +22,12 @@ public class MultiProperties extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

setupID();

return super.layout(area);
}
}

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

@@ -22,11 +22,10 @@ public class MultiPropertySet extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

setupID();
// this.properties.get("active-state");

return super.layout(area);
}
}

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

@@ -22,7 +22,7 @@ public class MultiSwitch extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -30,6 +30,5 @@ public class MultiSwitch extends ToBeImplementedElement {
// this.properties.get("auto-restore");
setupID();

return super.layout(area);
}
}

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

@@ -22,7 +22,7 @@ public class MultiToggle extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -30,6 +30,5 @@ public class MultiToggle extends ToBeImplementedElement {
setupID();
// this.properties.get("switch-to");

return super.layout(area);
}
}

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

@@ -53,12 +53,7 @@ public class PageNumber extends FObj {
});
}

public Status layout(Area area) throws FOPException {
if (!(area instanceof BlockArea)) {
log.warn("page-number outside block area");
return new Status(Status.OK);
}
if (this.marker == START) {
public void setup() throws FOPException {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -71,7 +66,7 @@ public class PageNumber extends FObj {
BackgroundProps bProps = propMgr.getBackgroundProps();

// Common Font Properties
//this.fontState = propMgr.getFontState(area.getFontInfo());
//this.fontState = propMgr.getFontState(structHandler.getFontInfo());
// Common Margin Properties-Inline
MarginInlineProps mProps = propMgr.getMarginInlineProps();
@@ -104,19 +99,7 @@ public class PageNumber extends FObj {
this.whiteSpaceCollapse =
this.properties.get("white-space-collapse").getEnum();
ts = new TextState();
this.marker = 0;

// initialize id
area.getIDReferences().initializeID(id, area);
}

String p = area.getPage().getFormattedNumber();
this.marker = FOText.addText((BlockArea)area,
propMgr.getFontState(area.getFontInfo()),
red, green, blue, wrapOption, null,
whiteSpaceCollapse, p.toCharArray(), 0,
p.length(), ts, VerticalAlign.BASELINE);
return new Status(Status.OK);

}

}

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

@@ -81,7 +81,6 @@ public class PageNumberCitation extends FObj {
float blue;
int wrapOption;
int whiteSpaceCollapse;
Area area;
String pageNumber;
String refId;
TextState ts;
@@ -103,15 +102,7 @@ public class PageNumberCitation extends FObj {
return null;
}

public Status layout(Area area) throws FOPException {
if (!(area instanceof BlockArea)) {
log.warn("page-number-citation outside block area");
return new Status(Status.OK);
}

IDReferences idReferences = area.getIDReferences();
this.area = area;
if (this.marker == START) {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -162,56 +153,8 @@ public class PageNumberCitation extends FObj {
this.refId = this.properties.get("ref-id").getString();

if (this.refId.equals("")) {
throw new FOPException("page-number-citation must contain \"ref-id\"");
}

// create id
idReferences.createID(id);
ts = new TextState();

this.marker = 0;
}

if (marker == 0) {
idReferences.configureID(id, area);
}


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;
LineArea la = blockArea.getCurrentLineArea();
if (la == null) {
return new Status(Status.AREA_FULL_NONE);
//throw new FOPException("page-number-citation must contain \"ref-id\"");
}
la.changeFont(propMgr.getFontState(area.getFontInfo()));
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;
}


if (this.marker == -1) {
return new Status(Status.OK);
} else {
return new Status(Status.AREA_FULL_NONE);
}

}


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

@@ -39,115 +39,4 @@ public class RetrieveMarker extends FObjMixed {
this.properties.get("retrieve-boundary").getEnum();
}

public Status layout(Area area) throws FOPException {
// locate qualifying areas by 'marker-class-name' and
// 'retrieve-boundary'. Initially we will always check
// the containing page
Page containingPage = area.getPage();
Marker bestMarker = searchPage(containingPage, true);

// if marker not yet found, and 'retrieve-boundary' permits,
// search forward by Page
if ((null == bestMarker)
&& (retrieveBoundary != RetrieveBoundary.PAGE)) {
// System.out.println("Null bestMarker and searching...");
Page currentPage = containingPage;
boolean isFirstCall = true;
while (bestMarker == null) {
Page previousPage = locatePreviousPage(currentPage,
retrieveBoundary,
isFirstCall);
isFirstCall = false;
// System.out.println("Previous page = '" + previousPage + "'");
bestMarker = searchPage(previousPage, false);
currentPage = previousPage;
}
}

Status status = new Status(Status.OK);
if (null != bestMarker) {
// System.out.println("Laying out marker '" + bestMarker + "' in area '" + area + "'");
// the 'markers' referred to in this method are internal; they have
// nothing to do with fo:marker
bestMarker.resetMarker();
status = bestMarker.layoutMarker(area);
}

return status;
}

private Marker searchPage(Page page,
boolean isContainingPage) throws FOPException {
Vector pageMarkers = page.getMarkers();
if (pageMarkers.isEmpty()) {
// System.out.println("No markers on page");
return null;
}

// if no longer the containing page (fo:retrieve-marker, or the page
// being processed), grab the last qualifying marker on this one
if (!isContainingPage) {
for (int c = pageMarkers.size(); c > 0; c--) {
Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1);
if (currentMarker.getMarkerClassName().equals(retrieveClassName)) {
return currentMarker;
}
}
}

// search forward if 'first-starting-within-page' or
// 'first-including-carryover'
if (retrievePosition == RetrievePosition.FIC) {
for (int c = 0; c < pageMarkers.size(); c++) {
Marker currentMarker = (Marker)pageMarkers.elementAt(c);
if (currentMarker.getMarkerClassName().equals(retrieveClassName)) {
return currentMarker;
}
}

} else if (retrievePosition == RetrievePosition.FSWP) {
for (int c = 0; c < pageMarkers.size(); c++) {
Marker currentMarker = (Marker)pageMarkers.elementAt(c);
if (currentMarker.getMarkerClassName().equals(retrieveClassName)) {
if (currentMarker.getRegistryArea().isFirst()) {
return currentMarker;
}
}
}

} else if (retrievePosition == RetrievePosition.LSWP) {
for (int c = pageMarkers.size(); c > 0; c--) {
Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1);
if (currentMarker.getMarkerClassName().equals(retrieveClassName)) {
if (currentMarker.getRegistryArea().isFirst()) {
return currentMarker;
}
}
}

} else if (retrievePosition == RetrievePosition.LEWP) {
for (int c = pageMarkers.size(); c > 0; c--) {
Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1);
if (currentMarker.getMarkerClassName().equals(retrieveClassName)) {
if (currentMarker.getRegistryArea().isLast()) {
return currentMarker;
}
}
}

} else {
throw new FOPException("Illegal 'retrieve-position' value");
}
return null;
}

private Page locatePreviousPage(Page page, int retrieveBoundary,
boolean isFirstCall) {
boolean pageWithinSequence = true;
if (retrieveBoundary == RetrieveBoundary.DOCUMENT)
pageWithinSequence = false;
return page.getAreaTree().getPreviousPage(page, pageWithinSequence,
isFirstCall);
}

}

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

@@ -7,7 +7,6 @@

package org.apache.fop.fo.flow;

import org.apache.fop.layout.Area;
import java.util.Enumeration;

public class RowSpanMgr {
@@ -41,7 +40,6 @@ public class RowSpanMgr {
totalRowHeight += rowHeight;
if (--rowsRemaining == 0) {
if (cell != null) {
cell.setRowHeight(totalRowHeight);
}
return true;
} else

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

@@ -11,67 +11,16 @@ package org.apache.fop.fo.flow;
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.fo.pagination.*;
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;

public class StaticContent extends Flow {

public StaticContent(FONode parent) {
super(parent);
((PageSequence)parent).setIsFlowSet(false); // hacquery of sorts
}

public Status layout(Area area) throws FOPException {
return layout(area, null);
}


public Status layout(Area area, Region region) throws FOPException {

// int numChildren = this.children.size();
// // Set area absolute height so that link rectangles will be drawn correctly in xsl-before and xsl-after
// String regionClass = "none";
// if (region != null) {
// regionClass = region.getRegionClass();
// } else {
// if (getFlowName().equals("xsl-region-before")) {
// regionClass = RegionBefore.REGION_CLASS;
// } else if (getFlowName().equals("xsl-region-after")) {
// regionClass = RegionAfter.REGION_CLASS;
// } else if (getFlowName().equals("xsl-region-start")) {
// regionClass = RegionStart.REGION_CLASS;
// } else if (getFlowName().equals("xsl-region-end")) {
// regionClass = RegionEnd.REGION_CLASS;
// }

// }

// if (area instanceof org.apache.fop.layout.AreaContainer)
// ((org.apache.fop.layout.AreaContainer)area).setAreaName(regionClass);

// if (regionClass.equals(RegionBefore.REGION_CLASS)) {
// area.setAbsoluteHeight(-area.getMaxHeight());
// } else if (regionClass.equals(RegionAfter.REGION_CLASS)) {
// area.setAbsoluteHeight(area.getPage().getBody().getMaxHeight());
// }
// setContentWidth(area.getContentWidth());

// for (int i = 0; i < numChildren; i++) {
// FObj fo = (FObj)children.elementAt(i);
public void setup() {

// Status status;
// if ((status = fo.layout(area)).isIncomplete()) {
// // in fact all should be laid out and clip, error etc depending on 'overflow'
// log.warn("Some static content could not fit in the area.");
// this.marker = i;
// if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
// status = new Status(Status.AREA_FULL_SOME);
// }
// return (status);
// }
// }
// resetMarker();
return new Status(Status.OK);
}

// flowname checking is more stringient for static content currently

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

@@ -44,18 +44,11 @@ public class Table extends FObj {
/** Maximum inline-progression-dimension */
private int maxIPD;

AreaContainer areaContainer;

public Table(FONode parent) {
super(parent);
}

public Status layout(Area area) throws FOPException {
if (this.marker == BREAK_AFTER) {
return new Status(Status.OK);
}

if (this.marker == START) {
public void setup() {
// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

@@ -115,487 +108,10 @@ public class Table extends FObj {
this.properties.get("table-omit-footer-at-break").getEnum()
== TableOmitFooterAtBreak.TRUE;

if (area instanceof BlockArea) {
area.end();
}
if (this.areaContainer
== null) { // check if anything was previously laid out
area.getIDReferences().createID(id);
}


this.marker = 0;

if (breakBefore == BreakBefore.PAGE) {
return new Status(Status.FORCE_PAGE_BREAK);
}

if (breakBefore == BreakBefore.ODD_PAGE) {
return new Status(Status.FORCE_PAGE_BREAK_ODD);
}

if (breakBefore == BreakBefore.EVEN_PAGE) {
return new Status(Status.FORCE_PAGE_BREAK_EVEN);
}

}

if ((spaceBefore != 0) && (this.marker == 0)) {
area.addDisplaySpace(spaceBefore);
}

if (marker == 0 && areaContainer == null) {
// configure id
area.getIDReferences().configureID(id, area);
}

int spaceLeft = area.spaceLeft();
this.areaContainer =
new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, 0,
area.getAllocationWidth(), area.spaceLeft(),
Position.STATIC);

areaContainer.foCreator = this; // G Seshadri
areaContainer.setPage(area.getPage());
areaContainer.setBackgroundColor(backgroundColor);
areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding());
areaContainer.start();

areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
areaContainer.setIDReferences(area.getIDReferences());

boolean addedHeader = false;
boolean addedFooter = false;
int numChildren = this.children.size();

// Set up the column vector;
// calculate width of all columns and get total width
if (columns.size()==0) {
findColumns(areaContainer);
if (this.bAutoLayout) {
log.warn("table-layout=auto is not supported, using fixed!");
}
// Pretend it's fixed...
this.contentWidth =
calcFixedColumnWidths(areaContainer.getAllocationWidth());
}
areaContainer.setAllocationWidth(this.contentWidth);
layoutColumns(areaContainer);
for (int i = this.marker; i < numChildren; i++) {
FONode fo = (FONode)children.get(i);
if (fo instanceof TableHeader) {
if (columns.size() == 0) {
log.warn("current implementation of tables requires a table-column for each column, indicating column-width");
return new Status(Status.OK);
}
tableHeader = (TableHeader)fo;
tableHeader.setColumns(columns);
} else if (fo instanceof TableFooter) {
if (columns.size() == 0) {
log.warn("current implementation of tables requires a table-column for each column, indicating column-width");
return new Status(Status.OK);
}
tableFooter = (TableFooter)fo;
tableFooter.setColumns(columns);
} else if (fo instanceof TableBody) {
if (columns.size() == 0) {
log.warn("current implementation of tables requires a table-column for each column, indicating column-width");
return new Status(Status.OK);
}
Status status;
if (tableHeader != null &&!addedHeader) {
if ((status =
tableHeader.layout(areaContainer)).isIncomplete()) {
tableHeader.resetMarker();
return new Status(Status.AREA_FULL_NONE);
}
addedHeader = true;
tableHeader.resetMarker();
area.setMaxHeight(area.getMaxHeight() - spaceLeft
+ this.areaContainer.getMaxHeight());
}
if (tableFooter != null &&!this.omitFooterAtBreak
&&!addedFooter) {
if ((status =
tableFooter.layout(areaContainer)).isIncomplete()) {
return new Status(Status.AREA_FULL_NONE);
}
addedFooter = true;
tableFooter.resetMarker();
}
//fo.setWidows(widows);
//fo.setOrphans(orphans);
((TableBody)fo).setColumns(columns);

if ((status = fo.layout(areaContainer)).isIncomplete()) {
this.marker = i;
if (bodyCount == 0
&& status.getCode() == Status.AREA_FULL_NONE) {
if (tableHeader != null)
tableHeader.removeLayout(areaContainer);
if (tableFooter != null)
tableFooter.removeLayout(areaContainer);
resetMarker();
// status = new Status(Status.AREA_FULL_SOME);
}
// areaContainer.end();
if (areaContainer.getContentHeight() > 0) {
area.addChild(areaContainer);
area.increaseHeight(areaContainer.getHeight());
area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
if (this.omitHeaderAtBreak) {
// remove header, no longer needed
tableHeader = null;
}
if (tableFooter != null &&!this.omitFooterAtBreak) {
// move footer to bottom of area and move up body
((TableBody)fo).setYPosition(tableFooter.getYPosition());
tableFooter.setYPosition(tableFooter.getYPosition()
+ ((TableBody)fo).getHeight());
}
setupColumnHeights();
status = new Status(Status.AREA_FULL_SOME);
}
return status;
} else {
bodyCount++;
}
area.setMaxHeight(area.getMaxHeight() - spaceLeft
+ this.areaContainer.getMaxHeight());
if (tableFooter != null &&!this.omitFooterAtBreak) {
// move footer to bottom of area and move up body
// space before and after footer will make this wrong
((TableBody)fo).setYPosition(tableFooter.getYPosition());
tableFooter.setYPosition(tableFooter.getYPosition()
+ ((TableBody)fo).getHeight());
}
}
}

if (tableFooter != null && this.omitFooterAtBreak) {
if (tableFooter.layout(areaContainer).isIncomplete()) {
// this is a problem since we need to remove a row
// from the last table body and place it on the
// next page so that it can have a footer at
// the end of the table.
log.warn("footer could not fit on page, moving last body row to next page");
area.addChild(areaContainer);
area.increaseHeight(areaContainer.getHeight());
area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
if (this.omitHeaderAtBreak) {
// remove header, no longer needed
tableHeader = null;
}
tableFooter.removeLayout(areaContainer);
tableFooter.resetMarker();
return new Status(Status.AREA_FULL_SOME);
}
}

if (height != 0)
areaContainer.setHeight(height);

setupColumnHeights();

areaContainer.end();
area.addChild(areaContainer);

/* should this be combined into above? */
area.increaseHeight(areaContainer.getHeight());

area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());

if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
}

if (area instanceof BlockArea) {
area.start();
}

if (breakAfter == BreakAfter.PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK);
}

if (breakAfter == BreakAfter.ODD_PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK_ODD);
}

if (breakAfter == BreakAfter.EVEN_PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK_EVEN);
}

return new Status(Status.OK);
}

protected void setupColumnHeights() {
Iterator eCol = columns.iterator();
while (eCol.hasNext()) {
TableColumn c = (TableColumn)eCol.next();
if ( c != null) {
c.setHeight(areaContainer.getContentHeight());
}
}
}

private void findColumns(Area areaContainer) throws FOPException {
int nextColumnNumber = 1;
Iterator e = children.iterator();
while (e.hasNext()) {
FONode fo = (FONode)e.next();
if (fo instanceof TableColumn) {
TableColumn c = (TableColumn)fo;
c.doSetup(areaContainer);
int numColumnsRepeated = c.getNumColumnsRepeated();
int currentColumnNumber = c.getColumnNumber();
if (currentColumnNumber == 0) {
currentColumnNumber = nextColumnNumber;
}

for (int j = 0; j < numColumnsRepeated; j++) {
if (currentColumnNumber > columns.size()) {
columns.ensureCapacity(currentColumnNumber);
}
if (columns.get(currentColumnNumber - 1) != null) {
log.warn("More than one column object assigned " +
"to column " +
currentColumnNumber);
}
columns.set(currentColumnNumber - 1, c);
currentColumnNumber++;
}
nextColumnNumber = currentColumnNumber;
}
}
}



private int calcFixedColumnWidths(int maxAllocationWidth) {
int nextColumnNumber=1;
int iEmptyCols=0;
double dTblUnits=0.0;
int iFixedWidth=0;
double dWidthFactor = 0.0;
double dUnitLength = 0.0;
double tuMin = 100000.0 ; // Minimum number of proportional units
Iterator eCol = columns.iterator();
while (eCol.hasNext()) {
TableColumn c = (TableColumn)eCol.next();
if (c == null) {
log.warn("No table-column specification for column " +
nextColumnNumber);
// What about sizing issues?
iEmptyCols++;
}
else {
Length colLength = c.getColumnWidthAsLength();
double tu = colLength.getTableUnits();
if (tu > 0 && tu < tuMin && colLength.mvalue()==0) {
/* Keep track of minimum number of proportional units
* in any column which has only proportional units.
*/
tuMin = tu;
}
dTblUnits += tu;
iFixedWidth += colLength.mvalue();
}
nextColumnNumber++;
}

setIPD((dTblUnits > 0.0), maxAllocationWidth);
if (dTblUnits > 0.0) {
int iProportionalWidth = 0;
if (this.optIPD > iFixedWidth) {
iProportionalWidth = this.optIPD - iFixedWidth;
}
else if (this.maxIPD > iFixedWidth) {
iProportionalWidth = this.maxIPD - iFixedWidth;
}
else {
iProportionalWidth = maxAllocationWidth - iFixedWidth;
}
if (iProportionalWidth > 0) {
dUnitLength = ((double)iProportionalWidth)/dTblUnits;
}
else {
log.error("Sum of fixed column widths " + iFixedWidth +
" greater than maximum available IPD " +
maxAllocationWidth + "; no space for " +
dTblUnits + " proportional units.");
/* Set remaining proportional units to a number which
* will assure the minimum column size for tuMin.
*/
dUnitLength = MINCOLWIDTH/tuMin;
// Reduce fixed column widths by this much???
}
//log.debug("1 table-unit = " + dUnitLength + " mpt");
}
else {
/* No proportional units. If minimum IPD is specified, check
* that sum of column widths > minIPD.
*/
int iTableWidth = iFixedWidth;
if (this.minIPD > iFixedWidth) {
iTableWidth = this.minIPD;
// Add extra space to each column
dWidthFactor = (double)this.minIPD/(double)iFixedWidth;
}
else if (this.maxIPD < iFixedWidth) {
// Note: if maxIPD=auto, use maxAllocWidth
log.warn("Sum of fixed column widths " + iFixedWidth +
" greater than maximum specified IPD " + this.maxIPD);
}
else if (this.optIPD != -1 && iFixedWidth != this.optIPD) {
log.warn("Sum of fixed column widths " + iFixedWidth +
" differs from specified optimum IPD " + this.optIPD);
}
}
// Now distribute the extra units onto each column and set offsets
int offset = 0;
eCol = columns.iterator();
while (eCol.hasNext()) {
TableColumn c = (TableColumn)eCol.next();
if (c != null) {
c.setColumnOffset(offset);
Length l = c.getColumnWidthAsLength();
if (dUnitLength > 0) {
l.resolveTableUnit(dUnitLength);
}
// Check minimum values and adjust if necessary
int colWidth = l.mvalue();
if (colWidth <= 0) {
log.warn("Zero-width table column!");
}
if (dWidthFactor > 0.0) {
// Increase column sizes to use up extra space
colWidth *= dWidthFactor;
}
c.setColumnWidth(colWidth);
offset += colWidth;
}
}
return offset;
}

private void layoutColumns(Area tableArea) throws FOPException {
Iterator eCol = columns.iterator();
while (eCol.hasNext()) {
TableColumn c = (TableColumn)eCol.next();
if (c != null) {
c.layout(tableArea);
}
}
}


public int getAreaHeight() {
return areaContainer.getHeight();
}

/**
* Return the content width of the boxes generated by this table FO.
*/
public int getContentWidth() {
if (areaContainer != null)
return areaContainer.getContentWidth(); // getAllocationWidth()??
else
return 0; // not laid out yet
}

public boolean generatesInlineAreas() {
return false;
}


/**
* Initialize table inline-progression-properties values
*/
private void setIPD(boolean bHasProportionalUnits, int maxAllocIPD) {
boolean bMaxIsSpecified = !this.ipd.getMaximum().getLength().isAuto();
if (bMaxIsSpecified) {
this.maxIPD = ipd.getMaximum().getLength().mvalue();
}
else {
this.maxIPD = maxAllocIPD;
}

if (ipd.getOptimum().getLength().isAuto()) {
this.optIPD = -1;
}
else {
this.optIPD = ipd.getMaximum().getLength().mvalue();
}
if (ipd.getMinimum().getLength().isAuto()) {
this.minIPD = -1;
}
else {
this.minIPD = ipd.getMinimum().getLength().mvalue();
}
if (bHasProportionalUnits && this.optIPD < 0) {
if (this.minIPD > 0) {
if (bMaxIsSpecified) {
this.optIPD = (minIPD + maxIPD)/2;
}
else {
this.optIPD = this.minIPD;
}
}
else if (bMaxIsSpecified) {
this.optIPD = this.maxIPD;
}
else {
log.error("At least one of minimum, optimum, or maximum " +
"IPD must be specified on table.");
this.optIPD = this.maxIPD;
}
}
}


// /**
// * Return the last TableRow in the header or null if no header or
// * no header in non-first areas.
// * @param bForInitialArea If true, return the header row for the
// * initial table area, else for a continuation area, taking into
// * account the omit-header-at-break property.
// */
// TableRow getLastHeaderRow(boolean bForInitialArea) {
// // Check omit...
// if ((tableHeader != null) &&
// (bForInitialArea || omitHeaderAtBreak == false)) {
// return tableHeader.children.lastElement();
// }
// return null;
// }

// /**
// * Return the first TableRow in the footer or null if no footer or
// * no footer in non-last areas.
// * @param bForFinalArea If true, return the footer row for the
// * final table area, else for a non-final area, taking into
// * account the omit-footer-at-break property.
// */
// TableRow getLastFooterRow(boolean bForFinalArea) {
// if ((tableFooter != null) &&
// (bForFinalArea || omitFooterAtBreak == false)) {
// return tableFooter.children.firstElement();
// }
// return null;
// }


// /**
// * Return border information for the side (start/end) of the column
// * whose number is iColNumber (first column = 1).
// * ATTENTION: for now we assume columns are in order in the array!
// */
// BorderInfo getColumnBorder(BorderInfo.Side side, int iColNumber) {
// TableColumn col = (TableColumn)columns.get(iColNumber);
// return col.getBorderInfo(side);
// }
}

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

@@ -22,7 +22,7 @@ public class TableAndCaption extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -46,7 +46,6 @@ public class TableAndCaption extends ToBeImplementedElement {
// this.properties.get("keep-with-next");
// this.properties.get("keep-with-previous");

return super.layout(area);
}

public boolean generatesInlineAreas() {

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

@@ -27,8 +27,6 @@ public class TableBody extends FObj {
ArrayList columns;
RowSpanMgr rowSpanMgr; // manage information about spanning rows

AreaContainer areaContainer;

public TableBody(FONode parent) {
super(parent);
}
@@ -37,25 +35,7 @@ public class TableBody extends FObj {
this.columns = columns;
}

public void setYPosition(int value) {
areaContainer.setYPosition(value);
}

public int getYPosition() {
return areaContainer.getCurrentYPosition();
}

public int getHeight() {
return areaContainer.getHeight() + spaceBefore + spaceAfter;
}

public Status layout(Area area) throws FOPException {
if (this.marker == BREAK_AFTER) {
return new Status(Status.OK);
}

if (this.marker == START) {

public void setup() throws FOPException {
// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

@@ -78,168 +58,7 @@ public class TableBody extends FObj {
this.backgroundColor =
this.properties.get("background-color").getColorType();

area.getIDReferences().createID(id);

if (area instanceof BlockArea) {
area.end();
}

if (rowSpanMgr == null) {
rowSpanMgr = new RowSpanMgr(columns.size());
}

// if (this.isInListBody) {
// startIndent += bodyIndent + distanceBetweenStarts;
// }

this.marker = 0;

}

if ((spaceBefore != 0) && (this.marker == 0)) {
area.increaseHeight(spaceBefore);
}

if (marker == 0) {
// configure id
area.getIDReferences().configureID(id, area);
}

int spaceLeft = area.spaceLeft();

/*
* Note: the parent FO must be a Table. The parent Area is the Block
* type area created by the Table, which is also a reference area.
* The content "width" (IPD) of the TableBody is the same as that
* of the containing table area, and its relative position is 0,0.
* Strictly speaking (CR), this FO should generate no areas!
*/
this.areaContainer =
new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0,
area.getContentHeight(),
area.getContentWidth(), // IPD
area.spaceLeft(), Position.RELATIVE);
areaContainer.foCreator = this; // G Seshadri
areaContainer.setPage(area.getPage());
areaContainer.setBackgroundColor(backgroundColor);
areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding());
areaContainer.start();

areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
areaContainer.setIDReferences(area.getIDReferences());

ArrayList keepWith = new ArrayList();
int numChildren = this.children.size();
TableRow lastRow = null;
boolean endKeepGroup = true;
for (int i = this.marker; i < numChildren; i++) {
Object child = children.get(i);
if (!(child instanceof TableRow)) {
throw new FOPException("Currently only Table Rows are supported in table body, header and footer");
}
TableRow row = (TableRow)child;

row.setRowSpanMgr(rowSpanMgr);
row.setColumns(columns);
row.doSetup(areaContainer);
if (row.getKeepWithPrevious().getType()
!= KeepValue.KEEP_WITH_AUTO && lastRow != null
&& keepWith.indexOf(lastRow)
== -1) {
keepWith.add(lastRow);
} else {
if (endKeepGroup && keepWith.size() > 0) {
keepWith = new ArrayList();
}
}

Status status;
if ((status = row.layout(areaContainer)).isIncomplete()) {
// BUG!!! don't distinguish between break-before and after!
if (status.isPageBreak()) {
this.marker = i;
area.addChild(areaContainer);
// areaContainer.end();

area.increaseHeight(areaContainer.getHeight());
area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
if (i == numChildren - 1) {
this.marker = BREAK_AFTER;
if (spaceAfter != 0) {
area.increaseHeight(spaceAfter);
}
}
return status;
}
if (keepWith.size()
> 0) { // && status.getCode() == Status.AREA_FULL_NONE
// FIXME!!! Handle rows spans!!!
row.removeLayout(areaContainer);
for (Iterator e = keepWith.iterator();
e.hasNext(); ) {
TableRow tr = (TableRow)e.next();
tr.removeLayout(areaContainer);
i--;
}
if (i == 0) {
resetMarker();
return new Status(Status.AREA_FULL_NONE);
}
}
this.marker = i;
if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
status = new Status(Status.AREA_FULL_SOME);
}
if (!((i == 0) && (areaContainer.getContentHeight() <= 0))) {
area.addChild(areaContainer);
// areaContainer.end();

area.increaseHeight(areaContainer.getHeight());
area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
}
return status;
} else if (status.getCode() == Status.KEEP_WITH_NEXT
|| rowSpanMgr.hasUnfinishedSpans()) {
keepWith.add(row);
endKeepGroup = false;
} else {
endKeepGroup = true;
}
lastRow = row;
area.setMaxHeight(area.getMaxHeight() - spaceLeft
+ this.areaContainer.getMaxHeight());
spaceLeft = area.spaceLeft();
}
area.addChild(areaContainer);
areaContainer.end();

area.increaseHeight(areaContainer.getHeight());

area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());

if (spaceAfter != 0) {
area.increaseHeight(spaceAfter);
area.setMaxHeight(area.getMaxHeight() - spaceAfter);
}

if (area instanceof BlockArea) {
area.start();
}

return new Status(Status.OK);
}

public void removeLayout(Area area) {
if (areaContainer != null) {
area.removeChild(areaContainer);
}
if (spaceBefore != 0) {
area.increaseHeight(-spaceBefore);
}
if (spaceAfter != 0) {
area.increaseHeight(-spaceAfter);
}
this.resetMarker();
}

}


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

@@ -22,7 +22,7 @@ public class TableCaption extends ToBeImplementedElement {
super(parent);
}

public Status layout(Area area) throws FOPException {
public void setup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -44,6 +44,5 @@ public class TableCaption extends ToBeImplementedElement {
// this.properties.get("keep-togethe");
// this.properties.get("width");

return super.layout(area);
}
}

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

@@ -83,8 +83,6 @@ public class TableCell extends FObj {
*/
int m_borderSeparation = 0;

AreaContainer cellArea;

public TableCell(FONode parent) {
super(parent);
}
@@ -186,175 +184,6 @@ public class TableCell extends FObj {
this.properties.get("height").getLength().mvalue();
}


public Status layout(Area area) throws FOPException {
int originalAbsoluteHeight = area.getAbsoluteHeight();
if (this.marker == BREAK_AFTER) {
return new Status(Status.OK);
}

if (this.marker == START) {
// if (!setup) {
// doSetup(area);
// }

// Calculate cell borders
// calcBorders(propMgr.getBorderAndPadding());

area.getIDReferences().createID(id);

this.marker = 0;
this.bDone=false;
}

/*
* if ((spaceBefore != 0) && (this.marker ==0)) {
* area.increaseHeight(spaceBefore);
* }
*/

if (marker == 0) {
// configure id
area.getIDReferences().configureID(id, area);
}

// int spaceLeft = area.spaceLeft() - m_borderSeparation/2 + borderHeight/2 ;
int spaceLeft = area.spaceLeft() - m_borderSeparation;
// The Area position defines the content rectangle! Borders
// and padding are outside of this rectangle.
this.cellArea =
new AreaContainer(propMgr.getFontState(area.getFontInfo()),
startOffset + startAdjust, beforeOffset,
width - widthAdjust, spaceLeft,
Position.RELATIVE);

cellArea.foCreator = this; // G Seshadri
cellArea.setPage(area.getPage());
try {
cellArea.setBorderAndPadding((BorderAndPadding)
propMgr.getBorderAndPadding().clone());
} catch (CloneNotSupportedException e) {
System.err.println("Can't clone BorderAndPadding: " + e) ;
cellArea.setBorderAndPadding(propMgr.getBorderAndPadding());
}
cellArea.setBackgroundColor(this.backgroundColor);
cellArea.start();

cellArea.setAbsoluteHeight(area.getAbsoluteHeight()); // ???
cellArea.setIDReferences(area.getIDReferences());
// ******** CHECK THIS: we've changed startOffset (KL)
cellArea.setTableCellXOffset(startOffset);

int numChildren = this.children.size();
for (int i = this.marker; bDone==false && i < numChildren; i++) {
FObj fo = (FObj)children.get(i);
fo.setIsInTableCell();
fo.forceWidth(width); // ???

// Overflows may cause a row to be re-layedout,
// need to pass already processed content.
this.marker = i;

Status status;
if ((status = fo.layout(cellArea)).isIncomplete()) {
// this.marker = i;
if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
return new Status(Status.AREA_FULL_NONE);
} else {
// hani Elabed 11/21/2000
area.addChild(cellArea);
// area.setAbsoluteHeight(cellArea.getAbsoluteHeight());
return new Status(Status.AREA_FULL_SOME);
}
}

area.setMaxHeight(area.getMaxHeight() - spaceLeft
+ this.cellArea.getMaxHeight());
}
this.bDone=true;
cellArea.end();
area.addChild(cellArea);

// Adjust for minimum cell content height
if (minCellHeight > cellArea.getContentHeight()) {
cellArea.setHeight(minCellHeight);
}

// This is the allocation height of the cell (including borders
// and padding
// ALSO need to include offsets if using "separate borders"
height = cellArea.getHeight();
top = cellArea.getCurrentYPosition(); // CHECK THIS!!!

// reset absoluteHeight to beginning of row
// area.setHeight(cellArea.getHeight() + spaceBefore + spaceAfter);
// I don't think we should do this here (KL) !!!
// area.setHeight(cellArea.getHeight());
// area.setAbsoluteHeight(originalAbsoluteHeight);

return new Status(Status.OK);
}

/**
* Return the allocation height of the cell area.
* Note: called by TableRow.
* We adjust the actual allocation height of the area by the value
* of border separation (for separate borders) or border height
* adjustment for collapse style (because current scheme makes cell
* overestimate the allocation height).
*/
public int getHeight() {
return cellArea.getHeight() + m_borderSeparation - borderHeight;
}

/**
* Set the final size of cell content rectangles to the actual row height
* and to vertically align the actual content within the cell rectangle.
* @param h Height of this row in the grid which is based on
* the allocation height of all the cells in the row, including any
* border separation values.
*/
public void setRowHeight(int h) {
int delta = h - getHeight();
// cellArea.increaseHeight(h + borderHeight/2 - cellArea.getHeight());
if (bRelativeAlign) {
// Must get info for all cells starting in row!
// verticalAlign can be BEFORE or BASELINE
// For now just treat like "before"
cellArea.increaseHeight(delta);
} else if (delta > 0) {
BorderAndPadding cellBP = cellArea.getBorderAndPadding();
switch (verticalAlign) {
case DisplayAlign.CENTER:
// Increase cell padding before and after and change
// "Y" position of content rectangle
cellArea.shiftYPosition(delta / 2);
cellBP.setPaddingLength(BorderAndPadding.TOP,
cellBP.getPaddingTop(false)
+ delta / 2);
cellBP.setPaddingLength(BorderAndPadding.BOTTOM,
cellBP.getPaddingBottom(false)
+ delta - delta / 2);
break;
case DisplayAlign.AFTER:
// Increase cell padding before and change
// "Y" position of content rectangle
cellBP.setPaddingLength(BorderAndPadding.TOP,
cellBP.getPaddingTop(false) + delta);
cellArea.shiftYPosition(delta);
break;
case DisplayAlign.BEFORE:
// cellArea.increaseHeight(delta);
cellBP.setPaddingLength(BorderAndPadding.BOTTOM,
cellBP.getPaddingBottom(false)
+ delta);

default: // OK
break;
}
}
}

/**
* Calculate cell border and padding, including offset of content
* rectangle from the theoretical grid position.

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

@@ -26,8 +26,6 @@ public class TableColumn extends FObj {

boolean setup = false;

AreaContainer areaContainer;

public TableColumn(FONode parent) {
super(parent);
}
@@ -56,7 +54,7 @@ public class TableColumn extends FObj {
return numColumnsRepeated;
}

public void doSetup(Area area) throws FOPException {
public void doSetup() throws FOPException {

// Common Border, Padding, and Background Properties
// only background apply, border apply if border-collapse
@@ -85,45 +83,8 @@ public class TableColumn extends FObj {

// initialize id
setupID();
area.getIDReferences().initializeID(id, area);

setup = true;
}

public Status layout(Area area) throws FOPException {
if (this.marker == BREAK_AFTER) {
return new Status(Status.OK);
}

if (this.marker == START) {
if (!setup) {
doSetup(area);
}
}
if (columnWidth > 0) {
this.areaContainer =
new AreaContainer(propMgr.getFontState(area.getFontInfo()),
columnOffset, 0, columnWidth,
area.getContentHeight(), Position.RELATIVE);
areaContainer.foCreator = this; // G Seshadri
areaContainer.setPage(area.getPage());
areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding());
areaContainer.setBackgroundColor(this.backgroundColor);
areaContainer.setHeight(area.getHeight());
area.addChild(areaContainer);
}
return new Status(Status.OK);
}

public void setColumnOffset(int columnOffset) {
this.columnOffset = columnOffset;
}

public void setHeight(int height) {
if (areaContainer != null) {
areaContainer.setMaxHeight(height);
areaContainer.setHeight(height);
}
}

}

+ 0
- 8
src/org/apache/fop/fo/flow/TableFooter.java View File

@@ -16,14 +16,6 @@ import org.apache.fop.apps.FOPException;

public class TableFooter extends TableBody {

public int getYPosition() {
return areaContainer.getCurrentYPosition() - spaceBefore;
}

public void setYPosition(int value) {
areaContainer.setYPosition(value + 2 * spaceBefore);
}

public TableFooter(FONode parent) {
super(parent);
}

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

@@ -34,8 +34,6 @@ public class TableRow extends FObj {
int minHeight = 0; // force row height
ArrayList columns;

AreaContainer areaContainer;

boolean areaAdded = false;

private RowSpanMgr rowSpanMgr = null;
@@ -171,7 +169,7 @@ public class TableRow extends FObj {
return keepWithPrevious;
}

public void doSetup(Area area) throws FOPException {
public void doSetup() {

// Common Accessibility Properties
AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
@@ -228,229 +226,6 @@ public class TableRow extends FObj {
}
}

public Status layout(Area area) throws FOPException {
boolean configID = false;

if (this.marker == BREAK_AFTER) {
return new Status(Status.OK);
}

// Layout the first area for this FO
if (this.marker == START) {
if (!setup)
doSetup(area);

// Only do this once. If the row is "thrown" and we start
// layout over again, we can skip this.
if (cellArray == null) {
initCellArray();
// check to make sure this row hasn't been partially
// laid out yet (with an id created already)
area.getIDReferences().createID(id);
configID = true;
}

this.marker = 0;
int breakStatus = propMgr.checkBreakBefore(area);
if (breakStatus != Status.OK)
return new Status(breakStatus);
}

// if (marker == 0 && configID) {
if (marker == 0) { // KDL: need to do this if thrown or if split?
// configure id
area.getIDReferences().configureID(id, area);
}

int spaceLeft = area.spaceLeft();

this.areaContainer =
new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, 0,
area.getContentWidth(), spaceLeft,
Position.RELATIVE);
areaContainer.foCreator = this; // G Seshadri
areaContainer.setPage(area.getPage());

areaContainer.setBackgroundColor(backgroundColor);
areaContainer.start();

areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
areaContainer.setIDReferences(area.getIDReferences());

largestCellHeight = minHeight;

// Flag indicaing whether any cell didn't fit in available space
boolean someCellDidNotLayoutCompletely = false;

/*
* If it takes multiple calls to completely layout the row,
* we need to process all of the children (cells)
* not just those from the marker so that the borders
* will be drawn properly.
*/
int offset = 0; // Offset of each cell from table start edge
int iColIndex = 0; // 1-based column index
Iterator eCols = columns.iterator();
/*
* Ideas: set offset on each column when they are initialized
* no need to calculate for each row.
* Pass column object to cell to get offset and width and border
* info if borders are "collapsed".
*/

while (eCols.hasNext()) {
TableCell cell;
++iColIndex;
TableColumn tcol = (TableColumn)eCols.next();
int colWidth = tcol.getColumnWidth();
if (cellArray.getCellType(iColIndex) == CellArray.CELLSTART) {
cell = cellArray.getCell(iColIndex);
} else {
/*
* If this cell is spanned from a previous row,
* and this is the last row, get the remaining height
* and use it to increase maxCellHeight if necessary
*/
if (rowSpanMgr.isInLastRow(iColIndex)) {
int h = rowSpanMgr.getRemainingHeight(iColIndex);
if (h > largestCellHeight)
largestCellHeight = h;
}
offset += colWidth;
continue;
}
// cell.setTableColumn(tcol);
cell.setStartOffset(offset);
offset += colWidth;


int rowSpan = cell.getNumRowsSpanned();
Status status;
if ((status = cell.layout(areaContainer)).isIncomplete()) {
if ((keepTogether.getType() == KeepValue.KEEP_WITH_ALWAYS)
|| (status.getCode() == Status.AREA_FULL_NONE)
|| rowSpan > 1) {
// We will put this row into the next column/page
// Note: the only time this shouldn't be honored is
// if this row is at the top of the column area.
// Remove spanning cells from RowSpanMgr?
this.resetMarker();
return new Status(Status.AREA_FULL_NONE);
} else if (status.getCode() == Status.AREA_FULL_SOME) {
/*
* Row is not keep-together, cell isn't spanning
* and part of it fits. We can break the cell and
* the row.
*/
someCellDidNotLayoutCompletely = true;
}
} // else {
// layout was complete for a particular cell
int h = cell.getHeight(); // allocation height of cell
if (rowSpan > 1) { // pass cell fo or area???
rowSpanMgr.addRowSpan(cell, iColIndex,
cell.getNumColumnsSpanned(), h,
rowSpan);
} else if (h > largestCellHeight) {
largestCellHeight = h;
}
// }
} // end of loop over all columns/cells

// This is in case a float was composed in the cells
area.setMaxHeight(area.getMaxHeight() - spaceLeft
+ this.areaContainer.getMaxHeight());

// Only do this for "STARTCELL", ending spans are handled separately
// What about empty cells? Yes, we should set their height too!
for (int iCol = 1; iCol <= columns.size(); iCol++) {
if (cellArray.getCellType(iCol) == CellArray.CELLSTART
&& rowSpanMgr.isSpanned(iCol) == false) {
cellArray.getCell(iCol).setRowHeight(largestCellHeight);
}
}

// Adjust spanning row information
// ??? what if some cells are broken???
rowSpanMgr.finishRow(largestCellHeight);

area.addChild(areaContainer);
areaContainer.setHeight(largestCellHeight);
areaAdded = true;
areaContainer.end();

/*
* The method addDisplaySpace increases both the content
* height of the parent area (table body, head or footer) and
* also its "absolute height". So we don't need to do this
* explicitly.
*
* Note: it doesn't look from the CR as though we should take
* into account borders and padding on rows, only background.
* The exception is perhaps if the borders are "collapsed", but
* they should still be rendered only on cells and not on the
* rows themselves. (Karen Lease - 01may2001)
*/
area.addDisplaySpace(largestCellHeight
+ areaContainer.getPaddingTop()
+ areaContainer.getBorderTopWidth()
+ areaContainer.getPaddingBottom()
+ areaContainer.getBorderBottomWidth());


// replaced by Hani Elabed 11/27/2000
// return new Status(Status.OK);

if (someCellDidNotLayoutCompletely) {
return new Status(Status.AREA_FULL_SOME);
} else {
if (rowSpanMgr.hasUnfinishedSpans()) {
// Ignore break after if row span!
return new Status(Status.KEEP_WITH_NEXT);
}
if (breakAfter == BreakAfter.PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK);
}

if (breakAfter == BreakAfter.ODD_PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK_ODD);
}

if (breakAfter == BreakAfter.EVEN_PAGE) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_PAGE_BREAK_EVEN);
}

if (breakAfter == BreakAfter.COLUMN) {
this.marker = BREAK_AFTER;
return new Status(Status.FORCE_COLUMN_BREAK);
}
if (keepWithNext.getType() != KeepValue.KEEP_WITH_AUTO) {
return new Status(Status.KEEP_WITH_NEXT);
}
return new Status(Status.OK);
}

}

public int getAreaHeight() {
return areaContainer.getHeight();
}

public void removeLayout(Area area) {
if (areaAdded)
area.removeChild(areaContainer);
areaAdded = false;
this.resetMarker();
}

public void resetMarker() {
super.resetMarker();
// Just reset all the states to not laid out and fix up row spans
}

/**
* Called by parent FO to initialize information about
* cells started in previous rows which span into this row.

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

@@ -691,10 +691,10 @@ public class PageSequence extends FObj {


Flow flow = (Flow)_flowMap.get(region.getRegionName());
if ((null == flow) || flow.getStatus().isIncomplete())
/*if ((null == flow) || flow.getStatus().isIncomplete())
return false;
else
return true;
return true;*/
}
return false;
}

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

@@ -11,7 +11,6 @@ package org.apache.fop.fo.pagination;
import org.apache.fop.fo.*;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.AreaTree;
import org.apache.fop.apps.FOPException;

// Java

+ 0
- 414
src/org/apache/fop/layout/Area.java View File

@@ -1,414 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// FOP
import org.apache.fop.datatypes.*;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.layout.inline.InlineSpace;

// Java
import java.util.Vector;
import java.util.Hashtable;

abstract public class Area extends Box {

/*
* nominal font size and nominal font family incorporated in
* fontState
*/
protected FontState fontState;
protected BorderAndPadding bp = null;

protected Vector children = new Vector();

/* max size in line-progression-direction */
protected int maxHeight;

/**
* Total height of content of this area.
*/
protected int currentHeight = 0;

// used to keep track of the current x position within a table. Required for drawing rectangle links.
protected int tableCellXOffset = 0;

// used to keep track of the absolute height on the page. Required for drawing rectangle links.
private int absoluteHeight = 0;

protected int contentRectangleWidth;

protected int allocationWidth;

/* the page this area is on */
protected Page page;

protected ColorType backgroundColor;

private IDReferences idReferences;

protected Vector markers;

// as defined in Section 6.1.1
protected org.apache.fop.fo.FObj generatedBy; // corresponds to 'generated-by' trait
protected Hashtable returnedBy;

// as defined in Section 6.1.1
protected String areaClass;

// as defined in Section 4.2.2
protected boolean isFirst = false;
protected boolean isLast = false;

/*
* author : Seshadri G
* * the fo which created it
*/
// This is deprecated and should be phased out in
// favour of using 'generatedBy'
public org.apache.fop.fo.FObj foCreator;

public Area(FontState fontState) {
setFontState(fontState);
this.markers = new Vector();
this.returnedBy = new Hashtable();
}

/**
* Creates a new <code>Area</code> instance.
*
* @param fontState a <code>FontState</code> value
* @param allocationWidth the inline-progression dimension of the content
* rectangle of the Area
* @param maxHeight the maximum block-progression dimension available
* for this Area (its allocation rectangle)
*/
public Area(FontState fontState, int allocationWidth, int maxHeight) {
setFontState(fontState);
this.allocationWidth = allocationWidth;
this.contentRectangleWidth = allocationWidth;
this.maxHeight = maxHeight;
this.markers = new Vector();
this.returnedBy = new Hashtable();
}

private void setFontState(FontState fontState) {
// fontState.setFontInfo(this.page.getFontInfo());
this.fontState = fontState;
}

public void addChild(Box child) {
this.children.addElement(child);
child.parent = this;
}

public void addChildAtStart(Box child) {
this.children.insertElementAt(child, 0);
child.parent = this;
}

public void addDisplaySpace(int size) {
this.addChild(new DisplaySpace(size));
this.absoluteHeight += size;
this.currentHeight += size;
}

public void addInlineSpace(int size) {
this.addChild(new InlineSpace(size));
// other adjustments...
}

public FontInfo getFontInfo() {
return this.page.getFontInfo();
}

public void end() {}

public int getAllocationWidth() {
/*
* ATTENTION: this may change your output!! (Karen Lease, 4mar2001)
* return this.allocationWidth - getPaddingLeft() - getPaddingRight()
* - getBorderLeftWidth() - getBorderRightWidth();
*/
return this.allocationWidth;
}

/**
* Set the allocation width.
* @param w The new allocation width.
* This sets content width to the same value.
* Currently only called during layout of Table to set the width
* to the total width of all the columns. Note that this assumes the
* column widths are explicitly specified.
*/
public void setAllocationWidth(int w) {
this.allocationWidth = w;
this.contentRectangleWidth = this.allocationWidth;
}

public Vector getChildren() {
return this.children;
}

public boolean hasChildren() {
return (this.children.size() != 0);
}

public int getContentWidth() {
/*
* ATTENTION: this may change your output!! (Karen Lease, 4mar2001)
* return contentRectangleWidth - getPaddingLeft() - getPaddingRight()
* - getBorderLeftWidth() - getBorderRightWidth();
*/
return contentRectangleWidth;
}

public FontState getFontState() {
return this.fontState;
}

/**
* Returns content height of the area.
*
* @return Content height in millipoints
*/
public int getContentHeight() {
return this.currentHeight;
}

/**
* Returns allocation height of this area.
* The allocation height is the sum of the content height plus border
* and padding in the vertical direction.
*
* @return allocation height in millipoints
*/
public int getHeight() {
return this.currentHeight + getPaddingTop() + getPaddingBottom()
+ getBorderTopWidth() + getBorderBottomWidth();
}

public int getMaxHeight() {
// Change KDL: return max height of content rectangle
return this.maxHeight;
/*
* return this.maxHeight - getPaddingTop() - getPaddingBottom() -
* getBorderTopWidth() - getBorderBottomWidth();
*/
}

public Page getPage() {
return this.page;
}

public ColorType getBackgroundColor() {
return this.backgroundColor;
}

// Must handle conditionality here, depending on isLast/isFirst
public int getPaddingTop() {
return (bp == null ? 0 : bp.getPaddingTop(false));
}

public int getPaddingLeft() {
return (bp == null ? 0 : bp.getPaddingLeft(false));
}

public int getPaddingBottom() {
return (bp == null ? 0 : bp.getPaddingBottom(false));
}

public int getPaddingRight() {
return (bp == null ? 0 : bp.getPaddingRight(false));
}

// Handle border-width, including conditionality
// For now, just pass false everywhere!
public int getBorderTopWidth() {
return (bp == null ? 0 : bp.getBorderTopWidth(false));
}

public int getBorderRightWidth() {
return (bp == null ? 0 : bp.getBorderRightWidth(false));
}

public int getBorderLeftWidth() {
return (bp == null ? 0 : bp.getBorderLeftWidth(false));
}

public int getBorderBottomWidth() {
return (bp == null ? 0 : bp.getBorderBottomWidth(false));
}

public int getTableCellXOffset() {
return tableCellXOffset;
}

public void setTableCellXOffset(int offset) {
tableCellXOffset = offset;
}

public int getAbsoluteHeight() {
return absoluteHeight;
}

public void setAbsoluteHeight(int value) {
absoluteHeight = value;
}

public void increaseAbsoluteHeight(int value) {
absoluteHeight += value;
}

public void increaseHeight(int amount) {
this.currentHeight += amount;
this.absoluteHeight += amount;
}

// Remove allocation height of child
public void removeChild(Area area) {
this.currentHeight -= area.getHeight();
this.absoluteHeight -= area.getHeight();
this.children.removeElement(area);
}

public void removeChild(DisplaySpace spacer) {
this.currentHeight -= spacer.getSize();
this.absoluteHeight -= spacer.getSize();
this.children.removeElement(spacer);
}

public void remove() {
this.parent.removeChild(this);
}

public void setPage(Page page) {
this.page = page;
}

public void setBackgroundColor(ColorType bgColor) {
this.backgroundColor = bgColor;
}

public void setBorderAndPadding(BorderAndPadding bp) {
this.bp = bp;
}

/**
* Return space remaining in the vertical direction (height).
* This returns maximum available space - current content height
* Note: content height should be based on allocation height of content!
* @return space remaining in base units (millipoints)
*/
public int spaceLeft() {
return maxHeight - currentHeight;
}

public void start() {}


/**
* Set the content height to the passed value if that value is
* larger than current content height. If the new content height
* is greater than the maximum available height, set the content height
* to the max. available (!!!)
*
* @param height allocation height of content in millipoints
*/
public void setHeight(int height) {
int prevHeight = currentHeight;
if (height > currentHeight) {
currentHeight = height;
}

if (currentHeight > getMaxHeight()) {
currentHeight = getMaxHeight();
}
absoluteHeight += (currentHeight - prevHeight);
}

public void setMaxHeight(int height) {
this.maxHeight = height;
}

public Area getParent() {
return this.parent;
}

public void setParent(Area parent) {
this.parent = parent;
}

public void setIDReferences(IDReferences idReferences) {
this.idReferences = idReferences;
}

public IDReferences getIDReferences() {
return idReferences;
}

/* Author seshadri */
public org.apache.fop.fo.FObj getfoCreator() {
return this.foCreator;
}

// Function not currently used! (KLease, 16mar01)

public AreaContainer getNearestAncestorAreaContainer() {
Area area = this.getParent();
while (!(area instanceof AreaContainer)) {
area = area.getParent();
}
return (AreaContainer)area;
}

public BorderAndPadding getBorderAndPadding() {
return bp;
}

public void addMarker(Marker marker) {
markers.addElement(marker);
}

public void addMarkers(Vector markers) {
markers.addAll(markers);
}

public void addLineagePair(org.apache.fop.fo.FObj fo, int areaPosition) {
returnedBy.put(fo, new Integer(areaPosition));
}

public Vector getMarkers() {
return markers;
}

public void setGeneratedBy(org.apache.fop.fo.FObj generatedBy) {
this.generatedBy = generatedBy;
}

public org.apache.fop.fo.FObj getGeneratedBy() {
return generatedBy;
}

public void isFirst(boolean isFirst) {
this.isFirst = isFirst;
}

public boolean isFirst() {
return isFirst;
}

public void isLast(boolean isLast) {
this.isLast = isLast;
}

public boolean isLast() {
return isLast;
}

}

+ 0
- 75
src/org/apache/fop/layout/AreaContainer.java View File

@@ -1,75 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// FOP
import org.apache.fop.render.Renderer;
import org.apache.fop.fo.properties.*;

// Java
import java.util.Vector;
import java.util.Enumeration;

public class AreaContainer extends Area {

private int xPosition; // should be able to take value 'left' and 'right' too
private int yPosition; // should be able to take value 'top' and 'bottom' too
private int position;

// use this for identifying the general usage of the area,
// like 'main-reference-area' or 'region-before'
private String areaName;

public AreaContainer(FontState fontState, int xPosition, int yPosition,
int allocationWidth, int maxHeight, int position) {
super(fontState, allocationWidth, maxHeight);
this.xPosition = xPosition;
this.yPosition = yPosition;
this.position = position;
// setIsReferenceArea(true); // Should always be true!
}

public int getPosition() {
return position;
}

public int getXPosition() {
// return xPosition + getPaddingLeft() + getBorderLeftWidth();
return xPosition;
}

public void setXPosition(int value) {
xPosition = value;
}

public int getYPosition() {
// return yPosition + getPaddingTop() + getBorderTopWidth();
return yPosition;
}

public int getCurrentYPosition() {
return yPosition;
}

public void setYPosition(int value) {
yPosition = value;
}

public void shiftYPosition(int value) {
yPosition += value;
}

public String getAreaName() {
return areaName;
}

public void setAreaName(String areaName) {
this.areaName = areaName;
}

}

+ 0
- 95
src/org/apache/fop/layout/AreaTree.java View File

@@ -1,95 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.flow.StaticContent;
import org.apache.fop.svg.*;
import org.apache.fop.render.Renderer;
import org.apache.fop.datatypes.IDReferences;
import org.apache.fop.extensions.ExtensionObj;
import org.apache.fop.fo.pagination.PageSequence;

// Java
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Stack;
import java.util.Vector;

/*
* Modified by Mark Lillywhite, mark-fop@inomial.com. No longer keeps
a list of pages in the tree, instead these are passed to the
StreamRenderer. No longer keeps it's own list of IDReferences;
these are handled by StreamRenderer. In many ways StreamRenderer
has taken over from AreaTree and possibly this might be a better
place to deal with things in the future..?<P>
Any extensions added to the AreaTree while generating a page
are given to the Page for the renderer to deal with.
*/

public class AreaTree {

/**
* object containing information on available fonts, including
* metrics
*/
FontInfo fontInfo;

/**
* List of root extension objects
*/
Vector rootExtensions = null;

public AreaTree() {
}

public void setFontInfo(FontInfo fontInfo) {
this.fontInfo = fontInfo;
}

public FontInfo getFontInfo() {
return this.fontInfo;
}

public Page getNextPage(Page current, boolean isWithinPageSequence,
boolean isFirstCall) {
//return streamRenderer.getNextPage(current, isWithinPageSequence,isFirstCall);
return null; // This will go away in new layout!
}

public Page getPreviousPage(Page current, boolean isWithinPageSequence,
boolean isFirstCall) {
//return streamRenderer.getPreviousPage(current,isWithinPageSequence,isFirstCall);
return null; // This will go away in new layout!
}

public void addPage(Page page)
throws FOPException {
// try {
// page.setExtensions(rootExtensions);
// rootExtensions = null;
// streamRenderer.queuePage(page);
// } catch (IOException e) {
// throw new FOPException(e);
// }
}

public IDReferences getIDReferences() {
return null;//streamRenderer.getIDReferences();
}

public void addExtension(ExtensionObj obj) {
if(rootExtensions ==null)
rootExtensions = new Vector();
rootExtensions.addElement(obj);
}

}

+ 0
- 228
src/org/apache/fop/layout/BlockArea.java View File

@@ -1,228 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// FOP
import org.apache.fop.render.Renderer;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.*;
import org.apache.fop.apps.*;
import org.apache.fop.fo.properties.*;

// Java
import java.util.Vector;
import java.util.Enumeration;

/**
* 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 */
protected int startIndent;
protected int endIndent;

/* first line startIndent modifier */
protected int textIndent;

protected int lineHeight;

protected int halfLeading;


/* text-align of all but the last line */
protected int align;

/* text-align of the last line */
protected int alignLastLine;

protected LineArea currentLineArea;
protected LinkSet currentLinkSet;

/* have any line areas been used? */
protected boolean hasLines = false;

/* hyphenation */
protected HyphenationProps hyphProps;

protected Vector pendingFootnotes = null;

public BlockArea(FontState fontState, int allocationWidth, int maxHeight,
int startIndent, int endIndent, int textIndent,
int align, int alignLastLine, int lineHeight) {
super(fontState, allocationWidth, maxHeight);

this.startIndent = startIndent;
this.endIndent = endIndent;
this.textIndent = textIndent;
this.contentRectangleWidth = allocationWidth - startIndent
- endIndent;
this.align = align;
this.alignLastLine = alignLastLine;
this.lineHeight = lineHeight;

if (fontState != null)
this.halfLeading = (lineHeight - fontState.getFontSize()) / 2;
}

/**
* Add a Line Area to this block area.
* Used internally to add a completed line area to this block area
* when either a new line area is created or this block area is
* completed.
*
* @param la the LineArea to add
*/
protected void addLineArea(LineArea la) {
if (!la.isEmpty()) {
la.verticalAlign();
this.addDisplaySpace(this.halfLeading);
int size = la.getHeight();
this.addChild(la);
this.increaseHeight(size);
this.addDisplaySpace(this.halfLeading);
}
// add pending footnotes
if (pendingFootnotes != null) {
for (Enumeration e = pendingFootnotes.elements();
e.hasMoreElements(); ) {
FootnoteBody fb = (FootnoteBody)e.nextElement();
Page page = getPage();
if (!Footnote.layoutFootnote(page, fb, this)) {
page.addPendingFootnote(fb);
}
}
pendingFootnotes = null;
}
}

/**
* Get the current line area in this block area.
* This is used to get the current line area for adding
* inline objects to.
* This will return null if there is not enough room left
* in the block area to accomodate the line area.
*
* @return the line area to be used to add inlie objects
*/
public LineArea getCurrentLineArea() {
if (currentHeight + lineHeight > maxHeight) {
return null;
}
this.currentLineArea.changeHyphenation(hyphProps);
this.hasLines = true;
return this.currentLineArea;
}

/**
* Create a new line area to add inline objects.
* This should be called after getting the current line area
* and discovering that the inline object will not fit inside the current
* line. This method will create a new line area to place the inline
* object into.
* This will return null if the new line cannot fit into the block area.
*
* @return the new current line area, which will be empty.
*/
public LineArea createNextLineArea() {
if (this.hasLines) {
this.currentLineArea.align(this.align);
this.addLineArea(this.currentLineArea);
}
this.currentLineArea = new LineArea(fontState, lineHeight,
halfLeading, allocationWidth,
startIndent, endIndent,
currentLineArea);
this.currentLineArea.changeHyphenation(hyphProps);
if (currentHeight + lineHeight > maxHeight) {
return null;
}
return this.currentLineArea;
}

public void setupLinkSet(LinkSet ls) {
if (ls != null) {
this.currentLinkSet = ls;
ls.setYOffset(currentHeight);
}
}

/**
* Notify this block that the area has completed layout.
* Indicates the the block has been fully laid out, this will
* add (if any) the current line area.
*/
public void end() {
if (this.hasLines) {
this.currentLineArea.addPending();
this.currentLineArea.align(this.alignLastLine);
this.addLineArea(this.currentLineArea);
}
}

public void start() {
currentLineArea = new LineArea(fontState, lineHeight, halfLeading,
allocationWidth,
startIndent + textIndent, endIndent,
null);
}

public int getEndIndent() {
return endIndent;
}

// KL: I think we should just return startIndent here!
public int getStartIndent() {
// return startIndent + paddingLeft + borderWidthLeft;
return startIndent;
}

public void setIndents(int startIndent, int endIndent) {
this.startIndent = startIndent;
this.endIndent = endIndent;
this.contentRectangleWidth = allocationWidth - startIndent
- endIndent;
}

/**
* Return the maximum space remaining for this area's content in
* the block-progression-dimension.
* Remove top and bottom padding and spacing since these reduce
* available space for content and they are not yet accounted for
* in the positioning of the object.
*/
public int spaceLeft() {
// return maxHeight - currentHeight ;
return maxHeight - currentHeight -
(getPaddingTop() + getPaddingBottom()
+ getBorderTopWidth() + getBorderBottomWidth());
}

public int getHalfLeading() {
return halfLeading;
}

public void setHyphenation(HyphenationProps hyphProps) {
this.hyphProps = hyphProps;
}

public void addFootnote(FootnoteBody fb) {
if (pendingFootnotes == null) {
pendingFootnotes = new Vector();
}
pendingFootnotes.addElement(fb);
}

}

+ 0
- 390
src/org/apache/fop/layout/BodyAreaContainer.java View File

@@ -1,390 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// FOP
import org.apache.fop.render.Renderer;
import org.apache.fop.fo.properties.*;
import org.apache.fop.datatypes.IDReferences;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.BlockContainer;

// Java
import java.util.Vector;
import java.util.Enumeration;

public class BodyAreaContainer extends Area {

// dimensions for the 'region-reference-area'
private int xPosition; // should be able to take value 'left' and 'right' too
private int yPosition; // should be able to take value 'top' and 'bottom' too
private int position;

// the column-count and column-gap
private int columnCount;
private int columnGap;

// the 3 primary reference areas
private AreaContainer mainReferenceArea;
private AreaContainer beforeFloatReferenceArea;
private AreaContainer footnoteReferenceArea;

// current heights
private int mainRefAreaHeight;
private int beforeFloatRefAreaHeight;
private int footnoteRefAreaHeight;

// reference area yPositions
private int mainYPosition;
private int beforeFloatYPosition;
private int footnoteYPosition;

// the start FO in case of rollback
private FObj startFO;
private boolean isNewSpanArea;

// keeps track of footnote state for multiple layouts
private int footnoteState = 0;

public BodyAreaContainer(FontState fontState, int xPosition,
int yPosition, int allocationWidth,
int maxHeight, int position, int columnCount,
int columnGap) {
super(fontState, allocationWidth, maxHeight);
this.xPosition = xPosition;
this.yPosition = yPosition;
this.position = position;
this.columnCount = columnCount;
this.columnGap = columnGap;

// create the primary reference areas
beforeFloatRefAreaHeight = 0;
footnoteRefAreaHeight = 0;
mainRefAreaHeight = maxHeight - beforeFloatRefAreaHeight
- footnoteRefAreaHeight;
beforeFloatReferenceArea = new AreaContainer(fontState, xPosition,
yPosition, allocationWidth, beforeFloatRefAreaHeight,
Position.ABSOLUTE);
beforeFloatReferenceArea.setAreaName("before-float-reference-area");
this.addChild(beforeFloatReferenceArea);
mainReferenceArea = new AreaContainer(fontState, xPosition,
yPosition, allocationWidth,
mainRefAreaHeight,
Position.ABSOLUTE);
mainReferenceArea.setAreaName("main-reference-area");
this.addChild(mainReferenceArea);
int footnoteRefAreaYPosition = yPosition - mainRefAreaHeight;
footnoteReferenceArea = new AreaContainer(fontState, xPosition,
footnoteRefAreaYPosition,
allocationWidth,
footnoteRefAreaHeight,
Position.ABSOLUTE);
footnoteReferenceArea.setAreaName("footnote-reference-area");
this.addChild(footnoteReferenceArea);

// all padding and border-width must be 0
// setBorderAndPadding(new BorderAndPadding());
// setPadding(0, 0, 0, 0);
// setBorderWidth(0, 0, 0, 0);
}

public int getPosition() {
return position;
}

public int getXPosition() {
return xPosition + getPaddingLeft() + getBorderLeftWidth();
}

public void setXPosition(int value) {
xPosition = value;
}

public int getYPosition() {
return yPosition + getPaddingTop() + getBorderTopWidth();
}

public void setYPosition(int value) {
yPosition = value;
}

public AreaContainer getMainReferenceArea() {
return mainReferenceArea;
}

public AreaContainer getBeforeFloatReferenceArea() {
return beforeFloatReferenceArea;
}

public AreaContainer getFootnoteReferenceArea() {
return footnoteReferenceArea;
}

public void setIDReferences(IDReferences idReferences) {
mainReferenceArea.setIDReferences(idReferences);
}

public IDReferences getIDReferences() {
return mainReferenceArea.getIDReferences();
}

/**
* Depending on the column-count of the next FO, determine whether
* a new span area needs to be constructed or not, and return the
* appropriate ColumnArea.
* The next cut of this method should also inspect the FO to see
* whether the area to be returned ought not to be the footnote
* or before-float reference area.
* @param fo The next formatting object
* @returns the next column area (possibly the current one)
*/
public AreaContainer getNextArea(FObj fo) throws FOPException {
isNewSpanArea = false;

int span = Span.NONE;
if (fo instanceof Block)
span = ((Block)fo).getSpan();
else if (fo instanceof BlockContainer)
span = ((BlockContainer)fo).getSpan();

if (this.mainReferenceArea.getChildren().isEmpty()) {
if (span == Span.ALL)
return addSpanArea(1);
else
return addSpanArea(columnCount);
}

Vector spanAreas = this.mainReferenceArea.getChildren();
SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size()
- 1);

if ((span == Span.ALL) && (spanArea.getColumnCount() == 1)) {
// return the single column area in the same span area
return spanArea.getCurrentColumnArea();
} else if ((span == Span.NONE)
&& (spanArea.getColumnCount() == columnCount)) {
// return the current column area in the same span area
return spanArea.getCurrentColumnArea();
} else if (span == Span.ALL) {
// create new span area with one column; return column area
return addSpanArea(1);
} else if (span == Span.NONE) {
// create new span area with multiple columns; return first column area
return addSpanArea(columnCount);
} else {
throw new FOPException("BodyAreaContainer::getNextArea(): Span attribute messed up");
}
}

/**
* Add a new span area with specified number of column areas.
* @param numColumns The number of column areas
* @returns AreaContainer The next column area
*/
private AreaContainer addSpanArea(int numColumns) {
resetHeights();
// create span area and child column-areas, using whatever
// height remains after existing span areas (in the main
// reference area).
int spanAreaYPosition = getYPosition()
- this.mainReferenceArea.getContentHeight();

SpanArea spanArea = new SpanArea(fontState, getXPosition(),
spanAreaYPosition, allocationWidth,
getRemainingHeight(), numColumns,
columnGap);
this.mainReferenceArea.addChild(spanArea);
spanArea.setPage(this.getPage());
this.isNewSpanArea = true;
return spanArea.getCurrentColumnArea();
}

/**
* This almost does what getNewArea() does, without actually
* returning an area. These 2 methods can be reworked.
* @param fo The next formatting object
* @returns boolean True if we need to balance.
*/
public boolean isBalancingRequired(FObj fo) {
if (this.mainReferenceArea.getChildren().isEmpty())
return false;

Vector spanAreas = this.mainReferenceArea.getChildren();
SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size()
- 1);

if (spanArea.isBalanced())
return false;

int span = Span.NONE;
if (fo instanceof Block)
span = ((Block)fo).getSpan();
else if (fo instanceof BlockContainer)
span = ((BlockContainer)fo).getSpan();

if ((span == Span.ALL) && (spanArea.getColumnCount() == 1))
return false;
else if ((span == Span.NONE)
&& (spanArea.getColumnCount() == columnCount))
return false;
else if (span == Span.ALL)
return true;
else if (span == Span.NONE)
return false;
else
return false;
}

/**
* This is where the balancing algorithm lives, or gets called.
* Right now it's primitive: get the total content height in all
* columns, divide by the column count, and add a heuristic
* safety factor.
* Then the previous (unbalanced) span area is removed, and a new
* one added with the computed max height.
*/
public void resetSpanArea() {
Vector spanAreas = this.mainReferenceArea.getChildren();
SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size()
- 1);

if (!spanArea.isBalanced()) {
// span area maintains a record of the total height of
// laid-out content in the previous (first) attempt
int newHeight = spanArea.getTotalContentHeight()
/ spanArea.getColumnCount();
newHeight += 2 * 15600; // ???

this.mainReferenceArea.removeChild(spanArea);
resetHeights();
SpanArea newSpanArea = new SpanArea(fontState, getXPosition(),
spanArea.getYPosition(),
allocationWidth, newHeight,
spanArea.getColumnCount(),
columnGap);
this.mainReferenceArea.addChild(newSpanArea);
newSpanArea.setPage(this.getPage());
newSpanArea.setIsBalanced();
this.isNewSpanArea = true;
} else {
throw new IllegalStateException("Trying to balance balanced area");
}
}

/**
* Determine remaining height for new span area. Needs to be
* modified for footnote and before-float reference areas when
* those are supported.
* @returns int The remaining available height in millipoints.
*/
public int getRemainingHeight() {
return this.mainReferenceArea.getMaxHeight()
- this.mainReferenceArea.getContentHeight();
}

/**
* Used by resetSpanArea() and addSpanArea() to adjust the main
* reference area height before creating a new span.
*/
private void resetHeights() {
int totalHeight = 0;
for (Enumeration e = this.mainReferenceArea.getChildren().elements();
e.hasMoreElements(); ) {
SpanArea spanArea = (SpanArea)e.nextElement();
int spanContentHeight = spanArea.getMaxContentHeight();
int spanMaxHeight = spanArea.getMaxHeight();

totalHeight += (spanContentHeight < spanMaxHeight)
? spanContentHeight : spanMaxHeight;
}
this.mainReferenceArea.setHeight(totalHeight);
}

/**
* Used in Flow when layout returns incomplete.
* @returns boolean Is this the last column in this span?
*/
public boolean isLastColumn() {
Vector spanAreas = this.mainReferenceArea.getChildren();
SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size()
- 1);
return spanArea.isLastColumn();
}

/**
* This variable is unset by getNextArea(), is set by addSpanArea(),
* and <i>may</i> be set by resetSpanArea().
* @returns boolean Is the span area new or not?
*/
public boolean isNewSpanArea() {
return isNewSpanArea;
}

public AreaContainer getCurrentColumnArea() {
Vector spanAreas = this.mainReferenceArea.getChildren();
SpanArea spanArea = (SpanArea)spanAreas.elementAt(spanAreas.size()
- 1);
return spanArea.getCurrentColumnArea();
}

public int getFootnoteState() {
return footnoteState;
}

public boolean needsFootnoteAdjusting() {
footnoteYPosition = footnoteReferenceArea.getYPosition();
switch (footnoteState) {
case 0:
resetHeights();
if (footnoteReferenceArea.getHeight() > 0
&& mainYPosition + mainReferenceArea.getHeight()
> footnoteYPosition) {
return true;
}
case 1:
break;
}
return false;
}

public void adjustFootnoteArea() {
footnoteState++;
if (footnoteState == 1) {
mainReferenceArea.setMaxHeight(footnoteReferenceArea.getYPosition()
- mainYPosition);
footnoteYPosition = footnoteReferenceArea.getYPosition();
footnoteReferenceArea.setMaxHeight(footnoteReferenceArea.getHeight());

Vector childs = footnoteReferenceArea.getChildren();
for (Enumeration en = childs.elements(); en.hasMoreElements(); ) {
Object obj = en.nextElement();
if (obj instanceof Area) {
Area childArea = (Area)obj;
footnoteReferenceArea.removeChild(childArea);
}
}

getPage().setPendingFootnotes(null);
}
}

protected static void resetMaxHeight(Area ar, int change) {
ar.setMaxHeight(change);
Vector childs = ar.getChildren();
for (Enumeration en = childs.elements(); en.hasMoreElements(); ) {
Object obj = en.nextElement();
if (obj instanceof Area) {
Area childArea = (Area)obj;
resetMaxHeight(childArea, change);
}
}
}

}

+ 0
- 49
src/org/apache/fop/layout/BodyRegionArea.java View File

@@ -1,49 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

import org.apache.fop.fo.properties.*;

// Represents region-body viewport/reference areas.
// The areas generated by fo:region-body are sufficiently dissimilar to
// the other 4 regions that we employ a different class

public class BodyRegionArea extends RegionArea {

// the column count and column-gap
private int columnCount;
private int columnGap;

public BodyRegionArea(int xPosition, int yPosition, int width,
int height) {
super(xPosition, yPosition, width, height);
}

public BodyAreaContainer makeBodyAreaContainer() {
return new BodyAreaContainer(null, xPosition, yPosition, width,
height, Position.ABSOLUTE, columnCount,
columnGap);
}

public void setColumnCount(int columnCount) {
this.columnCount = columnCount;
}

public int getColumnCount() {
return columnCount;
}

public void setColumnGap(int columnGap) {
this.columnGap = columnGap;
}

public int getColumnGap() {
return columnGap;
}

}

+ 0
- 15
src/org/apache/fop/layout/Box.java View File

@@ -1,15 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

import org.apache.fop.render.Renderer;

abstract public class Box {
protected Area parent;
protected AreaTree areaTree;
}

+ 0
- 53
src/org/apache/fop/layout/ColumnArea.java View File

@@ -1,53 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// FOP
import org.apache.fop.render.Renderer;
import org.apache.fop.fo.properties.Position;
import org.apache.fop.datatypes.IDReferences;

// Java
import java.util.Vector;
import java.util.Enumeration;

public class ColumnArea extends AreaContainer {

private int columnIndex;
private int maxColumns;

public ColumnArea(FontState fontState, int xPosition, int yPosition,
int allocationWidth, int maxHeight, int columnCount) {
super(fontState, xPosition, yPosition, allocationWidth, maxHeight,
Position.ABSOLUTE);
this.maxColumns = columnCount;
this.setAreaName("normal-flow-ref.-area");
}

public void end() {}

public void start() {}

public int spaceLeft() {
return maxHeight - currentHeight;
}

public int getColumnIndex() {
return columnIndex;
}

public void setColumnIndex(int columnIndex) {
this.columnIndex = columnIndex;
}

public void incrementSpanIndex() {
SpanArea span = (SpanArea)this.parent;
span.setCurrentColumn(span.getCurrentColumn() + 1);
}

}

+ 0
- 23
src/org/apache/fop/layout/DisplaySpace.java View File

@@ -1,23 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

import org.apache.fop.render.Renderer;

public class DisplaySpace extends Space {
private int size;

public DisplaySpace(int size) {
this.size = size;
}

public int getSize() {
return size;
}

}

+ 0
- 32
src/org/apache/fop/layout/ExtensionArea.java View File

@@ -1,32 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

import org.apache.fop.fo.*;

import org.apache.fop.extensions.*;
import org.apache.fop.render.*;

public class ExtensionArea extends Area {
private ExtensionObj _extensionObj;

public ExtensionArea(ExtensionObj obj) {
super(null);
_extensionObj = obj;
}

public FObj getExtensionObj() {
return _extensionObj;
}

public void render(Renderer renderer) {
// renderer.renderExtensionArea(this);
}


}

+ 0
- 1336
src/org/apache/fop/layout/LineArea.java
File diff suppressed because it is too large
View File


+ 0
- 163
src/org/apache/fop/layout/LinkSet.java View File

@@ -1,163 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// Java
import java.util.Vector;
import java.util.Enumeration;
import java.awt.Rectangle;

import org.apache.fop.layout.inline.InlineArea;

import org.apache.fop.fo.properties.WrapOption; // for enumerated
// values
// import org.apache.fop.fo.properties.WhiteSpaceCollapse; // for
// enumerated values
import org.apache.fop.fo.properties.TextAlign; // for enumerated
// values
import org.apache.fop.fo.properties.TextAlignLast; // for enumerated
// values

/**
* a set of rectangles on a page that are linked to a common
* destination
*/
public class LinkSet {

/**
* the destination of the links
*/
String destination;

/**
* the set of rectangles
*/
Vector rects = new Vector();

private int xoffset = 0;
private int yoffset = 0;

/* the maximum Y offset value encountered for this LinkSet */
private int maxY = 0;

protected int startIndent;
protected int endIndent;

private int linkType;

private Area area;

public final static int INTERNAL = 0, // represents internal link
EXTERNAL = 1; // represents external link

// property required for alignment adjustments
int contentRectangleWidth = 0;

public LinkSet(String destination, Area area, int linkType) {
this.destination = destination;
this.area = area;
this.linkType = linkType;
}

public void addRect(Rectangle r, LineArea lineArea,
InlineArea inlineArea) {
LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea,
inlineArea);
linkedRectangle.setY(this.yoffset);
if (this.yoffset > maxY) {
maxY = this.yoffset;
}
rects.addElement(linkedRectangle);
}

public void setYOffset(int y) {
this.yoffset = y;
}

public void setXOffset(int x) {
this.xoffset = x;
}

public void setContentRectangleWidth(int contentRectangleWidth) {
this.contentRectangleWidth = contentRectangleWidth;
}

public void applyAreaContainerOffsets(AreaContainer ac, Area area) {
int height = area.getAbsoluteHeight();
BlockArea ba = (BlockArea)area;
Enumeration re = rects.elements();
while (re.hasMoreElements()) {
LinkedRectangle r = (LinkedRectangle)re.nextElement();
r.setX(r.getX() + ac.getXPosition() + area.getTableCellXOffset());
r.setY(ac.getYPosition() - height + (maxY - r.getY())
- ba.getHalfLeading());
}
}

// intermediate implementation for joining all sublinks on same line
public void mergeLinks() {
int numRects = rects.size();
if (numRects == 1)
return;

LinkedRectangle curRect =
new LinkedRectangle((LinkedRectangle)rects.elementAt(0));
Vector nv = new Vector();

for (int ri = 1; ri < numRects; ri++) {
LinkedRectangle r = (LinkedRectangle)rects.elementAt(ri);

// yes, I'm really happy with comparing refs...
if (r.getLineArea() == curRect.getLineArea()) {
curRect.setWidth(r.getX() + r.getWidth() - curRect.getX());
} else {
nv.addElement(curRect);
curRect = new LinkedRectangle(r);
}

if (ri == numRects - 1)
nv.addElement(curRect);
}

rects = nv;
}

public void align() {
Enumeration re = rects.elements();
while (re.hasMoreElements()) {
LinkedRectangle r = (LinkedRectangle)re.nextElement();
r.setX(r.getX() + r.getLineArea().getStartIndent()
+ r.getInlineArea().getXOffset());
}
}

public String getDest() {
return this.destination;
}

public Vector getRects() {
return this.rects;
}

public int getEndIndent() {
return endIndent;
}

public int getStartIndent() {
return startIndent;
}

public Area getArea() {
return area;
}

public int getLinkType() {
return linkType;
}

}

+ 0
- 107
src/org/apache/fop/layout/LinkedRectangle.java View File

@@ -1,107 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// Java
import java.awt.Rectangle;

import org.apache.fop.layout.inline.InlineArea;

/**
* an object that stores a rectangle that is linked, and the LineArea
* that it is logically associated with
* @author Arved Sandstrom
* @author James Tauber
*/
public class LinkedRectangle {

/**
* the linked Rectangle
*/
protected Rectangle link;

/**
* the associated LineArea
*/
protected LineArea lineArea;

/**
* the associated InlineArea
*/
protected InlineArea inlineArea;

public LinkedRectangle(Rectangle link, LineArea lineArea,
InlineArea inlineArea) {
this.link = link;
this.lineArea = lineArea;
this.inlineArea = inlineArea;
}

public LinkedRectangle(LinkedRectangle lr) {
this.link = new Rectangle(lr.getRectangle());
this.lineArea = lr.getLineArea();
this.inlineArea = lr.getInlineArea();
}

public void setRectangle(Rectangle link) {
this.link = link;
}

public Rectangle getRectangle() {
return this.link;
}

public LineArea getLineArea() {
return this.lineArea;
}

public void setLineArea(LineArea lineArea) {
this.lineArea = lineArea;
}

public InlineArea getInlineArea() {
return this.inlineArea;
}

public void setLineArea(InlineArea inlineArea) {
this.inlineArea = inlineArea;
}

public void setX(int x) {
this.link.x = x;
}

public void setY(int y) {
this.link.y = y;
}

public void setWidth(int width) {
this.link.width = width;
}

public void setHeight(int height) {
this.link.height = height;
}

public int getX() {
return this.link.x;
}

public int getY() {
return this.link.y;
}

public int getWidth() {
return this.link.width;
}

public int getHeight() {
return this.link.height;
}

}

+ 0
- 221
src/org/apache/fop/layout/Page.java View File

@@ -1,221 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// FOP
import org.apache.fop.render.Renderer;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.*;
import org.apache.fop.apps.*;
import org.apache.fop.datatypes.IDReferences;
import org.apache.fop.fo.pagination.PageSequence;

// Java
import java.util.Vector;
import java.util.Enumeration;

/*Modified by Mark Lillywhite mark-fop@inomial.com. Added getIDReferences.
This is just a convenience method for renderers who no longer have access
to the AreaTree when rendering.
*/

public class Page {

private int height;
private int width;

private BodyAreaContainer body;
private AreaContainer before;
private AreaContainer after;
private AreaContainer start;
private AreaContainer end;

private AreaTree areaTree;

private Vector rootExtensions;

private PageSequence pageSequence;

protected int pageNumber = 0;
protected String formattedPageNumber;

protected Vector linkSets = new Vector();

private Vector idList = new Vector();

private Vector footnotes = null;

private Vector markers = null;

Page(AreaTree areaTree, int height, int width) {
this.areaTree = areaTree;
this.height = height;
this.width = width;
markers = new Vector();
}

public IDReferences getIDReferences() {
return areaTree.getIDReferences();
}

public void setPageSequence(PageSequence pageSequence) {
this.pageSequence = pageSequence;
}

public PageSequence getPageSequence() {
return pageSequence;
}

public AreaTree getAreaTree() {
return areaTree;
}

public void setNumber(int number) {
this.pageNumber = number;
}

public int getNumber() {
return this.pageNumber;
}

public void setFormattedNumber(String number) {
this.formattedPageNumber = number;
}

public String getFormattedNumber() {
return this.formattedPageNumber;
}

void addAfter(AreaContainer area) {
this.after = area;
area.setPage(this);
}

void addBefore(AreaContainer area) {
this.before = area;
area.setPage(this);
}

/**
* Ensure that page is set not only on B.A.C. but also on the
* three top-level reference areas.
* @param area The region-body area container (special)
*/
public void addBody(BodyAreaContainer area) {
this.body = area;
area.setPage(this);
((BodyAreaContainer)area).getMainReferenceArea().setPage(this);
((BodyAreaContainer)area).getBeforeFloatReferenceArea().setPage(this);
((BodyAreaContainer)area).getFootnoteReferenceArea().setPage(this);
}

void addEnd(AreaContainer area) {
this.end = area;
area.setPage(this);
}

void addStart(AreaContainer area) {
this.start = area;
area.setPage(this);
}

public AreaContainer getAfter() {
return this.after;
}

public AreaContainer getBefore() {
return this.before;
}

public AreaContainer getStart() {
return this.start;
}

public AreaContainer getEnd() {
return this.end;
}

public BodyAreaContainer getBody() {
return this.body;
}

public int getHeight() {
return this.height;
}

public int getWidth() {
return this.width;
}

public FontInfo getFontInfo() {
return this.areaTree.getFontInfo();
}

public void addLinkSet(LinkSet linkSet) {
this.linkSets.addElement(linkSet);
}

public Vector getLinkSets() {
return this.linkSets;
}

public boolean hasLinks() {
return (!this.linkSets.isEmpty());
}

public void addToIDList(String id) {
idList.addElement(id);
}

public Vector getIDList() {
return idList;
}

public Vector getPendingFootnotes() {
return footnotes;
}

public Vector getExtensions() {
return rootExtensions;
}

public void setExtensions(Vector extensions) {
this.rootExtensions = extensions;
}

public void setPendingFootnotes(Vector v) {
footnotes = v;
if (footnotes != null) {
for (Enumeration e = footnotes.elements();
e.hasMoreElements(); ) {
FootnoteBody fb = (FootnoteBody)e.nextElement();
if (!Footnote.layoutFootnote(this, fb, null)) {
// footnotes are too large to fit on empty page
}

}
footnotes = null;
}
}

public void addPendingFootnote(FootnoteBody fb) {
if (footnotes == null) {
footnotes = new Vector();
}
footnotes.addElement(fb);
}

public void registerMarker(Marker marker) {
markers.addElement(marker);
}

public Vector getMarkers() {
return this.markers;
}

}

+ 0
- 46
src/org/apache/fop/layout/RegionArea.java View File

@@ -1,46 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

import org.apache.fop.fo.properties.*;
import org.apache.fop.datatypes.ColorType;

public class RegionArea {

protected int xPosition;
protected int yPosition;
protected int width;
protected int height;

protected ColorType backgroundColor;

public RegionArea(int xPosition, int yPosition, int width, int height) {
this.xPosition = xPosition;
this.yPosition = yPosition;
this.width = width;
this.height = height;
}

public AreaContainer makeAreaContainer() {
return new AreaContainer(null, xPosition, yPosition, width, height,
Position.ABSOLUTE);
}

public ColorType getBackgroundColor() {
return this.backgroundColor;
}

public void setBackgroundColor(ColorType bgColor) {
this.backgroundColor = bgColor;
}

public int getHeight() {
return height;
}

}

+ 0
- 10
src/org/apache/fop/layout/Space.java View File

@@ -1,10 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

abstract public class Space extends Box {}

+ 0
- 120
src/org/apache/fop/layout/SpanArea.java View File

@@ -1,120 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout;

// FOP
import org.apache.fop.render.Renderer;
import org.apache.fop.fo.properties.Position;
import org.apache.fop.datatypes.IDReferences;

// Java
import java.util.Vector;
import java.util.Enumeration;

public class SpanArea extends AreaContainer {

private int columnCount;
private int currentColumn = 1;
private int columnGap = 0;

// has the area been balanced?
private boolean isBalanced = false;

public SpanArea(FontState fontState, int xPosition, int yPosition,
int allocationWidth, int maxHeight, int columnCount,
int columnGap) {
super(fontState, xPosition, yPosition, allocationWidth, maxHeight,
Position.ABSOLUTE);

this.contentRectangleWidth = allocationWidth;
this.columnCount = columnCount;
this.columnGap = columnGap;

int columnWidth = (allocationWidth - columnGap * (columnCount - 1))
/ columnCount;
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
int colXPosition = (xPosition
+ columnIndex * (columnWidth + columnGap));
int colYPosition = yPosition;
ColumnArea colArea = new ColumnArea(fontState, colXPosition,
colYPosition, columnWidth,
maxHeight, columnCount);
addChild(colArea);
colArea.setColumnIndex(columnIndex + 1);
}
}

public void end() {}

public void start() {}

public int spaceLeft() {
return maxHeight - currentHeight;
}

public int getColumnCount() {
return columnCount;
}

public int getCurrentColumn() {
return currentColumn;
}

public void setCurrentColumn(int currentColumn) {
if (currentColumn <= columnCount)
this.currentColumn = currentColumn;
else
this.currentColumn = columnCount;
}

public AreaContainer getCurrentColumnArea() {
return (AreaContainer)getChildren().elementAt(currentColumn - 1);
}

public boolean isBalanced() {
return isBalanced;
}

public void setIsBalanced() {
this.isBalanced = true;
}

public int getTotalContentHeight() {
int totalContentHeight = 0;
for (Enumeration e = getChildren().elements();
e.hasMoreElements(); ) {
totalContentHeight +=
((AreaContainer)e.nextElement()).getContentHeight();
}
return totalContentHeight;
}

public int getMaxContentHeight() {
int maxContentHeight = 0;
for (Enumeration e = getChildren().elements();
e.hasMoreElements(); ) {
AreaContainer nextElm = (AreaContainer)e.nextElement();
if (nextElm.getContentHeight() > maxContentHeight)
maxContentHeight = nextElm.getContentHeight();
}
return maxContentHeight;
}

public void setPage(Page page) {
this.page = page;
for (Enumeration e = getChildren().elements();
e.hasMoreElements(); ) {
((AreaContainer)e.nextElement()).setPage(page);
}
}

public boolean isLastColumn() {
return (currentColumn == columnCount);
}

}

+ 0
- 206
src/org/apache/fop/layout/inline/ForeignObjectArea.java View File

@@ -1,206 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout.inline;

// FOP
import org.apache.fop.render.Renderer;
import org.apache.fop.layout.*;

// Java
import java.util.Vector;
import java.util.Enumeration;

public class ForeignObjectArea extends InlineArea {

protected int xOffset = 0;
/* text-align of contents */
protected int align;
/* vertical align of contents */
protected int valign;
/* scaling method */
protected int scaling;
protected Area foreignObject;
/* height according to the instream-foreign-object */
protected int cheight;
/* width according to the instream-foreign-object */
protected int cwidth;
/* width of the content */
protected int awidth;
/* height of the content */
protected int aheight;
/* width */
protected int width;
boolean wauto;
boolean hauto;
boolean cwauto;
boolean chauto;
int overflow;

public ForeignObjectArea(FontState fontState, int width) {
super(fontState, width, 0, 0, 0);
}

/**
* This is NOT the content width of the instream-foreign-object.
* This is the content width for a Box.
*/
public int getContentWidth() {
return getEffectiveWidth();
}

/**
* This is NOT the content height of the instream-foreign-object.
* This is the content height for a Box.
*/
public int getHeight() {
return getEffectiveHeight();
}

public int getXOffset() {
return this.xOffset;
}

public void setStartIndent(int startIndent) {
xOffset = startIndent;
}

public void setObject(Area fobject) {
foreignObject = fobject;
}

public Area getObject() {
return foreignObject;
}

public void setSizeAuto(boolean wa, boolean ha) {
wauto = wa;
hauto = ha;
}

public void setContentSizeAuto(boolean wa, boolean ha) {
cwauto = wa;
chauto = ha;
}

public boolean isContentWidthAuto() {
return cwauto;
}

public boolean isContentHeightAuto() {
return chauto;
}

public void setAlign(int align) {
this.align = align;
}

public int getAlign() {
return this.align;
}

public void setVerticalAlign(int align) {
this.valign = align;
}

public int getVerticalAlign() {
return this.valign;
}

public void setOverflow(int o) {
this.overflow = o;
}

public int getOverflow() {
return this.overflow;
}

public void setHeight(int height) {
this.height = height;
}

public void setWidth(int width) {
this.width = width;
}

public void setContentHeight(int cheight) {
this.cheight = cheight;
}

public void setContentWidth(int cwidth) {
this.cwidth = cwidth;
}

public void setScaling(int scaling) {
this.scaling = scaling;
}

public int scalingMethod() {
return this.scaling;
}

public void setIntrinsicWidth(int w) {
awidth = w;
}

public void setIntrinsicHeight(int h) {
aheight = h;
}

public int getIntrinsicHeight() {
return aheight;
}

public int getIntrinsicWidth() {
return awidth;
}

public int getEffectiveHeight() {
if (this.hauto) {
if (this.chauto) {
return aheight;
} else {
// need to handle percentages, this would be a scaling factor on the
// instrinsic height (content determined height)
// if(this.properties.get("content-height").getLength().isPercentage()) {
// switch(scaling) {
// case Scaling.UNIFORM:
// break;
// case Scaling.NON_UNIFORM:
// break;
// }
// } else {
return this.cheight;
}
} else {
return this.height;
}
}

public int getEffectiveWidth() {
if (this.wauto) {
if (this.cwauto) {
return awidth;
} else {
// need to handle percentages, this would be a scaling factor on the
// instrinsic height (content determined height)
// if(this.properties.get("content-width").getLength().isPercentage()) {
// switch(scaling) {
// case Scaling.UNIFORM:
// break;
// case Scaling.NON_UNIFORM:
// break;
// }
// } else {
return this.cwidth;
}
} else {
return this.width;
}
}

}

+ 0
- 115
src/org/apache/fop/layout/inline/InlineArea.java View File

@@ -1,115 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout.inline;

import org.apache.fop.render.Renderer;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.FontState;
import org.apache.fop.layout.*;

public abstract class InlineArea extends Area {

private int yOffset = 0;

/**
* amount of space added since the original layout - needed by links
*/
private int xOffset = 0;
protected int height = 0;
private int verticalAlign = 0;
protected String pageNumberId = null;
private float red, green, blue;

// Textdecoration
protected boolean underlined = false;
protected boolean overlined = false;
protected boolean lineThrough = false;


public InlineArea(FontState fontState, int width, float red, float green,
float blue) {
super(fontState);
this.contentRectangleWidth = width;
this.red = red;
this.green = green;
this.blue = blue;
}

public float getBlue() {
return this.blue;
}

public float getGreen() {
return this.green;
}

public float getRed() {
return this.red;
}

public void setHeight(int height) {
this.height = height;
}

public int getHeight() {
return this.height;
}

public void setVerticalAlign(int align) {
this.verticalAlign = align;
}

public int getVerticalAlign() {
return this.verticalAlign;
}

public void setYOffset(int yOffset) {
this.yOffset = yOffset;
}

public int getYOffset() {
return this.yOffset;
}

public void setXOffset(int xOffset) {
this.xOffset = xOffset;
}

public int getXOffset() {
return this.xOffset;
}

public String getPageNumberID() {
return pageNumberId;
}

public void setUnderlined(boolean ul) {
this.underlined = ul;
}

public boolean getUnderlined() {
return this.underlined;
}

public void setOverlined(boolean ol) {
this.overlined = ol;
}

public boolean getOverlined() {
return this.overlined;
}

public void setLineThrough(boolean lt) {
this.lineThrough = lt;
}

public boolean getLineThrough() {
return this.lineThrough;
}

}

+ 0
- 90
src/org/apache/fop/layout/inline/InlineSpace.java View File

@@ -1,90 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout.inline;

import org.apache.fop.render.Renderer;
import org.apache.fop.layout.*;

public class InlineSpace extends Space {
private int size; // in millipoints
private boolean resizeable =
true; // to disallow size changes during justification of a line
// Used to discard some pending spaces in LineArea
private boolean eatable = false;

// Textdecoration
protected boolean underlined = false;
protected boolean overlined = false;
protected boolean lineThrough = false;


public InlineSpace(int amount) {
this.size = amount;
}

public InlineSpace(int amount, boolean resizeable) {
this.resizeable = resizeable;
this.size = amount;
}

/**
* @param ul true if text should be underlined
*/
public void setUnderlined(boolean ul) {
this.underlined = ul;
}

public boolean getUnderlined() {
return this.underlined;
}

public void setOverlined(boolean ol) {
this.overlined = ol;
}

public boolean getOverlined() {
return this.overlined;
}

public void setLineThrough(boolean lt) {
this.lineThrough = lt;
}

public boolean getLineThrough() {
return this.lineThrough;
}

public int getSize() {
return size;
}

public void setSize(int amount) {
this.size = amount;
}

public boolean getResizeable() {
return resizeable;
}

public void setResizeable(boolean resizeable) {
this.resizeable = resizeable;
}

/**
* And eatable InlineSpace is discarded if it occurs
* as the first pending element in a LineArea
*/
public void setEatable(boolean eatable) {
this.eatable = eatable;
}

public boolean isEatable() {
return eatable;
}

}

+ 0
- 59
src/org/apache/fop/layout/inline/LeaderArea.java View File

@@ -1,59 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout.inline;

import org.apache.fop.render.Renderer;
import org.apache.fop.layout.*;

import java.util.Vector;
import java.util.Enumeration;

public class LeaderArea extends InlineArea {

int ruleThickness;
int leaderLengthOptimum;
int leaderPattern;
int ruleStyle;

float red, green, blue;
public LeaderArea(FontState fontState, float red, float green,
float blue, String text, int leaderLengthOptimum,
int leaderPattern, int ruleThickness, int ruleStyle) {
super(fontState, leaderLengthOptimum, red, green, blue);

this.leaderPattern = leaderPattern;
this.leaderLengthOptimum = leaderLengthOptimum;
this.ruleStyle = ruleStyle;
// following the xsl spec rule: if rule-style="none" set thickness to 0;
// actually in pdf this doesn't work, because a very thin line is still shown
// this is handled in the pdf renderer
if (ruleStyle == org.apache.fop.fo.properties.RuleStyle.NONE) {
ruleThickness = 0;
}
this.ruleThickness = ruleThickness;
}

public int getRuleThickness() {
return this.ruleThickness;
}

public int getRuleStyle() {
return this.ruleStyle;
}

public int getLeaderPattern() {
return this.leaderPattern;
}

public int getLeaderLength() {
return this.contentRectangleWidth;
}



}

+ 0
- 23
src/org/apache/fop/layout/inline/PageNumberInlineArea.java View File

@@ -1,23 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout.inline;

import org.apache.fop.render.Renderer;
import org.apache.fop.datatypes.IDNode;
import org.apache.fop.layout.*;

public class PageNumberInlineArea extends WordArea {


public PageNumberInlineArea(FontState fontState, float red, float green,
float blue, String refid, int width) {
super(fontState, red, green, blue, "?", width);
this.pageNumberId = refid;
}

}

+ 0
- 42
src/org/apache/fop/layout/inline/WordArea.java View File

@@ -1,42 +0,0 @@
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/

package org.apache.fop.layout.inline;

import org.apache.fop.render.Renderer;
import org.apache.fop.layout.FontState;

public class WordArea extends InlineArea {

private String text;

// Textdecoration
protected boolean underlined = false;
protected boolean overlined = false;
protected boolean lineThrough = false;


public WordArea(FontState fontState, float red, float green, float blue,
String text, int width) {
super(fontState, width, red, green, blue);
this.text = text;
this.contentRectangleWidth = width;
}

public String getText() {
return this.text;
}

public void setUnderlined(boolean ul) {
this.underlined = ul;
}

public boolean getUnderlined() {
return this.underlined;
}

}

+ 2
- 3
src/org/apache/fop/pdf/PDFDocument.java View File

@@ -14,7 +14,6 @@ package org.apache.fop.pdf;
// referenced and I'd rather not do it
import org.apache.fop.image.FopImage;

import org.apache.fop.layout.LinkSet;
import org.apache.fop.datatypes.ColorSpace;

import org.apache.fop.render.pdf.CIDFont;
@@ -60,7 +59,7 @@ public class PDFDocument {
/**
* the version of PDF supported
*/
protected static final String pdfVersion = "1.3";
protected static final String pdfVersion = "1.4";

/**
* the current character position
@@ -999,7 +998,7 @@ public class PDFDocument {
PDFLink link = new PDFLink(++this.objectcount, rect);
this.objects.add(link);

if (linkType == LinkSet.EXTERNAL) {
if (linkType == PDFLink.EXTERNAL) {
// check destination
if (destination.endsWith(".pdf")) { // FileSpec
PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount,

+ 2
- 0
src/org/apache/fop/pdf/PDFLink.java View File

@@ -14,6 +14,8 @@ import java.awt.Rectangle;
* class representing an /Annot object of /Subtype /Link
*/
public class PDFLink extends PDFObject {
public static final int EXTERNAL = 0;
public static final int INTERNAL = 1;

float ulx;
float uly;

+ 1
- 1
src/org/apache/fop/render/awt/AWTRenderer.java View File

@@ -72,7 +72,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable

/**
* Image Object and Graphics Object. The Graphics Object is the Graphics
* object that is contained withing the Image Object.
* object that is contained within the Image Object.
*/
private BufferedImage pageImage = null;
private Graphics2D graphics = null;

+ 1
- 1
src/org/apache/fop/render/pdf/PDFRenderer.java View File

@@ -519,7 +519,7 @@ public class PDFRenderer extends PrintRenderer {
currentStream.add("ET\nq\n" + ((float)w) + " 0 0 "
+ ((float)-h) + " "
+ (((float)currentBlockIPPosition) / 1000f) + " "
+ (((float)(currentBPPosition - 1000 * h)) / 1000f) + " cm\n" + "/Im"
+ (((float)(currentBPPosition + 1000 * h)) / 1000f) + " cm\n" + "/Im"
+ xobj + " Do\nQ\nBT\n");
}


+ 2
- 2
src/org/apache/fop/svg/PDFANode.java View File

@@ -55,10 +55,10 @@ public class PDFANode extends CompositeGraphicsNode {
super.paint(g2d);
if(g2d instanceof PDFGraphics2D) {
PDFGraphics2D pdfg = (PDFGraphics2D)g2d;
int type = org.apache.fop.layout.LinkSet.EXTERNAL;
int type = org.apache.fop.pdf.PDFLink.EXTERNAL;
Shape outline = getOutline();
if(destination.startsWith("#svgView(viewBox(")) {
type = org.apache.fop.layout.LinkSet.INTERNAL;
type = org.apache.fop.pdf.PDFLink.INTERNAL;
String nums = destination.substring(17, destination.length() - 2);
float x = 0;
float y = 0;

+ 1
- 1
src/org/apache/fop/svg/PDFGraphics2D.java View File

@@ -166,7 +166,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
Rectangle rect = b.getBounds();
rect.height = -rect.height;

if(linkType != LinkSet.EXTERNAL) {
if(linkType != PDFLink.EXTERNAL) {
String pdfdest = "/FitR " + dest;
currentPage.addAnnotation(pdfDoc.makeLinkCurrentPage(rect, pdfdest));
} else {

+ 1
- 0
src/org/apache/fop/svg/PDFTextElementBridge.java View File

@@ -98,3 +98,4 @@ public class PDFTextElementBridge extends SVGTextElementBridge {
return true;
}
}


+ 0
- 1
src/org/apache/fop/svg/SVGElement.java View File

@@ -10,7 +10,6 @@ package org.apache.fop.svg;
// FOP
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.layout.Area;
import org.apache.fop.layout.FontState;
import org.apache.fop.apps.FOPException;
import org.apache.fop.layout.inline.*;

Loading…
Cancel
Save