]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
SGK/AHS: inling of images
authorarved <arved@unknown>
Sun, 10 Jun 2001 17:02:41 +0000 (17:02 +0000)
committerarved <arved@unknown>
Sun, 10 Jun 2001 17:02:41 +0000 (17:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194285 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/flow/ExternalGraphic.java
src/org/apache/fop/image/ImageArea.java

index 46c6be514e7f6a2d6f1624c1eb545e7ad6aea33d..d828a5d06e934229de5528eb60c4b2f5eb870af4 100644 (file)
@@ -44,9 +44,7 @@ package org.apache.fop.fo.flow;
 import org.apache.fop.fo.*;
 import org.apache.fop.messaging.MessageHandler;
 import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.Area;
-import org.apache.fop.layout.BlockArea;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.layout.*;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.image.*;
 
@@ -58,6 +56,8 @@ import java.net.MalformedURLException;
 
 public class ExternalGraphic extends FObj {
 
+       int breakAfter;
+       int breakBefore;
        int align;
        int startIndent;
        int endIndent;
@@ -103,7 +103,7 @@ public class ExternalGraphic extends FObj {
                        this.id = this.properties.get("id").getString();
 
                        area.getIDReferences().createID(id);
-
+/*
                        if (area instanceof BlockArea) {
                                area.end();
                        }
@@ -114,6 +114,7 @@ public class ExternalGraphic extends FObj {
                                                forcedStartOffset;
                        }
 
+*/
                        this.marker = 0;
                }
 
@@ -172,13 +173,64 @@ public class ExternalGraphic extends FObj {
 
                        imageArea.start();
                        imageArea.end();
-                       area.addChild(imageArea);
-                       area.increaseHeight(imageArea.getHeight());
+                       //area.addChild(imageArea);
+                       //area.increaseHeight(imageArea.getHeight());
 
                        if (spaceAfter != 0) {
                                area.addDisplaySpace(spaceAfter);
+                       }
+                         if (breakBefore == BreakBefore.PAGE || ((spaceBefore + imageArea.getHeight()) > area.spaceLeft()))                            {
+                               return new Status(Status.FORCE_PAGE_BREAK);
+                               }
+
+                       if (breakBefore == BreakBefore.ODD_PAGE) {
+                       return new Status(Status.FORCE_PAGE_BREAK_ODD);
                        }
 
+                       if (breakBefore == BreakBefore.EVEN_PAGE) {
+                       return new Status(Status.FORCE_PAGE_BREAK_EVEN);
+                       }
+       
+
+                       if (area instanceof BlockArea) {
+                           BlockArea ba = (BlockArea)area;
+                           LineArea la = ba.getCurrentLineArea();
+                           if(la == null) {
+                               return new Status(Status.AREA_FULL_NONE);
+                            }
+                           la.addPending();
+                           if(imageArea.getContentWidth() > la.getRemainingWidth()) {
+                               la = ba.createNextLineArea();
+                               if(la == null) {
+                               return new Status(Status.AREA_FULL_NONE);
+                            }
+                       }
+                       la.addInlineArea(imageArea);
+                       } else {
+                           area.addChild(imageArea);
+                           area.increaseHeight(imageArea.getContentHeight());
+                       }
+                       imageArea.setPage(area.getPage());
+
+                       if (breakAfter == BreakAfter.PAGE) {
+                               this.marker = BREAK_AFTER;
+                               return new Status(Status.FORCE_PAGE_BREAK);
+                       }
+
+                       if (breakAfter == BreakAfter.ODD_PAGE) {
+                               this.marker = BREAK_AFTER;
+                               return new Status(Status.FORCE_PAGE_BREAK_ODD);
+                       }
+
+                       if (breakAfter == BreakAfter.EVEN_PAGE) {
+                               this.marker = BREAK_AFTER;
+                               return new Status(Status.FORCE_PAGE_BREAK_EVEN);
+                       }
+
+
+
+
+
                }
                catch (MalformedURLException urlex) {
                        // bad URL
@@ -191,9 +243,9 @@ public class ExternalGraphic extends FObj {
                                        imgex.getMessage());
                }
 
-               if (area instanceof BlockArea) {
-                       area.start();
-               }
+               //if (area instanceof BlockArea) {
+               //      area.start();
+               //}
 
                return new Status(Status.OK);
        }
index 65c512861fd241a986bae04e81a6d7fec1c624d6..e09afced7e3e053fff92706435372f5855fa7734 100644 (file)
@@ -54,24 +54,32 @@ package org.apache.fop.image;
 
 import org.apache.fop.fo.properties.TextAlign;
 import org.apache.fop.layout.*;
+import org.apache.fop.layout.inline.*;
+
 import org.apache.fop.render.Renderer;
 
 import java.util.Vector;
 import java.util.Enumeration;
 
-public class ImageArea extends Area {
+public class ImageArea extends InlineArea {
 
     protected int xOffset = 0;
+    protected int align;
+    protected int valign;
     protected FopImage image;
+    
 
     public ImageArea(FontState fontState, FopImage img,
                     int AllocationWidth, int width, int height,
                     int startIndent, int endIndent, int align)  {
-       super(fontState,width,height);
+       super(fontState,width,0,0,0);
        this.currentHeight = height;
        this.contentRectangleWidth = width;
+       this.height = height;
        this.image = img;
+       this.align = align;
 
+/*
        switch (align) {
        case TextAlign.START:
            xOffset = startIndent;
@@ -90,6 +98,7 @@ public class ImageArea extends Area {
            xOffset = startIndent + ((endIndent - startIndent) - width)/2;
            break;
        }
+       */
     }
 
     public int getXOffset() {
@@ -107,4 +116,34 @@ public class ImageArea extends Area {
     public int getImageHeight() {
        return currentHeight;
     }
+               
+    public void setAlign(int align)
+    {
+               this.align = align;
+       }
+
+    public int getAlign()
+    {
+               return this.align;
+       }
+
+    public void setVerticalAlign(int align)
+    {
+               this.valign = align;
+       }
+
+    public int getVerticalAlign()
+    {
+               return this.valign;
+       }
+
+ public void setStartIndent(int startIndent)
+   {
+    xOffset = startIndent;
+   }
+
+
+
 }
+
+