]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Support for absolute positioning and borders (contributed by Jon Smirl)
authorfotis <fotis@unknown>
Tue, 7 Mar 2000 09:47:35 +0000 (09:47 +0000)
committerfotis <fotis@unknown>
Tue, 7 Mar 2000 09:47:35 +0000 (09:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193285 13f79535-47bb-0310-9956-ffa450edef68

17 files changed:
src/codegen/properties.xml
src/org/apache/fop/apps/Version.java
src/org/apache/fop/datatypes/Length.java
src/org/apache/fop/fo/PropertyListBuilder.java
src/org/apache/fop/fo/StandardElementMapping.java
src/org/apache/fop/fo/flow/Block.java
src/org/apache/fop/fo/flow/Table.java
src/org/apache/fop/fo/flow/TableBody.java
src/org/apache/fop/fo/flow/TableCell.java
src/org/apache/fop/fo/flow/TableColumn.java
src/org/apache/fop/fo/flow/TableRow.java
src/org/apache/fop/layout/Area.java
src/org/apache/fop/layout/AreaContainer.java
src/org/apache/fop/layout/BlockArea.java
src/org/apache/fop/layout/LineArea.java
src/org/apache/fop/layout/Region.java
src/org/apache/fop/render/pdf/PDFRenderer.java

index e23bcd41e30b397b2c47464094b430130512c249..e4c02a6d2c7b5de9022d1f0700d23d4605472ebb 100644 (file)
@@ -1,3 +1,4 @@
+<?xml version="1.0" ?>
 <property-list>
   <property>
     <name>font-size</name>
     <datatype>ColorType</datatype>
     <default>transparent</default>
   </property>
+  <property>
+    <name>padding</name>
+    <class-name>Padding</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>padding-before</name>
+    <class-name>PaddingBefore</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>padding-after</name>
+    <class-name>PaddingAfter</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>padding-start</name>
+    <class-name>PaddingStart</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>padding-end</name>
+    <class-name>PaddingEnd</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
   <property>
     <name>padding-top</name>
     <class-name>PaddingTop</class-name>
     <datatype>String</datatype>
     <default></default>
   </property>
+  <property>
+    <name>border-before-color</name>
+    <class-name>BorderBeforeColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-before-style</name>
+    <class-name>BorderBeforeStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-before-width</name>
+    <class-name>BorderBeforeWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-after-color</name>
+    <class-name>BorderAfterColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-after-style</name>
+    <class-name>BorderAfterStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-after-width</name>
+    <class-name>BorderAfterWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-start-color</name>
+    <class-name>BorderStartColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-start-style</name>
+    <class-name>BorderStartStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-start-width</name>
+    <class-name>BorderStartWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-end-color</name>
+    <class-name>BorderEndColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-end-style</name>
+    <class-name>BorderEndStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-end-width</name>
+    <class-name>BorderEndWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-top-color</name>
+    <class-name>BorderTopColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-top-style</name>
+    <class-name>BorderTopStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-top-width</name>
+    <class-name>BorderTopWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-bottom-color</name>
+    <class-name>BorderBottomColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-bottom-style</name>
+    <class-name>BorderBottomStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-bottom-width</name>
+    <class-name>BorderBottomWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-left-color</name>
+    <class-name>BorderLeftColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-left-style</name>
+    <class-name>BorderLeftStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-left-width</name>
+    <class-name>BorderLeftWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-right-color</name>
+    <class-name>BorderRightColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-right-style</name>
+    <class-name>BorderRightStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-right-width</name>
+    <class-name>BorderRightWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-color</name>
+    <class-name>BorderColor</class-name>
+    <inherited>false</inherited>
+    <datatype>ColorType</datatype>
+    <default>black</default>
+  </property>
+  <property>
+    <name>border-style</name>
+    <class-name>BorderStyle</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="NONE">none</value>
+        <value const="HIDDEN">hidden</value>
+        <value const="DOTTED">dotted</value>
+        <value const="DASHED">dashed</value>
+        <value const="SOLID">solid</value>
+        <value const="DOUBLE">double</value>
+        <value const="GROOVE">groove</value>
+        <value const="RIDGE">ridge</value>
+        <value const="INSET">inset</value>
+        <value const="OUTSET">outset</value>
+        <value const="TRANSPARENT">transparent</value>
+      </enumeration>
+    </datatype>
+    <default>none</default>
+  </property>
+  <property>
+    <name>border-width</name>
+    <class-name>BorderWidth</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>border-top</name>
+    <class-name>BorderTop</class-name>
+    <inherited>false</inherited>
+    <datatype>String</datatype>
+    <default>normal</default>
+  </property>
+  <property>
+    <name>border-bottom</name>
+    <class-name>BorderBottom</class-name>
+    <inherited>false</inherited>
+    <datatype>String</datatype>
+    <default>normal</default>
+  </property>
+  <property>
+    <name>border-left</name>
+    <class-name>BorderLeft</class-name>
+    <inherited>false</inherited>
+    <datatype>String</datatype>
+    <default>normal</default>
+  </property>
+  <property>
+    <name>border-right</name>
+    <class-name>BorderRight</class-name>
+    <inherited>false</inherited>
+    <datatype>String</datatype>
+    <default>normal</default>
+  </property>
+  <property>
+    <name>position</name>
+    <class-name>Position</class-name>
+    <inherited>false</inherited>
+    <datatype>
+      <enumeration>
+        <value const="STATIC">static</value>
+        <value const="RELATIVE">relative</value>
+        <value const="ABSOLUTE">absolute</value>
+        <value const="FIXED">fixed</value>
+      </enumeration>
+    </datatype>
+    <default>static</default>
+  </property>
+  <property>
+    <name>top</name>
+    <class-name>Top</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>auto</default>
+  </property>
+  <property>
+    <name>right</name>
+    <class-name>Right</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>auto</default>
+  </property>
+  <property>
+    <name>bottom</name>
+    <class-name>Bottom</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>auto</default>
+  </property>
+  <property>
+    <name>left</name>
+    <class-name>Left</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>auto</default>
+  </property>
+  <property>
+    <name>width</name>
+    <class-name>Width</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>auto</default>
+  </property>
+  <property>
+    <name>height</name>
+    <class-name>Height</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>auto</default>
+  </property>
 </property-list>
  
+
index 473a50d8919b379041316edce66be2c8f1510883..74ee9097792d66c392312291dd75503b3acff12c 100644 (file)
@@ -51,7 +51,7 @@
 
 package org.apache.fop.apps;
 
-/**
+/** 
  * class representing the version of FOP.
  */
 public class Version {
index 15b95edf275ed5752e7debc4a139db25d548f593..082bfd930149d4d616059f6568d5a92c20d4144b 100644 (file)
@@ -60,6 +60,8 @@ public class Length {
     protected int millipoints = 0;
 
     protected double fontsize = 12;
+    
+    boolean auto = false;
 
     /**
      * set the length given a particular String specifying length and units
@@ -95,6 +97,8 @@ public class Length {
        if (l == 0) {
            System.err.println("WARNING: empty length");
            this.millipoints = 0;
+        } else if (len.equals("auto")) {
+          this.auto = true;
        } else {
            String unit = len.substring(l-2);
            double dvalue =
index ebec11f1cf08132aa34aeb3d931ca6f522748f8d..4dd71632b881b882f82ec127d96a2c3bba4ebf80 100644 (file)
@@ -118,6 +118,50 @@ public class PropertyListBuilder {
        propertyTable.put("x2",SVGLength.maker());
        propertyTable.put("y1",SVGLength.maker());
        propertyTable.put("y2",SVGLength.maker());
+        
+       propertyTable.put("border-after-color",BorderAfterColor.maker());
+       propertyTable.put("border-after-style",BorderAfterStyle.maker());
+       propertyTable.put("border-after-width",BorderAfterWidth.maker());
+       propertyTable.put("border-before-color",BorderBeforeColor.maker());
+       propertyTable.put("border-before-style",BorderBeforeStyle.maker());
+       propertyTable.put("border-before-width",BorderBeforeWidth.maker());
+       propertyTable.put("border-bottom",BorderBottom.maker());
+       propertyTable.put("border-bottom-color",BorderBottomColor.maker());
+       propertyTable.put("border-bottom-style",BorderBottomStyle.maker());
+       propertyTable.put("border-bottom-width",BorderBottomWidth.maker());
+       propertyTable.put("border-color",BorderColor.maker());
+       propertyTable.put("border-end-color",BorderEndColor.maker());
+       propertyTable.put("border-end-style",BorderEndStyle.maker());
+       propertyTable.put("border-end-width",BorderEndWidth.maker());
+       propertyTable.put("border-left",BorderLeft.maker());
+       propertyTable.put("border-left-color",BorderLeftColor.maker());
+       propertyTable.put("border-left-style",BorderLeftStyle.maker());
+       propertyTable.put("border-left-width",BorderLeftWidth.maker());
+       propertyTable.put("border-right",BorderRight.maker());
+       propertyTable.put("border-right-color",BorderRightColor.maker());
+       propertyTable.put("border-right-style",BorderRightStyle.maker());
+       propertyTable.put("border-right-width",BorderRightWidth.maker());
+       propertyTable.put("border-start-color",BorderStartColor.maker());
+       propertyTable.put("border-start-color",BorderStartColor.maker());
+       propertyTable.put("border-start-width",BorderStartWidth.maker());
+       propertyTable.put("border-style",BorderStyle.maker());
+       propertyTable.put("border-top",BorderTop.maker());
+       propertyTable.put("border-top-color",BorderTopColor.maker());
+       propertyTable.put("border-top-style",BorderTopStyle.maker());
+       propertyTable.put("border-top-style",BorderTopStyle.maker());
+       propertyTable.put("border-width",BorderWidth.maker());
+       propertyTable.put("bottom",Bottom.maker());
+       propertyTable.put("height",Height.maker());
+       propertyTable.put("left",Left.maker());
+       propertyTable.put("padding",Padding.maker());
+       propertyTable.put("padding-after",PaddingAfter.maker());
+       propertyTable.put("padding-before",PaddingBefore.maker());
+       propertyTable.put("padding-end",PaddingEnd.maker());
+       propertyTable.put("padding-start",PaddingStart.maker());
+       propertyTable.put("position",Position.maker());
+       propertyTable.put("right",Right.maker());
+       propertyTable.put("top",Top.maker());
+       propertyTable.put("width",Width.maker());
     }
 
     public Property computeProperty(PropertyList propertyList, String propertyName) {
@@ -128,7 +172,7 @@ public class PropertyListBuilder {
        if (propertyMaker != null) {
            p = propertyMaker.compute(propertyList);
        } else {
-           //System.err.println("WARNING: property " + propertyName + " ignored");
+           System.err.println("WARNING: property " + propertyName + " ignored");
        }
        return p;
     }
@@ -172,7 +216,7 @@ public class PropertyListBuilder {
        if (propertyMaker != null) {
            p = propertyMaker.make(propertyList);
        } else {
-           //System.err.println("WARNING: property " + propertyName + " ignored");
+           System.err.println("WARNING: property " + propertyName + " ignored");
        }
        return p;
     }
index 515c96ab9d713fa4e3422c92b06b019e0b09aa7a..63dbf592a2de516fb06ac6fada67e8783eb62474 100644 (file)
@@ -81,6 +81,7 @@ public class StandardElementMapping implements ElementMapping {
        builder.addMapping(uri, "static-content",
                           StaticContent.maker());
        builder.addMapping(uri, "block", Block.maker()); 
+       builder.addMapping(uri, "block-container", BlockContainer.maker()); 
        builder.addMapping(uri, "list-block", ListBlock.maker());
        builder.addMapping(uri, "list-item", ListItem.maker());
        builder.addMapping(uri, "list-item-label",
index 76599ca236784b2ef4b5e8a5a4280985149deaa5..8d743ee41b9dd0d947c5130ef0a7918f73346f3b 100644 (file)
@@ -88,7 +88,11 @@ public class Block extends FObjMixed {
     int paddingBottom;
     int paddingLeft;
     int paddingRight;
-
+    
+    ColorType borderColor;
+    int borderWidth;
+    int borderStyle;
+    
     BlockArea blockArea;
 
     // this may be helpful on other FOs too
@@ -142,14 +146,27 @@ public class Block extends FObjMixed {
            this.backgroundColor =
                this.properties.get("background-color").getColorType();
            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.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.borderColor =
+               this.properties.get("border-color").getColorType();
+           this.borderWidth =
+               this.properties.get("border-width").getLength().mvalue();
+           this.borderStyle =
+               this.properties.get("border-style").getEnum();
+            
            if (area instanceof BlockArea) {
                area.end();
            }
@@ -164,12 +181,6 @@ public class Block extends FObjMixed {
                startIndent += bodyIndent + distanceBetweenStarts;
            }
 
-           if (this.isInTableCell) {
-               startIndent += forcedStartOffset;
-               endIndent = area.getAllocationWidth() - forcedWidth -
-                   forcedStartOffset;
-           }
-
            this.marker = 0;
 
            if (breakBefore == BreakBefore.PAGE) {
@@ -195,12 +206,17 @@ public class Block extends FObjMixed {
 
        this.blockArea =
            new BlockArea(fs, area.getAllocationWidth(), 
-                         area.spaceLeft(), startIndent, endIndent,
+                         area.spaceLeft(), 
+                          startIndent, 
+                          endIndent,
                          textIndent, align, alignLast, lineHeight);
        blockArea.setPage(area.getPage());
        blockArea.setBackgroundColor(backgroundColor);
        blockArea.setPadding(paddingTop, paddingLeft, paddingBottom,
                             paddingRight);
+        blockArea.setBorderStyle(borderStyle, borderStyle, borderStyle, borderStyle); 
+        blockArea.setBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); 
+        blockArea.setBorderColor(borderColor, borderColor, borderColor, borderColor); 
        blockArea.start();
 
        int numChildren = this.children.size();
index cca3e44d21eeb146b24d13c69a703d92813ff98e..01b3f5f3a9f2cb3765cbade0110bc7aa6eee7d2a 100644 (file)
@@ -77,16 +77,20 @@ public class Table extends FObj {
     FontState fs;
     int breakBefore;
     int breakAfter;
-    int startIndent;
-    int endIndent;
     int spaceBefore;
     int spaceAfter;
     ColorType backgroundColor;
+    int width;
+    int height;
+    ColorType borderColor;
+    int borderWidth;
+    int borderStyle;
+    
 
     Vector columns = new Vector();
     int currentColumnNumber = 0;
 
-    BlockArea blockArea;
+    AreaContainer areaContainer;
 
     public Table(FObj parent, PropertyList propertyList) {
        super(parent, propertyList);
@@ -114,25 +118,28 @@ public class Table extends FObj {
                this.properties.get("break-before").getEnum(); 
            this.breakAfter =
                this.properties.get("break-after").getEnum(); 
-           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.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();
 
            if (area instanceof BlockArea) {
                area.end();
            }
 
-           if (this.isInListBody) {
-               startIndent += bodyIndent + distanceBetweenStarts;
-           }
-
            this.marker = 0;
 
            if (breakBefore == BreakBefore.PAGE) {
@@ -152,16 +159,19 @@ public class Table extends FObj {
            area.addDisplaySpace(spaceBefore);
        }
 
-       this.blockArea =
-           new BlockArea(fs, area.getAllocationWidth(), 
-                         area.spaceLeft(), startIndent, endIndent, 0,
-                         0, 0, 0);
-       blockArea.setPage(area.getPage());
-       blockArea.setBackgroundColor(backgroundColor);
-       blockArea.start();
+       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();
 
        // added by Eric Schaeffer
        currentColumnNumber = 0;
+        int offset = 0;
 
        int numChildren = this.children.size();
        for (int i = this.marker; i < numChildren; i++) {
@@ -177,39 +187,45 @@ public class Table extends FObj {
                    columns.setSize(num);
                }
                columns.setElementAt(c, num-1);
+                c.setColumnOffset(offset);
+               fo.layout(areaContainer);
+                offset += c.getColumnWidth();
            } else if (fo instanceof TableBody) {
                if (columns.size() == 0) {
                    System.err.println("WARNING: current implementation of tables requires a table-column for each column, indicating column-width");
                    return new Status(Status.OK);
                }
                
-               //if (this.isInListBody) {
-               //fo.setIsInListBody();
-               //fo.setDistanceBetweenStarts(this.distanceBetweenStarts);
-               //fo.setBodyIndent(this.bodyIndent);
-               //}
-
                ((TableBody) fo).setColumns(columns);
 
                Status status;
-               if ((status = fo.layout(blockArea)).isIncomplete()) {
+               if ((status = fo.layout(areaContainer)).isIncomplete()) {
                    this.marker = i;
                    if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
                        status = new Status(Status.AREA_FULL_SOME);
                    }
-                   //blockArea.end();
-                   area.addChild(blockArea);
-                   area.increaseHeight(blockArea.getHeight());
+                   //areaContainer.end();
+                   area.addChild(areaContainer);
+                   area.increaseHeight(areaContainer.getHeight());
                    return status;
                }
            }
        }
+        if (height != 0)
+          areaContainer.setHeight(height);
+
+       for (int i = 0; i < numChildren; i++) {
+           FONode fo = (FONode) children.elementAt(i);
+           if (fo instanceof TableColumn) {
+               ((TableColumn)fo).setHeight(areaContainer.getHeight());
+           }
+       }
 
-       blockArea.end();
-       area.addChild(blockArea);
+       areaContainer.end();
+       area.addChild(areaContainer);
 
        /* should this be combined into above? */
-       area.increaseHeight(blockArea.getHeight());
+       area.increaseHeight(areaContainer.getHeight());
 
        if (spaceAfter != 0) {
            area.addDisplaySpace(spaceAfter);
@@ -238,6 +254,6 @@ public class Table extends FObj {
     }
 
     public int getAreaHeight() {
-       return blockArea.getHeight();
+       return areaContainer.getHeight();
     }
 }
index f7d64f8fe6b8e06a511bc5754c188243f6682b54..440a53b4a3bc328ca27487f80eccc0cc43398c9d 100644 (file)
@@ -75,15 +75,13 @@ public class TableBody extends FObj {
     }
 
     FontState fs;
-    int startIndent;
-    int endIndent;
     int spaceBefore;
     int spaceAfter;
     ColorType backgroundColor;
 
     Vector columns;
 
-    BlockArea blockArea;
+    AreaContainer areaContainer;
 
     public TableBody(FObj parent, PropertyList propertyList) {
        super(parent, propertyList);
@@ -111,10 +109,6 @@ public class TableBody extends FObj {
            
            this.fs = new FontState(area.getFontInfo(), fontFamily, 
                                    fontStyle, fontWeight, fontSize);  
-           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 =
@@ -138,44 +132,36 @@ public class TableBody extends FObj {
            area.addDisplaySpace(spaceBefore);
        }
 
-       this.blockArea =
-           new BlockArea(fs, area.getAllocationWidth(), 
-                         area.spaceLeft(), startIndent, endIndent, 0,
-                         0, 0, 0);
-       blockArea.setPage(area.getPage());
-       blockArea.setBackgroundColor(backgroundColor);
-       blockArea.start();
+       this.areaContainer =
+           new AreaContainer(fs, -area.borderWidthLeft, -area.borderWidthTop, area.getAllocationWidth(), 
+                         area.spaceLeft(), Position.RELATIVE);
+       areaContainer.setPage(area.getPage());
+       areaContainer.setBackgroundColor(backgroundColor);
+       areaContainer.start();
 
        int numChildren = this.children.size();
        for (int i = this.marker; i < numChildren; i++) {
            TableRow row = (TableRow) children.elementAt(i);
 
-           //if (this.isInListBody) {
-           //fo.setIsInListBody();
-           //fo.setDistanceBetweenStarts(this.distanceBetweenStarts);
-           //fo.setBodyIndent(this.bodyIndent);
-           //}
-
            row.setColumns(columns);
 
            Status status;
-           if ((status = row.layout(blockArea)).isIncomplete()) {
+           if ((status = row.layout(areaContainer)).isIncomplete()) {
                this.marker = i;
                if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
                    status = new Status(Status.AREA_FULL_SOME);
                }
-               //blockArea.end();
-               area.addChild(blockArea);
-               area.increaseHeight(blockArea.getHeight());
+               area.addChild(areaContainer);
+               //areaContainer.end();
+               area.increaseHeight(areaContainer.getHeight());
                return status;
            }
        }
-
-       blockArea.end();
-       area.addChild(blockArea);
+       area.addChild(areaContainer);
+       areaContainer.end();
 
        /* should this be combined into above? */
-       area.increaseHeight(blockArea.getHeight());
+       area.increaseHeight(areaContainer.getHeight());
 
        if (spaceAfter != 0) {
            area.addDisplaySpace(spaceAfter);
@@ -189,6 +175,6 @@ public class TableBody extends FObj {
     }
 
     public int getAreaHeight() {
-       return blockArea.getHeight();
+       return areaContainer.getHeight();
     }
 }
index d40e2e92bbc0e697c15d36c55415f0a62aaa0319..784d205f78ab0c5efacdc2c121dbd73aa6c48567 100644 (file)
@@ -70,18 +70,25 @@ public class TableCell extends FObj {
        return new TableCell.Maker();
     }
 
-    FontState fs;
-    int startIndent;
-    int endIndent;
     int spaceBefore;
     int spaceAfter;
     ColorType backgroundColor;
 
+    FontState fs;
+    ColorType borderColor;
+    int borderWidth;
+    int borderStyle;
+    int paddingTop;
+    int paddingBottom;
+    int paddingLeft;
+    int paddingRight;
+    int position;
+    
     protected int startOffset;
     protected int width;
     protected int height = 0;
 
-    BlockArea blockArea;
+    AreaContainer areaContainer;
 
     public TableCell(FObj parent, PropertyList propertyList) {
        super(parent, propertyList);
@@ -113,10 +120,28 @@ public class TableCell extends FObj {
            
            this.fs = new FontState(area.getFontInfo(), fontFamily, 
                                    fontStyle, fontWeight, fontSize);  
-           this.startIndent =
-               this.properties.get("start-indent").getLength().mvalue(); 
-           this.endIndent =
-               this.properties.get("end-indent").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.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 =
@@ -140,25 +165,26 @@ public class TableCell extends FObj {
            area.addDisplaySpace(spaceBefore);
        }
 
-       this.blockArea =
-           new BlockArea(fs, area.getAllocationWidth(), 
-                         area.spaceLeft(), startIndent, endIndent, 0,
-                         0, 0, 0);
-       blockArea.setPage(area.getPage());
-       blockArea.setBackgroundColor(backgroundColor);
-       blockArea.start();
-
-       // added by Eric Schaeffer
-       height = 0;
+       this.areaContainer =
+           new AreaContainer(fs, startOffset - area.borderWidthLeft,
+                              - area.borderWidthTop,
+                          width, area.spaceLeft(), Position.RELATIVE);
+       areaContainer.setPage(area.getPage());
+       areaContainer.setPadding(paddingTop, paddingLeft, paddingBottom,
+                            paddingRight);
+       areaContainer.setBackgroundColor(backgroundColor);
+        areaContainer.setBorderStyle(borderStyle, borderStyle, borderStyle, borderStyle); 
+        areaContainer.setBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); 
+        areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor); 
+       areaContainer.start();
 
        int numChildren = this.children.size();
        for (int i = this.marker; i < numChildren; i++) {
            FObj fo = (FObj) children.elementAt(i);
            fo.setIsInTableCell();
-           fo.forceStartOffset(startOffset);
            fo.forceWidth(width);
            Status status;
-           if ((status = fo.layout(blockArea)).isIncomplete()) {
+           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);
@@ -166,18 +192,19 @@ public class TableCell extends FObj {
                    return new Status(Status.AREA_FULL_SOME);
                }
            }
-           // bug fix from Eric Schaeffer
-           // height += blockArea.getHeight();
-           height = blockArea.getHeight();
-
        }
-       blockArea.end();
-       area.addChild(blockArea);
+       areaContainer.end();
+       area.addChild(areaContainer);
 
        return new Status(Status.OK);
     }
 
     public int getHeight() {
-       return height;
+       return areaContainer.getHeight();;
+    }
+    
+    public void setHeight(int height) {
+       areaContainer.setMaxHeight(height);
+       areaContainer.setHeight(height);
     }
 }
index 82ba4af6c6896febf57e0583fa7b08f8b950af6f..fe0ca4064fdaa6182ff9b1b216f88c73e335b293 100644 (file)
@@ -56,9 +56,20 @@ import org.apache.fop.fo.*;
 import org.apache.fop.fo.properties.*;
 import org.apache.fop.layout.*;
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.*;
 
 public class TableColumn extends FObj {
        
+    FontState fs;
+    ColorType backgroundColor;
+    ColorType borderColor;
+    int borderWidth;
+    int borderStyle;
+    int columnWidth;
+    int columnOffset;
+    
+    AreaContainer areaContainer;
+    
     public static class Maker extends FObj.Maker {
        public FObj make(FObj parent, PropertyList propertyList)
            throws FOPException {
@@ -76,10 +87,63 @@ public class TableColumn extends FObj {
     }
 
     public int getColumnWidth() {
-       return this.properties.get("column-width").getLength().mvalue();
+        return columnWidth;
     }
 
     public int getColumnNumber() {
        return 0; // not implemented yet
     }
+    
+    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.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.columnWidth = 
+                this.properties.get("column-width").getLength().mvalue();
+        }
+
+       this.areaContainer =
+           new AreaContainer(fs, columnOffset - area.borderWidthLeft, -area.borderWidthTop, columnWidth, 
+                         area.getHeight(), 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.setHeight(area.getHeight());
+       area.addChild(areaContainer);
+        
+       return new Status(Status.OK);
+    }
+    
+    public void setColumnOffset(int columnOffset) {
+      this.columnOffset = columnOffset; 
+    }
+    
+    public void setHeight(int height) {
+       areaContainer.setMaxHeight(height);
+       areaContainer.setHeight(height);
+    }
+    
 }
index 3c8b53ce64c6db374bcd6596046507cc8ba4ff1e..5fd80a5adb915f1213f86a11cd5e4653c1c835cd 100644 (file)
@@ -75,18 +75,20 @@ public class TableRow extends FObj {
     }
 
     FontState fs;
-    int startIndent;
-    int endIndent;
     int spaceBefore;
     int spaceAfter;
     ColorType backgroundColor;
+    
+    ColorType borderColor;
+    int borderWidth;
+    int borderStyle;
 
     int widthOfCellsSoFar = 0;
     int largestCellHeight = 0;
 
     Vector columns;
 
-    BlockArea blockArea;
+    AreaContainer areaContainer;
 
     public TableRow(FObj parent, PropertyList propertyList) {
        super(parent, propertyList);
@@ -114,25 +116,23 @@ public class TableRow extends FObj {
            
            this.fs = new FontState(area.getFontInfo(), fontFamily, 
                                    fontStyle, fontWeight, fontSize);  
-           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.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();
 
            if (area instanceof BlockArea) {
                area.end();
            }
 
-           //if (this.isInListBody) {
-           //startIndent += bodyIndent + distanceBetweenStarts;
-           //}
-
            this.marker = 0;
 
        }
@@ -141,13 +141,16 @@ public class TableRow extends FObj {
            area.addDisplaySpace(spaceBefore);
        }
 
-       this.blockArea =
-           new BlockArea(fs, area.getAllocationWidth(), 
-                         area.spaceLeft(), startIndent, endIndent, 0,
-                         0, 0, 0);
-       blockArea.setPage(area.getPage());
-       blockArea.setBackgroundColor(backgroundColor);
-       blockArea.start();
+       this.areaContainer =
+           new AreaContainer(fs, -area.borderWidthLeft, -area.borderWidthTop, 
+                           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();
 
        int numChildren = this.children.size();
        if (numChildren != columns.size()) {
@@ -175,27 +178,30 @@ public class TableRow extends FObj {
            widthOfCellsSoFar += width;
 
            Status status;
-           if ((status = cell.layout(blockArea)).isIncomplete()) {
+           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);
                }
-               //blockArea.end();
-               area.addChild(blockArea);
-               area.increaseHeight(blockArea.getHeight());
+               area.addChild(areaContainer);
+               //areaContainer.end();
+               area.increaseHeight(areaContainer.getHeight());
                return status;
            }
 
            int h = cell.getHeight();
-           blockArea.addDisplaySpace(-h);
            if (h > largestCellHeight) {
                largestCellHeight = h;
            }
-
+       }
+       for (int i = 0; i < numChildren; i++) {
+           TableCell cell = (TableCell)children.elementAt(i);
+            cell.setHeight(largestCellHeight);
        }
 
-       blockArea.end();
-       area.addChild(blockArea);
+       area.addChild(areaContainer);
+       areaContainer.end();
+        area.setHeight(largestCellHeight);
        area.addDisplaySpace(largestCellHeight);
        // bug fix from Eric Schaeffer
        //area.increaseHeight(largestCellHeight);
@@ -212,6 +218,6 @@ public class TableRow extends FObj {
     }
 
     public int getAreaHeight() {
-       return blockArea.getHeight();
+       return areaContainer.getHeight();
     }
 }
index e16d7df54731b9f95e340707bcf2b51e324bfb80..fe445c47d445b3da3d4535e7b1850df94a93362d 100644 (file)
@@ -74,9 +74,6 @@ abstract public class Area extends Box {
 
     protected int allocationWidth;
 
-    /* the inner-most area container the area is in */
-    protected AreaContainer areaContainer;
-
     /* the page this area is on */
     protected Page page;
 
@@ -86,6 +83,19 @@ abstract public class Area extends Box {
     protected int paddingLeft;
     protected int paddingBottom;
     protected int paddingRight;
+    
+    public int borderWidthTop;
+    public int borderWidthLeft;
+    public int borderWidthRight;
+    public int borderWidthBottom;
+    public int borderStyleTop;
+    public int borderStyleLeft;
+    public int borderStyleRight;
+    public int borderStyleBottom;
+    public ColorType borderColorTop;
+    public ColorType borderColorLeft;
+    public ColorType borderColorRight;
+    public ColorType borderColorBottom;
 
     public Area (FontState fontState) {
        this.fontState = fontState;
@@ -94,6 +104,7 @@ abstract public class Area extends Box {
     public Area (FontState fontState, int allocationWidth, int maxHeight) {
        this.fontState = fontState;
        this.allocationWidth = allocationWidth;
+        this.contentRectangleWidth = allocationWidth;
        this.maxHeight = maxHeight;
     }
 
@@ -120,7 +131,7 @@ abstract public class Area extends Box {
     }
     
     public int getAllocationWidth() {
-       return this.allocationWidth;
+       return this.allocationWidth - paddingLeft - paddingRight - borderWidthLeft - borderWidthRight;
     }
     
     public Vector getChildren() {
@@ -128,19 +139,23 @@ abstract public class Area extends Box {
     }
        
     public int getContentWidth() {
-       return this.contentRectangleWidth;
+       return contentRectangleWidth - paddingLeft - paddingRight - borderWidthLeft - borderWidthRight;
     }
 
     public FontState getFontState() {
        return this.fontState;
     }
 
-    public int getHeight() {
+    public int getContentHeight() {
        return this.currentHeight;
     }
 
+    public int getHeight() {
+       return this.currentHeight + paddingTop + paddingBottom + borderWidthTop + borderWidthBottom;
+    }
+
     public int getMaxHeight() {
-       return this.maxHeight;
+       return this.maxHeight - paddingTop - paddingBottom - borderWidthTop - borderWidthBottom;
     }
 
     public Page getPage() {
@@ -195,10 +210,46 @@ abstract public class Area extends Box {
        this.paddingRight = right;
     }
 
+    public void setBorderWidth(int top, int left, int bottom, int right) {
+       this.borderWidthTop = top;
+       this.borderWidthLeft = left;
+       this.borderWidthBottom = bottom;
+       this.borderWidthRight = right;
+    }
+
+    public void setBorderStyle(int top, int left, int bottom, int right) {
+       this.borderStyleTop = top;
+       this.borderStyleLeft = left;
+       this.borderStyleBottom = bottom;
+       this.borderStyleRight = right;
+    }
+
+    public void setBorderColor(ColorType top, ColorType left, ColorType bottom, ColorType right) {
+       this.borderColorTop = top;
+       this.borderColorLeft = left;
+       this.borderColorBottom = bottom;
+       this.borderColorRight = right;
+    }
+
     public int spaceLeft() {
        return maxHeight - currentHeight;
     }
 
     public void start() {
     }
+    
+    public void setHeight(int height) {
+      if (height > currentHeight)
+        currentHeight = height;
+      if (currentHeight > getMaxHeight())
+        currentHeight = getMaxHeight();
+    }
+    
+    public void setMaxHeight(int height) {
+      this.maxHeight = height;
+    }
+    
+    public Area getParent() {
+      return this.parent;
+    }
 }
index af39677cf5419001ec38eec55b3ed7d4f0951300..45fedba8e267643a21449dae490bde31f6ac822d 100644 (file)
@@ -52,6 +52,7 @@ package org.apache.fop.layout;
 
 // FOP
 import org.apache.fop.render.Renderer;
+import org.apache.fop.fo.properties.*;
 
 // Java
 import java.util.Vector;
@@ -61,22 +62,28 @@ public class AreaContainer extends Area {
 
     private int xPosition; // should be able to take value 'left' and 'right' too
     private int yPosition; // should be able to take value 'top' and 'bottom' too
+    private int position;
 
-    AreaContainer(int xPosition, int yPosition, int allocationWidth, int maxHeight) {
-       super(null, allocationWidth, maxHeight);
+    public AreaContainer(FontState fontState, int xPosition, int yPosition, int allocationWidth, int maxHeight, int position) {
+       super(fontState, allocationWidth, maxHeight);
        this.xPosition = xPosition;
        this.yPosition = yPosition;
+        this.position = position;
     }
 
     public void render(Renderer renderer) {
        renderer.renderAreaContainer(this);
     }
 
+    public int getPosition() {
+       return position;
+    }
+
     public int getXPosition() {
-       return xPosition;
+        return xPosition + this.paddingLeft + this.borderWidthLeft;
     }
 
     public int getYPosition() {
-       return yPosition;
+      return yPosition + this.paddingTop + this.borderWidthTop;
     }
 }
index 2532e9567527018d23cfba6ee85f6926f8684e9a..9cd8b98cae270c07d3de447c8fedfedb220a26fd 100644 (file)
@@ -95,7 +95,8 @@ public class BlockArea extends Area {
        this.alignLastLine = alignLastLine;
        this.lineHeight = lineHeight;
 
-       this.halfLeading = (lineHeight - fontState.getFontSize())/2;
+        if (fontState != null)
+         this.halfLeading = (lineHeight - fontState.getFontSize())/2;
     }
 
     public void render(Renderer renderer) {
@@ -182,9 +183,15 @@ public class BlockArea extends Area {
     }
 
     public int getStartIndent() {
-       return startIndent;
+       return startIndent + paddingLeft + borderWidthLeft;
     }
 
+    public void setIndents(int startIndent, int endIndent) {
+       this.startIndent = startIndent;
+       this.endIndent = endIndent;
+       this.contentRectangleWidth = allocationWidth - startIndent - endIndent;
+    }
+    
     public int spaceLeft() {
        return maxHeight - currentHeight;
     }
index 64b8c21a0e37f5bd50ef982a48634459e9d023c5..092685a4a64df4db196374b282277c193b1091b7 100644 (file)
@@ -300,7 +300,7 @@ public class LineArea extends Area {
 
                    wordWidth = charWidth;
                    if ((finalWidth + spaceWidth + wordWidth) >
-                       this.contentRectangleWidth) { 
+                       this.getContentWidth()) { 
                        if (overrun)
                            System.err.print(">");
                        if (this.wrapOption == WrapOption.WRAP)
@@ -320,7 +320,7 @@ public class LineArea extends Area {
                }
 
                if ((finalWidth + spaceWidth + pendingWidth + wordWidth) >
-                   this.contentRectangleWidth) { 
+                   this.getContentWidth()) { 
                    
                    // BREAK MID WORD
                    if (wordStart == start) { // if couldn't even fit
@@ -386,15 +386,15 @@ public class LineArea extends Area {
        
        switch (type) {
        case TextAlign.START: // left
-           padding = this.contentRectangleWidth - finalWidth;
+           padding = this.getContentWidth() - finalWidth;
            endIndent += padding;
            break;
        case TextAlign.END: // right
-           padding = this.contentRectangleWidth - finalWidth;
+           padding = this.getContentWidth() - finalWidth;
            startIndent += padding;
            break;
        case TextAlign.CENTERED: // center
-           padding = (this.contentRectangleWidth - finalWidth)/2;
+           padding = (this.getContentWidth() - finalWidth)/2;
            startIndent += padding;
            endIndent += padding;
            break;
@@ -412,7 +412,7 @@ public class LineArea extends Area {
                }
            }
            if (spaceCount > 0) {
-               padding = (this.contentRectangleWidth - finalWidth) /
+               padding = (this.getContentWidth() - finalWidth) /
                    spaceCount; 
            } else { // no spaces
                padding = 0;
index 0e4ed529a41d54381258d95eb3fd85dd72e4050e..634960e4e591471efc0e4aeb70960693d3eea38f 100644 (file)
@@ -49,6 +49,7 @@
  
  */
 package org.apache.fop.layout;
+import org.apache.fop.fo.properties.*;
 
 public class Region {
 
@@ -65,6 +66,6 @@ public class Region {
     }
 
     public AreaContainer makeAreaContainer() {
-       return new AreaContainer(xPosition, yPosition, width, height);
+       return new AreaContainer(null, xPosition, yPosition, width, height, Position.ABSOLUTE);
     }
 }
index 17926ffc867818f22a838f85169f4c132579dc2b..a2af3330fb41b00ec1f184d4a781f61175b09075 100644 (file)
@@ -55,6 +55,7 @@ package org.apache.fop.render.pdf;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.image.ImageArea;
 import org.apache.fop.image.FopImage;
+import org.apache.fop.fo.properties.*;
 import org.apache.fop.layout.*;
 import org.apache.fop.datatypes.*;
 import org.apache.fop.svg.*;
@@ -81,9 +82,6 @@ public class PDFRenderer implements Renderer {
     /** the current stream to add PDF commands to */
     PDFStream currentStream;
 
-    /** the current annotation list to add annotations to */
-    PDFAnnotList currentAnnotList;
-
     /** the current (internal) font name */
     protected String currentFontName;
 
@@ -214,45 +212,91 @@ public class PDFRenderer implements Renderer {
      * @param area the area container to render
      */
     public void renderAreaContainer(AreaContainer area) {
+        
+        int saveY = this.currentYPosition;
+        int saveX = this.currentAreaContainerXPosition;
+        
+        if (area.getPosition() == Position.ABSOLUTE) {
+            // Y position is computed assuming positive Y axis, adjust for negative postscript one
+         this.currentYPosition = area.getYPosition() - 2 * area.getPaddingTop() - 2 * area.borderWidthTop;
+         this.currentAreaContainerXPosition = area.getXPosition();
+        } else if (area.getPosition() == Position.RELATIVE) {
+         this.currentYPosition -= area.getYPosition();
+         this.currentAreaContainerXPosition += area.getXPosition();
+        } else if (area.getPosition() == Position.STATIC) {
+         this.currentYPosition -= area.getPaddingTop() + area.borderWidthTop;
+         this.currentAreaContainerXPosition += area.getPaddingLeft() + area.borderWidthLeft;
+        }
 
-       /* move into position */
-       currentStream.add("1 0 0 1 "
-                         + (area.getXPosition()/1000f) + " "
-                         + (area.getYPosition()/1000f) + " Tm\n");
-
-       this.currentYPosition = area.getYPosition();
-       this.currentAreaContainerXPosition = area.getXPosition();
-
+        doFrame(area);
+        
        Enumeration e = area.getChildren().elements();
        while (e.hasMoreElements()) {
            Box b = (Box) e.nextElement();
            b.render(this);
        }
+        if (area.getPosition() != Position.STATIC) {
+          this.currentYPosition = saveY;
+          this.currentAreaContainerXPosition = saveX;
+        } else 
+          this.currentYPosition -= area.getHeight();
     }
-
-    /**
-     * render block area to PDF
-     *
-     * @param area the block area to render
-     */
-    public void renderBlockArea(BlockArea area) {
-       int rx = this.currentAreaContainerXPosition
-           + area.getStartIndent();
+    
+    private void doFrame(Area area) {
+        int w, h;
+       int rx = this.currentAreaContainerXPosition;
+       w = area.getContentWidth();
+        if (area instanceof BlockArea)
+         rx += ((BlockArea)area).getStartIndent();
+       h = area.getContentHeight();
        int ry = this.currentYPosition;
-       int w = area.getContentWidth();
-       int h = area.getHeight();
        ColorType bg = area.getBackgroundColor();
-       int pt = area.getPaddingTop();
-       int pl = area.getPaddingLeft();
-       int pb = area.getPaddingBottom();
-       int pr = area.getPaddingRight();
+        
+        rx = rx - area.getPaddingLeft();
+        ry = ry + area.getPaddingTop();
+        w = w + area.getPaddingLeft() + area.getPaddingRight();
+        h = h + area.getPaddingTop() + area.getPaddingBottom();
+        
        // I'm not sure I should have to check for bg being null
        // but I do
        if ((bg != null) && (bg.alpha() == 0)) {
-           this.addRect(rx - pl, ry + pt, w + pl + pr , - (h + pt + pb),
+           this.addRect(rx, ry, w, -h,
                         bg.red(), bg.green(), bg.blue(),
                         bg.red(), bg.green(), bg.blue());
        }
+    
+        rx = rx - area.borderWidthLeft;
+        ry = ry + area.borderWidthTop;
+        w = w + area.borderWidthLeft + area.borderWidthRight;
+        h = h + area.borderWidthTop + area.borderWidthBottom;
+        
+        if (area.borderWidthTop != 0)
+          addLine(rx, ry, rx + w, ry, 
+                area.borderWidthTop,  
+                area.borderColorTop.red(), area.borderColorTop.green(), area.borderColorTop.blue());
+        if (area.borderWidthLeft != 0)
+          addLine(rx, ry, rx, ry - h, 
+                area.borderWidthLeft,  
+                area.borderColorLeft.red(), area.borderColorLeft.green(), area.borderColorLeft.blue());
+        if (area.borderWidthRight != 0)
+          addLine(rx + w, ry, rx + w, ry - h, 
+                area.borderWidthRight,  
+                area.borderColorRight.red(), area.borderColorRight.green(), area.borderColorRight.blue());
+        if (area.borderWidthBottom != 0)
+          addLine(rx, ry - h, rx + w, ry - h, 
+                area.borderWidthBottom,  
+                area.borderColorBottom.red(), area.borderColorBottom.green(), area.borderColorBottom.blue());
+
+    } 
+   
+
+    /**
+     * render block area to PDF
+     *
+     * @param area the block area to render
+     */
+    public void renderBlockArea(BlockArea area) {
+        doFrame(area);
        Enumeration e = area.getChildren().elements();
        while (e.hasMoreElements()) {
            Box b = (Box) e.nextElement();
@@ -461,9 +505,11 @@ public class PDFRenderer implements Renderer {
        
        currentStream.add("ET\n");
 
-       if (page.hasLinks()) {
-            currentAnnotList = this.pdfDoc.makeAnnotList();
+       this.pdfDoc.makePage(this.pdfResources, currentStream,
+                            page.getWidth()/1000,
+                            page.getHeight()/1000);
 
+       /*if (page.hasLinks()) {
            Enumeration e = page.getLinkSets().elements();
            while (e.hasMoreElements()) {
                LinkSet linkSet = (LinkSet) e.nextElement();
@@ -471,20 +517,10 @@ public class PDFRenderer implements Renderer {
                Enumeration f = linkSet.getRects().elements();
                while (f.hasMoreElements()) {
                    Rectangle rect = (Rectangle) f.nextElement();
-                   currentAnnotList.addLink(
-                        this.pdfDoc.makeLink(rect, dest)
-                    );
+                   this.pdfDoc.makeLink(rect, dest);
                }
            }
-       } else {
-            currentAnnotList = null;
-        }
-
-       this.pdfDoc.makePage(this.pdfResources, currentStream,
-                             currentAnnotList,
-                            page.getWidth()/1000,
-                            page.getHeight()/1000);
-
+       } */
     }
 
     /**
@@ -516,3 +552,4 @@ public class PDFRenderer implements Renderer {
        FontSetup.addToResources(this.pdfDoc, fontInfo);
     }
 }
+