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) {
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.
*/
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);
}
}
}
* and their processing
*/
public class FObjMixed extends FObj {
- FOText.TextInfo textInfo = null;
+ TextInfo textInfo = null;
FontInfo fontInfo=null;
public FObjMixed(FONode parent) {
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);
}
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();
return new RecursiveCharIterator(this);
}
-
-
}
--- /dev/null
+/*
+ * $Id$
+ * 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;
+ }
+
}
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
// Handle a sequence of inline-producing children in
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;
}
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);
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);
}
}
} catch (Exception e) {
- e.printStackTrace();
+ //e.printStackTrace();
try {
is.reset();
} catch (IOException ioe) { }
this.parentLM = lm;
}
+ public int getContentIPD() {
+ return 0;
+ }
/**
* Propagates to lower level layout managers. It iterates over the
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;
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
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
}
public void addChild (Area childArea);
public boolean splitArea(Area areaToSplit, SplitContext context);
public void setParentLM(LayoutManager lm);
+ public int getContentIPD();
}
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
private boolean bFirstLine;
private LayoutManager curLM;
private MinOptMax remainingIPD;
+ private int lineHeight = 14000;
public LineLayoutManager(ListIterator fobjIter) {
super(null);
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;
}
// lineArea.setContentIPD(parent.getContentIPD());
// remainingIPD = parent.getContentIPD();
// OR???
- // remainingIPD = parentLM.getContentIPD();
- remainingIPD = new MinOptMax(300000); // TESTING!!!
+ remainingIPD = new MinOptMax(parentLM.getContentIPD());
this.bFirstLine = false;
}
// 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();
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;
// }
// 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();
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;
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';
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;
// 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;
// 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;
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. */
public boolean splitArea(Area areaToSplit, SplitContext context) {
context.nextArea = areaToSplit;
*/
package org.apache.fop.render;
+import org.apache.fop.fo.FOUserAgent;
+
import org.apache.log.Logger;
import java.util.HashMap;
*/
public class RendererContext {
String mime;
- Logger log;
+ FOUserAgent userAgent;
HashMap props = new HashMap();
public RendererContext(String m) {
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) {
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;
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);
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;
}
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);
}