You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2001/01/30 05:50:27 UTC
cvs commit: xml-fop/src/org/apache/fop/render/pdf PDFRenderer.java
keiron 01/01/29 20:50:27
Modified: src/org/apache/fop/fo/flow InstreamForeignObject.java
src/org/apache/fop/layout BlockArea.java LineArea.java
src/org/apache/fop/layout/inline ForeignObjectArea.java
InlineArea.java
src/org/apache/fop/render/pdf PDFRenderer.java
Log:
places svg inline
first part in moving towards proper inline areas
Revision Changes Path
1.8 +24 -8 xml-fop/src/org/apache/fop/fo/flow/InstreamForeignObject.java
Index: InstreamForeignObject.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/InstreamForeignObject.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- InstreamForeignObject.java 2001/01/25 15:05:51 1.7
+++ InstreamForeignObject.java 2001/01/30 04:50:22 1.8
@@ -1,4 +1,4 @@
-/*-- $Id: InstreamForeignObject.java,v 1.7 2001/01/25 15:05:51 eschaeffer Exp $ --
+/*-- $Id: InstreamForeignObject.java,v 1.8 2001/01/30 04:50:22 keiron Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -180,11 +180,11 @@
/* if is embedded in a block area */
if (area instanceof BlockArea) {
/* temporarily end the block area */
- area.end();
+// area.end();
}
if(this.areaCurrent == null) {
this.areaCurrent =
- new ForeignObjectArea(fs, area.getAllocationWidth(), area.spaceLeft());
+ new ForeignObjectArea(fs, area.getAllocationWidth());
this.areaCurrent.start();
areaCurrent.setWidth(this.width);
@@ -234,6 +234,22 @@
}
}
+ if (area instanceof BlockArea) {
+ BlockArea ba = (BlockArea)area;
+ LineArea la = ba.getCurrentLineArea();
+ la.addPending();
+ if(areaCurrent.getEffectiveWidth() > la.getRemainingWidth()) {
+ la = ba.createNextLineArea();
+ if(la == null) {
+ return new Status(Status.AREA_FULL_NONE);
+ }
+ }
+ la.addInlineArea(areaCurrent);
+ } else {
+ area.addChild(areaCurrent);
+ area.increaseHeight(areaCurrent.getEffectiveHeight());
+ }
+
if (this.isInLabel) {
startIndent += bodyIndent;
/* endIndent += (areaCurrent.getEffectiveWidth()
@@ -257,27 +273,27 @@
/* if there is a space-before */
if (spaceBefore != 0) {
/* add a display space */
- area.addDisplaySpace(spaceBefore);
+// area.addDisplaySpace(spaceBefore);
}
/* add the SVG area to the containing area */
- area.addChild(areaCurrent);
+// area.addChild(areaCurrent);
areaCurrent.setPage(area.getPage());
/* increase the height of the containing area accordingly */
- area.increaseHeight(areaCurrent.getEffectiveHeight());
+// area.increaseHeight(areaCurrent.getEffectiveHeight());
/* if there is a space-after */
if (spaceAfter != 0) {
/* add a display space */
- area.addDisplaySpace(spaceAfter);
+// area.addDisplaySpace(spaceAfter);
}
/* if is embedded in a block area */
if (area instanceof BlockArea) {
/* re-start the block area */
- area.start();
+// area.start();
}
if (breakAfter == BreakAfter.PAGE) {
1.23 +2 -1 xml-fop/src/org/apache/fop/layout/BlockArea.java
Index: BlockArea.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/BlockArea.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- BlockArea.java 2001/01/30 00:03:06 1.22
+++ BlockArea.java 2001/01/30 04:50:23 1.23
@@ -1,4 +1,4 @@
-/*-- $Id: BlockArea.java,v 1.22 2001/01/30 00:03:06 keiron Exp $ --
+/*-- $Id: BlockArea.java,v 1.23 2001/01/30 04:50:23 keiron Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -132,6 +132,7 @@
public void addLineArea(LineArea la) {
if (!la.isEmpty()) {
+ la.verticalAlign();
this.addDisplaySpace(this.halfLeading);
int size = la.getHeight();
this.addChild(la);
1.30 +50 -2 xml-fop/src/org/apache/fop/layout/LineArea.java
Index: LineArea.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/LineArea.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- LineArea.java 2001/01/24 00:31:28 1.29
+++ LineArea.java 2001/01/30 04:50:23 1.30
@@ -1,4 +1,4 @@
-/*-- $Id: LineArea.java,v 1.29 2001/01/24 00:31:28 keiron Exp $ --
+/*-- $Id: LineArea.java,v 1.30 2001/01/30 04:50:23 keiron Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -183,6 +183,7 @@
new PageNumberInlineArea(currentFontState, this.red,
this.green, this.blue, refid, width);
+ pia.setYOffset(placementOffset);
pendingAreas.addElement(pia);
pendingWidth += width;
wordWidth = 0;
@@ -293,6 +294,7 @@
this.red, this.green, this.blue,
new String(data, wordStart,
wordLength), wordWidth);
+ ia.setYOffset(placementOffset);
ia.setUnderlined(ul);
addChild(ia);
if (ls != null) {
@@ -411,6 +413,7 @@
this.green, this.blue,
new String(data, wordStart, wordLength), wordWidth);
+ pia.setYOffset(placementOffset);
pia.setUnderlined(ul);
if (ls != null) {
@@ -466,6 +469,7 @@
new LeaderArea(fontState, red, green, blue, "",
leaderLength, leaderPattern, ruleThickness,
ruleStyle);
+ leaderArea.setYOffset(placementOffset);
pendingAreas.addElement(leaderArea);
break;
case LeaderPattern.DOTS:
@@ -507,6 +511,7 @@
new WordArea(currentFontState, this.red,
this.green, this.blue, new String ("."),
this.currentFontState.width(46));
+ leaderPatternArea.setYOffset(placementOffset);
int dotsFactor = (int) Math.floor (
((double) leaderLength) /
((double) leaderPatternWidth));
@@ -611,6 +616,32 @@
}
}
+ /**
+ * Balance (vertically) the inline areas within this line.
+ */
+ public void verticalAlign()
+ {
+ int superHeight = -this.placementOffset;
+ int maxHeight = this.allocationHeight;
+ Enumeration e = children.elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box) e.nextElement();
+ if(b instanceof InlineArea) {
+ InlineArea ia = (InlineArea)b;
+ if(ia.getHeight() > maxHeight) {
+ maxHeight = ia.getHeight();
+ }
+ int vert = ia.getVerticalAlign();
+/* if(vert == VerticalAlign.SUPER) {
+ int tbe = fontState.getAscender();
+ ia.setYOffset(placementOffset - (tbe - h));
+ }*/
+ } else {
+ }
+ }
+ this.allocationHeight = maxHeight;
+ }
+
public void changeColor(float red, float green, float blue) {
this.red = red;
this.green = green;
@@ -646,7 +677,8 @@
}
public boolean isEmpty() {
- return (prev == 0);
+ return !(pendingAreas.size() > 0 || children.size() > 0);
+// return (prev == 0);
}
public Vector getPendingAreas() {
@@ -700,6 +732,7 @@
WordArea leaderPatternArea =
new WordArea(currentFontState, this.red, this.green,
this.blue, new String (leaderChars), leaderLength);
+ leaderPatternArea.setYOffset(placementOffset);
return leaderPatternArea;
}
@@ -858,6 +891,18 @@
return width;
}
+ public int getRemainingWidth()
+ {
+ return this.getContentWidth() - this.getCurrentXPosition();
+ }
+
+ public void addInlineArea(Area box)
+ {
+ addPending();
+ addChild(box);
+ prev = TEXT;
+ finalWidth += box.getContentWidth();
+ }
/** adds a single character to the line area tree*/
public int addCharacter (char data, LinkSet ls, boolean ul) {
@@ -877,6 +922,7 @@
ia = new WordArea(currentFontState,
this.red, this.green, this.blue,
new Character(data).toString(),width);
+ ia.setYOffset(placementOffset);
ia.setUnderlined(ul);
pendingAreas.addElement(ia);
if (Character.isSpaceChar(data)) {
@@ -902,12 +948,14 @@
hia = new WordArea(currentFontState,
this.red, this.green, this.blue,
new Character(startChar).toString(),1);
+ hia.setYOffset(placementOffset);
this.addChild(hia);
}
int wordWidth = this.getWordWidth(word);
hia = new WordArea(currentFontState,
this.red, this.green, this.blue,
word,word.length());
+ hia.setYOffset(placementOffset);
this.addChild(hia);
//calculate the space needed
1.2 +23 -8 xml-fop/src/org/apache/fop/layout/inline/ForeignObjectArea.java
Index: ForeignObjectArea.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/inline/ForeignObjectArea.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ForeignObjectArea.java 2001/01/24 00:35:39 1.1
+++ ForeignObjectArea.java 2001/01/30 04:50:24 1.2
@@ -1,4 +1,4 @@
-/*-- $Id: ForeignObjectArea.java,v 1.1 2001/01/24 00:35:39 keiron Exp $ --
+/*-- $Id: ForeignObjectArea.java,v 1.2 2001/01/30 04:50:24 keiron Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -58,8 +58,8 @@
import java.util.Vector;
import java.util.Enumeration;
-public class ForeignObjectArea extends Area {
-
+public class ForeignObjectArea extends InlineArea {
+
protected int xOffset = 0;
/* text-align of contents */
protected int align;
@@ -78,22 +78,37 @@
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) {
- super(fontState, width, height);
+ public ForeignObjectArea(FontState fontState, int width) {
+ super(fontState, width, 0, 0, 0);
}
public void render(Renderer renderer) {
if(foreignObject != null)
renderer.renderForeignObjectArea(this);
+ }
+
+ /**
+ * This is NOT the content width of the instream-foreign-object.
+ * This is the content width for a Box.
+ */
+ public int getContentWidth()
+ {
+ return getEffectiveWidth();
+ }
+
+ /**
+ * This is NOT the content height of the instream-foreign-object.
+ * This is the content height for a Box.
+ */
+ public int getHeight()
+ {
+ return getEffectiveHeight();
}
public int getXOffset()
1.3 +2 -2 xml-fop/src/org/apache/fop/layout/inline/InlineArea.java
Index: InlineArea.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/inline/InlineArea.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InlineArea.java 2001/01/24 22:48:51 1.2
+++ InlineArea.java 2001/01/30 04:50:25 1.3
@@ -1,4 +1,4 @@
-/*-- $Id: InlineArea.java,v 1.2 2001/01/24 22:48:51 keiron Exp $ --
+/*-- $Id: InlineArea.java,v 1.3 2001/01/30 04:50:25 keiron Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -58,7 +58,7 @@
public abstract class InlineArea extends Area {
private int yOffset = 0;
- private int height = 0;
+ protected int height = 0;
private int verticalAlign = 0;
protected String pageNumberId = null;
private float red, green, blue;
1.47 +8 -3 xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java
Index: PDFRenderer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- PDFRenderer.java 2001/01/24 00:31:33 1.46
+++ PDFRenderer.java 2001/01/30 04:50:26 1.47
@@ -1,4 +1,4 @@
-/*-- $Id: PDFRenderer.java,v 1.46 2001/01/24 00:31:33 keiron Exp $ --
+/*-- $Id: PDFRenderer.java,v 1.47 2001/01/30 04:50:26 keiron Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -516,7 +516,7 @@
currentStream.add("Q\n");
currentStream.add("BT\n");
this.currentXPosition += area.getEffectiveWidth();
- this.currentYPosition -= area.getEffectiveHeight();
+// this.currentYPosition -= area.getEffectiveHeight();
}
/**
@@ -669,7 +669,12 @@
Enumeration e = area.getChildren().elements();
while (e.hasMoreElements()) {
Box b = (Box) e.nextElement();
- this.currentYPosition = ry - area.getPlacementOffset();
+ if(b instanceof InlineArea) {
+ InlineArea ia = (InlineArea)b;
+ this.currentYPosition = ry - ia.getYOffset();
+ } else {
+ this.currentYPosition = ry - area.getPlacementOffset();
+ }
b.render(this);
}