From 7464d725f84b11e5e55f210817b1b1a02726497a Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Tue, 12 Dec 2000 03:12:52 +0000 Subject: [PATCH] Updated tables to handle headers, footers, keep-with colspan is partly done Also fixed the bug where some of a block was missing if near end of page Code changes sponsored by Dresdner Bank, Germany git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193859 13f79535-47bb-0310-9956-ffa450edef68 --- src/codegen/foproperties.xml | 68 +- src/org/apache/fop/fo/FONode.java | 13 + src/org/apache/fop/fo/FOText.java | 17 + .../apache/fop/fo/StandardElementMapping.java | 2 + src/org/apache/fop/fo/flow/Block.java | 582 +++++++++--------- src/org/apache/fop/fo/flow/Table.java | 49 +- src/org/apache/fop/fo/flow/TableBody.java | 76 ++- src/org/apache/fop/fo/flow/TableCell.java | 35 +- src/org/apache/fop/fo/flow/TableFooter.java | 93 +++ src/org/apache/fop/fo/flow/TableHeader.java | 83 +++ src/org/apache/fop/fo/flow/TableRow.java | 87 ++- src/org/apache/fop/layout/AreaContainer.java | 51 +- 12 files changed, 821 insertions(+), 335 deletions(-) create mode 100644 src/org/apache/fop/fo/flow/TableFooter.java create mode 100644 src/org/apache/fop/fo/flow/TableHeader.java diff --git a/src/codegen/foproperties.xml b/src/codegen/foproperties.xml index 59e1d4358..14e4deccf 100644 --- a/src/codegen/foproperties.xml +++ b/src/codegen/foproperties.xml @@ -8,6 +8,36 @@ new ColorType(strval) + + generic-boolean + GenericBoolean + Enum + + true + false + + + + generic-keep + GenericKeep + Number + 0 + -1 + + conditional-length-template GenericCondLength @@ -300,11 +330,7 @@ white-space-collapse true - Enum - - true - false - + GenericBoolean true @@ -376,12 +402,20 @@ keep-with-next false - Enum - - true - false - - false + GenericKeep + auto + + + keep-with-previous + false + GenericKeep + auto + + + keep-together + false + GenericKeep + auto background-color @@ -857,6 +891,18 @@ Number 1 + + widows + true + Number + 2 + + + orphans + true + Number + 2 + region-name diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index 884e4070f..e4d22c2f6 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -92,6 +92,9 @@ abstract public class FONode { protected int forcedStartOffset = 0; protected int forcedWidth = 0; + protected int widows = 0; + protected int orphans = 0; + protected LinkSet linkSet; protected FONode(FObj parent) { @@ -178,6 +181,16 @@ abstract public class FONode { } } + public void setWidows(int wid) + { + widows = wid; + } + + public void setOrphans(int orph) + { + orphans = orph; + } + public void removeAreas() { // still to do } diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java index 325aeccbc..f282dcffe 100644 --- a/src/org/apache/fop/fo/FOText.java +++ b/src/org/apache/fop/fo/FOText.java @@ -95,6 +95,23 @@ public class FOText extends FONode { this.underlined = ul; } + public boolean willCreateArea() + { + this.whiteSpaceCollapse = this.parent.properties.get( + "white-space-collapse").getEnum(); + if(this.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE && length > 0) { + return true; + } + for (int i = start; i < start + length - 1; i++) { + char ch = ca[i]; + if (!((ch == ' ') || (ch == '\n') || (ch == '\r') || + (ch == '\t'))) { // whitespace + return true; + } + } + return false; + } + public Status layout(Area area) throws FOPException { if (!(area instanceof BlockArea)) { MessageHandler.errorln("WARNING: text outside block area" + diff --git a/src/org/apache/fop/fo/StandardElementMapping.java b/src/org/apache/fop/fo/StandardElementMapping.java index 7bb19c215..b882012b0 100644 --- a/src/org/apache/fop/fo/StandardElementMapping.java +++ b/src/org/apache/fop/fo/StandardElementMapping.java @@ -99,7 +99,9 @@ public class StandardElementMapping implements ElementMapping { ExternalGraphic.maker()); builder.addMapping(uri, "table", Table.maker()); builder.addMapping(uri, "table-column", TableColumn.maker()); + builder.addMapping(uri, "table-header", TableHeader.maker()); builder.addMapping(uri, "table-body", TableBody.maker()); + builder.addMapping(uri, "table-footer", TableFooter.maker()); builder.addMapping(uri, "table-row", TableRow.maker()); builder.addMapping(uri, "table-cell", TableCell.maker()); builder.addMapping(uri, "basic-link", BasicLink.maker()); diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index 9f4edb778..55348eb60 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ The Apache Software License, Version 1.1 ============================================================================ - + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. - + 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -41,12 +41,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by - James Tauber . For more information on the Apache + James Tauber . For more information on the Apache Software Foundation, please see . - + */ package org.apache.fop.fo.flow; @@ -60,16 +60,16 @@ import org.apache.fop.datatypes.*; import org.apache.fop.apps.FOPException; public class Block extends FObjMixed { - + public static class Maker extends FObj.Maker { - public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new Block(parent, propertyList); - } + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new Block(parent, propertyList); + } } public static FObj.Maker maker() { - return new Block.Maker(); + return new Block.Maker(); } FontState fs; @@ -89,9 +89,11 @@ public class Block extends FObjMixed { int paddingBottom; int paddingLeft; int paddingRight; - + int blockWidows; + int blockOrphans; + String id; - + ColorType borderTopColor; int borderTopWidth; int borderTopStyle; @@ -104,285 +106,311 @@ public class Block extends FObjMixed { ColorType borderRightColor; int borderRightWidth; int borderRightStyle; - + BlockArea blockArea; // this may be helpful on other FOs too boolean anythingLaidOut = false; public Block(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:block"; + super(parent, propertyList); + this.name = "fo:block"; } public Status layout(Area area) throws FOPException { - // MessageHandler.error(" b:LAY[" + marker + "] "); - - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - String fontFamily = - this.properties.get("font-family").getString(); - String fontStyle = - this.properties.get("font-style").getString(); - String fontWeight = - this.properties.get("font-weight").getString(); - int fontSize = - this.properties.get("font-size").getLength().mvalue(); - - this.fs = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize); - this.align = this.properties.get("text-align").getEnum(); - this.alignLast = - this.properties.get("text-align-last").getEnum(); - this.breakBefore = - this.properties.get("break-before").getEnum(); - this.breakAfter = - this.properties.get("break-after").getEnum(); - this.lineHeight = - this.properties.get("line-height").getLength().mvalue(); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.textIndent = - this.properties.get("text-indent").getLength().mvalue(); - this.keepWithNext = - this.properties.get("keep-with-next").getEnum(); - this.backgroundColor = - this.properties.get("background-color").getColorType(); - this.paddingTop = - this.properties.get("padding").getLength().mvalue(); + // MessageHandler.error(" b:LAY[" + marker + "] "); + + if (this.marker == BREAK_AFTER) { + return new Status(Status.OK); + } + + if (this.marker == START) { + String fontFamily = + this.properties.get("font-family").getString(); + String fontStyle = + this.properties.get("font-style").getString(); + String fontWeight = + this.properties.get("font-weight").getString(); + int fontSize = + this.properties.get("font-size").getLength().mvalue(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize); + this.align = this.properties.get("text-align").getEnum(); + this.alignLast = + this.properties.get("text-align-last").getEnum(); + this.breakBefore = + this.properties.get("break-before").getEnum(); + this.breakAfter = this.properties.get("break-after").getEnum(); + this.lineHeight = this.properties.get( + "line-height").getLength().mvalue(); + this.startIndent = this.properties.get( + "start-indent").getLength().mvalue(); + this.endIndent = this.properties.get( + "end-indent").getLength().mvalue(); + this.spaceBefore = this.properties.get( + "space-before.optimum").getLength().mvalue(); + this.spaceAfter = this.properties.get( + "space-after.optimum").getLength().mvalue(); + this.textIndent = this.properties.get( + "text-indent").getLength().mvalue(); + this.keepWithNext = + this.properties.get("keep-with-next").getEnum(); + this.backgroundColor = this.properties.get( + "background-color").getColorType(); + this.paddingTop = + this.properties.get("padding").getLength().mvalue(); this.paddingLeft = this.paddingTop; this.paddingRight = this.paddingTop; this.paddingBottom = this.paddingTop; if (this.paddingTop == 0) { - this.paddingTop = - this.properties.get("padding-top").getLength().mvalue(); - this.paddingLeft = - this.properties.get("padding-left").getLength().mvalue(); - this.paddingBottom = - this.properties.get("padding-bottom").getLength().mvalue(); - this.paddingRight = - this.properties.get("padding-right").getLength().mvalue(); + this.paddingTop = this.properties.get( + "padding-top").getLength().mvalue(); + this.paddingLeft = this.properties.get( + "padding-left").getLength().mvalue(); + this.paddingBottom = this.properties.get( + "padding-bottom").getLength().mvalue(); + this.paddingRight = this.properties.get( + "padding-right").getLength().mvalue(); + } + this.borderTopColor = + this.properties.get("border-color").getColorType(); + this.borderBottomColor = this.borderTopColor; + this.borderLeftColor = this.borderTopColor; + this.borderRightColor = this.borderTopColor; + if (this.borderTopColor == null) { + this.borderTopColor = this.properties.get( + "border-top-color").getColorType(); + this.borderBottomColor = this.properties.get( + "border-bottom-color").getColorType(); + this.borderLeftColor = this.properties.get( + "border-left-color").getColorType(); + this.borderRightColor = this.properties.get( + "border-right-color").getColorType(); + } + this.borderTopWidth = this.properties.get( + "border-width").getLength().mvalue(); + this.borderBottomWidth = this.borderTopWidth; + this.borderLeftWidth = this.borderTopWidth; + this.borderRightWidth = this.borderTopWidth; + if (this.borderTopWidth == 0) { + this.borderTopWidth = this.properties.get( + "border-top-width").getLength().mvalue(); + this.borderBottomWidth = this.properties.get( + "border-bottom-width").getLength().mvalue(); + this.borderLeftWidth = this.properties.get( + "border-left-width").getLength().mvalue(); + this.borderRightWidth = this.properties.get( + "border-right-width").getLength().mvalue(); } - this.borderTopColor = - this.properties.get("border-color").getColorType(); - this.borderBottomColor = this.borderTopColor; - this.borderLeftColor = this.borderTopColor; - this.borderRightColor = this.borderTopColor; - if (this.borderTopColor == null) { - this.borderTopColor = - this.properties.get("border-top-color").getColorType(); - this.borderBottomColor = - this.properties.get("border-bottom-color").getColorType(); - this.borderLeftColor = - this.properties.get("border-left-color").getColorType(); - this.borderRightColor = - this.properties.get("border-right-color").getColorType(); - } - this.borderTopWidth = - this.properties.get("border-width").getLength().mvalue(); - this.borderBottomWidth = this.borderTopWidth; - this.borderLeftWidth = this.borderTopWidth; - this.borderRightWidth = this.borderTopWidth; - if (this.borderTopWidth == 0) { - this.borderTopWidth = - this.properties.get("border-top-width").getLength().mvalue(); - this.borderBottomWidth = - this.properties.get("border-bottom-width").getLength().mvalue(); - this.borderLeftWidth = - this.properties.get("border-left-width").getLength().mvalue(); - this.borderRightWidth = - this.properties.get("border-right-width").getLength().mvalue(); - } - this.borderTopStyle = - this.properties.get("border-style").getEnum(); - this.borderBottomStyle = this.borderTopStyle; - this.borderLeftStyle = this.borderTopStyle; - this.borderRightStyle = this.borderTopStyle; - if (this.borderTopStyle == 0) { - this.borderTopStyle = - this.properties.get("border-top-style").getEnum(); - this.borderBottomStyle = - this.properties.get("border-bottom-style").getEnum(); - this.borderLeftStyle = - this.properties.get("border-left-style").getEnum(); - this.borderRightStyle = - this.properties.get("border-right-style").getEnum(); - } - - this.id = - this.properties.get("id").getString(); - - if (area instanceof BlockArea) { - area.end(); - } - if (this.isInLabel) { - startIndent += bodyIndent; - endIndent += (area.getAllocationWidth() - - distanceBetweenStarts - startIndent) - + labelSeparation; - } - else if (this.isInListBody) { - startIndent += bodyIndent + distanceBetweenStarts; - } - - 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 (anythingLaidOut) { - this.textIndent = 0; - } - - if ( marker==0 ) { - area.getIDReferences().configureID(id,area); + this.borderTopStyle = + this.properties.get("border-style").getEnum(); + this.borderBottomStyle = this.borderTopStyle; + this.borderLeftStyle = this.borderTopStyle; + this.borderRightStyle = this.borderTopStyle; + if (this.borderTopStyle == 0) { + this.borderTopStyle = + this.properties.get("border-top-style").getEnum(); + this.borderBottomStyle = this.properties.get( + "border-bottom-style").getEnum(); + this.borderLeftStyle = this.properties.get( + "border-left-style").getEnum(); + this.borderRightStyle = this.properties.get( + "border-right-style").getEnum(); + } + this.blockWidows = + this.properties.get("widows").getNumber().intValue(); + this.blockOrphans = + this.properties.get("orphans").getNumber().intValue(); + + this.id = this.properties.get("id").getString(); + + if (area instanceof BlockArea) { + area.end(); + } + if (this.isInLabel) { + startIndent += bodyIndent; + endIndent += (area.getAllocationWidth() - + distanceBetweenStarts - startIndent) + + labelSeparation; + } else if (this.isInListBody) { + startIndent += bodyIndent + distanceBetweenStarts; + } + + 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); + } + + int numChildren = this.children.size(); + for (int i = 0; i < numChildren; i++) { + FONode fo = (FONode) children.elementAt(i); + if (fo instanceof FOText) { + if (((FOText) fo).willCreateArea()) { + fo.setWidows(blockWidows); + break; + } + } else { + fo.setWidows(blockWidows); + break; + } + } + + for (int i = numChildren - 1; i > 0; i--) { + FONode fo = (FONode) children.elementAt(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().configureID(id, area); } - - this.blockArea = - new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), - startIndent, - endIndent, - textIndent, align, alignLast, lineHeight); - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.setPadding(paddingTop, paddingLeft, paddingBottom, - paddingRight); - blockArea.setBorderStyle(borderTopStyle, borderLeftStyle, - borderBottomStyle, borderRightStyle); - blockArea.setBorderWidth(borderTopWidth, borderLeftWidth, - borderBottomWidth, borderRightWidth); - blockArea.setBorderColor(borderTopColor, borderLeftColor, - borderBottomColor, borderRightColor); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); + + this.blockArea = new BlockArea(fs, area.getAllocationWidth(), + area.spaceLeft(), startIndent, endIndent, textIndent, + align, alignLast, lineHeight); + blockArea.setPage(area.getPage()); + blockArea.setBackgroundColor(backgroundColor); + blockArea.setPadding(paddingTop, paddingLeft, paddingBottom, + paddingRight); + blockArea.setBorderStyle(borderTopStyle, borderLeftStyle, + borderBottomStyle, borderRightStyle); + blockArea.setBorderWidth(borderTopWidth, borderLeftWidth, + borderBottomWidth, borderRightWidth); + blockArea.setBorderColor(borderTopColor, borderLeftColor, + borderBottomColor, borderRightColor); + 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.elementAt(i); - if (this.isInListBody) { - fo.setIsInListBody(); - fo.setDistanceBetweenStarts(this.distanceBetweenStarts); - fo.setBodyIndent(this.bodyIndent); - } - 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); - anythingLaidOut = true; - - return status; - } - else // i == 0 nothing was laid out.. - { - anythingLaidOut = false; - return status; - } - } - - //blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - anythingLaidOut = true; - return status; - } - anythingLaidOut = true; - } - - blockArea.end(); - 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(); - } - - 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 (keepWithNext == KeepWithNext.TRUE) { - return new Status(Status.KEEP_WITH_NEXT); - } - - //MessageHandler.error(" b:OK" + marker + " "); - return new Status(Status.OK); + int numChildren = this.children.size(); + for (int i = this.marker; i < numChildren; i++) { + FONode fo = (FONode) children.elementAt(i); + if (this.isInListBody) { + fo.setIsInListBody(); + fo.setDistanceBetweenStarts(this.distanceBetweenStarts); + fo.setBodyIndent(this.bodyIndent); + } + 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.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.increaseHeight(blockArea.getHeight()); + area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); + anythingLaidOut = true; + return status; + } + anythingLaidOut = true; + } + + blockArea.end(); + 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(); + } + + 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 (keepWithNext != 0) { + return new Status(Status.KEEP_WITH_NEXT); + } + + //MessageHandler.error(" b:OK" + marker + " "); + return new Status(Status.OK); } public int getAreaHeight() { - return blockArea.getHeight(); + return blockArea.getHeight(); } - /** - * Return the content width of the boxes generated by this FO. - */ - protected int getContentWidth() { - if (blockArea != null) - return blockArea.getContentWidth(); //getAllocationWidth()?? - else return 0; // not laid out yet - } + /** + * Return the content width of the boxes generated by this FO. + */ + protected int getContentWidth() { + if (blockArea != null) + return blockArea.getContentWidth(); //getAllocationWidth()?? + else + return 0; // not laid out yet + } } diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index 03272fcec..659adc177 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -87,6 +87,8 @@ public class Table extends FObj { int borderWidth; int borderStyle; String id; + TableHeader tableHeader = null; + TableFooter tableFooter = null; Vector columns = new Vector(); int currentColumnNumber = 0; @@ -203,30 +205,69 @@ public class Table extends FObj { c.setColumnOffset(offset); fo.layout(areaContainer); offset += c.getColumnWidth(); + } else if (fo instanceof TableHeader) { + if (columns.size() == 0) { + MessageHandler.errorln("WARNING: 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) { + MessageHandler.errorln("WARNING: 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) { MessageHandler.errorln("WARNING: current implementation of tables requires a table-column for each column, indicating column-width"); return new Status(Status.OK); } - + Status status; + if(tableHeader != null) { + if ((status = tableHeader.layout(areaContainer)).isIncomplete()) { + return new Status(Status.AREA_FULL_NONE); + } + tableHeader.resetMarker(); + } + if(tableFooter != null) { + if ((status = tableFooter.layout(areaContainer)).isIncomplete()) { + return new Status(Status.AREA_FULL_NONE); + } + tableFooter.resetMarker(); + } + fo.setWidows(widows); + fo.setOrphans(orphans); ((TableBody) fo).setColumns(columns); - Status status; if ((status = fo.layout(areaContainer)).isIncomplete()) { this.marker = i; - if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - status = new Status(Status.AREA_FULL_SOME); + if (/*(i != 0) && */(status.getCode() == Status.AREA_FULL_NONE)) { +// status = new Status(Status.AREA_FULL_SOME); } //areaContainer.end(); if(!(/*(i == 0) && */(areaContainer.getContentHeight() <= 0))) { area.addChild(areaContainer); area.increaseHeight(areaContainer.getHeight()); area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); + if(tableFooter != null) { + // move footer to bottom of area and move up body + ((TableBody) fo).setYPosition(tableFooter.getYPosition()); + tableFooter.setYPosition(tableFooter.getYPosition() + ((TableBody) fo).getHeight()); + } } return status; } + if(tableFooter != null) { + // 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 (height != 0) areaContainer.setHeight(height); diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index c7b04986f..d4854e7c5 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -60,6 +60,7 @@ import org.apache.fop.apps.FOPException; // Java import java.util.Vector; +import java.util.Enumeration; public class TableBody extends FObj { @@ -78,6 +79,9 @@ public class TableBody extends FObj { int spaceBefore; int spaceAfter; ColorType backgroundColor; + ColorType borderColor; + int borderWidth; + int borderStyle; String id; Vector columns; @@ -93,6 +97,21 @@ public class TableBody extends FObj { this.columns = columns; } + public void setYPosition(int value) + { + areaContainer.setYPosition(value); + } + + public int getYPosition() + { + return areaContainer.getYPosition(); + } + + public int getHeight() + { + return areaContainer.getHeight(); + } + public Status layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { return new Status(Status.OK); @@ -116,6 +135,12 @@ public class TableBody extends FObj { this.properties.get("space-after.optimum").getLength().mvalue(); this.backgroundColor = this.properties.get("background-color").getColorType(); + this.borderColor = + this.properties.get("border-color").getColorType(); + this.borderWidth = + this.properties.get("border-width").getLength().mvalue(); + this.borderStyle = + this.properties.get("border-style").getEnum(); this.id = this.properties.get("id").getString(); @@ -143,27 +168,69 @@ public class TableBody extends FObj { } this.areaContainer = - new AreaContainer(fs, -area.borderWidthLeft, -area.borderWidthTop, area.getAllocationWidth(), + new AreaContainer(fs, -area.borderWidthLeft, -area.borderWidthTop + area.getHeight(), area.getAllocationWidth(), area.spaceLeft(), Position.RELATIVE); areaContainer.setPage(area.getPage()); areaContainer.setBackgroundColor(backgroundColor); + areaContainer.setBorderStyle(borderStyle, borderStyle, borderStyle, borderStyle); + areaContainer.setBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); + areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor); areaContainer.start(); areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); areaContainer.setIDReferences(area.getIDReferences()); + Vector keepWith = new Vector(); int numChildren = this.children.size(); + TableRow lastRow = null; for (int i = this.marker; i < numChildren; i++) { TableRow row = (TableRow) children.elementAt(i); row.setColumns(columns); + row.doSetup(areaContainer); + if(row.getKeepWithPrevious() != 0 && lastRow != null) { + keepWith.addElement(lastRow); + } Status status; if ((status = row.layout(areaContainer)).isIncomplete()) { + if(keepWith.size() > 0) { // && status.getCode() == Status.AREA_FULL_NONE + for(Enumeration e = keepWith.elements(); e.hasMoreElements(); ) { + TableRow tr = (TableRow)e.nextElement(); + tr.removeLayout(areaContainer); + i--; + } + } this.marker = i; if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { status = new Status(Status.AREA_FULL_SOME); } + if(i < widows && numChildren >= widows) { + resetMarker(); + return new Status(Status.AREA_FULL_NONE); + } + if(numChildren <= orphans) { + resetMarker(); + return new Status(Status.AREA_FULL_NONE); + } + if(numChildren - i < orphans && numChildren > orphans) { + for(int count = numChildren - orphans - i; count > 0; count--) { + row = (TableRow) children.elementAt(count); + row.removeLayout(areaContainer); + i--; + } + if(i < widows && numChildren >= widows) { + resetMarker(); + return new Status(Status.AREA_FULL_NONE); + } + this.marker = i; + area.addChild(areaContainer); + //areaContainer.end(); + + area.increaseHeight(areaContainer.getHeight()); + area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); + return new Status(Status.AREA_FULL_SOME); + } if(!((i == 0) && (areaContainer.getContentHeight() <= 0))) { area.addChild(areaContainer); //areaContainer.end(); @@ -172,7 +239,14 @@ public class TableBody extends FObj { area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); } return status; + } else if(status.getCode() == Status.KEEP_WITH_NEXT) { + keepWith.addElement(row); + } else { + if(keepWith.size() > 0 && row.getKeepWithPrevious() != 0) { + keepWith = new Vector(); + } } + lastRow = row; } area.addChild(areaContainer); areaContainer.end(); diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index f3147191c..d6de38989 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -93,10 +93,13 @@ public class TableCell extends FObj { int paddingRight; int position; String id; + int numColumnsSpanned; + int numRowsSpanned; protected int startOffset; protected int width; protected int height = 0; + boolean setup = false; AreaContainer areaContainer; @@ -113,12 +116,22 @@ public class TableCell extends FObj { this.width = width; } - public Status layout(Area area) throws FOPException { - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } + public int getNumColumnsSpanned() + { + return numColumnsSpanned; + } - if (this.marker == START) { + public int getNumRowsSpanned() + { + return numRowsSpanned; + } + + public void doSetup(Area area) throws FOPException + { + this.numColumnsSpanned = + this.properties.get("number-columns-spanned").getNumber().intValue(); + this.numRowsSpanned = + this.properties.get("number-rows-spanned").getNumber().intValue(); String fontFamily = this.properties.get("font-family").getString(); String fontStyle = @@ -199,6 +212,16 @@ public class TableCell extends FObj { this.properties.get("background-color").getColorType(); this.id = this.properties.get("id").getString(); + } + + 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 (area instanceof BlockArea) { area.end(); @@ -255,6 +278,8 @@ public class TableCell extends FObj { } else { // hani Elabed 11/21/2000 area.addChild(areaContainer); +// area.setHeight(getHeight()); + area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); return new Status(Status.AREA_FULL_SOME); } diff --git a/src/org/apache/fop/fo/flow/TableFooter.java b/src/org/apache/fop/fo/flow/TableFooter.java new file mode 100644 index 000000000..7fa15b77a --- /dev/null +++ b/src/org/apache/fop/fo/flow/TableFooter.java @@ -0,0 +1,93 @@ +/*-- $Id$ -- + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "FOP" and "Apache Software Foundation" must not be used to + endorse or promote products derived from this software without prior + written permission. For written permission, please contact + apache@apache.org. + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + James Tauber . For more information on the Apache + Software Foundation, please see . + + */ + +package org.apache.fop.fo.flow; + +// FOP +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.apps.FOPException; + +// Java +import java.util.Vector; +import java.util.Enumeration; + +public class TableFooter extends TableBody { + + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, PropertyList propertyList) + throws FOPException { + return new TableFooter(parent, propertyList); + } + } + + public int getYPosition() + { + return areaContainer.getYPosition() - spaceBefore; + } + + public void setYPosition(int value) + { + areaContainer.setYPosition(value + 2 * spaceBefore); + } + + public static FObj.Maker maker() { + return new TableFooter.Maker(); + } + + public TableFooter(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:table-footer"; + } + +} diff --git a/src/org/apache/fop/fo/flow/TableHeader.java b/src/org/apache/fop/fo/flow/TableHeader.java new file mode 100644 index 000000000..bd926ff7b --- /dev/null +++ b/src/org/apache/fop/fo/flow/TableHeader.java @@ -0,0 +1,83 @@ +/*-- $Id$ -- + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "FOP" and "Apache Software Foundation" must not be used to + endorse or promote products derived from this software without prior + written permission. For written permission, please contact + apache@apache.org. + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + James Tauber . For more information on the Apache + Software Foundation, please see . + + */ + +package org.apache.fop.fo.flow; + +// FOP +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.apps.FOPException; + +// Java +import java.util.Vector; +import java.util.Enumeration; + +public class TableHeader extends TableBody { + + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, PropertyList propertyList) + throws FOPException { + return new TableHeader(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new TableHeader.Maker(); + } + + public TableHeader(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:table-header"; + } + +} diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index fdc571c3d..8c6e0b5d4 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -75,6 +75,8 @@ public class TableRow extends FObj { return new TableRow.Maker(); } + boolean setup = false; + FontState fs; int spaceBefore; int spaceAfter; @@ -97,6 +99,8 @@ public class TableRow extends FObj { int paddingBottom; int paddingLeft; int paddingRight; + int keepWithNext; + int keepWithPrevious; int widthOfCellsSoFar = 0; int largestCellHeight = 0; @@ -155,6 +159,7 @@ public class TableRow extends FObj { /** the width of the cell so far.*/ private int widthOfCellSoFar; + private int column = 0; /** * simple no args constructor. @@ -223,6 +228,11 @@ public class TableRow extends FObj { public final void setWidthOfCellSoFar(int aWidth) { widthOfCellSoFar = aWidth; } + public int getColumn() + { return column; } + + public void setColumn(int col) + { column = col; } } @@ -235,12 +245,13 @@ public class TableRow extends FObj { this.columns = columns; } - public Status layout(Area area) throws FOPException { - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } + public int getKeepWithPrevious() + { + return keepWithPrevious; + } - if (this.marker == START) { + public void doSetup(Area area) throws FOPException + { String fontFamily = this.properties.get("font-family").getString(); String fontStyle = @@ -303,6 +314,10 @@ public class TableRow extends FObj { this.borderRightStyle = this.properties.get("border-right-style").getEnum(); } + this.keepWithNext = + this.properties.get("keep-with-next").getNumber().intValue(); + this.keepWithPrevious = + this.properties.get("keep-with-previous").getNumber().intValue(); this.paddingTop = this.properties.get("padding").getLength().mvalue(); this.paddingLeft = this.paddingTop; @@ -320,6 +335,17 @@ public class TableRow extends FObj { } this.id= this.properties.get("id").getString(); + 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 (area instanceof BlockArea) { area.end(); @@ -386,10 +412,10 @@ public class TableRow extends FObj { areaContainer.setIDReferences(area.getIDReferences()); int numChildren = this.children.size(); - if (numChildren != columns.size()) { - MessageHandler.errorln("WARNING: Number of children under table-row not equal to number of table-columns"); - return new Status(Status.OK); - } +// if (numChildren != columns.size()) { +// MessageHandler.errorln("WARNING: Number of children under table-row not equal to number of table-columns"); +// return new Status(Status.OK); +// } // added by Eric Schaeffer widthOfCellsSoFar = 0; @@ -398,13 +424,20 @@ public class TableRow extends FObj { // added by Hani Elabed 11/27/2000 boolean someCellDidNotLayoutCompletely = false; - + int colCount = -1; for (int i = this.marker; i < numChildren; i++) { TableCell cell = (TableCell) children.elementAt(i); // added by Hani Elabed 11/22/2000 CellState cellState = (CellState) cells.elementAt( i ); + if(colCount == -1) { + colCount = cellState.getColumn(); + } + cell.doSetup(areaContainer); + int numCols = cell.getNumColumnsSpanned(); + int numRows = cell.getNumRowsSpanned(); + //if (this.isInListBody) { //fo.setIsInListBody(); @@ -419,7 +452,12 @@ public class TableRow extends FObj { //cell.setStartOffset(widthOfCellsSoFar); cell.setStartOffset( cellState.getWidthOfCellSoFar() ); - int width = ((TableColumn) columns.elementAt(i)).getColumnWidth(); + int width = 0; + cellState.setColumn(colCount); + for(int count = 0; count < numCols && count < columns.size(); count++) { + width += ((TableColumn) columns.elementAt(colCount)).getColumnWidth(); + colCount++; + } cell.setWidth(width); widthOfCellsSoFar += width; @@ -428,10 +466,10 @@ public class TableRow extends FObj { if ((status = cell.layout(areaContainer)).isIncomplete()) { this.marker = i; - if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) +/* if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { status = new Status(Status.AREA_FULL_SOME); - } + }*/ if( status.getCode() == Status.AREA_FULL_SOME ) @@ -464,6 +502,7 @@ public class TableRow extends FObj { // removing something that was added by succession // of cell.layout() // just to keep my sanity here, Hani + area.increaseHeight(areaContainer.getHeight()); area.removeChild(areaContainer); this.resetMarker(); this.removeID(area.getIDReferences()); @@ -495,8 +534,10 @@ public class TableRow extends FObj { } // added by Dresdner Bank, Germany - if(spacer != null) + if(spacer != null) { area.addChild(spacer); + spacer = null; + } area.addChild(areaContainer); areaContainer.end(); @@ -544,6 +585,9 @@ public class TableRow extends FObj { } else { + if (keepWithNext != 0) { + return new Status(Status.KEEP_WITH_NEXT); + } return new Status(Status.OK); } @@ -552,4 +596,19 @@ public class TableRow extends FObj { public int getAreaHeight() { return areaContainer.getHeight(); } + + public void removeLayout(Area area) + { + if(spacer != null) + area.removeChild(spacer); + + // removing something that was added by succession + // of cell.layout() + // just to keep my sanity here, Hani +// area.increaseHeight(areaContainer.getHeight()); + area.removeChild(areaContainer); + this.resetMarker(); + this.removeID(area.getIDReferences()); + marker = 0; + } } diff --git a/src/org/apache/fop/layout/AreaContainer.java b/src/org/apache/fop/layout/AreaContainer.java index cdd66f62b..2f994f32e 100644 --- a/src/org/apache/fop/layout/AreaContainer.java +++ b/src/org/apache/fop/layout/AreaContainer.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ The Apache Software License, Version 1.1 ============================================================================ - + Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - + 4. The names "Fop" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. - + 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -41,12 +41,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by - James Tauber . For more information on the Apache + James Tauber . For more information on the Apache Software Foundation, please see . - + */ package org.apache.fop.layout; @@ -57,38 +57,43 @@ 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; - public AreaContainer(FontState fontState, int xPosition, int yPosition, int allocationWidth, int maxHeight, int position) { - super(fontState, allocationWidth, maxHeight); - this.xPosition = xPosition; - this.yPosition = yPosition; + 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; } public void render(Renderer renderer) { - renderer.renderAreaContainer(this); + renderer.renderAreaContainer(this); } public int getPosition() { - return position; + return position; } public int getXPosition() { return xPosition + this.paddingLeft + this.borderWidthLeft; } - public void setXPosition(int value) - { - xPosition=value; + public void setXPosition(int value) { + xPosition = value; } public int getYPosition() { - return yPosition + this.paddingTop + this.borderWidthTop; + return yPosition + this.paddingTop + this.borderWidthTop; + } + + public void setYPosition(int value) { + yPosition = value; } } -- 2.39.5