]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
In the AFP stream, put the TLE fields associated to a page sequence before the Page...
authorVincent Hennebert <vhennebert@apache.org>
Fri, 24 Apr 2009 14:39:32 +0000 (14:39 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Fri, 24 Apr 2009 14:39:32 +0000 (14:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@768321 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/afp/modca/AbstractPageObject.java
src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java
src/java/org/apache/fop/afp/modca/PageGroup.java

index c043faf2e7124ff446dc1fb31913bc3db210f178..cd8c44b5eca2aaa18c8e0207e91fd6b30fd79d42 100644 (file)
@@ -211,6 +211,17 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject implemen
         return currentPresentationTextObject;
     }
 
+    /**
+     * Returns the list of {@link TagLogicalElement}s.
+     * @return the TLEs
+     */
+    protected List getTagLogicalElements() {
+        if (tagLogicalElements == null) {
+            this.tagLogicalElements = new java.util.ArrayList/*<TagLogicalElement>*/();
+        }
+        return this.tagLogicalElements;
+    }
+
     /**
      * Creates a TagLogicalElement on the page.
      *
@@ -223,10 +234,8 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject implemen
      */
     public void createTagLogicalElement(String name, String value, int tleID) {
         TagLogicalElement tle = new TagLogicalElement(name, value, tleID);
-        if (tagLogicalElements == null) {
-            tagLogicalElements = new java.util.ArrayList/*<TagLogicalElement>*/();
-        }
-        tagLogicalElements.add(tle);
+        List list = getTagLogicalElements();
+        list.add(tle);
     }
 
     /**
index 6546fa978a242fe9c2957c44f7017c628c1019db..d96b1911e442fb4b03427f97f6365eb514c50941 100644 (file)
@@ -141,12 +141,25 @@ implements Streamable {
 
     /** {@inheritDoc} */
     protected void writeObjects(Collection/*<AbstractAFPObject>*/ objects, OutputStream os)
-    throws IOException {
+            throws IOException {
+        writeObjects(objects, os, false);
+    }
+
+    /**
+     * Writes a collection of {@link AbstractAFPObject}s to the AFP Datastream.
+     *
+     * @param objects a list of AFPObjects
+     * @param os The stream to write to
+     * @param forceWrite true if writing should happen in any case
+     * @throws java.io.IOException an I/O exception of some sort has occurred.
+     */
+    protected void writeObjects(Collection/*<AbstractAFPObject>*/ objects, OutputStream os,
+            boolean forceWrite) throws IOException {
         if (objects != null && objects.size() > 0) {
             Iterator it = objects.iterator();
             while (it.hasNext()) {
                 AbstractAFPObject ao = (AbstractAFPObject)it.next();
-                if (canWrite(ao)) {
+                if (forceWrite || canWrite(ao)) {
                     ao.writeToStream(os);
                     it.remove();
                 } else {
index 4e578718b2b0d9e6b7d84ecef7d7767fbb976b5d..f70b6fc521f104ff0da08639baae73c46ec179fd 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.fop.afp.modca;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.List;
 
 import org.apache.fop.afp.Factory;
 
@@ -36,9 +35,6 @@ import org.apache.fop.afp.Factory;
  */
 public class PageGroup extends AbstractResourceEnvironmentGroupContainer {
 
-    /** The tag logical elements contained within this group */
-    private List tagLogicalElements = null;
-
     /**
      * Sequence number for TLE's.
      */
@@ -56,13 +52,6 @@ public class PageGroup extends AbstractResourceEnvironmentGroupContainer {
         this.tleSequence = tleSequence;
     }
 
-    private List getTagLogicalElements() {
-        if (tagLogicalElements == null) {
-            this.tagLogicalElements = new java.util.ArrayList();
-        }
-        return this.tagLogicalElements;
-    }
-
     /**
      * Creates a TagLogicalElement on the page.
      *
@@ -88,7 +77,7 @@ public class PageGroup extends AbstractResourceEnvironmentGroupContainer {
 
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
-        writeObjects(tagLogicalElements, os);
+        writeObjects(tagLogicalElements, os, true);
         super.writeContent(os);
     }