]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
moved code out of block area -> char and pag num
authorKeiron Liddle <keiron@apache.org>
Tue, 30 Jan 2001 00:03:06 +0000 (00:03 +0000)
committerKeiron Liddle <keiron@apache.org>
Tue, 30 Jan 2001 00:03:06 +0000 (00:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193990 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/flow/Character.java
src/org/apache/fop/fo/flow/PageNumberCitation.java
src/org/apache/fop/layout/BlockArea.java

index cefc59626dffa280eb5212a828531469846be097..c7168cbc8e89766f367a2ba8deacb6d6ebbecb3e 100644 (file)
@@ -60,6 +60,7 @@ import org.apache.fop.layout.Area;
 import org.apache.fop.layout.inline.InlineArea;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.layout.FontState;
+import org.apache.fop.layout.LineArea;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.messaging.MessageHandler;
 
@@ -81,7 +82,6 @@ public class Character  extends FObj {
                public final static int OK = 0;
                public final static int DOESNOT_FIT = 1;
 
-
                public Character(FObj parent, PropertyList propertyList) {
                                super(parent, propertyList);
                                this.name = "fo:character";
@@ -143,10 +143,27 @@ public class Character  extends FObj {
                                // initialize id
                                String id = this.properties.get("id").getString();
                                blockArea.getIDReferences().initializeID(id, blockArea);
-                               blockArea.addCharacter(fontstate,red,green,blue,wrapOption,this.getLinkSet(),
-                                                                                                                        whiteSpaceCollapse,characterValue,textDecoration);
-                               return new Status(Status.OK);
 
+        LineArea la = blockArea.getCurrentLineArea();
+        la.changeFont(fontstate);
+        la.changeColor(red, green, blue);
+        la.changeWrapOption(wrapOption);
+        la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
+        blockArea.setupLinkSet(this.getLinkSet());
+        int result = la.addCharacter(characterValue, this.getLinkSet(), textDecoration);
+        if (result == Character.DOESNOT_FIT) {
+            la = blockArea.createNextLineArea();
+            if(la == null) {
+                return new Status(Status.AREA_FULL_NONE);
+            }
+            la.changeFont(fontstate);
+            la.changeColor(red, green, blue);
+            la.changeWrapOption(wrapOption);
+            la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
+            blockArea.setupLinkSet(this.getLinkSet());
+            la.addCharacter(characterValue, this.getLinkSet(), textDecoration);
+        }
+                               return new Status(Status.OK);
 
                }
 
index ce339c67503002733c5e0b03441c0e52e77d03d2..16e979526c3b40af27340e259830c2d68203a142 100644 (file)
@@ -206,9 +206,19 @@ public class PageNumberCitation extends FObj {
                                                                                                        pageNumber.toCharArray(), 0, pageNumber.length(),
                                                                                                        false);
                                } else { // add pageNumberCitation to area to be resolved during rendering
-                                               this.marker = ((BlockArea) area).addPageNumberCitation(fs, red,
-                                                                                                       green, blue, wrapOption, null, whiteSpaceCollapse,
-                                                                                                       refId);
+            BlockArea blockArea = (BlockArea)area;
+            LineArea la = blockArea.getCurrentLineArea();
+            la.changeFont(fs);
+            la.changeColor(red, green, blue);
+            la.changeWrapOption(wrapOption);
+            la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
+/*            la.changeHyphenation(language, country, hyphenate,
+                                                                        hyphenationChar, hyphenationPushCharacterCount,
+                                                                        hyphenationRemainCharacterCount);*/
+
+//            blockArea.setupLinkSet(null);
+            la.addPageNumberCitation(refId, null);
+            this.marker = -1;
                                }
 
 
index e114cee5268e6e0754adf331958aca0497057a69..e36dbc4c2472b4a48d086012bde4e6890f1f5849 100644 (file)
@@ -62,6 +62,16 @@ import java.util.Vector;
 import java.util.Enumeration;
 import org.apache.fop.messaging.MessageHandler;
 
+/**
+ * This class represents a Block Area.
+ * A block area is made up of a sequence of Line Areas.
+ *
+ * This class is used to organise the sequence of line areas as
+ * inline areas are added to this block it creates and ands line areas
+ * to hold the inline areas.
+ * This uses the line-height and line-stacking-strategy to work
+ * out how to stack the lines.
+ */
 public class BlockArea extends Area {
 
                /* relative to area container */
@@ -141,31 +151,6 @@ public class BlockArea extends Area {
                                }
                }
 
-               public int addPageNumberCitation(FontState fontState, float red,
-                                                                                                                                                float green, float blue, int wrapOption, LinkSet ls,
-                                                                                                                                                int whiteSpaceCollapse, String refid) {
-
-                               this.currentLineArea.changeFont(fontState);
-                               this.currentLineArea.changeColor(red, green, blue);
-                               this.currentLineArea.changeWrapOption(wrapOption);
-                               this.currentLineArea.changeWhiteSpaceCollapse(whiteSpaceCollapse);
-                               this.currentLineArea.changeHyphenation(language, country, hyphenate,
-                                                                                                                                hyphenationChar, hyphenationPushCharacterCount,
-                                                                                                                                hyphenationRemainCharacterCount);
-
-
-                               if (ls != null) {
-                                               this.currentLinkSet = ls;
-                                               ls.setYOffset(currentHeight);
-                               }
-
-                               this.currentLineArea.addPageNumberCitation(refid, ls);
-                               this.hasLines = true;
-
-                               return -1;
-
-               }
-
                // font-variant support : addText is a wrapper for addRealText
                // added by Eric SCHAEFFER
                public int addText(FontState fontState, float red, float green,
@@ -359,45 +344,36 @@ public class BlockArea extends Area {
                                return 1;
                }
 
-               public void addCharacter(FontState fontState, float red, float green,
-                                                                                        float blue, int wrapOption, LinkSet ls,
-                                                                                        int whiteSpaceCollapse, char data, boolean ul) {
+    public LineArea getCurrentLineArea()
+    {
+        return this.currentLineArea;
+    }
 
-                               this.currentLineArea.changeFont(fontState);
-                               this.currentLineArea.changeColor(red, green, blue);
-                               this.currentLineArea.changeWrapOption(wrapOption);
-                               this.currentLineArea.changeWhiteSpaceCollapse(whiteSpaceCollapse);
-
-                               if (ls != null) {
-                                               this.currentLinkSet = ls;
-                                               ls.setYOffset(currentHeight);
-                               }
-
-                               int marker = this.currentLineArea.addCharacter(data, ls, ul);
-                               //if character didn't fit into line, open a new one
-                               if (marker == org.apache.fop.fo.flow.Character.DOESNOT_FIT) {
+    public LineArea createNextLineArea()
+    {
+                               if (this.hasLines) {
+                                               this.currentLineArea.addPending();
                                                this.currentLineArea.align(this.align);
+//                                             this.currentLineArea.verticalAlign();
                                                this.addLineArea(this.currentLineArea);
-
+                               }
                                                this.currentLineArea =
                                                        new LineArea(fontState, lineHeight, halfLeading,
                                                                                                         allocationWidth, startIndent, endIndent,
                                                                                                         currentLineArea);
-                                               this.currentLineArea.changeFont(fontState);
-                                               this.currentLineArea.changeColor(red, green, blue);
-                                               this.currentLineArea.changeWrapOption(wrapOption);
-                                               this.currentLineArea.changeWhiteSpaceCollapse(
-                                                       whiteSpaceCollapse);
+                               if (currentHeight + lineHeight > maxHeight) {
+                                               return null;
+                               }
+        return this.currentLineArea;
+    }
+
+    public void setupLinkSet(LinkSet ls)
+    {
                                                if (ls != null) {
                                                                this.currentLinkSet = ls;
                                                                ls.setYOffset(currentHeight);
                                                }
-
-                                               this.currentLineArea.addCharacter(data, ls, ul);
-                               }
-                               this.hasLines = true;
-               }
-
+    }
 
                public void end() {
                                if (this.hasLines) {