]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Handling of markers introduced or modified to use getMarkers.
authorPeter Bernard West <pbwest@apache.org>
Wed, 21 Jan 2004 11:01:30 +0000 (11:01 +0000)
committerPeter Bernard West <pbwest@apache.org>
Wed, 21 Jan 2004 11:01:30 +0000 (11:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197234 13f79535-47bb-0310-9956-ffa450edef68

20 files changed:
src/java/org/apache/fop/fo/flow/FoBasicLink.java
src/java/org/apache/fop/fo/flow/FoBidiOverride.java
src/java/org/apache/fop/fo/flow/FoBlock.java
src/java/org/apache/fop/fo/flow/FoBlockContainer.java
src/java/org/apache/fop/fo/flow/FoFlow.java
src/java/org/apache/fop/fo/flow/FoInline.java
src/java/org/apache/fop/fo/flow/FoInlineContainer.java
src/java/org/apache/fop/fo/flow/FoListBlock.java
src/java/org/apache/fop/fo/flow/FoListItemBody.java
src/java/org/apache/fop/fo/flow/FoListItemLabel.java
src/java/org/apache/fop/fo/flow/FoMultiCase.java
src/java/org/apache/fop/fo/flow/FoMultiToggle.java
src/java/org/apache/fop/fo/flow/FoTableAndCaption.java
src/java/org/apache/fop/fo/flow/FoTableBody.java
src/java/org/apache/fop/fo/flow/FoTableCaption.java
src/java/org/apache/fop/fo/flow/FoTableCell.java
src/java/org/apache/fop/fo/flow/FoTableFooter.java
src/java/org/apache/fop/fo/flow/FoTableHeader.java
src/java/org/apache/fop/fo/flow/FoTableRow.java
src/java/org/apache/fop/fo/flow/FoTitle.java

index 5aae317f55452c22358257d10ab8645646d9d7b9..a5b6e18a5442a8801f2fc296fc926557a64cdae5 100644 (file)
@@ -157,6 +157,7 @@ public class FoBasicLink extends FONode {
     {
         super(foTree, FObjectNames.BASIC_LINK, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         do {
             try {
index 2c07da62c4ab9a6fda41f65ac8749a3a55bbd4f7..8a38c9677208bee4bdaa17a5dab4a74e52228fba 100644 (file)
@@ -144,6 +144,7 @@ public class FoBidiOverride extends FONode {
     {
         super(foTree, FObjectNames.BIDI_OVERRIDE, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         do {
             try {
index 161425fcd8a761e60b94681ef67c786f94df42ab..1e22dc0dd2693025e1a5e20aec37e2f8b5516035 100644 (file)
@@ -169,6 +169,7 @@ public class FoBlock extends FONode {
     {
         super(foTree, FObjectNames.BLOCK, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         do {
             try {
index 04a6fb2bd18d9f6aaeab5d4067ec031dec6ccca9..0f1c8c4907c8fe4415460711dd2cc09105d4cee0 100644 (file)
@@ -159,6 +159,7 @@ public class FoBlockContainer extends FONode {
         // absolutely positioned areas.  They are not allowed as descendents
         // of fo:title, fo:float or fo:footnote.  They are not allowed to
         // have any fo:marker children.
+        getMarkers();
         XmlEvent ev = null;
         try {
             // Get at least one %block;
index e422792c359ddf234237bce75810caae19b31278..ae7b2e2e913a36d3c2e7ab89dd5a6717e7b7e615 100644 (file)
@@ -122,6 +122,7 @@ public class FoFlow extends FONode {
     {
         super(foTree, FObjectNames.FLOW, parent, event,
               FONode.FLOW_SET, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev;
         try {
             // Get at least one %block;
index 1873402c87ace4bdceba5935c24f1763ab5674e8..eccab7d8d7ba637df188f995d8768bd373058422 100644 (file)
@@ -158,6 +158,7 @@ public class FoInline extends FONode {
     {
         super(foTree, FObjectNames.INLINE, parent, event,
                                   stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         do {
             try {
index 6ac8129a19e97e114241db0385a57608bf18de34..ea079556d2d867fb29eb5b96954611a4e16f5381 100644 (file)
@@ -155,6 +155,7 @@ public class FoInlineContainer extends FONode {
     {
         super(foTree, FObjectNames.INLINE_CONTAINER, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         try {
             // Get at least one %block;
index 7220e6a7a09948403e22f29ce85cde3d45c033cc..613194f4a4301a50ae76cde3a2545873258b5180 100644 (file)
@@ -130,9 +130,6 @@ public class FoListBlock extends FONode {
         }
     }
 
-    /** The number of markers on this FO. */
-    private int numMarkers = 0;
-
     /** The number of list-items on this FO. */
     private int numItems = 0;
 
@@ -157,18 +154,9 @@ public class FoListBlock extends FONode {
                           stateFlags, sparsePropsMap, sparseIndices);
         XmlEvent ev;
         // Look for zero or more markers
-        String nowProcessing = "marker";
+        getMarkers();
+        String nowProcessing;
         try {
-            while ((ev = xmlevents.expectStartElement
-                    (FObjectNames.MARKER, XmlEvent.DISCARD_W_SPACE))
-                   != null) {
-                new FoMarker(getFOTree(), this, (FoXmlEvent)ev, stateFlags);
-                numMarkers++;
-                ev = xmlevents.getEndElement(
-                        XmlEventReader.DISCARD_EV, ev);
-                namespaces.relinquishEvent(ev);
-            }
-
             // Look for one or more table-rows
             nowProcessing = "list-item";
             while ((ev = xmlevents.expectStartElement
index bc2e73e5966f2e463c87bba27cab8b51432dfd5b..d277acb99ad057d9844e207303c72c0cb1d663ee 100644 (file)
@@ -135,6 +135,7 @@ public class FoListItemBody extends FONode {
     {
         super(foTree, FObjectNames.LIST_ITEM_BODY, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         try {
             // Get at least one %block;
index 8b4be53ab5e83dda089031c5780a298d9e98147f..89efaaa822ea5ca9af08c7bfd1e28ed9e5f83baf 100644 (file)
@@ -135,6 +135,7 @@ public class FoListItemLabel extends FONode {
     {
         super(foTree, FObjectNames.LIST_ITEM_LABEL, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         try {
             // Get at least one %block;
index 74e8ef2f15c4ac63fcd459befbbc20181674da7a..7de61b705debe51156f37dbd3c1e3fb9d52bc2e5 100644 (file)
@@ -141,6 +141,10 @@ public class FoMultiCase extends FONode {
         super(foTree, FObjectNames.MULTI_CASE, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
         stateFlags |= FONode.MC_MULTI_CASE;
+        if (getMarkers() != 0) {
+            throw new FOPException(
+            "fo:marker illegal as child of fo:multi-case");
+        }
         XmlEvent ev = null;
         do {
             try {
index 548f91f42e66c6688b77b6c99266e9017fc19ede..513ea694f050db4becdbe337cb6ad63234f20a82 100644 (file)
@@ -138,34 +138,38 @@ public class FoMultiToggle extends FONode {
         super(foTree, FObjectNames.MULTI_TOGGLE, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
         XmlEvent ev = null;
-        if ((stateFlags & FONode.MC_MULTI_CASE) != 0)
-        do {
-            try {
-                if ((stateFlags & FONode.MC_OUT_OF_LINE) == 0)
-                    ev = xmlevents.expectPcdataOrInlineOrBlock();
-                else
-                    ev = xmlevents.expectOutOfLinePcdataOrInlineOrBlock();
-                if (ev != null) {
-                    // Generate the flow object
-                    //System.out.println("Generating flow object for " + ev);
-                    FObjects.fobjects.makeFlowObject
-                                (foTree, this, ev, stateFlags);
-                    if (ev.getType() != XmlEvent.CHARACTERS) {
-                        ev = xmlevents.getEndElement(
-                                XmlEventReader.DISCARD_EV, ev);
+        if ((stateFlags & FONode.MC_MULTI_CASE) != 0) {
+            do {
+                try {
+                    if ((stateFlags & FONode.MC_OUT_OF_LINE) == 0)
+                        ev = xmlevents.expectPcdataOrInlineOrBlock();
+                    else
+                        ev = xmlevents.expectOutOfLinePcdataOrInlineOrBlock();
+                    if (ev != null) {
+                        // Generate the flow object
+                        FObjects.fobjects.makeFlowObject
+                        (foTree, this, ev, stateFlags);
+                        if (ev.getType() != XmlEvent.CHARACTERS) {
+                            ev = xmlevents.getEndElement(
+                                    XmlEventReader.DISCARD_EV, ev);
+                        }
+                        namespaces.relinquishEvent(ev);
                     }
+                } catch(UnexpectedStartElementException e) {
+                    ev = xmlevents.getStartElement();
+                    MessageHandler.logln
+                    ("Ignoring unexpected Start Element: "
+                            + ev.getQName());
+                    ev = xmlevents.getEndElement(
+                            XmlEventReader.DISCARD_EV, ev);
                     namespaces.relinquishEvent(ev);
                 }
-            } catch(UnexpectedStartElementException e) {
-                ev = xmlevents.getStartElement();
-                MessageHandler.logln
-                        ("Ignoring unexpected Start Element: "
-                                                         + ev.getQName());
-                ev = xmlevents.getEndElement(
-                        XmlEventReader.DISCARD_EV, ev);
-                namespaces.relinquishEvent(ev);
-            }
-        } while (ev != null);
+            } while (ev != null);
+        } else {
+            throw new FOPException(
+                    "fo:multi-toggle only permitted as a descendant of "
+                    + "fo:multi-case");
+        }
 
         makeSparsePropsSet();
     }
index 4680cdd52258f3c96de18fbcfe5644c428dcd032..0f6a25347929496eba7569e6e61f3936ceb986bf 100644 (file)
@@ -130,9 +130,6 @@ public class FoTableAndCaption extends FONode {
         }
     }
 
-    /** The number of markers on this FO. */
-    private int numMarkers = 0;
-
     /** The offset of table-caption within the children. */
     private int captionOffset = -1;
 
@@ -159,18 +156,10 @@ public class FoTableAndCaption extends FONode {
                           stateFlags, sparsePropsMap, sparseIndices);
         XmlEvent ev;
         // Look for zero or more markers
-        String nowProcessing = "marker";
+        // Markers are cleaned up within the <code>getMarkers</code> method
+        getMarkers();
+        String nowProcessing;
         try {
-            while ((ev = xmlevents.expectStartElement
-                    (FObjectNames.MARKER, XmlEvent.DISCARD_W_SPACE))
-                   != null) {
-                new FoMarker(getFOTree(), this, (FoXmlEvent)ev, stateFlags);
-                numMarkers++;
-                ev = xmlevents.getEndElement(
-                        XmlEventReader.DISCARD_EV, ev);
-                namespaces.relinquishEvent(ev);
-            }
-
             // Look for optional table-caption
             nowProcessing = "table-caption";
             if ((ev = xmlevents.expectStartElement
index f02145cd9b35b8c4971283abce8da390cb948a6b..02e186fe995defd43b9da1100f1060aefd031f05 100644 (file)
@@ -125,9 +125,6 @@ public class FoTableBody extends FONode {
         }
     }
 
-    /** The number of markers on this FO. */
-    private int numMarkers = 0;
-
     /** The number of table-rows on this FO. */
     private int numRows = 0;
 
@@ -158,19 +155,11 @@ public class FoTableBody extends FONode {
     {
         super(foTree, FObjectNames.TABLE_BODY, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
-        XmlEvent ev;
         // Look for zero or more markers
-        String nowProcessing = "marker";
+        getMarkers();
+        XmlEvent ev;
+        String nowProcessing;
         try {
-            while ((ev = xmlevents.expectStartElement
-                    (FObjectNames.MARKER, XmlEvent.DISCARD_W_SPACE))
-                   != null) {
-                new FoMarker(getFOTree(), this, (FoXmlEvent)ev, stateFlags);
-                numMarkers++;
-                ev = xmlevents.getEndElement(XmlEventReader.DISCARD_EV, ev);
-                namespaces.relinquishEvent(ev);
-            }
-
             // Look for one or more table-rows
             nowProcessing = "table-row";
             while ((ev = xmlevents.expectStartElement
index 276b05e233220d9430681fb73b20e29cb705cbb6..5eff8dc0c991a401b1515c8d737aa00d786bb3bf 100644 (file)
@@ -145,6 +145,7 @@ public class FoTableCaption extends FONode {
     {
         super(foTree, FObjectNames.TABLE_CAPTION, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         try {
             // Get at least one %block;
index 174e673a66bf3876ed7cac12fdec63da4f772f63..15ec8c899eed02f0d7d09342a5b05697dd6a0c58 100644 (file)
@@ -154,6 +154,7 @@ public class FoTableCell extends FONode {
     {
         super(foTree, FObjectNames.TABLE_CELL, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
+        getMarkers();
         XmlEvent ev = null;
         try {
             // Get at least one %block;
index 54b2fc80d85d86d96b3fe6fe82e55dfe77fe603c..1760c2b3b08bbb9b4d0a7d2443cb03e3855d60a9 100644 (file)
@@ -125,9 +125,6 @@ public class FoTableFooter extends FONode {
         }
     }
 
-    /** The number of markers on this FO. */
-    private int numMarkers = 0;
-
     /** The number of table-rows on this FO. */
     private int numRows = 0;
 
@@ -158,9 +155,10 @@ public class FoTableFooter extends FONode {
     {
         super(foTree, FObjectNames.TABLE_FOOTER, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
-        XmlEvent ev;
         // Look for zero or more markers
-        String nowProcessing = "marker";
+        getMarkers();
+        XmlEvent ev;
+        String nowProcessing;
         try {
             while ((ev = xmlevents.expectStartElement
                     (FObjectNames.MARKER, XmlEvent.DISCARD_W_SPACE))
index ea241347644577075bf1f0042f5181fdbd33216e..6e2c4c6cbe6b18e3ba98a3d18c74b0af98387242 100644 (file)
@@ -125,9 +125,6 @@ public class FoTableHeader extends FONode {
         }
     }
 
-    /** The number of markers on this FO. */
-    private int numMarkers = 0;
-
     /** The number of table-rows on this FO. */
     private int numRows = 0;
 
@@ -158,9 +155,10 @@ public class FoTableHeader extends FONode {
     {
         super(foTree, FObjectNames.TABLE_HEADER, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
-        XmlEvent ev;
         // Look for zero or more markers
-        String nowProcessing = "marker";
+        getMarkers();
+        XmlEvent ev;
+        String nowProcessing;
         try {
             while ((ev = xmlevents.expectStartElement
                     (FObjectNames.MARKER, XmlEvent.DISCARD_W_SPACE))
index efb007dd3c9659c4fcf6cba7d51701668bac0176..4af2e75324985b2961feabc37e65772a2b749ec2 100644 (file)
@@ -155,10 +155,7 @@ public class FoTableRow extends FONode {
         super(foTree, FObjectNames.TABLE_ROW, parent, event,
                           stateFlags, sparsePropsMap, sparseIndices);
         XmlEvent ev;
-        // Look for zero or more markers
-        String nowProcessing = "table-cell";
         try {
-            nowProcessing = "table-cell";
             if ((ev = xmlevents.expectStartElement
                     (FObjectNames.TABLE_CELL, XmlEvent.DISCARD_W_SPACE))
                    != null) {
@@ -174,11 +171,6 @@ public class FoTableRow extends FONode {
                         ("No table-cell in table-row.");
             firstCellOffset = 0;
 
-            /*
-        } catch (NoSuchElementException e) {
-            throw new FOPException
-                ("Unexpected EOF while processing " + nowProcessing + ".");
-            */
         } catch(TreeException e) {
             throw new FOPException("TreeException: " + e.getMessage());
         } catch(PropertyException e) {
index 87180f933d4b779bc2eb3b91e763c8efedf83d38..b03733505704271de4e773941ce5c437e74766da 100644 (file)
@@ -142,6 +142,10 @@ public class FoTitle extends FONode {
     {
         super(foTree, FObjectNames.TITLE, parent, event,
               FONode.TITLE_SET, sparsePropsMap, sparseIndices);
+        if (getMarkers() != 0) {
+            throw new FOPException(
+            "fo:marker illegal as child of fo:title");
+        }
         XmlEvent ev = null;
         do {
             try {