]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
AHS: improving area information
authorarved <arved@unknown>
Tue, 17 Jul 2001 03:16:29 +0000 (03:16 +0000)
committerarved <arved@unknown>
Tue, 17 Jul 2001 03:16:29 +0000 (03:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194357 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/flow/FootnoteBody.java
src/org/apache/fop/fo/flow/Marker.java
src/org/apache/fop/fo/flow/StaticContent.java
src/org/apache/fop/layout/Area.java
src/org/apache/fop/layout/AreaContainer.java
src/org/apache/fop/layout/BodyAreaContainer.java
src/org/apache/fop/layout/ColumnArea.java
src/org/apache/fop/render/xml/XMLRenderer.java

index 4b5e95c6ca75cbdd8c88196c08383792ccc6a731..38e1fdb140b4d03e75472e48195d2bf9952260eb 100644 (file)
@@ -54,6 +54,7 @@ package org.apache.fop.fo.flow;
 // FOP
 import org.apache.fop.fo.*;
 import org.apache.fop.layout.Area;
+import org.apache.fop.layout.AreaClass;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.properties.*;
 import org.apache.fop.layout.*;
@@ -85,6 +86,7 @@ public class FootnoteBody extends FObj {
                        throws FOPException {
                super(parent, propertyList);
                this.name = "fo:footnote-body";
+               this.areaClass = AreaClass.setAreaClass(AreaClass.XSL_FOOTNOTE);
        }
 
     public Status layout(Area area) throws FOPException {
@@ -96,6 +98,7 @@ public class FootnoteBody extends FObj {
                      area.getAllocationWidth(),
                      area.spaceLeft(), startIndent, endIndent, textIndent,
                      align, alignLast, lineHeight);
+         blockArea.generatedBy = this;
       blockArea.setPage(area.getPage());
       blockArea.start();
 
index 627d985421ea85f1d6e6efc539d462e8912e712a..1b9ad20e743140f8af63f340725e15045eee0369 100644 (file)
@@ -50,6 +50,7 @@ public class Marker extends FObjMixed {
          public Status layout(Area area) throws FOPException {
                // no layout action desired
                this.registryArea = area;
+               area.addMarker(this);
                area.getPage().registerMarker(this);
                // System.out.println("Marker being registered in area '" + area + "'");
                return new Status(Status.OK);
index 154e9002534ae8bbc3b69897e88cd7015a6a0b19..4d0069163a7e805c90309b63f4e2d0bc1094c225 100644 (file)
@@ -62,6 +62,9 @@ public class StaticContent extends Flow {
 
         }
 
+               if (area instanceof org.apache.fop.layout.AreaContainer)
+                       ((org.apache.fop.layout.AreaContainer)area).setAreaName(regionClass);
+                       
         if (regionClass.equals(RegionBefore.REGION_CLASS)) {
             area.setAbsoluteHeight(-area.getMaxHeight());
         } else if (regionClass.equals(RegionAfter.REGION_CLASS)) {
index fc10ebf0669302d46e25599bfb45f99e52dd9b28..c25a7cbf51b18c4e8b245026abc37e108615aef4 100644 (file)
@@ -361,6 +361,10 @@ abstract public class Area extends Box {
     return bp;
   }
 
+  public void addMarker(Marker marker) {
+         markers.addElement(marker);
+  }
+  
   public void addMarkers(Vector markers) {
          markers.addAll(markers);
   }
@@ -368,4 +372,8 @@ abstract public class Area extends Box {
   public void addLineagePair(org.apache.fop.fo.FObj fo, int areaPosition) {
          returnedBy.put(fo, new Integer(areaPosition));
   }
+  
+  public Vector getMarkers() {
+         return markers;
+  }
 }
index 0ceb5c249f302370afc28548653c05435ad0f335..e15a8ca61b12f070ea927f6d56d2048dee84f189 100644 (file)
@@ -20,6 +20,10 @@ public class AreaContainer extends Area {
     private int yPosition; // should be able to take value 'top' and 'bottom' too
     private int position;
 
+       // use this for identifying the general usage of the area,
+       // like 'main-reference-area' or 'region-before'
+       private String areaName;
+       
     public AreaContainer(FontState fontState, int xPosition,
                          int yPosition, int allocationWidth, int maxHeight,
                          int position) {
@@ -63,4 +67,12 @@ public class AreaContainer extends Area {
     public void shiftYPosition(int value) {
         yPosition += value;
     }
+  
+  public String getAreaName() {
+         return areaName;
+  }
+  
+  public void setAreaName(String areaName) {
+         this.areaName = areaName;
+  }
 }
index 67df63d7d09cd0c349e8d362ac46b660822daef4..7aa5fde1f3a8728f5b538b97809a3e748e64d7b3 100644 (file)
@@ -68,13 +68,16 @@ public class BodyAreaContainer extends Area {
        mainRefAreaHeight = maxHeight - beforeFloatRefAreaHeight - footnoteRefAreaHeight;
        beforeFloatReferenceArea = new AreaContainer(fontState, xPosition, yPosition,
                allocationWidth, beforeFloatRefAreaHeight, Position.ABSOLUTE);
+       beforeFloatReferenceArea.setAreaName("before-float-reference-area");
        this.addChild(beforeFloatReferenceArea);
        mainReferenceArea = new AreaContainer(fontState, xPosition, yPosition,
                allocationWidth, mainRefAreaHeight, Position.ABSOLUTE);
+       mainReferenceArea.setAreaName("main-reference-area");
        this.addChild(mainReferenceArea);
        int footnoteRefAreaYPosition = yPosition - mainRefAreaHeight;
        footnoteReferenceArea = new AreaContainer(fontState, xPosition, footnoteRefAreaYPosition,
                allocationWidth, footnoteRefAreaHeight, Position.ABSOLUTE);
+       footnoteReferenceArea.setAreaName("footnote-reference-area");
        this.addChild(footnoteReferenceArea);
        
        // all padding and border-width must be 0
index 24530f1fa1e8fb948973ee3c6e67e0e7c96a9eae..e5e24181b86382efa54e3d263ae3d028af342bba 100644 (file)
@@ -25,6 +25,7 @@ public class ColumnArea extends AreaContainer {
                super(fontState, xPosition, yPosition, allocationWidth,
                        maxHeight, Position.ABSOLUTE);
                this.maxColumns = columnCount;
+               this.setAreaName("normal-flow-ref.-area");
     }
 
     public void render(Renderer renderer) {
index 9f47e8787fe7b6ad1bf8a8b8e0753617e9c46346..405e7a04e880f4c91b6c93d8c7c33997e69ffa9a 100644 (file)
@@ -149,7 +149,7 @@ public class XMLRenderer implements Renderer {
      * @param area the area container to render
      */
     public void renderAreaContainer(AreaContainer area) {
-        writeStartTag("<AreaContainer>");
+        writeStartTag("<AreaContainer name=\"" + area.getAreaName() + "\">");
         Enumeration e = area.getChildren().elements();
         while (e.hasMoreElements()) {
             Box b = (Box) e.nextElement();
@@ -194,9 +194,35 @@ public class XMLRenderer implements Renderer {
      * @param area the block area to render
      */
     public void renderBlockArea(BlockArea area) {
-        writeStartTag("<BlockArea start-indent=\"" +
-                      area.getStartIndent() + "\" end-indent=\"" +
-                      area.getEndIndent() + "\">");
+               StringBuffer baText = new StringBuffer();
+               baText.append("<BlockArea start-indent=\"" + area.getStartIndent() + "\"");
+               baText.append(" end-indent=\"" + area.getEndIndent() + "\"");
+               baText.append("\nis-first=\"" + area.isFirst + "\"");
+               baText.append(" is-last=\"" + area.isLast + "\"");
+               if (null != area.generatedBy)
+                       baText.append(" generated-by=\"" + area.generatedBy.getName() +
+                       "//" + area.generatedBy + "\"");
+               baText.append(">");
+        writeStartTag(baText.toString());
+               
+               // write out marker info
+               java.util.Vector markers = area.getMarkers();
+               if (!markers.isEmpty()) {
+                       writeStartTag("<Markers>");
+                       for (int m = 0; m < markers.size(); m++) {
+                               org.apache.fop.fo.flow.Marker marker =
+                                       (org.apache.fop.fo.flow.Marker)markers.elementAt(m);
+                               StringBuffer maText = new StringBuffer();
+                               maText.append("<Marker marker-class-name=\"" +
+                                       marker.getMarkerClassName() + "\"");
+                               maText.append(" RegisteredArea=\"" +
+                                       marker.getRegistryArea() + "\"");
+                               maText.append("/>");
+                               writeEmptyElementTag(maText.toString());
+                       }
+                       writeEndTag("</Markers>");
+               }
+               
         Enumeration e = area.getChildren().elements();
         while (e.hasMoreElements()) {
             Box b = (Box) e.nextElement();
@@ -310,7 +336,7 @@ public class XMLRenderer implements Renderer {
     public void renderPage(Page page) {
         BodyAreaContainer body;
         AreaContainer before, after;
-        writeStartTag("<Page number=\"" + page.getNumber() + "\">");
+        writeStartTag("<Page number=\"" + page.getFormattedNumber() + "\">");
         body = page.getBody();
         before = page.getBefore();
         after = page.getAfter();