aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2000-08-10 06:46:54 +0000
committerKeiron Liddle <keiron@apache.org>2000-08-10 06:46:54 +0000
commit11fae5f8d1b29d3ef2ebeba5eb123f5f577d4dd4 (patch)
treef769080fee95753be84d9350a38bc9bc5efd2b53 /src/org
parent80cdbad0cd86d16bad8415d166b765deae88fb85 (diff)
downloadxmlgraphics-fop-11fae5f8d1b29d3ef2ebeba5eb123f5f577d4dd4.tar.gz
xmlgraphics-fop-11fae5f8d1b29d3ef2ebeba5eb123f5f577d4dd4.zip
added better size handling
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193625 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r--src/org/apache/fop/fo/flow/InstreamForeignObject.java40
-rw-r--r--src/org/apache/fop/layout/ForeignObjectArea.java165
-rw-r--r--src/org/apache/fop/svg/SVG.java10
3 files changed, 190 insertions, 25 deletions
diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java
index bad9ed132..ed92b6628 100644
--- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java
+++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java
@@ -94,6 +94,7 @@ public class InstreamForeignObject extends FObj {
FontState fs;
int breakBefore;
int breakAfter;
+ int scaling;
int width;
int height;
int contwidth;
@@ -105,7 +106,7 @@ public class InstreamForeignObject extends FObj {
int spaceBefore;
int spaceAfter;
- Area areaCurrent;
+ ForeignObjectArea areaCurrent;
/**
* constructs an instream-foreign-object object (called by Maker).
@@ -138,6 +139,9 @@ public class InstreamForeignObject extends FObj {
String fontStyle = this.properties.get("font-style").getString();
String fontWeight = this.properties.get("font-weight").getString();
int fontSize = this.properties.get("font-size").getLength().mvalue();
+ int align = this.properties.get("text-align").getEnum();
+ int valign = this.properties.get("vertical-align").getEnum();
+ int overflow = this.properties.get("overflow").getEnum();
this.fs = new FontState(area.getFontInfo(), fontFamily,
fontStyle, fontWeight, fontSize);
@@ -158,6 +162,8 @@ public class InstreamForeignObject extends FObj {
this.spaceAfter =
this.properties.get("space-after.optimum").getLength().mvalue();
+ this.scaling = this.properties.get("scaling").getEnum();
+
area.getIDReferences().createID(id);
/* if is embedded in a block area */
if (area instanceof BlockArea) {
@@ -166,18 +172,28 @@ public class InstreamForeignObject extends FObj {
}
if(this.areaCurrent == null) {
this.areaCurrent =
- new ForeignObjectArea(fs, area.getAllocationWidth(),
- area.spaceLeft(), 0);
+ new ForeignObjectArea(fs, area.getAllocationWidth(), area.spaceLeft());
this.areaCurrent.start();
+ areaCurrent.setWidth(this.width);
+ areaCurrent.setHeight(this.height);
+ areaCurrent.setContentWidth(this.contwidth);
+ areaCurrent.setContentHeight(this.contheight);
+ areaCurrent.setScaling(this.scaling);
+ areaCurrent.setAlign(align);
+ areaCurrent.setVerticalAlign(valign);
+ areaCurrent.setOverflow(overflow);
+ areaCurrent.setSizeAuto(wauto, hauto);
+ areaCurrent.setContentSizeAuto(cwauto, chauto);
+
+ // this means that children can get the fontstate
areaCurrent.setPage(area.getPage());
- /* iterate over the child formatting objects and lay them out
- into the SVG area */
int numChildren = this.children.size();
if(numChildren > 1) {
throw new FOPException("Only one child element is allowed in an instream-foreign-object");
}
+ /* layout foreign object */
if(this.children.size() > 0) {
FONode fo = (FONode) children.elementAt(0);
Status status;
@@ -193,14 +209,8 @@ public class InstreamForeignObject extends FObj {
this.marker = 0;
- if(this.hauto) {
- if (breakBefore == BreakBefore.PAGE || ((spaceBefore + areaCurrent.getHeight()) > area.spaceLeft())) {
- return new Status(Status.FORCE_PAGE_BREAK);
- }
- } else {
- if (breakBefore == BreakBefore.PAGE || (this.height > area.spaceLeft())) {
- return new Status(Status.FORCE_PAGE_BREAK);
- }
+ if (breakBefore == BreakBefore.PAGE || ((spaceBefore + areaCurrent.getEffectiveHeight()) > area.spaceLeft())) {
+ return new Status(Status.FORCE_PAGE_BREAK);
}
if (breakBefore == BreakBefore.ODD_PAGE) {
@@ -222,11 +232,9 @@ public class InstreamForeignObject extends FObj {
area.addChild(areaCurrent);
areaCurrent.setPage(area.getPage());
- /* layout foreign object */
-// svg.start();
/* increase the height of the containing area accordingly */
- area.increaseHeight(areaCurrent.getHeight());
+ area.increaseHeight(areaCurrent.getEffectiveHeight());
/* if there is a space-after */
if (spaceAfter != 0) {
diff --git a/src/org/apache/fop/layout/ForeignObjectArea.java b/src/org/apache/fop/layout/ForeignObjectArea.java
index da61c76da..cdb1e47de 100644
--- a/src/org/apache/fop/layout/ForeignObjectArea.java
+++ b/src/org/apache/fop/layout/ForeignObjectArea.java
@@ -59,15 +59,34 @@ import java.util.Enumeration;
public class ForeignObjectArea extends Area {
- /* text-align of all but the last line */
+ /* text-align of contents */
protected int align;
+ /* vertical align of contents */
+ protected int valign;
+ /* scaling method */
+ protected int scaling;
protected Area foreignObject;
+ /* height according to the instream-foreign-object */
+ protected int cheight;
+ /* width according to the instream-foreign-object */
+ protected int cwidth;
+ /* width of the content */
+ protected int awidth;
+ /* height of the content */
+ protected int aheight;
+ /* width */
+ protected int width;
+ /* height */
+ protected int height;
+ boolean wauto;
+ boolean hauto;
+ boolean cwauto;
+ boolean chauto;
+ int overflow;
public ForeignObjectArea(FontState fontState, int width,
- int height, int align) {
+ int height) {
super(fontState, width, height);
-
- this.align = align;
}
public void render(Renderer renderer) {
@@ -82,4 +101,142 @@ public class ForeignObjectArea extends Area {
public Area getObject() {
return foreignObject;
}
+
+ public void setSizeAuto(boolean wa, boolean ha)
+ {
+ wauto = wa;
+ hauto = ha;
+ }
+
+ public void setContentSizeAuto(boolean wa, boolean ha)
+ {
+ cwauto = wa;
+ chauto = ha;
+ }
+
+ 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 setOverflow(int o)
+ {
+ this.overflow = o;
+ }
+
+ public int getOverflow()
+ {
+ return this.overflow;
+ }
+
+ public void setHeight(int height)
+ {
+ this.height = height;
+ }
+
+ public void setWidth(int width)
+ {
+ this.width = width;
+ }
+
+ public void setContentHeight(int cheight)
+ {
+ this.cheight = cheight;
+ }
+
+ public void setContentWidth(int cwidth)
+ {
+ this.cwidth = cwidth;
+ }
+
+ public void setScaling(int scaling)
+ {
+ this.scaling = scaling;
+ }
+
+ public int scalingMethod()
+ {
+ return this.scaling;
+ }
+
+ public void setIntrinsicWidth(int w)
+ {
+ awidth = w;
+ }
+
+ public void setIntrinsicHeight(int h)
+ {
+ aheight = h;
+ }
+
+ public int getIntrinsicHeight()
+ {
+ return aheight;
+ }
+
+ public int getIntrinsicWidth()
+ {
+ return awidth;
+ }
+
+ public int getEffectiveHeight()
+ {
+ if(this.hauto) {
+ if(this.chauto) {
+ return aheight;
+ } else {
+ // need to handle percentages, this would be a scaling factor on the
+ // instrinsic height (content determined height)
+ // if(this.properties.get("content-height").getLength().isPercentage()) {
+ // switch(scaling) {
+ // case Scaling.UNIFORM:
+ // break;
+ // case Scaling.NON_UNIFORM:
+ // break;
+ // }
+ // } else {
+ return this.cheight;
+ }
+ } else {
+ return this.height;
+ }
+ }
+
+ public int getEffectiveWidth()
+ {
+ if(this.wauto) {
+ if(this.cwauto) {
+ return awidth;
+ } else {
+ // need to handle percentages, this would be a scaling factor on the
+ // instrinsic height (content determined height)
+ // if(this.properties.get("content-width").getLength().isPercentage()) {
+ // switch(scaling) {
+ // case Scaling.UNIFORM:
+ // break;
+ // case Scaling.NON_UNIFORM:
+ // break;
+ // }
+ // } else {
+ return this.cwidth;
+ }
+ } else {
+ return this.width;
+ }
+ }
}
diff --git a/src/org/apache/fop/svg/SVG.java b/src/org/apache/fop/svg/SVG.java
index 9c2959224..660af2647 100644
--- a/src/org/apache/fop/svg/SVG.java
+++ b/src/org/apache/fop/svg/SVG.java
@@ -194,13 +194,17 @@ public class SVG extends FObj implements GraphicsCreator {
}
/* create an SVG area */
+ /* if width and height are zero, may want to get the bounds of the content. */
SVGArea svg = new SVGArea(fs, width, height);
svg.setStyle(((SVGStyle)this.properties.get("style")).getStyle());
svg.setTransform(((SVGTransform)this.properties.get("transform")).oldgetTransform());
svg.start();
/* add the SVG area to the containing area */
- ((ForeignObjectArea)area).setObject(svg);
+ ForeignObjectArea foa = (ForeignObjectArea)area;
+ foa.setObject(svg);
+ foa.setIntrinsicWidth(svg.getWidth());
+ foa.setIntrinsicHeight(svg.getHeight());
/* iterate over the child formatting objects and lay them out
into the SVG area */
@@ -216,10 +220,6 @@ public class SVG extends FObj implements GraphicsCreator {
/* finish off the SVG area */
svg.end();
- /* increase the height of the containing area accordingly */
- area.increaseHeight(svg.getHeight());
-// area.setWidth(svg.getWidth());
-
/* return status */
return new Status(Status.OK);
}