keiron 02/03/21 01:37:15
Modified: src/org/apache/fop/fo FOText.java FOUserAgent.java
FObjMixed.java
src/org/apache/fop/fo/flow Block.java
InstreamForeignObject.java
src/org/apache/fop/image ImageLoader.java
src/org/apache/fop/image/analyser SVGReader.java
XMLReader.java
src/org/apache/fop/layoutmgr AbstractLayoutManager.java
BlockLayoutManager.java LayoutManager.java
LineLayoutManager.java PageLayoutManager.java
TextLayoutManager.java
src/org/apache/fop/render RendererContext.java
src/org/apache/fop/render/pdf PDFXMLHandler.java
Added: src/org/apache/fop/fo TextInfo.java
Log:
a simple impl of getting ipd and line height
some adjustments to user agent
Revision Changes Path
1.31 +1 -17 xml-fop/src/org/apache/fop/fo/FOText.java
Index: FOText.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FOText.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- FOText.java 8 Mar 2002 15:41:47 -0000 1.30
+++ FOText.java 21 Mar 2002 09:37:14 -0000 1.31
@@ -1,5 +1,5 @@
/*
- * $Id: FOText.java,v 1.30 2002/03/08 15:41:47 keiron Exp $
+ * $Id: FOText.java,v 1.31 2002/03/21 09:37:14 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources."
@@ -35,22 +35,6 @@
protected int start;
protected int length;
TextInfo textInfo;
-
- public static class TextInfo {
- public FontState fs;
- public float red;
- public float green;
- public float blue;
- public int wrapOption;
- public int whiteSpaceCollapse;
- public int verticalAlign;
-
- // Textdecoration
- public boolean underlined = false;
- public boolean overlined = false;
- public boolean lineThrough = false;
- }
-
TextState ts;
public FOText(char[] chars, int s, int e, TextInfo ti) {
1.7 +16 -4 xml-fop/src/org/apache/fop/fo/FOUserAgent.java
Index: FOUserAgent.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FOUserAgent.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FOUserAgent.java 22 Feb 2002 09:18:47 -0000 1.6
+++ FOUserAgent.java 21 Mar 2002 09:37:14 -0000 1.7
@@ -1,5 +1,5 @@
/*
- * $Id: FOUserAgent.java,v 1.6 2002/02/22 09:18:47 keiron Exp $
+ * $Id: FOUserAgent.java,v 1.7 2002/03/21 09:37:14 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -44,14 +44,25 @@
return log;
}
- public void setBaseDirectory(String b) {
+ public void setBaseURL(String b) {
base = b;
}
- public String getBaseDirectory() {
+ public String getBaseURL() {
return base;
}
+ public float getPixelToMM() {
+ return 0.35277777777777777778f;
+ }
+
+ /**
+ * If to create hot links to footnotes and before floats.
+ */
+ public boolean linkToFootnotes() {
+ return true;
+ }
+
/**
* Set the default xml handler for the given mime type.
*/
@@ -92,10 +103,11 @@
handler.handleXML(ctx, doc, namespace);
} catch (Throwable t) {
// could not handle document
- ctx.getLogger().error("Could not render XML", t);
+ log.error("Could not render XML", t);
}
} else {
// no handler found for document
+ log.debug("No handler defined for XML: " + namespace);
}
}
}
1.19 +4 -8 xml-fop/src/org/apache/fop/fo/FObjMixed.java
Index: FObjMixed.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FObjMixed.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- FObjMixed.java 21 Nov 2001 22:13:36 -0000 1.18
+++ FObjMixed.java 21 Mar 2002 09:37:14 -0000 1.19
@@ -1,5 +1,5 @@
/*
- * $Id: FObjMixed.java,v 1.18 2001/11/21 22:13:36 klease Exp $
+ * $Id: FObjMixed.java,v 1.19 2002/03/21 09:37:14 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -20,7 +20,7 @@
* and their processing
*/
public class FObjMixed extends FObj {
- FOText.TextInfo textInfo = null;
+ TextInfo textInfo = null;
FontInfo fontInfo=null;
public FObjMixed(FONode parent) {
@@ -33,7 +33,7 @@
protected void addCharacters(char data[], int start, int length) {
if(textInfo == null) {
- textInfo = new FOText.TextInfo();
+ textInfo = new TextInfo();
try {
textInfo.fs = propMgr.getFontState(fontInfo);
@@ -43,9 +43,7 @@
}
ColorType c = getProperty("color").getColorType();
- textInfo.red = c.red();
- textInfo.green = c.green();
- textInfo.blue = c.blue();
+ textInfo.color = c;
textInfo.verticalAlign =
getProperty("vertical-align").getEnum();
@@ -97,8 +95,6 @@
public CharIterator charIterator() {
return new RecursiveCharIterator(this);
}
-
-
}
1.1 xml-fop/src/org/apache/fop/fo/TextInfo.java
Index: TextInfo.java
===================================================================
/*
* $Id: TextInfo.java,v 1.1 2002/03/21 09:37:14 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources."
*/
package org.apache.fop.fo;
// FOP
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.datatypes.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.apps.FOPException;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.TextLayoutManager;
import java.util.NoSuchElementException;
/**
*/
public class TextInfo {
public FontState fs;
public ColorType color;
public int wrapOption;
public int whiteSpaceCollapse;
public int verticalAlign;
// Textdecoration
public boolean underlined = false;
public boolean overlined = false;
public boolean lineThrough = false;
}
1.50 +19 -4 xml-fop/src/org/apache/fop/fo/flow/Block.java
Index: Block.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Block.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- Block.java 25 Feb 2002 21:28:01 -0000 1.49
+++ Block.java 21 Mar 2002 09:37:14 -0000 1.50
@@ -1,5 +1,5 @@
/*
- * $Id: Block.java,v 1.49 2002/02/25 21:28:01 klease Exp $
+ * $Id: Block.java,v 1.50 2002/03/21 09:37:14 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -367,14 +367,29 @@
}
public LayoutManager getLayoutManager() {
- return new BlockLayoutManager(this);
- }
+BlockLayoutManager blm = new BlockLayoutManager(this);
+TextInfo ti = new TextInfo();
+
+/* try {
+ ti.fs = propMgr.getFontState(fontInfo);
+ } catch (FOPException fopex) {
+ log.error("Error setting FontState for characters: " +
+ fopex.getMessage());
+ }*/
+
+ ColorType c = getProperty("color").getColorType();
+ ti.color = c;
+ ti.verticalAlign =
+ getProperty("vertical-align").getEnum();
+
+blm.setBlockTextInfo(ti);
+ return blm;
+ }
public boolean generatesInlineAreas() {
return false;
}
-
public void addChild(FONode child) {
// Handle whitespace based on values of properties
1.23 +5 -1 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.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- InstreamForeignObject.java 5 Mar 2002 10:25:39 -0000 1.22
+++ InstreamForeignObject.java 21 Mar 2002 09:37:15 -0000 1.23
@@ -1,5 +1,5 @@
/*
- * $Id: InstreamForeignObject.java,v 1.22 2002/03/05 10:25:39 keiron Exp $
+ * $Id: InstreamForeignObject.java,v 1.23 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -133,6 +133,10 @@
ForeignObject foreign = new ForeignObject(doc, ns);
areaCurrent = new Viewport(foreign);
+ areaCurrent.setWidth((int)size.getX() * 1000);
+ areaCurrent.setHeight((int)size.getY() * 1000);
+ areaCurrent.setOffset(0);
+
return areaCurrent;
}
1.3 +2 -2 xml-fop/src/org/apache/fop/image/ImageLoader.java
Index: ImageLoader.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/ImageLoader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ImageLoader.java 22 Feb 2002 09:18:47 -0000 1.2
+++ ImageLoader.java 21 Mar 2002 09:37:15 -0000 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: ImageLoader.java,v 1.2 2002/02/22 09:18:47 keiron Exp $
+ * $Id: ImageLoader.java,v 1.3 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -30,7 +30,7 @@
if (!valid || image != null) {
return image;
}
- String base = userAgent.getBaseDirectory();
+ String base = userAgent.getBaseURL();
image = ImageFactory.loadImage(url, base, userAgent);
if (image == null) {
cache.invalidateImage(url, userAgent);
1.22 +2 -3 xml-fop/src/org/apache/fop/image/analyser/SVGReader.java
Index: SVGReader.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/analyser/SVGReader.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- SVGReader.java 8 Mar 2002 11:00:19 -0000 1.21
+++ SVGReader.java 21 Mar 2002 09:37:15 -0000 1.22
@@ -1,5 +1,5 @@
/*
- * $Id: SVGReader.java,v 1.21 2002/03/08 11:00:19 keiron Exp $
+ * $Id: SVGReader.java,v 1.22 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -164,8 +164,7 @@
Element e = ((SVGDocument) doc).getRootElement();
String s;
SVGUserAgent userAg =
- new SVGUserAgent(new AffineTransform());
- userAg.setLogger(ua.getLogger());
+ new SVGUserAgent(ua, new AffineTransform());
BridgeContext ctx = new BridgeContext(userAg);
UnitProcessor.Context uctx =
UnitProcessor.createContext(ctx, e);
1.2 +2 -2 xml-fop/src/org/apache/fop/image/analyser/XMLReader.java
Index: XMLReader.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/image/analyser/XMLReader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLReader.java 8 Mar 2002 11:00:19 -0000 1.1
+++ XMLReader.java 21 Mar 2002 09:37:15 -0000 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: XMLReader.java,v 1.1 2002/03/08 11:00:19 keiron Exp $
+ * $Id: XMLReader.java,v 1.2 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -82,7 +82,7 @@
}
}
} catch (Exception e) {
- e.printStackTrace();
+ //e.printStackTrace();
try {
is.reset();
} catch (IOException ioe) { }
1.6 +4 -1 xml-fop/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java
Index: AbstractLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/AbstractLayoutManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractLayoutManager.java 8 Jan 2002 09:52:17 -0000 1.5
+++ AbstractLayoutManager.java 21 Mar 2002 09:37:15 -0000 1.6
@@ -1,5 +1,5 @@
/*
- * $Id: AbstractLayoutManager.java,v 1.5 2002/01/08 09:52:17 keiron Exp $
+ * $Id: AbstractLayoutManager.java,v 1.6 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -30,6 +30,9 @@
this.parentLM = lm;
}
+ public int getContentIPD() {
+ return 0;
+ }
/**
* Propagates to lower level layout managers. It iterates over the
1.4 +19 -13 xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java
Index: BlockLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/BlockLayoutManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BlockLayoutManager.java 8 Jan 2002 09:52:17 -0000 1.3
+++ BlockLayoutManager.java 21 Mar 2002 09:37:15 -0000 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: BlockLayoutManager.java,v 1.3 2002/01/08 09:52:17 keiron Exp $
+ * $Id: BlockLayoutManager.java,v 1.4 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -8,6 +8,7 @@
package org.apache.fop.layoutmgr;
import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.TextInfo;
import org.apache.fop.area.Area;
import org.apache.fop.area.BlockParent;
import org.apache.fop.area.Block;
@@ -26,17 +27,21 @@
super(fobj);
}
- // DESIGN. Potential alternative to getParentArea() scheme
- // /**
- // * Called by child layout manager to get the available space for
- // * content in the inline progression direction.
- // * Note that a manager may need to ask its parent for this.
- // * For a block area, available IPD is determined by indents.
- // */
- // public int getContentIPD() {
- // getArea(); // make if not existing
- // return blockArea.getIPD();
- // }
+ public void setBlockTextInfo(TextInfo ti) {
+
+ }
+
+ /**
+ * Called by child layout manager to get the available space for
+ * content in the inline progression direction.
+ * Note that a manager may need to ask its parent for this.
+ * For a block area, available IPD is determined by indents.
+ */
+ public int getContentIPD() {
+ // adjust for side floats and indents
+ //getParentArea(null); // make if not existing
+ return curBlockArea.getIPD();
+ }
/**
* Generate areas by tellings all layout managers for its FO's
@@ -77,8 +82,9 @@
curBlockArea = new Block();
// Set up dimensions
// Must get dimensions from parent area
- //MinOptMax referenceIPD = parentLM.getReferenceIPD();
Area parentArea = parentLM.getParentArea(curBlockArea);
+ int referenceIPD = parentArea.getIPD();
+ curBlockArea.setIPD(referenceIPD);
// Get reference IPD from parentArea
setCurrentArea(curBlockArea); // ??? for generic operations
}
1.4 +2 -1 xml-fop/src/org/apache/fop/layoutmgr/LayoutManager.java
Index: LayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LayoutManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LayoutManager.java 11 Nov 2001 22:14:45 -0000 1.3
+++ LayoutManager.java 21 Mar 2002 09:37:15 -0000 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: LayoutManager.java,v 1.3 2001/11/11 22:14:45 klease Exp $
+ * $Id: LayoutManager.java,v 1.4 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -20,4 +20,5 @@
public void addChild (Area childArea);
public boolean splitArea(Area areaToSplit, SplitContext context);
public void setParentLM(LayoutManager lm);
+ public int getContentIPD();
}
1.4 +16 -4 xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java
Index: LineLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/LineLayoutManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LineLayoutManager.java 8 Jan 2002 09:52:17 -0000 1.3
+++ LineLayoutManager.java 21 Mar 2002 09:37:15 -0000 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: LineLayoutManager.java,v 1.3 2002/01/08 09:52:17 keiron Exp $
+ * $Id: LineLayoutManager.java,v 1.4 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -15,6 +15,8 @@
import org.apache.fop.area.inline.InlineArea;
import java.util.ListIterator;
+import java.util.List;
+import java.util.Iterator;
/**
* LayoutManager for lines. It builds one or more lines containing
@@ -29,6 +31,7 @@
private boolean bFirstLine;
private LayoutManager curLM;
private MinOptMax remainingIPD;
+ private int lineHeight = 14000;
public LineLayoutManager(ListIterator fobjIter) {
super(null);
@@ -68,7 +71,17 @@
if (lineArea != null) {
// Adjust spacing as necessary
// Calculate height, based on content (or does the Area do this?)
- lineArea.setHeight(14000);
+ int maxHeight = lineHeight;
+ List inlineAreas = lineArea.getInlineAreas();
+ for(Iterator iter = inlineAreas.iterator(); iter.hasNext(); ) {
+ InlineArea inline = (InlineArea)iter.next();
+ int h = inline.getHeight();
+ if(h > maxHeight) {
+ maxHeight = h;
+ }
+ }
+ lineArea.setHeight(maxHeight);
+
parentLM.addChild(lineArea);
lineArea = null;
}
@@ -96,8 +109,7 @@
// lineArea.setContentIPD(parent.getContentIPD());
// remainingIPD = parent.getContentIPD();
// OR???
- // remainingIPD = parentLM.getContentIPD();
- remainingIPD = new MinOptMax(300000); // TESTING!!!
+ remainingIPD = new MinOptMax(parentLM.getContentIPD());
this.bFirstLine = false;
}
1.5 +7 -5 xml-fop/src/org/apache/fop/layoutmgr/PageLayoutManager.java
Index: PageLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/PageLayoutManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PageLayoutManager.java 8 Jan 2002 09:52:17 -0000 1.4
+++ PageLayoutManager.java 21 Mar 2002 09:37:15 -0000 1.5
@@ -1,5 +1,5 @@
/*
- * $Id: PageLayoutManager.java,v 1.4 2002/01/08 09:52:17 keiron Exp $
+ * $Id: PageLayoutManager.java,v 1.5 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -130,13 +130,12 @@
// for a float. When?
}
-
-
private PageViewport makeNewPage(boolean bIsBlank, boolean bIsLast) {
finishPage();
try {
curPage = ((PageSequence) fobj).createPage(bIsBlank, bIsLast);
} catch (FOPException fopex) { /* ???? */
+ fopex.printStackTrace();
}
curBody = (BodyRegion) curPage.getPage(). getRegion(
RegionReference.BODY).getRegion();
@@ -306,10 +305,9 @@
curBody.setMainReference(new MainReference());
}
-
-
private Flow createFlow() {
curFlow = new Flow();
+ curFlow.setIPD(curSpan.getIPD()); // adjust for columns
// Set IPD and max BPD on the curFlow from curBody
curSpan.addFlow(curFlow);
return curFlow;
@@ -328,6 +326,10 @@
// }
// else newpos = new MinOptMax();
curSpan = new Span(numCols);
+ // get Width or Height as IPD for span
+ curSpan.setIPD((int) curPage.getPage(). getRegion(
+ RegionReference.BODY).getViewArea().getWidth());
+
//curSpan.setPosition(BPD, newpos);
curBody.getMainReference().addSpan(curSpan);
createFlow();
1.5 +23 -24 xml-fop/src/org/apache/fop/layoutmgr/TextLayoutManager.java
Index: TextLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/layoutmgr/TextLayoutManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TextLayoutManager.java 11 Feb 2002 09:45:39 -0000 1.4
+++ TextLayoutManager.java 21 Mar 2002 09:37:15 -0000 1.5
@@ -1,5 +1,5 @@
/*
- * $Id: TextLayoutManager.java,v 1.4 2002/02/11 09:45:39 keiron Exp $
+ * $Id: TextLayoutManager.java,v 1.5 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -8,9 +8,9 @@
package org.apache.fop.layoutmgr;
import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.FOText; // For TextInfo: TODO: make independent!
+import org.apache.fop.fo.TextInfo;
import org.apache.fop.area.Area;
-import org.apache.fop.area.Property;
+import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.Word;
import org.apache.fop.area.inline.Space;
import org.apache.fop.util.CharUtilities;
@@ -26,7 +26,7 @@
public class TextLayoutManager extends LeafNodeLayoutManager {
private char[] chars;
- private FOText.TextInfo textInfo;
+ private TextInfo textInfo;
private static final char NEWLINE = '\n';
private static final char RETURN = '\r';
@@ -42,7 +42,7 @@
protected static final int TEXT = 2;
public TextLayoutManager(FObj fobj, char[] chars,
- FOText.TextInfo textInfo) {
+ TextInfo textInfo) {
super(fobj);
this.chars = chars;
this.textInfo = textInfo;
@@ -72,7 +72,7 @@
// With CID fonts, space isn't neccesary currentFontState.width(32)
int whitespaceWidth = CharUtilities.getCharWidth(' ', textInfo.fs);
- int wordStart = 0;
+ int wordStart = -1;
int wordLength = 0;
int wordWidth = 0;
int spaceWidth = 0;
@@ -152,15 +152,8 @@
// spaces. Split the word and add Space
// as necessary. All spaces inside the word
// Have a fixed width.
- Word curWordArea = new Word();
- curWordArea.setWidth(wordWidth);
- curWordArea.setWord( new String(chars, wordStart + 1,
- wordLength));
- Property prop = new Property();
- prop.propType = Property.FONT_STATE;
- prop.data = textInfo.fs;
- curWordArea.addProperty(prop);
- parentLM.addChild(curWordArea);
+ parentLM.addChild(createWord(new String(chars, wordStart +
1,
+ wordLength), wordWidth));
// reset word width
wordWidth = 0;
@@ -221,19 +214,25 @@
wordLength = chars.length - 1 - wordStart;
}
- Word curWordArea = new Word();
- curWordArea.setWidth(wordWidth);
- curWordArea.setWord(
- new String(chars, wordStart + 1, wordLength));
- Property prop = new Property();
- prop.propType = Property.FONT_STATE;
- prop.data = textInfo.fs;
- curWordArea.addProperty(prop);
- parentLM.addChild(curWordArea);
+ parentLM.addChild(createWord(new String(chars, wordStart + 1,
wordLength), wordWidth));
}
chars = null;
+ }
+
+ protected Word createWord(String str, int width) {
+ Word curWordArea = new Word();
+ curWordArea.setWidth(width);
+ curWordArea.setHeight(textInfo.fs.getAscender() -
textInfo.fs.getDescender());
+ curWordArea.setOffset(textInfo.fs.getAscender());
+
+ curWordArea.setWord(str);
+ Trait prop = new Trait();
+ prop.propType = Trait.FONT_STATE;
+ prop.data = textInfo.fs;
+ curWordArea.addTrait(prop);
+ return curWordArea;
}
/** Try to split the word area by hyphenating the word. */
1.3 +8 -6 xml-fop/src/org/apache/fop/render/RendererContext.java
Index: RendererContext.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/RendererContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RendererContext.java 8 Jan 2002 09:52:17 -0000 1.2
+++ RendererContext.java 21 Mar 2002 09:37:15 -0000 1.3
@@ -1,11 +1,13 @@
/*
- * $Id: RendererContext.java,v 1.2 2002/01/08 09:52:17 keiron Exp $
+ * $Id: RendererContext.java,v 1.3 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.render;
+import org.apache.fop.fo.FOUserAgent;
+
import org.apache.log.Logger;
import java.util.HashMap;
@@ -17,7 +19,7 @@
*/
public class RendererContext {
String mime;
- Logger log;
+ FOUserAgent userAgent;
HashMap props = new HashMap();
public RendererContext(String m) {
@@ -28,12 +30,12 @@
return mime;
}
- public void setLogger(Logger logger) {
- log = logger;
+ public void setUserAgent(FOUserAgent ua) {
+ userAgent = ua;
}
- public Logger getLogger() {
- return log;
+ public FOUserAgent getUserAgent() {
+ return userAgent;
}
public void setProperty(String name, Object val) {
1.3 +6 -6 xml-fop/src/org/apache/fop/render/pdf/PDFXMLHandler.java
Index: PDFXMLHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pdf/PDFXMLHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PDFXMLHandler.java 18 Mar 2002 12:30:46 -0000 1.2
+++ PDFXMLHandler.java 21 Mar 2002 09:37:15 -0000 1.3
@@ -1,5 +1,5 @@
/*
- * $Id: PDFXMLHandler.java,v 1.2 2002/03/18 12:30:46 keiron Exp $
+ * $Id: PDFXMLHandler.java,v 1.3 2002/03/21 09:37:15 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -12,6 +12,7 @@
import org.apache.fop.render.RendererContext;
import org.apache.fop.pdf.*;
import org.apache.fop.svg.*;
+import org.apache.fop.svg.SVGUserAgent;
import org.apache.fop.layout.FontState;
import org.apache.log.Logger;
@@ -104,9 +105,8 @@
float sx = 1, sy = 1;
int xOffset = pdfInfo.x, yOffset = pdfInfo.y;
- org.apache.fop.svg.SVGUserAgent ua
- = new org.apache.fop.svg.SVGUserAgent(new AffineTransform());
- ua.setLogger(context.getLogger());
+ SVGUserAgent ua
+ = new SVGUserAgent(context.getUserAgent(), new AffineTransform());
GVTBuilder builder = new GVTBuilder();
BridgeContext ctx = new BridgeContext(ua);
@@ -122,7 +122,7 @@
try {
root = builder.build(ctx, doc);
} catch (Exception e) {
- context.getLogger().error("svg graphic could not be built: "
+ context.getUserAgent().getLogger().error("svg graphic could not be
built: "
+ e.getMessage(), e);
return;
}
@@ -168,7 +168,7 @@
root.paint(graphics);
pdfInfo.currentStream.add(graphics.getString());
} catch (Exception e) {
- context.getLogger().error("svg graphic could not be rendered: "
+ context.getUserAgent().getLogger().error("svg graphic could not be
rendered: "
+ e.getMessage(), e);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]