From 2c4d2fab77151a9a9ca4fbce43747be2e0464e3a Mon Sep 17 00:00:00 2001 From: eschaeffer Date: Thu, 25 Jan 2001 15:05:54 +0000 Subject: [PATCH] Added small-caps support in all fo. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193986 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/flow/Block.java | 1 + .../apache/fop/fo/flow/BlockContainer.java | 425 +++--- src/org/apache/fop/fo/flow/Character.java | 165 +-- .../apache/fop/fo/flow/ExternalGraphic.java | 38 +- src/org/apache/fop/fo/flow/FootnoteBody.java | 188 +-- src/org/apache/fop/fo/flow/InlineGraphic.java | 186 +-- .../fop/fo/flow/InstreamForeignObject.java | 113 +- src/org/apache/fop/fo/flow/Leader.java | 203 +-- src/org/apache/fop/fo/flow/ListBlock.java | 330 ++--- src/org/apache/fop/fo/flow/ListItem.java | 208 +-- src/org/apache/fop/fo/flow/PageNumber.java | 158 +-- .../fop/fo/flow/PageNumberCitation.java | 228 ++-- src/org/apache/fop/fo/flow/Table.java | 683 +++++----- src/org/apache/fop/fo/flow/TableBody.java | 489 +++---- src/org/apache/fop/fo/flow/TableCell.java | 451 +++---- src/org/apache/fop/fo/flow/TableColumn.java | 325 ++--- src/org/apache/fop/fo/flow/TableRow.java | 1141 +++++++++-------- 17 files changed, 2703 insertions(+), 2629 deletions(-) diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index f5f5f0417..bbc60d915 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -151,6 +151,7 @@ public class Block extends FObjMixed { this.fs = new FontState(area.getFontInfo(), fontFamily, fontStyle, fontWeight, fontSize, fontVariant); + this.align = this.properties.get("text-align").getEnum(); this.alignLast = this.properties.get("text-align-last").getEnum(); diff --git a/src/org/apache/fop/fo/flow/BlockContainer.java b/src/org/apache/fop/fo/flow/BlockContainer.java index 440f39368..2397f4c97 100644 --- a/src/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/org/apache/fop/fo/flow/BlockContainer.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + + 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. - + 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. - + 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. - + 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. - + 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. - + "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; @@ -64,235 +64,240 @@ import java.util.Hashtable; import java.util.Enumeration; public class BlockContainer extends FObj { - - FontState fs; - ColorType backgroundColor; - int paddingTop; - int paddingBottom; - int paddingLeft; - int paddingRight; - int position; - - int top; - int bottom; - int left; - int right; - int width; - int height; - - ColorType borderTopColor; - int borderTopWidth; - int borderTopStyle; - ColorType borderBottomColor; - int borderBottomWidth; - int borderBottomStyle; - ColorType borderLeftColor; - int borderLeftWidth; - int borderLeftStyle; - ColorType borderRightColor; - int borderRightWidth; - int borderRightStyle; - + + FontState fs; + ColorType backgroundColor; + int paddingTop; + int paddingBottom; + int paddingLeft; + int paddingRight; + int position; + + int top; + int bottom; + int left; + int right; + int width; + int height; + + ColorType borderTopColor; + int borderTopWidth; + int borderTopStyle; + ColorType borderBottomColor; + int borderBottomWidth; + int borderBottomStyle; + ColorType borderLeftColor; + int borderLeftWidth; + int borderLeftStyle; + ColorType borderRightColor; + int borderRightWidth; + int borderRightStyle; + int span; - - AreaContainer areaContainer; - public static class Maker extends FObj.Maker { + AreaContainer areaContainer; + + public static class Maker extends FObj.Maker { public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new BlockContainer(parent, propertyList); + throws FOPException { + return new BlockContainer(parent, propertyList); } - } + } - public static FObj.Maker maker() { + public static FObj.Maker maker() { return new BlockContainer.Maker(); - } + } - PageSequence pageSequence; + PageSequence pageSequence; - protected BlockContainer(FObj parent, PropertyList propertyList) + protected BlockContainer(FObj parent, PropertyList propertyList) throws FOPException { super(parent, propertyList); - this.name = "fo:block-container"; - this.span = this.properties.get("span").getEnum(); - } - - public Status layout(Area area) throws FOPException { + this.name = "fo:block-container"; + this.span = this.properties.get("span").getEnum(); + } + + public Status layout(Area area) throws FOPException { if (this.marker == START) { - this.marker = 0; - - 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.backgroundColor = + this.marker = 0; + + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + this.backgroundColor = this.properties.get("background-color").getColorType(); - this.paddingTop = + 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.position = + 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.position = this.properties.get("position").getEnum(); - this.top = + this.top = this.properties.get("top").getLength().mvalue(); - this.bottom = + this.bottom = this.properties.get("bottom").getLength().mvalue(); - this.left = + this.left = this.properties.get("left").getLength().mvalue(); - this.right = + this.right = this.properties.get("right").getLength().mvalue(); - this.width = + this.width = this.properties.get("width").getLength().mvalue(); - this.height = + this.height = this.properties.get("height").getLength().mvalue(); - - this.borderTopColor = + + 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.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-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.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-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.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(); - } - - span = this.properties.get("span").getEnum(); - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id,area); - } + 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(); + } + + 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; - } + + AreaContainer container = (AreaContainer)area; + if ((this.width == 0) && (this.height == 0)) { + width = right - left; + height = bottom - top; + } this.areaContainer = - new AreaContainer(fs, container.getXPosition() + left, container.getYPosition() - top, width, height, - position); + new AreaContainer(fs, container.getXPosition() + left, container.getYPosition() - top, width, height, + position); areaContainer.setPage(area.getPage()); areaContainer.setBackgroundColor(backgroundColor); areaContainer.setPadding(paddingTop, paddingLeft, paddingBottom, - paddingRight); - areaContainer.setBorderStyle(borderTopStyle, borderLeftStyle, - borderBottomStyle, borderRightStyle); - areaContainer.setBorderWidth(borderTopWidth, borderLeftWidth, - borderBottomWidth, borderRightWidth); - areaContainer.setBorderColor(borderTopColor, borderLeftColor, - borderBottomColor, borderRightColor); + paddingRight); + areaContainer.setBorderStyle(borderTopStyle, borderLeftStyle, + borderBottomStyle, borderRightStyle); + areaContainer.setBorderWidth(borderTopWidth, borderLeftWidth, + borderBottomWidth, borderRightWidth); + areaContainer.setBorderColor(borderTopColor, borderLeftColor, + borderBottomColor, borderRightColor); areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - + + 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.elementAt(i); - Status status; - if ((status = fo.layout(areaContainer)).isIncomplete()) { - /* + FObj fo = (FObj) children.elementAt(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 + 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; + this.marker = i; + return status; } - */ - } - if (status.getCode() == Status.KEEP_WITH_NEXT) { + */ + } + if (status.getCode() == Status.KEEP_WITH_NEXT) { prevChildMustKeepWithNext = true; - } + } } - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); + area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); areaContainer.end(); - if (position == Position.ABSOLUTE) - areaContainer.setHeight(height); + 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() { + } + + /** + * 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() { return true; - } + } - public int getSpan() { - return this.span; - } + public int getSpan() { + return this.span; + } } diff --git a/src/org/apache/fop/fo/flow/Character.java b/src/org/apache/fop/fo/flow/Character.java index 0a3a7915a..cefc59626 100644 --- a/src/org/apache/fop/fo/flow/Character.java +++ b/src/org/apache/fop/fo/flow/Character.java @@ -1,35 +1,35 @@ /* ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + 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. + 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. + 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. + 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. + 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. + "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 @@ -78,71 +78,76 @@ import org.apache.fop.messaging.MessageHandler; * */ public class Character extends FObj { - public final static int OK = 0; - public final static int DOESNOT_FIT = 1; - - - public Character(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:character"; - } - - public static FObj.Maker maker() { - return new Character.Maker(); - } - - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Character(parent, propertyList); - } - } - - - public Status layout(Area area) throws FOPException { - BlockArea blockArea; - blockArea = (BlockArea) area; - boolean textDecoration; - - //retrieving font property information for fo:leader - 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(); - //wrapping it up into Fontstate - FontState fontstate = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize); - //color properties - ColorType c = this.properties.get("color").getColorType(); - float red = c.red(); - float green = c.green(); - float blue = c.blue(); - - int whiteSpaceCollapse = this.properties.get( - "white-space-collapse").getEnum(); - int wrapOption = this.parent.properties.get("wrap-option").getEnum(); - - int tmp = this.properties.get("text-decoration").getEnum(); - if (tmp == org.apache.fop.fo.properties.TextDecoration.UNDERLINE) { - textDecoration = true; - } else { - textDecoration = false; - } - - //Character specific properties - char characterValue = this.properties.get("character").getCharacter(); - - - // initialize id - String id = this.properties.get("id").getString(); - blockArea.getIDReferences().initializeID(id, blockArea); - blockArea.addCharacter(fontstate,red,green,blue,wrapOption,this.getLinkSet(), - whiteSpaceCollapse,characterValue,textDecoration); - return new Status(Status.OK); - - - } + public final static int OK = 0; + public final static int DOESNOT_FIT = 1; + + + public Character(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:character"; + } + + public static FObj.Maker maker() { + return new Character.Maker(); + } + + + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new Character(parent, propertyList); + } + } + + + public Status layout(Area area) throws FOPException { + BlockArea blockArea; + blockArea = (BlockArea) area; + boolean textDecoration; + + //retrieving font property information for fo:leader + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + FontState fontstate = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + //color properties + ColorType c = this.properties.get("color").getColorType(); + float red = c.red(); + float green = c.green(); + float blue = c.blue(); + + int whiteSpaceCollapse = this.properties.get( + "white-space-collapse").getEnum(); + int wrapOption = this.parent.properties.get("wrap-option").getEnum(); + + int tmp = this.properties.get("text-decoration").getEnum(); + if (tmp == org.apache.fop.fo.properties.TextDecoration.UNDERLINE) { + textDecoration = true; + } else { + textDecoration = false; + } + + //Character specific properties + char characterValue = this.properties.get("character").getCharacter(); + + + // initialize id + String id = this.properties.get("id").getString(); + blockArea.getIDReferences().initializeID(id, blockArea); + blockArea.addCharacter(fontstate,red,green,blue,wrapOption,this.getLinkSet(), + whiteSpaceCollapse,characterValue,textDecoration); + return new Status(Status.OK); + + + } } diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java index f2a145926..5636fa70a 100644 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java @@ -81,17 +81,21 @@ public class ExternalGraphic extends FObj { public Status layout(Area area) throws FOPException { if (this.marker == START) { - String fontFamily = + String fontFamily = this.properties.get("font-family").getString(); - String fontStyle = + String fontStyle = this.properties.get("font-style").getString(); - String fontWeight = + String fontWeight = this.properties.get("font-weight").getString(); - int fontSize = + int fontSize = this.properties.get("font-size").getLength().mvalue(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); - this.fs = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize); + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); // FIXME this.align = this.properties.get("text-align").getEnum(); @@ -110,7 +114,7 @@ public class ExternalGraphic extends FObj { this.width = this.properties.get("width").getLength().mvalue(); - this.height = + this.height = this.properties.get("height").getLength().mvalue(); this.id = this.properties.get("id").getString(); @@ -123,8 +127,8 @@ public class ExternalGraphic extends FObj { if (this.isInLabel) { startIndent += bodyIndent; - endIndent += (area.getAllocationWidth() - - distanceBetweenStarts - startIndent) + + endIndent += (area.getAllocationWidth() - + distanceBetweenStarts - startIndent) + labelSeparation; } @@ -134,7 +138,7 @@ public class ExternalGraphic extends FObj { if (this.isInTableCell) { startIndent += forcedStartOffset; - endIndent = area.getAllocationWidth() - forcedWidth - + endIndent = area.getAllocationWidth() - forcedWidth - forcedStartOffset; } @@ -153,11 +157,11 @@ public class ExternalGraphic extends FObj { height = (int) ((imgHeight * 1000d)); } else if (height == 0) { - height = (int) ((imgHeight * ((double) width)) / + height = (int) ((imgHeight * ((double) width)) / imgWidth); } else if (width == 0) { - width = (int) ((imgWidth * ((double) height)) / + width = (int) ((imgWidth * ((double) height)) / imgHeight); } } @@ -180,8 +184,8 @@ public class ExternalGraphic extends FObj { return new Status(Status.AREA_FULL_NONE); } - this.imageArea = - new ImageArea(fs, img, area.getAllocationWidth(), + this.imageArea = + new ImageArea(fs, img, area.getAllocationWidth(), width, height, startIndent, endIndent, align); if ((spaceBefore != 0) && (this.marker == 0)) { @@ -205,12 +209,12 @@ public class ExternalGraphic extends FObj { } catch (MalformedURLException urlex) { // bad URL - MessageHandler.errorln("Error while creating area : " + + MessageHandler.errorln("Error while creating area : " + urlex.getMessage()); } catch (FopImageException imgex) { // image error - MessageHandler.errorln("Error while creating area : " + + MessageHandler.errorln("Error while creating area : " + imgex.getMessage()); } @@ -228,7 +232,7 @@ public class ExternalGraphic extends FObj { public static class Maker extends FObj.Maker { - public FObj make(FObj parent, + public FObj make(FObj parent, PropertyList propertyList) throws FOPException { return new ExternalGraphic(parent, propertyList); } diff --git a/src/org/apache/fop/fo/flow/FootnoteBody.java b/src/org/apache/fop/fo/flow/FootnoteBody.java index 91f6eb8b0..3ec00bbe0 100644 --- a/src/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/org/apache/fop/fo/flow/FootnoteBody.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + + 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. - + 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. - + 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. - + 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. - + 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. - + "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; @@ -62,70 +62,74 @@ import org.apache.fop.layout.*; import java.util.Enumeration; public class FootnoteBody extends FObj { - FontState fs; - int align; - int alignLast; - int lineHeight; - int startIndent; - int endIndent; - int textIndent; - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new FootnoteBody(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new FootnoteBody.Maker(); - } - - public FootnoteBody(FObj parent, PropertyList propertyList) - throws FOPException { - super(parent, propertyList); - this.name = "fo:footnote-body"; - } - - public Status layout(Area area) throws FOPException { - if(this.marker == START) { - this.marker = 0; - } - 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(); - - FontState fs = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize); - - BlockArea blockArea = new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, textIndent, - align, alignLast, lineHeight); - 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.elementAt(i); - Status status; - if ( (status = fo.layout(blockArea)).isIncomplete() ) { - this.resetMarker(); - return status; - } - } - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - return new Status(Status.OK); - } + FontState fs; + int align; + int alignLast; + int lineHeight; + int startIndent; + int endIndent; + int textIndent; + + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, PropertyList propertyList) + throws FOPException { + return new FootnoteBody(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new FootnoteBody.Maker(); + } + + public FootnoteBody(FObj parent, PropertyList propertyList) + throws FOPException { + super(parent, propertyList); + this.name = "fo:footnote-body"; + } + + public Status layout(Area area) throws FOPException { + if(this.marker == START) { + this.marker = 0; + } + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + FontState fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + BlockArea blockArea = new BlockArea(fs, area.getAllocationWidth(), + area.spaceLeft(), startIndent, endIndent, textIndent, + align, alignLast, lineHeight); + 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.elementAt(i); + Status status; + if ( (status = fo.layout(blockArea)).isIncomplete() ) { + this.resetMarker(); + return status; + } + } + blockArea.end(); + area.addChild(blockArea); + area.increaseHeight(blockArea.getHeight()); + return new Status(Status.OK); + } } diff --git a/src/org/apache/fop/fo/flow/InlineGraphic.java b/src/org/apache/fop/fo/flow/InlineGraphic.java index e94836f0e..ee585998c 100644 --- a/src/org/apache/fop/fo/flow/InlineGraphic.java +++ b/src/org/apache/fop/fo/flow/InlineGraphic.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + + 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. - + 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. - + 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. - + 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. - + 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. - + "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 . - + */ /* Modified by Eric SCHAEFFER */ @@ -70,98 +70,102 @@ import java.net.MalformedURLException; public class InlineGraphic extends FObj { - public static class Maker extends FObj.Maker { + public static class Maker extends FObj.Maker { public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new InlineGraphic(parent, propertyList); + throws FOPException { + return new InlineGraphic(parent, propertyList); } - } + } - public static FObj.Maker maker() { + public static FObj.Maker maker() { return new InlineGraphic.Maker(); - } - - FontState fs; - int align; - int startIndent; - int endIndent; - int spaceBefore; - int spaceAfter; - String href; - int height; - int width; - String id; - - ImageArea imageArea; - - public InlineGraphic(FObj parent, PropertyList propertyList) { + } + + FontState fs; + int align; + int startIndent; + int endIndent; + int spaceBefore; + int spaceAfter; + String href; + int height; + int width; + String id; + + ImageArea imageArea; + + public InlineGraphic(FObj parent, PropertyList propertyList) { super(parent, propertyList); this.name = "fo:inline-graphic"; - } + } + + public Status layout(Area area) throws FOPException { - public Status layout(Area area) throws FOPException { - if (this.marker == START) { - String fontFamily = + String fontFamily = this.properties.get("font-family").getString(); - String fontStyle = + String fontStyle = this.properties.get("font-style").getString(); - String fontWeight = + String fontWeight = this.properties.get("font-weight").getString(); - int fontSize = + int fontSize = this.properties.get("font-size").getLength().mvalue(); - - this.fs = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); - // FIXME - this.align = this.properties.get("text-align").getEnum(); + // FIXME + this.align = this.properties.get("text-align").getEnum(); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = + this.startIndent = + this.properties.get("start-indent").getLength().mvalue(); + this.endIndent = this.properties.get("end-indent").getLength().mvalue(); - this.spaceBefore = + this.spaceBefore = this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); + this.spaceAfter = + this.properties.get("space-after.optimum").getLength().mvalue(); - this.href = this.properties.get("href").getString(); + this.href = this.properties.get("href").getString(); - this.width = + this.width = this.properties.get("width").getLength().mvalue(); - this.height = + this.height = this.properties.get("height").getLength().mvalue(); - this.id = this.properties.get("id").getString(); + this.id = this.properties.get("id").getString(); - area.getIDReferences().createID(id); + area.getIDReferences().createID(id); - if (area instanceof BlockArea) { + if (area instanceof BlockArea) { area.end(); - } + } - if (this.isInLabel) { + if (this.isInLabel) { startIndent += bodyIndent; endIndent += (area.getAllocationWidth() - - distanceBetweenStarts - startIndent) - + labelSeparation; - } + - distanceBetweenStarts - startIndent) + + labelSeparation; + } - if (this.isInListBody) { + if (this.isInListBody) { startIndent += bodyIndent + distanceBetweenStarts; - } + } - if (this.isInTableCell) { + if (this.isInTableCell) { startIndent += forcedStartOffset; endIndent = area.getAllocationWidth() - forcedWidth - - forcedStartOffset; - } + forcedStartOffset; + } - this.marker = 0; + this.marker = 0; } - + try { FopImage img = FopImageFactory.Make(href); // if width / height needs to be computed @@ -196,13 +200,13 @@ public class InlineGraphic extends FObj { ); if ((spaceBefore != 0) && (this.marker == 0)) { - area.addDisplaySpace(spaceBefore); + area.addDisplaySpace(spaceBefore); } - if (marker == 0) { - // configure id - area.getIDReferences().configureID(id,area); - } + if (marker == 0) { + // configure id + area.getIDReferences().configureID(id,area); + } imageArea.start(); imageArea.end(); @@ -210,7 +214,7 @@ public class InlineGraphic extends FObj { area.increaseHeight(imageArea.getHeight()); if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); + area.addDisplaySpace(spaceAfter); } } catch (MalformedURLException urlex) { @@ -222,9 +226,9 @@ MessageHandler.errorln("Error while creating area : " + imgex.getMessage()); } if (area instanceof BlockArea) { - area.start(); + area.start(); } return new Status(Status.OK); - } + } } diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java index a980d7ef9..fe8b2f3db 100644 --- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + + 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. - + 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. - + 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. - + 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. - + 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. - + "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; @@ -106,10 +106,10 @@ public class InstreamForeignObject extends FObj { boolean chauto; int spaceBefore; int spaceAfter; - int startIndent; - int endIndent; + int startIndent; + int endIndent; - ForeignObjectArea areaCurrent; + ForeignObjectArea areaCurrent; /** * constructs an instream-foreign-object object (called by Maker). @@ -130,7 +130,7 @@ public class InstreamForeignObject extends FObj { * @return the status of the layout */ public Status layout(Area area) throws FOPException { - + if (this.marker == BREAK_AFTER) { return new Status(Status.OK); } @@ -142,13 +142,18 @@ public class InstreamForeignObject extends FObj { 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(); - int align = this.properties.get("text-align").getEnum(); - int valign = this.properties.get("vertical-align").getEnum(); - int overflow = this.properties.get("overflow").getEnum(); - + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + this.fs = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize); - + fontStyle, fontWeight, fontSize, fontVariant); + + int align = this.properties.get("text-align").getEnum(); + int valign = this.properties.get("vertical-align").getEnum(); + int overflow = this.properties.get("overflow").getEnum(); + this.breakBefore = this.properties.get("break-before").getEnum(); this.breakAfter = this.properties.get("break-after").getEnum(); this.width = this.properties.get("width").getLength().mvalue(); @@ -159,10 +164,10 @@ public class InstreamForeignObject extends FObj { this.hauto = this.properties.get("height").getLength().isAuto(); this.cwauto = this.properties.get("content-width").getLength().isAuto(); this.chauto = this.properties.get("content-height").getLength().isAuto(); - - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = + + 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(); @@ -171,7 +176,7 @@ public class InstreamForeignObject extends FObj { this.scaling = this.properties.get("scaling").getEnum(); - area.getIDReferences().createID(id); + area.getIDReferences().createID(id); /* if is embedded in a block area */ if (area instanceof BlockArea) { /* temporarily end the block area */ @@ -179,7 +184,7 @@ public class InstreamForeignObject extends FObj { } if(this.areaCurrent == null) { this.areaCurrent = - new ForeignObjectArea(fs, area.getAllocationWidth(), area.spaceLeft()); + new ForeignObjectArea(fs, area.getAllocationWidth(), area.spaceLeft()); this.areaCurrent.start(); areaCurrent.setWidth(this.width); @@ -198,7 +203,7 @@ public class InstreamForeignObject extends FObj { int numChildren = this.children.size(); if(numChildren > 1) { - throw new FOPException("Only one child element is allowed in an instream-foreign-object"); + throw new FOPException("Only one child element is allowed in an instream-foreign-object"); } /* layout foreign object */ if(this.children.size() > 0) { @@ -229,22 +234,22 @@ public class InstreamForeignObject extends FObj { } } - if (this.isInLabel) { + if (this.isInLabel) { startIndent += bodyIndent; /* endIndent += (areaCurrent.getEffectiveWidth() - - distanceBetweenStarts - startIndent) - + labelSeparation;*/ - } + - distanceBetweenStarts - startIndent) + + labelSeparation;*/ + } - if (this.isInListBody) { + if (this.isInListBody) { startIndent += bodyIndent + distanceBetweenStarts; - } + } - if (this.isInTableCell) { + if (this.isInTableCell) { startIndent += forcedStartOffset; /* endIndent = areaCurrent.getEffectiveWidth() - forcedWidth - - forcedStartOffset;*/ - } + forcedStartOffset;*/ + } areaCurrent.setStartIndent(startIndent); // areaCurrent.setEndIndent(endIndent); @@ -274,7 +279,7 @@ public class InstreamForeignObject extends FObj { /* re-start the block area */ area.start(); } - + if (breakAfter == BreakAfter.PAGE) { this.marker = BREAK_AFTER; return new Status(Status.FORCE_PAGE_BREAK); @@ -284,7 +289,7 @@ public class InstreamForeignObject extends FObj { 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); diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java index 297c82b18..32d62765f 100644 --- a/src/org/apache/fop/fo/flow/Leader.java +++ b/src/org/apache/fop/fo/flow/Leader.java @@ -1,35 +1,35 @@ /*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + 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. + 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. + 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. + 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. + 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. + "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 @@ -69,91 +69,96 @@ import org.apache.fop.messaging.MessageHandler; public class Leader extends FObjMixed { - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Leader(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new Leader.Maker(); - } - - public Leader(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:leader"; - } - - public Status layout(Area area) throws FOPException { - BlockArea blockArea; - //restriction in this version - if (!(area instanceof BlockArea)) { - MessageHandler.errorln("WARNING: in this version of Fop fo:leader must be a direct child of fo:block "); - return new Status(Status.OK); - } else { - blockArea = (BlockArea) area; - } - - //retrieving font property information for fo:leader - 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(); - //wrapping it up into Fontstate - FontState fontstate = new FontState(area.getFontInfo(), fontFamily, - fontStyle, fontWeight, fontSize); - //color properties - ColorType c = this.properties.get("color").getColorType(); - float red = c.red(); - float green = c.green(); - float blue = c.blue(); - - //fo:leader specific properties - //determines the pattern of leader; allowed values: space, rule,dots, use-content - int leaderPattern = this.properties.get("leader-pattern").getEnum(); - //length of the leader - int leaderLengthOptimum = this.properties.get( - "leader-length.optimum").getLength().mvalue(); - int leaderLengthMinimum = this.properties.get( - "leader-length.minimum").getLength().mvalue(); - int leaderLengthMaximum = this.properties.get( - "leader-length.maximum").getLength().mvalue(); - //the following properties only apply for leader-pattern = "rule" - int ruleThickness = this.properties.get( - "rule-thickness").getLength().mvalue(); - int ruleStyle = this.properties.get("rule-style").getEnum(); - // if leaderPatternWidth = 0 = default = use-font-metric - int leaderPatternWidth = this.properties.get( - "leader-pattern-width").getLength().mvalue(); - int leaderAlignment = - this.properties.get("leader-alignment").getEnum(); - - // initialize id - String id = this.properties.get("id").getString(); - blockArea.getIDReferences().initializeID(id, blockArea); - - //adds leader to blockarea, there the leaderArea is generated - int succeeded = blockArea.addLeader(fontstate, 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); - } - } - - /* //should only be necessary for use-content - protected void addCharacters(char data[], int start, int length) { - FOText textNode = new FOText(data,start,length, this); - children.addElement(textNode); - } - */ + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new Leader(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new Leader.Maker(); + } + + public Leader(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:leader"; + } + + public Status layout(Area area) throws FOPException { + BlockArea blockArea; + //restriction in this version + if (!(area instanceof BlockArea)) { + MessageHandler.errorln("WARNING: in this version of Fop fo:leader must be a direct child of fo:block "); + return new Status(Status.OK); + } else { + blockArea = (BlockArea) area; + } + + //retrieving font property information for fo:leader + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + FontState fontstate = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + //color properties + ColorType c = this.properties.get("color").getColorType(); + float red = c.red(); + float green = c.green(); + float blue = c.blue(); + + //fo:leader specific properties + //determines the pattern of leader; allowed values: space, rule,dots, use-content + int leaderPattern = this.properties.get("leader-pattern").getEnum(); + //length of the leader + int leaderLengthOptimum = this.properties.get( + "leader-length.optimum").getLength().mvalue(); + int leaderLengthMinimum = this.properties.get( + "leader-length.minimum").getLength().mvalue(); + int leaderLengthMaximum = this.properties.get( + "leader-length.maximum").getLength().mvalue(); + //the following properties only apply for leader-pattern = "rule" + int ruleThickness = this.properties.get( + "rule-thickness").getLength().mvalue(); + int ruleStyle = this.properties.get("rule-style").getEnum(); + // if leaderPatternWidth = 0 = default = use-font-metric + int leaderPatternWidth = this.properties.get( + "leader-pattern-width").getLength().mvalue(); + int leaderAlignment = + this.properties.get("leader-alignment").getEnum(); + + // initialize id + String id = this.properties.get("id").getString(); + blockArea.getIDReferences().initializeID(id, blockArea); + + //adds leader to blockarea, there the leaderArea is generated + int succeeded = blockArea.addLeader(fontstate, 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); + } + } + + /* //should only be necessary for use-content + protected void addCharacters(char data[], int start, int length) { + FOText textNode = new FOText(data,start,length, this); + children.addElement(textNode); + } + */ } diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java index 4526a81b7..962e9103e 100644 --- a/src/org/apache/fop/fo/flow/ListBlock.java +++ b/src/org/apache/fop/fo/flow/ListBlock.java @@ -1,35 +1,35 @@ /*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + 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. + 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. + 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. + 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. + 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. + "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 @@ -66,153 +66,157 @@ import java.util.Enumeration; public class ListBlock extends FObj { - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new ListBlock(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new ListBlock.Maker(); - } - - FontState fs; - int align; - int alignLast; - int breakBefore; - int breakAfter; - int lineHeight; - int startIndent; - int endIndent; - int spaceBefore; - int spaceAfter; - int provisionalDistanceBetweenStarts; - int provisionalLabelSeparation; - int spaceBetweenListRows = 0; - ColorType backgroundColor; - - public ListBlock(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:list-block"; - } - - public Status layout(Area area) throws FOPException { - 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.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.provisionalDistanceBetweenStarts = this.properties.get( - "provisional-distance-between-starts").getLength(). - mvalue(); - this.provisionalLabelSeparation = this.properties.get( - "provisional-label-separation").getLength().mvalue(); - this.spaceBetweenListRows = 0; // not used at present - 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.isInListBody) { - startIndent += bodyIndent + distanceBetweenStarts; - bodyIndent = startIndent; - } - - if (this.isInTableCell) { - startIndent += forcedStartOffset; - endIndent += area.getAllocationWidth() - forcedWidth - - forcedStartOffset; - } - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - } - - BlockArea blockArea = new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, 0, align, - alignLast, lineHeight); - 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.elementAt(i) instanceof ListItem)) { - MessageHandler.errorln("WARNING: This version of FOP requires list-items inside list-blocks"); - return new Status(Status.OK); - } - ListItem listItem = (ListItem) children.elementAt(i); - listItem.setDistanceBetweenStarts( - this.provisionalDistanceBetweenStarts); - listItem.setLabelSeparation(this.provisionalLabelSeparation); - listItem.setBodyIndent(this.bodyIndent); - 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(); - } - - return new Status(Status.OK); - } - - public void setBodyIndent(int indent) { - if (! this.isInListBody) { - super.setBodyIndent(indent); - } - } + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new ListBlock(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new ListBlock.Maker(); + } + + FontState fs; + int align; + int alignLast; + int breakBefore; + int breakAfter; + int lineHeight; + int startIndent; + int endIndent; + int spaceBefore; + int spaceAfter; + int provisionalDistanceBetweenStarts; + int provisionalLabelSeparation; + int spaceBetweenListRows = 0; + ColorType backgroundColor; + + public ListBlock(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:list-block"; + } + + public Status layout(Area area) throws FOPException { + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + this.align = this.properties.get("text-align").getEnum(); + this.alignLast = + this.properties.get("text-align-last").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.provisionalDistanceBetweenStarts = this.properties.get( + "provisional-distance-between-starts").getLength(). + mvalue(); + this.provisionalLabelSeparation = this.properties.get( + "provisional-label-separation").getLength().mvalue(); + this.spaceBetweenListRows = 0; // not used at present + 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.isInListBody) { + startIndent += bodyIndent + distanceBetweenStarts; + bodyIndent = startIndent; + } + + if (this.isInTableCell) { + startIndent += forcedStartOffset; + endIndent += area.getAllocationWidth() - forcedWidth - + forcedStartOffset; + } + + // initialize id + String id = this.properties.get("id").getString(); + area.getIDReferences().initializeID(id, area); + } + + BlockArea blockArea = new BlockArea(fs, area.getAllocationWidth(), + area.spaceLeft(), startIndent, endIndent, 0, align, + alignLast, lineHeight); + 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.elementAt(i) instanceof ListItem)) { + MessageHandler.errorln("WARNING: This version of FOP requires list-items inside list-blocks"); + return new Status(Status.OK); + } + ListItem listItem = (ListItem) children.elementAt(i); + listItem.setDistanceBetweenStarts( + this.provisionalDistanceBetweenStarts); + listItem.setLabelSeparation(this.provisionalLabelSeparation); + listItem.setBodyIndent(this.bodyIndent); + 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(); + } + + return new Status(Status.OK); + } + + public void setBodyIndent(int indent) { + if (! this.isInListBody) { + super.setBodyIndent(indent); + } + } } diff --git a/src/org/apache/fop/fo/flow/ListItem.java b/src/org/apache/fop/fo/flow/ListItem.java index 541687fea..b5a889642 100644 --- a/src/org/apache/fop/fo/flow/ListItem.java +++ b/src/org/apache/fop/fo/flow/ListItem.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + + 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. - + 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. - + 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. - + 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. - + 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. - + "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; @@ -64,93 +64,97 @@ import java.util.Enumeration; public class ListItem extends FObj { - public static class Maker extends FObj.Maker { + public static class Maker extends FObj.Maker { public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new ListItem(parent, propertyList); + throws FOPException { + return new ListItem(parent, propertyList); } - } + } - public static FObj.Maker maker() { + public static FObj.Maker maker() { return new ListItem.Maker(); - } - - FontState fs; - int align; - int alignLast; - int breakBefore; - int breakAfter; - int lineHeight; - int startIndent; - int endIndent; - int spaceBefore; - int spaceAfter; - String id; - - public ListItem(FObj parent, PropertyList propertyList) { + } + + FontState fs; + int align; + int alignLast; + int breakBefore; + int breakAfter; + int lineHeight; + int startIndent; + int endIndent; + int spaceBefore; + int spaceAfter; + String id; + + public ListItem(FObj parent, PropertyList propertyList) { super(parent, propertyList); this.name = "fo:list-item"; - } + } - public Status layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { 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.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.id = - this.properties.get("id").getString(); - - area.getIDReferences().createID(id); - - this.marker = 0; + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + this.align = this.properties.get("text-align").getEnum(); + this.alignLast = + this.properties.get("text-align-last").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.id = + this.properties.get("id").getString(); + + 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(); + area.end(); } if (spaceBefore != 0) { - area.addDisplaySpace(spaceBefore); + area.addDisplaySpace(spaceBefore); } startIndent += this.bodyIndent; BlockArea blockArea = - new BlockArea(fs, area.getAllocationWidth(), - area.spaceLeft(), startIndent, endIndent, - 0, align, alignLast, lineHeight); + new BlockArea(fs, area.getAllocationWidth(), + area.spaceLeft(), startIndent, endIndent, + 0, align, alignLast, lineHeight); blockArea.setPage(area.getPage()); blockArea.start(); - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); + 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"); + throw new FOPException("list-item must have exactly two children"); } ListItemLabel label = (ListItemLabel) children.elementAt(0); ListItemBody body = (ListItemBody) children.elementAt(1); @@ -171,38 +175,38 @@ public class ListItem extends FObj { // body failed completely or only got some text in if (this.marker == 0) { - // configure id - area.getIDReferences().configureID(id,area); + // configure id + area.getIDReferences().configureID(id,area); - status = label.layout(blockArea); - if (status.isIncomplete()) { + 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()); + this.marker = 1; + return status; } blockArea.end(); area.addChild(blockArea); area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); + area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); + area.addDisplaySpace(spaceAfter); } /* not sure this is needed given we know area is from list block */ if (area instanceof BlockArea) { - area.start(); + area.start(); } return new Status(Status.OK); - } + } } diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java index a8b0b2189..8eb8741ef 100644 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ b/src/org/apache/fop/fo/flow/PageNumber.java @@ -1,35 +1,35 @@ /*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + 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. + 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. + 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. + 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. + 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. + "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 @@ -64,67 +64,71 @@ import java.util.Enumeration; public class PageNumber extends FObj { - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new PageNumber(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new PageNumber.Maker(); - } - - FontState fs; - float red; - float green; - float blue; - int wrapOption; - int whiteSpaceCollapse; - - public PageNumber(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:page-number"; - } - - public Status layout(Area area) throws FOPException { - if (!(area instanceof BlockArea)) { - MessageHandler.errorln("WARNING: page-number outside block area"); - 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); - - ColorType c = this.properties.get("color").getColorType(); - this.red = c.red(); - this.green = c.green(); - this.blue = c.blue(); - - this.wrapOption = this.properties.get("wrap-option").getEnum(); - this.whiteSpaceCollapse = - this.properties.get("white-space-collapse").getEnum(); - - this.marker = 0; - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - } - - String p = Integer.toString(area.getPage().getNumber()); - this.marker = ((BlockArea) area).addText(fs, red, green, blue, - wrapOption, null, whiteSpaceCollapse, p.toCharArray(), - 0, p.length(), false); - return new Status(Status.OK); - } + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new PageNumber(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new PageNumber.Maker(); + } + + FontState fs; + float red; + float green; + float blue; + int wrapOption; + int whiteSpaceCollapse; + + public PageNumber(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:page-number"; + } + + public Status layout(Area area) throws FOPException { + if (!(area instanceof BlockArea)) { + MessageHandler.errorln("WARNING: page-number outside block area"); + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + ColorType c = this.properties.get("color").getColorType(); + this.red = c.red(); + this.green = c.green(); + this.blue = c.blue(); + + this.wrapOption = this.properties.get("wrap-option").getEnum(); + this.whiteSpaceCollapse = + this.properties.get("white-space-collapse").getEnum(); + + this.marker = 0; + + // initialize id + String id = this.properties.get("id").getString(); + area.getIDReferences().initializeID(id, area); + } + + String p = Integer.toString(area.getPage().getNumber()); + this.marker = ((BlockArea) area).addText(fs, red, green, blue, + wrapOption, null, whiteSpaceCollapse, p.toCharArray(), + 0, p.length(), false); + return new Status(Status.OK); + } } diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java index cfcb2c51d..ce339c675 100644 --- a/src/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java @@ -1,35 +1,35 @@ /*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + 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. + 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. + 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. + 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. + 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. + "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 @@ -117,104 +117,108 @@ import org.apache.fop.apps.FOPException; */ public class PageNumberCitation extends FObj { - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new PageNumberCitation(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new PageNumberCitation.Maker(); - } - - FontState fs; - float red; - float green; - float blue; - int wrapOption; - int whiteSpaceCollapse; - Area area; - String pageNumber; - String refId; - String id; - - - public PageNumberCitation(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:page-number-citation"; - } - - - public Status layout(Area area) throws FOPException { - if (!(area instanceof BlockArea)) { - MessageHandler.errorln("WARNING: page-number-citation outside block area"); - return new Status(Status.OK); - } - - IDReferences idReferences = area.getIDReferences(); - this.area = area; - 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); - - ColorType c = this.properties.get("color").getColorType(); - this.red = c.red(); - this.green = c.green(); - this.blue = c.blue(); - - this.wrapOption = this.properties.get("wrap-option").getEnum(); - this.whiteSpaceCollapse = - this.properties.get("white-space-collapse").getEnum(); - - this.refId = this.properties.get("ref-id").getString(); - - if (this.refId.equals("")) { - throw new FOPException("page-number-citation must contain \"ref-id\""); - } - - // create id - this.id = this.properties.get("id").getString(); - idReferences.createID(id); - - 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 = ((BlockArea) area).addText(fs, red, green, blue, - wrapOption, null, whiteSpaceCollapse, - pageNumber.toCharArray(), 0, pageNumber.length(), - false); - } else { // add pageNumberCitation to area to be resolved during rendering - this.marker = ((BlockArea) area).addPageNumberCitation(fs, red, - green, blue, wrapOption, null, whiteSpaceCollapse, - refId); - } - - - if (this.marker == -1) { - return new Status(Status.OK); - } else { - return new Status(Status.AREA_FULL_NONE); - } - - } + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new PageNumberCitation(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new PageNumberCitation.Maker(); + } + + FontState fs; + float red; + float green; + float blue; + int wrapOption; + int whiteSpaceCollapse; + Area area; + String pageNumber; + String refId; + String id; + + + public PageNumberCitation(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:page-number-citation"; + } + + + public Status layout(Area area) throws FOPException { + if (!(area instanceof BlockArea)) { + MessageHandler.errorln("WARNING: page-number-citation outside block area"); + return new Status(Status.OK); + } + + IDReferences idReferences = area.getIDReferences(); + this.area = area; + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + ColorType c = this.properties.get("color").getColorType(); + this.red = c.red(); + this.green = c.green(); + this.blue = c.blue(); + + this.wrapOption = this.properties.get("wrap-option").getEnum(); + this.whiteSpaceCollapse = + this.properties.get("white-space-collapse").getEnum(); + + this.refId = this.properties.get("ref-id").getString(); + + if (this.refId.equals("")) { + throw new FOPException("page-number-citation must contain \"ref-id\""); + } + + // create id + this.id = this.properties.get("id").getString(); + idReferences.createID(id); + + 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 = ((BlockArea) area).addText(fs, red, green, blue, + wrapOption, null, whiteSpaceCollapse, + pageNumber.toCharArray(), 0, pageNumber.length(), + false); + } else { // add pageNumberCitation to area to be resolved during rendering + this.marker = ((BlockArea) area).addPageNumberCitation(fs, red, + green, blue, wrapOption, null, whiteSpaceCollapse, + refId); + } + + + if (this.marker == -1) { + return new Status(Status.OK); + } else { + return new Status(Status.AREA_FULL_NONE); + } + + } } diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index cfe2771df..fee17d2de 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -1,35 +1,35 @@ /*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + 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. + 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. + 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. + 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. + 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. + "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 @@ -64,330 +64,335 @@ import java.util.Vector; public class Table extends FObj { - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Table(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new Table.Maker(); - } - - FontState fs; - int breakBefore; - int breakAfter; - int spaceBefore; - int spaceAfter; - ColorType backgroundColor; - int width; - int height; - ColorType borderColor; - int borderWidth; - int borderStyle; - String id; - TableHeader tableHeader = null; - TableFooter tableFooter = null; - boolean omitHeaderAtBreak = false; - boolean omitFooterAtBreak = false; - - Vector columns = new Vector(); - int currentColumnNumber = 0; - int bodyCount = 0; - - AreaContainer areaContainer; - - public Table(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table"; - } - - public Status layout(Area area) throws FOPException { - 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.breakBefore = - this.properties.get("break-before").getEnum(); - this.breakAfter = this.properties.get("break-after").getEnum(); - this.spaceBefore = this.properties.get( - "space-before.optimum").getLength().mvalue(); - this.spaceAfter = this.properties.get( - "space-after.optimum").getLength().mvalue(); - this.backgroundColor = this.properties.get( - "background-color").getColorType(); - this.width = this.properties.get("width").getLength().mvalue(); - this.height = - this.properties.get("height").getLength().mvalue(); - - 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(); - - this.omitHeaderAtBreak = this.properties.get("table-omit-header-at-break").getEnum() == TableOmitHeaderAtBreak.TRUE; - this.omitFooterAtBreak = this.properties.get("table-omit-footer-at-break").getEnum() == TableOmitFooterAtBreak.TRUE; - - if (area instanceof BlockArea) { - area.end(); - } - - 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) { - // configure id - area.getIDReferences().configureID(id, area); - } - - this.areaContainer = - new AreaContainer(fs, 0, 0, area.getAllocationWidth(), - area.spaceLeft(), Position.STATIC); - 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()); - - // added by Eric Schaeffer - currentColumnNumber = 0; - int offset = 0; - - boolean addedHeader = false; - boolean addedFooter = false; - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - FONode fo = (FONode) children.elementAt(i); - if (fo instanceof TableColumn) { - TableColumn c = (TableColumn) fo; - int num = c.getColumnNumber(); - if (num == 0) { - num = currentColumnNumber + 1; - } - currentColumnNumber = num; - if (num > columns.size()) { - columns.setSize(num); - } - columns.setElementAt(c, num - 1); - c.setColumnOffset(offset); - fo.layout(areaContainer); - offset += c.getColumnWidth(); - } - } - areaContainer.setAllocationWidth(offset); - - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode) children.elementAt(i); - 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 && !addedHeader) { - if ((status = tableHeader.layout(areaContainer)). - isIncomplete()) { - return new Status(Status.AREA_FULL_NONE); - } - addedHeader = true; - tableHeader.resetMarker(); - } - 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++; - } - 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. - MessageHandler.errorln("WARNING: 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() - { - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - FONode fo = (FONode) children.elementAt(i); - if (fo instanceof TableColumn) { - ((TableColumn) fo).setHeight(areaContainer.getHeight()); - } - } - } - - 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 static class Maker extends FObj.Maker { + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new Table(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new Table.Maker(); + } + + FontState fs; + int breakBefore; + int breakAfter; + int spaceBefore; + int spaceAfter; + ColorType backgroundColor; + int width; + int height; + ColorType borderColor; + int borderWidth; + int borderStyle; + String id; + TableHeader tableHeader = null; + TableFooter tableFooter = null; + boolean omitHeaderAtBreak = false; + boolean omitFooterAtBreak = false; + + Vector columns = new Vector(); + int currentColumnNumber = 0; + int bodyCount = 0; + + AreaContainer areaContainer; + + public Table(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:table"; + } + + public Status layout(Area area) throws FOPException { + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + this.breakBefore = + this.properties.get("break-before").getEnum(); + this.breakAfter = this.properties.get("break-after").getEnum(); + this.spaceBefore = this.properties.get( + "space-before.optimum").getLength().mvalue(); + this.spaceAfter = this.properties.get( + "space-after.optimum").getLength().mvalue(); + this.backgroundColor = this.properties.get( + "background-color").getColorType(); + this.width = this.properties.get("width").getLength().mvalue(); + this.height = + this.properties.get("height").getLength().mvalue(); + + 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(); + + this.omitHeaderAtBreak = this.properties.get("table-omit-header-at-break").getEnum() == TableOmitHeaderAtBreak.TRUE; + this.omitFooterAtBreak = this.properties.get("table-omit-footer-at-break").getEnum() == TableOmitFooterAtBreak.TRUE; + + if (area instanceof BlockArea) { + area.end(); + } + + 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) { + // configure id + area.getIDReferences().configureID(id, area); + } + + this.areaContainer = + new AreaContainer(fs, 0, 0, area.getAllocationWidth(), + area.spaceLeft(), Position.STATIC); + 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()); + + // added by Eric Schaeffer + currentColumnNumber = 0; + int offset = 0; + + boolean addedHeader = false; + boolean addedFooter = false; + int numChildren = this.children.size(); + for (int i = 0; i < numChildren; i++) { + FONode fo = (FONode) children.elementAt(i); + if (fo instanceof TableColumn) { + TableColumn c = (TableColumn) fo; + int num = c.getColumnNumber(); + if (num == 0) { + num = currentColumnNumber + 1; + } + currentColumnNumber = num; + if (num > columns.size()) { + columns.setSize(num); + } + columns.setElementAt(c, num - 1); + c.setColumnOffset(offset); + fo.layout(areaContainer); + offset += c.getColumnWidth(); + } + } + areaContainer.setAllocationWidth(offset); + + for (int i = this.marker; i < numChildren; i++) { + FONode fo = (FONode) children.elementAt(i); + 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 && !addedHeader) { + if ((status = tableHeader.layout(areaContainer)). + isIncomplete()) { + return new Status(Status.AREA_FULL_NONE); + } + addedHeader = true; + tableHeader.resetMarker(); + } + 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++; + } + 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. + MessageHandler.errorln("WARNING: 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() + { + int numChildren = this.children.size(); + for (int i = 0; i < numChildren; i++) { + FONode fo = (FONode) children.elementAt(i); + if (fo instanceof TableColumn) { + ((TableColumn) fo).setHeight(areaContainer.getHeight()); + } + } + } + + 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 + } } diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index c03ce5695..fdd3afe89 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -1,35 +1,35 @@ /*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + 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. + 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. + 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. + 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. + 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. + "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 @@ -64,232 +64,237 @@ import java.util.Enumeration; public class TableBody extends FObj { - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableBody(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new TableBody.Maker(); - } - - FontState fs; - int spaceBefore; - int spaceAfter; - ColorType backgroundColor; - ColorType borderColor; - int borderWidth; - int borderStyle; - String id; - - Vector columns; - - AreaContainer areaContainer; - - public TableBody(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table-body"; - } - - public void setColumns(Vector columns) { - 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) { - 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.spaceBefore = this.properties.get( - "space-before.optimum").getLength().mvalue(); - this.spaceAfter = 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(); - - area.getIDReferences().createID(id); - - if (area instanceof BlockArea) { - area.end(); - } - - //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); - } - - this.areaContainer = 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; - boolean endKeepGroup = true; - for (int i = this.marker; i < numChildren; i++) { - TableRow row = (TableRow) children.elementAt(i); - - row.setColumns(columns); - row.doSetup(areaContainer); - if (row.getKeepWithPrevious().getType() != KeepValue.KEEP_WITH_AUTO && lastRow != null && - keepWith.indexOf(lastRow) == -1) { - keepWith.addElement(lastRow); - } else { - if(endKeepGroup && keepWith.size() > 0) { - keepWith = new Vector(); - } - } - - Status status; - if ((status = row.layout(areaContainer)).isIncomplete()) { - if (keepWith.size() > 0) { // && status.getCode() == Status.AREA_FULL_NONE - row.removeLayout(areaContainer); - for (Enumeration e = keepWith.elements(); - e.hasMoreElements();) { - TableRow tr = (TableRow) e.nextElement(); - 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 < 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 = i; - count > numChildren - orphans - 1; 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(); - - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight( - areaContainer.getAbsoluteHeight()); - } - return status; - } else if (status.getCode() == Status.KEEP_WITH_NEXT) { - keepWith.addElement(row); - endKeepGroup = false; - } else { - endKeepGroup = true; - } - lastRow = row; - } - area.addChild(areaContainer); - areaContainer.end(); - - area.increaseHeight(areaContainer.getHeight()); - - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.increaseHeight(spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - - return new Status(Status.OK); - } - - public void removeLayout(Area area) { - area.removeChild(areaContainer); - if (spaceBefore != 0) { - area.increaseHeight(-spaceBefore); - } - if (spaceAfter != 0) { - area.increaseHeight(-spaceAfter); - } - this.resetMarker(); - } + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new TableBody(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new TableBody.Maker(); + } + + FontState fs; + int spaceBefore; + int spaceAfter; + ColorType backgroundColor; + ColorType borderColor; + int borderWidth; + int borderStyle; + String id; + + Vector columns; + + AreaContainer areaContainer; + + public TableBody(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:table-body"; + } + + public void setColumns(Vector columns) { + 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) { + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + this.spaceBefore = this.properties.get( + "space-before.optimum").getLength().mvalue(); + this.spaceAfter = 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(); + + area.getIDReferences().createID(id); + + if (area instanceof BlockArea) { + area.end(); + } + + //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); + } + + this.areaContainer = 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; + boolean endKeepGroup = true; + for (int i = this.marker; i < numChildren; i++) { + TableRow row = (TableRow) children.elementAt(i); + + row.setColumns(columns); + row.doSetup(areaContainer); + if (row.getKeepWithPrevious().getType() != KeepValue.KEEP_WITH_AUTO && lastRow != null && + keepWith.indexOf(lastRow) == -1) { + keepWith.addElement(lastRow); + } else { + if(endKeepGroup && keepWith.size() > 0) { + keepWith = new Vector(); + } + } + + Status status; + if ((status = row.layout(areaContainer)).isIncomplete()) { + if (keepWith.size() > 0) { // && status.getCode() == Status.AREA_FULL_NONE + row.removeLayout(areaContainer); + for (Enumeration e = keepWith.elements(); + e.hasMoreElements();) { + TableRow tr = (TableRow) e.nextElement(); + 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 < 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 = i; + count > numChildren - orphans - 1; 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(); + + area.increaseHeight(areaContainer.getHeight()); + area.setAbsoluteHeight( + areaContainer.getAbsoluteHeight()); + } + return status; + } else if (status.getCode() == Status.KEEP_WITH_NEXT) { + keepWith.addElement(row); + endKeepGroup = false; + } else { + endKeepGroup = true; + } + lastRow = row; + } + area.addChild(areaContainer); + areaContainer.end(); + + area.increaseHeight(areaContainer.getHeight()); + + area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); + + if (spaceAfter != 0) { + area.increaseHeight(spaceAfter); + } + + if (area instanceof BlockArea) { + area.start(); + } + + return new Status(Status.OK); + } + + public void removeLayout(Area area) { + area.removeChild(areaContainer); + if (spaceBefore != 0) { + area.increaseHeight(-spaceBefore); + } + if (spaceAfter != 0) { + area.increaseHeight(-spaceAfter); + } + this.resetMarker(); + } } diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index ecdd81359..b98e31bb5 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + + 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. - + 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. - + 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. - + 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. - + 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. - + "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; @@ -59,264 +59,269 @@ import org.apache.fop.datatypes.*; public class TableCell extends FObj { - public static class Maker extends FObj.Maker { + public static class Maker extends FObj.Maker { public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new TableCell(parent, propertyList); + throws FOPException { + return new TableCell(parent, propertyList); } - } + } - public static FObj.Maker maker() { + public static FObj.Maker maker() { return new TableCell.Maker(); - } - - int spaceBefore; - int spaceAfter; - ColorType backgroundColor; - - FontState fs; - ColorType borderTopColor; - int borderTopWidth; - int borderTopStyle; - ColorType borderBottomColor; - int borderBottomWidth; - int borderBottomStyle; - ColorType borderLeftColor; - int borderLeftWidth; - int borderLeftStyle; - ColorType borderRightColor; - int borderRightWidth; - int borderRightStyle; - int paddingTop; - int paddingBottom; - int paddingLeft; - int paddingRight; - int position; - String id; - int numColumnsSpanned; - int numRowsSpanned; - - protected int startOffset; - protected int width; - - protected int height = 0; - protected int top; - protected int verticalAlign = VerticalAlign.BASELINE; - - boolean setup = false; - - AreaContainer areaContainer; - - public TableCell(FObj parent, PropertyList propertyList) { + } + + int spaceBefore; + int spaceAfter; + ColorType backgroundColor; + + FontState fs; + ColorType borderTopColor; + int borderTopWidth; + int borderTopStyle; + ColorType borderBottomColor; + int borderBottomWidth; + int borderBottomStyle; + ColorType borderLeftColor; + int borderLeftWidth; + int borderLeftStyle; + ColorType borderRightColor; + int borderRightWidth; + int borderRightStyle; + int paddingTop; + int paddingBottom; + int paddingLeft; + int paddingRight; + int position; + String id; + int numColumnsSpanned; + int numRowsSpanned; + + protected int startOffset; + protected int width; + + protected int height = 0; + protected int top; + protected int verticalAlign = VerticalAlign.BASELINE; + + boolean setup = false; + + AreaContainer areaContainer; + + public TableCell(FObj parent, PropertyList propertyList) { super(parent, propertyList); this.name = "fo:table-cell"; - } + } - public void setStartOffset(int offset) { + public void setStartOffset(int offset) { startOffset = offset; - } + } - public void setWidth(int width) { + public void setWidth(int width) { this.width = width; - } + } - public int getNumColumnsSpanned() - { - return numColumnsSpanned; - } + public int getNumColumnsSpanned() + { + return numColumnsSpanned; + } - public int getNumRowsSpanned() - { - return numRowsSpanned; - } + public int getNumRowsSpanned() + { + return numRowsSpanned; + } - public void doSetup(Area area) throws FOPException - { - this.numColumnsSpanned = + public void doSetup(Area area) throws FOPException + { + this.numColumnsSpanned = this.properties.get("number-columns-spanned").getNumber().intValue(); - this.numRowsSpanned = + this.numRowsSpanned = this.properties.get("number-rows-spanned").getNumber().intValue(); - 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.borderTopColor = + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + 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.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-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.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-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.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.paddingTop = + 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.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.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.backgroundColor = + 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.spaceBefore = + this.properties.get("space-before.optimum").getLength().mvalue(); + this.spaceAfter = + this.properties.get("space-after.optimum").getLength().mvalue(); + this.backgroundColor = this.properties.get("background-color").getColorType(); - this.id = - this.properties.get("id").getString(); - } + this.id = + this.properties.get("id").getString(); + } - public Status layout(Area area) throws FOPException { + public Status layout(Area area) throws FOPException { int originalAbsoluteHeight = area.getAbsoluteHeight(); - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + if (this.marker == BREAK_AFTER) { + return new Status(Status.OK); } if (this.marker == START) { - if(!setup) - doSetup(area); + if(!setup) + doSetup(area); - if (area instanceof BlockArea) { + if (area instanceof BlockArea) { area.end(); - } + } - //if (this.isInListBody) { - //startIndent += bodyIndent + distanceBetweenStarts; - //} + //if (this.isInListBody) { + //startIndent += bodyIndent + distanceBetweenStarts; + //} - area.getIDReferences().createID(id); + area.getIDReferences().createID(id); - this.marker = 0; + this.marker = 0; } if ((spaceBefore != 0) && (this.marker ==0)) { - area.increaseHeight(spaceBefore); + area.increaseHeight(spaceBefore); } - if ( marker==0 ) { - // configure id - area.getIDReferences().configureID(id,area); - } + if ( marker==0 ) { + // configure id + area.getIDReferences().configureID(id,area); + } this.areaContainer = - new AreaContainer(fs, startOffset - area.borderWidthLeft, - - area.borderWidthTop + ((this.marker ==0) ? spaceBefore : 0), - width, area.spaceLeft(), Position.RELATIVE); + new AreaContainer(fs, startOffset - area.borderWidthLeft, + - area.borderWidthTop + ((this.marker ==0) ? spaceBefore : 0), + width, area.spaceLeft(), Position.RELATIVE); areaContainer.setPage(area.getPage()); areaContainer.setPadding(paddingTop, paddingLeft, paddingBottom, - paddingRight); + paddingRight); areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderStyle(borderTopStyle, borderLeftStyle, - borderBottomStyle, borderRightStyle); - areaContainer.setBorderWidth(borderTopWidth, borderLeftWidth, - borderBottomWidth, borderRightWidth); - areaContainer.setBorderColor(borderTopColor, borderLeftColor, - borderBottomColor, borderRightColor); + areaContainer.setBorderStyle(borderTopStyle, borderLeftStyle, + borderBottomStyle, borderRightStyle); + areaContainer.setBorderWidth(borderTopWidth, borderLeftWidth, + borderBottomWidth, borderRightWidth); + areaContainer.setBorderColor(borderTopColor, borderLeftColor, + borderBottomColor, borderRightColor); areaContainer.start(); - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - areaContainer.setTableCellXOffset(startOffset); + areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); + areaContainer.setIDReferences(area.getIDReferences()); + areaContainer.setTableCellXOffset(startOffset); int numChildren = this.children.size(); for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj) children.elementAt(i); - fo.setIsInTableCell(); - fo.forceWidth(width); - verticalAlign = fo.properties.get("vertical-align").getEnum(); - Status status; - if ((status = fo.layout(areaContainer)).isIncomplete()) { + FObj fo = (FObj) children.elementAt(i); + fo.setIsInTableCell(); + fo.forceWidth(width); + verticalAlign = fo.properties.get("vertical-align").getEnum(); + Status status; + if ((status = fo.layout(areaContainer)).isIncomplete()) { this.marker = i; if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - return new Status(Status.AREA_FULL_NONE); + return new Status(Status.AREA_FULL_NONE); } else { // hani Elabed 11/21/2000 area.addChild(areaContainer); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); + area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - return new Status(Status.AREA_FULL_SOME); + return new Status(Status.AREA_FULL_SOME); } - } + } } areaContainer.end(); area.addChild(areaContainer); - height = areaContainer.getHeight(); - top = areaContainer.getCurrentYPosition(); - // reset absoluteHeight to beginning of row - area.setHeight(areaContainer.getHeight() + spaceBefore + spaceAfter); - area.setAbsoluteHeight(originalAbsoluteHeight); + height = areaContainer.getHeight(); + top = areaContainer.getCurrentYPosition(); + // reset absoluteHeight to beginning of row + area.setHeight(areaContainer.getHeight() + spaceBefore + spaceAfter); + area.setAbsoluteHeight(originalAbsoluteHeight); return new Status(Status.OK); - } + } - public int getHeight() { + public int getHeight() { return areaContainer.getHeight() + spaceBefore + spaceAfter; - } - - public void setRowHeight(int h) { - areaContainer.setMaxHeight(h); - switch(verticalAlign) { - case VerticalAlign.MIDDLE: - areaContainer.setHeight(height); - areaContainer.setYPosition(spaceBefore + top + h / 2 - height / 2); - break; - case VerticalAlign.BASELINE: - default: - areaContainer.setHeight(h - (spaceBefore + spaceAfter)); - break; - } - } + } + + public void setRowHeight(int h) { + areaContainer.setMaxHeight(h); + switch(verticalAlign) { + case VerticalAlign.MIDDLE: + areaContainer.setHeight(height); + areaContainer.setYPosition(spaceBefore + top + h / 2 - height / 2); + break; + case VerticalAlign.BASELINE: + default: + areaContainer.setHeight(h - (spaceBefore + spaceAfter)); + break; + } + } } diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java index 9d668b8a3..a543e3f32 100644 --- a/src/org/apache/fop/fo/flow/TableColumn.java +++ b/src/org/apache/fop/fo/flow/TableColumn.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - + + 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. - + 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. - + 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. - + 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. - + 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. - + "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; @@ -59,168 +59,173 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.*; public class TableColumn extends FObj { - - FontState fs; - ColorType backgroundColor; - ColorType borderTopColor; - int borderTopWidth; - int borderTopStyle; - ColorType borderBottomColor; - int borderBottomWidth; - int borderBottomStyle; - ColorType borderLeftColor; - int borderLeftWidth; - int borderLeftStyle; - ColorType borderRightColor; - int borderRightWidth; - int borderRightStyle; - int paddingTop; - int paddingBottom; - int paddingLeft; - int paddingRight; - - int columnWidth; - int columnOffset; - - AreaContainer areaContainer; - - public static class Maker extends FObj.Maker { + + FontState fs; + ColorType backgroundColor; + ColorType borderTopColor; + int borderTopWidth; + int borderTopStyle; + ColorType borderBottomColor; + int borderBottomWidth; + int borderBottomStyle; + ColorType borderLeftColor; + int borderLeftWidth; + int borderLeftStyle; + ColorType borderRightColor; + int borderRightWidth; + int borderRightStyle; + int paddingTop; + int paddingBottom; + int paddingLeft; + int paddingRight; + + int columnWidth; + int columnOffset; + + AreaContainer areaContainer; + + public static class Maker extends FObj.Maker { public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new TableColumn(parent, propertyList); + throws FOPException { + return new TableColumn(parent, propertyList); } - } + } - public static FObj.Maker maker() { + public static FObj.Maker maker() { return new TableColumn.Maker(); - } + } - public TableColumn(FObj parent, PropertyList propertyList) { + public TableColumn(FObj parent, PropertyList propertyList) { super(parent, propertyList); this.name = "fo:table-column"; - } + } - public int getColumnWidth() { - return columnWidth; - } + public int getColumnWidth() { + return columnWidth; + } - public int getColumnNumber() { + public int getColumnNumber() { return 0; // not implemented yet - } - - public Status layout(Area area) throws FOPException { + } + + public Status layout(Area area) throws FOPException { if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); + 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.backgroundColor = + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + this.backgroundColor = this.properties.get("background-color").getColorType(); - this.borderTopColor = + 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.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-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.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-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.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.paddingTop = + 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.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.columnWidth = - this.properties.get("column-width").getLength().mvalue(); - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id,area); - } + 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.columnWidth = + this.properties.get("column-width").getLength().mvalue(); + + // initialize id + String id = this.properties.get("id").getString(); + area.getIDReferences().initializeID(id,area); + } this.areaContainer = - new AreaContainer(fs, columnOffset - area.borderWidthLeft, -area.borderWidthTop, columnWidth, - area.getHeight(), Position.RELATIVE); + new AreaContainer(fs, columnOffset - area.borderWidthLeft, -area.borderWidthTop, columnWidth, + area.getHeight(), Position.RELATIVE); areaContainer.setPage(area.getPage()); - areaContainer.setPadding(paddingTop, paddingLeft, paddingBottom, - paddingRight); + areaContainer.setPadding(paddingTop, paddingLeft, paddingBottom, + paddingRight); areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderStyle(borderTopStyle, borderLeftStyle, - borderBottomStyle, borderRightStyle); - areaContainer.setBorderWidth(borderTopWidth, borderLeftWidth, - borderBottomWidth, borderRightWidth); - areaContainer.setBorderColor(borderTopColor, borderLeftColor, - borderBottomColor, borderRightColor); - areaContainer.setHeight(area.getHeight()); + areaContainer.setBorderStyle(borderTopStyle, borderLeftStyle, + borderBottomStyle, borderRightStyle); + areaContainer.setBorderWidth(borderTopWidth, borderLeftWidth, + borderBottomWidth, borderRightWidth); + areaContainer.setBorderColor(borderTopColor, borderLeftColor, + borderBottomColor, borderRightColor); + 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) { + } + + public void setColumnOffset(int columnOffset) { + this.columnOffset = columnOffset; + } + + public void setHeight(int height) { areaContainer.setMaxHeight(height); areaContainer.setHeight(height); - } - + } + } diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index 604a13bb7..048db3e3a 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -1,35 +1,35 @@ /*-- $Id$ -- ============================================================================ - The Apache Software License, Version 1.1 + The Apache Software License, Version 1.1 ============================================================================ - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + 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. + 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. + 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. + 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. + 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. + "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 @@ -64,560 +64,565 @@ import java.util.Vector; public class TableRow extends FObj { - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableRow(parent, propertyList); - } - } - - public static FObj.Maker maker() { - return new TableRow.Maker(); - } - - boolean setup = false; - - FontState fs; - int spaceBefore; - int spaceAfter; - ColorType backgroundColor; - String id; - - ColorType borderTopColor; - int borderTopWidth; - int borderTopStyle; - ColorType borderBottomColor; - int borderBottomWidth; - int borderBottomStyle; - ColorType borderLeftColor; - int borderLeftWidth; - int borderLeftStyle; - ColorType borderRightColor; - int borderRightWidth; - int borderRightStyle; - int paddingTop; - int paddingBottom; - int paddingLeft; - int paddingRight; - KeepValue keepWithNext; - KeepValue keepWithPrevious; - - int widthOfCellsSoFar = 0; - int largestCellHeight = 0; - - Vector columns; - - AreaContainer areaContainer; - - // added by Dresdner Bank, Germany - DisplaySpace spacer = null; - boolean hasAddedSpacer = false; - DisplaySpace spacerAfter = null; - boolean areaAdded = false; - - /** - * The list of cell states for this row. This is the location of - * where I will be storing the state of each cell so that I can - * spread a cell over multiple pages if I have to. This is part - * of fixing the TableRow larger than a single page bug. - * Hani Elabed, 11/22/2000. - */ - public Vector cells = null; - - /** - * CellState
- * - * Copyright @ 2000 Circuit Court Automation Program. - * state of Wisconsin. - * All Rights Reserved. - *

- * This class is a container class for encapsulating a the - * state of a cell - * - * - * - * - * - * - * - *
Name: CellState
Purpose: a helpful container class
Description: This class is a container class for - * encapsulating the state of a - * cell belonging to a TableRow class - *
- * - * @author Hani Elabed - * @version 0.14.0, 11/22/2000 - * @since JDK1.1 - */ - public final class CellState { - /** the cell location or index starting at 0.*/ - private int location; - - /** true if the layout of the cell was complete, false otherwise.*/ - private boolean layoutCompleted; - - /** the width of the cell so far.*/ - private int widthOfCellSoFar; - - private int column = 0; - - /** - * simple no args constructor. - */ - public CellState() { - this(0, false, 0); - } - - /** - * three argument fill everything constructor. - * @param int the location(index) of the cell. - * @param boolean flag of wether the cell was completely laid out or not. - * @param int the horizontal offset(width so far) of the cell. - */ - public CellState(int aLocation, boolean completed, int aWidth) { - - location = aLocation; - layoutCompleted = completed; - widthOfCellSoFar = aWidth; - } - - /** - * returns the index of the cell starting at 0. - * @return int the location of the cell. - */ - public final int getLocation() { - return location; - } - - /** - * sets the location of the cell. - * @param int, the location of the cell. - */ - public final void setLocation(int aLocation) { - location = aLocation; - } - - - /** - * returns true if the cell was completely laid out. - * @return false if cell was partially laid out. - */ - public final boolean isLayoutComplete() { - return layoutCompleted; - } - - /** - * sets the layoutCompleted flag. - * @param boolean, the layout Complete state of the cell. - */ - public final void setLayoutComplete(boolean completed) { - layoutCompleted = completed; - } - - - /** - * returns the horizontal offset of the cell. - * @return int the horizontal offset of the cell, also known as width - * of the cell so far. - */ - public final int getWidthOfCellSoFar() { - return widthOfCellSoFar; - } - - /** - * sets the width of the Cell So Far, i.e the cell's offset. - * @param int, the horizontal offset of the cell. - */ - public final void setWidthOfCellSoFar(int aWidth) { - widthOfCellSoFar = aWidth; - } - - public int getColumn() { - return column; - } - - public void setColumn(int col) { - column = col; - } - } - - - public TableRow(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table-row"; - } - - public void setColumns(Vector columns) { - this.columns = columns; - } - - public KeepValue getKeepWithPrevious() { - return keepWithPrevious; - } - - public void doSetup(Area area) throws FOPException { - 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.spaceBefore = this.properties.get( - "space-before.optimum").getLength().mvalue(); - this.spaceAfter = this.properties.get( - "space-after.optimum").getLength().mvalue(); - this.backgroundColor = - this.properties.get("background-color").getColorType(); - 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.keepWithNext = getKeepValue("keep-with-next.within-column"); - this.keepWithPrevious = getKeepValue("keep-with-previous.within-column"); - 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.id = this.properties.get("id").getString(); - setup = true; - } - - private KeepValue getKeepValue(String sPropName) { - Property p= this.properties.get(sPropName); - Number n = p.getNumber(); - if (n != null) - return new KeepValue(KeepValue.KEEP_WITH_VALUE, n.intValue()); - switch(p.getEnum()) { - case 2: - return new KeepValue(KeepValue.KEEP_WITH_ALWAYS, 0); - //break; - case 1: - default: - return new KeepValue(KeepValue.KEEP_WITH_AUTO, 0); - //break; - } - } - - public Status layout(Area area) throws FOPException { - boolean configID = false; - - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - if (!setup) - doSetup(area); - - if (area instanceof BlockArea) { - area.end(); - } - if (cells == null) { // check to make sure this row hasn't been partially - // laid out yet (with an id created already) + public static class Maker extends FObj.Maker { + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new TableRow(parent, propertyList); + } + } + + public static FObj.Maker maker() { + return new TableRow.Maker(); + } + + boolean setup = false; + + FontState fs; + int spaceBefore; + int spaceAfter; + ColorType backgroundColor; + String id; + + ColorType borderTopColor; + int borderTopWidth; + int borderTopStyle; + ColorType borderBottomColor; + int borderBottomWidth; + int borderBottomStyle; + ColorType borderLeftColor; + int borderLeftWidth; + int borderLeftStyle; + ColorType borderRightColor; + int borderRightWidth; + int borderRightStyle; + int paddingTop; + int paddingBottom; + int paddingLeft; + int paddingRight; + KeepValue keepWithNext; + KeepValue keepWithPrevious; + + int widthOfCellsSoFar = 0; + int largestCellHeight = 0; + + Vector columns; + + AreaContainer areaContainer; + + // added by Dresdner Bank, Germany + DisplaySpace spacer = null; + boolean hasAddedSpacer = false; + DisplaySpace spacerAfter = null; + boolean areaAdded = false; + + /** + * The list of cell states for this row. This is the location of + * where I will be storing the state of each cell so that I can + * spread a cell over multiple pages if I have to. This is part + * of fixing the TableRow larger than a single page bug. + * Hani Elabed, 11/22/2000. + */ + public Vector cells = null; + + /** + * CellState
+ * + * Copyright @ 2000 Circuit Court Automation Program. + * state of Wisconsin. + * All Rights Reserved. + *

+ * This class is a container class for encapsulating a the + * state of a cell + * + * + * + * + * + * + * + *
Name: CellState
Purpose: a helpful container class
Description: This class is a container class for + * encapsulating the state of a + * cell belonging to a TableRow class + *
+ * + * @author Hani Elabed + * @version 0.14.0, 11/22/2000 + * @since JDK1.1 + */ + public final class CellState { + /** the cell location or index starting at 0.*/ + private int location; + + /** true if the layout of the cell was complete, false otherwise.*/ + private boolean layoutCompleted; + + /** the width of the cell so far.*/ + private int widthOfCellSoFar; + + private int column = 0; + + /** + * simple no args constructor. + */ + public CellState() { + this(0, false, 0); + } + + /** + * three argument fill everything constructor. + * @param int the location(index) of the cell. + * @param boolean flag of wether the cell was completely laid out or not. + * @param int the horizontal offset(width so far) of the cell. + */ + public CellState(int aLocation, boolean completed, int aWidth) { + + location = aLocation; + layoutCompleted = completed; + widthOfCellSoFar = aWidth; + } + + /** + * returns the index of the cell starting at 0. + * @return int the location of the cell. + */ + public final int getLocation() { + return location; + } + + /** + * sets the location of the cell. + * @param int, the location of the cell. + */ + public final void setLocation(int aLocation) { + location = aLocation; + } + + + /** + * returns true if the cell was completely laid out. + * @return false if cell was partially laid out. + */ + public final boolean isLayoutComplete() { + return layoutCompleted; + } + + /** + * sets the layoutCompleted flag. + * @param boolean, the layout Complete state of the cell. + */ + public final void setLayoutComplete(boolean completed) { + layoutCompleted = completed; + } + + + /** + * returns the horizontal offset of the cell. + * @return int the horizontal offset of the cell, also known as width + * of the cell so far. + */ + public final int getWidthOfCellSoFar() { + return widthOfCellSoFar; + } + + /** + * sets the width of the Cell So Far, i.e the cell's offset. + * @param int, the horizontal offset of the cell. + */ + public final void setWidthOfCellSoFar(int aWidth) { + widthOfCellSoFar = aWidth; + } + + public int getColumn() { + return column; + } + + public void setColumn(int col) { + column = col; + } + } + + + public TableRow(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "fo:table-row"; + } + + public void setColumns(Vector columns) { + this.columns = columns; + } + + public KeepValue getKeepWithPrevious() { + return keepWithPrevious; + } + + public void doSetup(Area area) throws FOPException { + 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(); + // font-variant support + // added by Eric SCHAEFFER + int fontVariant = + this.properties.get("font-variant").getEnum(); + + this.fs = new FontState(area.getFontInfo(), fontFamily, + fontStyle, fontWeight, fontSize, fontVariant); + + this.spaceBefore = this.properties.get( + "space-before.optimum").getLength().mvalue(); + this.spaceAfter = this.properties.get( + "space-after.optimum").getLength().mvalue(); + this.backgroundColor = + this.properties.get("background-color").getColorType(); + 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.keepWithNext = getKeepValue("keep-with-next.within-column"); + this.keepWithPrevious = getKeepValue("keep-with-previous.within-column"); + 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.id = this.properties.get("id").getString(); + setup = true; + } + + private KeepValue getKeepValue(String sPropName) { + Property p= this.properties.get(sPropName); + Number n = p.getNumber(); + if (n != null) + return new KeepValue(KeepValue.KEEP_WITH_VALUE, n.intValue()); + switch(p.getEnum()) { + case 2: + return new KeepValue(KeepValue.KEEP_WITH_ALWAYS, 0); + //break; + case 1: + default: + return new KeepValue(KeepValue.KEEP_WITH_AUTO, 0); + //break; + } + } + + public Status layout(Area area) throws FOPException { + boolean configID = false; + + if (this.marker == BREAK_AFTER) { + return new Status(Status.OK); + } + + if (this.marker == START) { + if (!setup) + doSetup(area); + + if (area instanceof BlockArea) { + area.end(); + } + if (cells == null) { // 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; - } - - if ((spaceBefore != 0) && (this.marker == 0)) { - spacer = new DisplaySpace(spaceBefore); - area.increaseHeight(spaceBefore); - } - - if (marker == 0 && configID) { - // configure id - area.getIDReferences().configureID(id, area); - } - - this.areaContainer = new AreaContainer(fs, -area.borderWidthLeft, - -area.borderWidthTop, area.getAllocationWidth(), - area.spaceLeft(), Position.RELATIVE); - areaContainer.setPage(area.getPage()); - areaContainer.setPadding(paddingTop, paddingLeft, - paddingBottom, paddingRight); - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderStyle(borderTopStyle, borderLeftStyle, - borderBottomStyle, borderRightStyle); - areaContainer.setBorderWidth(borderTopWidth, borderLeftWidth, - borderBottomWidth, borderRightWidth); - areaContainer.setBorderColor(borderTopColor, borderLeftColor, - borderBottomColor, borderRightColor); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - // cells is The list of cell states for this row. This is the location of - // where I will be storing the state of each cell so that I can - // spread a cell over multiple pages if I have to. This is part - // of fixing the TableRow larger than a single page bug. - // Hani Elabed, 11/22/2000. - if (cells == null)// do it once.. - { - widthOfCellsSoFar = 0; - cells = new Vector(); - int colCount = 0; - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - TableCell cell = (TableCell) children.elementAt(i); - cell.doSetup(areaContainer); - int numCols = cell.getNumColumnsSpanned(); - int numRows = cell.getNumRowsSpanned(); - int width = 0; - CellState state = - new CellState(i, false, widthOfCellsSoFar); - state.setColumn(colCount); - // add the state of a cell. - cells.insertElementAt(state, i); - for (int count = 0; - count < numCols && count < columns.size(); - count++) { - width += ((TableColumn) columns.elementAt(colCount)). - getColumnWidth(); - colCount++; - } - - cell.setWidth(width); - widthOfCellsSoFar += width; - - } - } - - 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); - // } - - // added by Eric Schaeffer - largestCellHeight = 0; - - // added by Hani Elabed 11/27/2000 - boolean someCellDidNotLayoutCompletely = false; - - 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 (this.isInListBody) { - //fo.setIsInListBody(); - //fo.setDistanceBetweenStarts(this.distanceBetweenStarts); - //fo.setBodyIndent(this.bodyIndent); - //} - - - //--- this is modified to preserve the state of start - //--- offset of the cell. - //--- change by Hani Elabed 11/22/2000 - cell.setStartOffset(cellState.getWidthOfCellSoFar()); - - Status status; - if ((status = cell.layout(areaContainer)).isIncomplete()) { - this.marker = i; - /* if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) - { - status = new Status(Status.AREA_FULL_SOME); - }*/ - - - if (status.getCode() == Status.AREA_FULL_SOME) { - // this whole block added by - // Hani Elabed 11/27/2000 - - cellState.setLayoutComplete(false); - - // locate the first cell - // that need to be laid out further - - for (int j = 0; j < numChildren; j++) { - CellState state = (CellState) cells.elementAt(j); - - if (! state.isLayoutComplete()) { - this.marker = j; - break; // out of for loop - } - } - } else { - // added on 11/28/2000, by Dresdner Bank, Germany - if (spacer != null) { - area.removeChild(spacer); - spacer = null; - } - hasAddedSpacer = false; - if(spacerAfter != null) - area.removeChild(spacerAfter); - spacerAfter = null; - - // 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()); - - // hani elabed 11/27/2000 - cellState.setLayoutComplete(false); - - return status; - } - } else // layout was complete for a particular cell - { // Hani Elabed - cellState.setLayoutComplete(true); - } - - int h = cell.getHeight(); - if (h > largestCellHeight) { - largestCellHeight = h; - } - } - - for (int i = 0; i < numChildren; i++) { - TableCell cell = (TableCell) children.elementAt(i); - cell.setRowHeight(largestCellHeight); - } - - // added by Dresdner Bank, Germany - if (!hasAddedSpacer && spacer != null) { - area.addChild(spacer); - hasAddedSpacer = true; - } - - area.addChild(areaContainer); - areaContainer.setHeight(largestCellHeight); - areaAdded = true; - areaContainer.end(); - area.addDisplaySpace(largestCellHeight + - areaContainer.getPaddingTop() + - areaContainer.borderWidthTop + - areaContainer.getPaddingBottom() + - areaContainer.borderWidthBottom); - - // bug fix from Eric Schaeffer - //area.increaseHeight(largestCellHeight); - - // test to see if some cells are not - // completely laid out. - // Hani Elabed 11/22/2000 - for (int i = 0; i < numChildren; i++) { - CellState cellState = (CellState) cells.elementAt(i); - - if (! cellState.isLayoutComplete()) { - someCellDidNotLayoutCompletely = true; - break; // out of for loop - } - } - - if (!someCellDidNotLayoutCompletely && spaceAfter != 0) { - spacerAfter = new DisplaySpace(spaceAfter); - area.addChild(spacerAfter); - area.increaseHeight(spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - - // replaced by Hani Elabed 11/27/2000 - //return new Status(Status.OK); - - if (someCellDidNotLayoutCompletely) { - return new Status(Status.AREA_FULL_SOME); - } else { - 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 (spacer != null) { - if(hasAddedSpacer) { - area.removeChild(spacer); - } else { - area.increaseHeight(-spaceBefore); - } - } - if(spacerAfter != null) - area.removeChild(spacerAfter); - //area.increaseHeight(areaContainer.getHeight()); - if(areaAdded) - area.removeChild(areaContainer); - areaAdded = false; - this.resetMarker(); - cells = null; - this.removeID(area.getIDReferences()); - } - - public void resetMarker() - { - super.resetMarker(); - spacer = null; - spacerAfter = null; - hasAddedSpacer = false; - } + } + + + this.marker = 0; + } + + if ((spaceBefore != 0) && (this.marker == 0)) { + spacer = new DisplaySpace(spaceBefore); + area.increaseHeight(spaceBefore); + } + + if (marker == 0 && configID) { + // configure id + area.getIDReferences().configureID(id, area); + } + + this.areaContainer = new AreaContainer(fs, -area.borderWidthLeft, + -area.borderWidthTop, area.getAllocationWidth(), + area.spaceLeft(), Position.RELATIVE); + areaContainer.setPage(area.getPage()); + areaContainer.setPadding(paddingTop, paddingLeft, + paddingBottom, paddingRight); + areaContainer.setBackgroundColor(backgroundColor); + areaContainer.setBorderStyle(borderTopStyle, borderLeftStyle, + borderBottomStyle, borderRightStyle); + areaContainer.setBorderWidth(borderTopWidth, borderLeftWidth, + borderBottomWidth, borderRightWidth); + areaContainer.setBorderColor(borderTopColor, borderLeftColor, + borderBottomColor, borderRightColor); + areaContainer.start(); + + areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); + areaContainer.setIDReferences(area.getIDReferences()); + + // cells is The list of cell states for this row. This is the location of + // where I will be storing the state of each cell so that I can + // spread a cell over multiple pages if I have to. This is part + // of fixing the TableRow larger than a single page bug. + // Hani Elabed, 11/22/2000. + if (cells == null)// do it once.. + { + widthOfCellsSoFar = 0; + cells = new Vector(); + int colCount = 0; + int numChildren = this.children.size(); + for (int i = 0; i < numChildren; i++) { + TableCell cell = (TableCell) children.elementAt(i); + cell.doSetup(areaContainer); + int numCols = cell.getNumColumnsSpanned(); + int numRows = cell.getNumRowsSpanned(); + int width = 0; + CellState state = + new CellState(i, false, widthOfCellsSoFar); + state.setColumn(colCount); + // add the state of a cell. + cells.insertElementAt(state, i); + for (int count = 0; + count < numCols && count < columns.size(); + count++) { + width += ((TableColumn) columns.elementAt(colCount)). + getColumnWidth(); + colCount++; + } + + cell.setWidth(width); + widthOfCellsSoFar += width; + + } + } + + 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); + // } + + // added by Eric Schaeffer + largestCellHeight = 0; + + // added by Hani Elabed 11/27/2000 + boolean someCellDidNotLayoutCompletely = false; + + 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 (this.isInListBody) { + //fo.setIsInListBody(); + //fo.setDistanceBetweenStarts(this.distanceBetweenStarts); + //fo.setBodyIndent(this.bodyIndent); + //} + + + //--- this is modified to preserve the state of start + //--- offset of the cell. + //--- change by Hani Elabed 11/22/2000 + cell.setStartOffset(cellState.getWidthOfCellSoFar()); + + Status status; + if ((status = cell.layout(areaContainer)).isIncomplete()) { + this.marker = i; + /* if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) + { + status = new Status(Status.AREA_FULL_SOME); + }*/ + + + if (status.getCode() == Status.AREA_FULL_SOME) { + // this whole block added by + // Hani Elabed 11/27/2000 + + cellState.setLayoutComplete(false); + + // locate the first cell + // that need to be laid out further + + for (int j = 0; j < numChildren; j++) { + CellState state = (CellState) cells.elementAt(j); + + if (! state.isLayoutComplete()) { + this.marker = j; + break; // out of for loop + } + } + } else { + // added on 11/28/2000, by Dresdner Bank, Germany + if (spacer != null) { + area.removeChild(spacer); + spacer = null; + } + hasAddedSpacer = false; + if(spacerAfter != null) + area.removeChild(spacerAfter); + spacerAfter = null; + + // 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()); + + // hani elabed 11/27/2000 + cellState.setLayoutComplete(false); + + return status; + } + } else // layout was complete for a particular cell + { // Hani Elabed + cellState.setLayoutComplete(true); + } + + int h = cell.getHeight(); + if (h > largestCellHeight) { + largestCellHeight = h; + } + } + + for (int i = 0; i < numChildren; i++) { + TableCell cell = (TableCell) children.elementAt(i); + cell.setRowHeight(largestCellHeight); + } + + // added by Dresdner Bank, Germany + if (!hasAddedSpacer && spacer != null) { + area.addChild(spacer); + hasAddedSpacer = true; + } + + area.addChild(areaContainer); + areaContainer.setHeight(largestCellHeight); + areaAdded = true; + areaContainer.end(); + area.addDisplaySpace(largestCellHeight + + areaContainer.getPaddingTop() + + areaContainer.borderWidthTop + + areaContainer.getPaddingBottom() + + areaContainer.borderWidthBottom); + + // bug fix from Eric Schaeffer + //area.increaseHeight(largestCellHeight); + + // test to see if some cells are not + // completely laid out. + // Hani Elabed 11/22/2000 + for (int i = 0; i < numChildren; i++) { + CellState cellState = (CellState) cells.elementAt(i); + + if (! cellState.isLayoutComplete()) { + someCellDidNotLayoutCompletely = true; + break; // out of for loop + } + } + + if (!someCellDidNotLayoutCompletely && spaceAfter != 0) { + spacerAfter = new DisplaySpace(spaceAfter); + area.addChild(spacerAfter); + area.increaseHeight(spaceAfter); + } + + if (area instanceof BlockArea) { + area.start(); + } + + // replaced by Hani Elabed 11/27/2000 + //return new Status(Status.OK); + + if (someCellDidNotLayoutCompletely) { + return new Status(Status.AREA_FULL_SOME); + } else { + 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 (spacer != null) { + if(hasAddedSpacer) { + area.removeChild(spacer); + } else { + area.increaseHeight(-spaceBefore); + } + } + if(spacerAfter != null) + area.removeChild(spacerAfter); + //area.increaseHeight(areaContainer.getHeight()); + if(areaAdded) + area.removeChild(areaContainer); + areaAdded = false; + this.resetMarker(); + cells = null; + this.removeID(area.getIDReferences()); + } + + public void resetMarker() + { + super.resetMarker(); + spacer = null; + spacerAfter = null; + hasAddedSpacer = false; + } } -- 2.39.5