git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196888 13f79535-47bb-0310-9956-ffa450edef68tags/Root_Temp_KnuthStylePageBreaking
// FOP | // FOP | ||||
import org.apache.fop.apps.FOUserAgent; | |||||
import org.apache.fop.area.AreaTree; | import org.apache.fop.area.AreaTree; | ||||
import org.apache.fop.area.AreaTreeModel; | import org.apache.fop.area.AreaTreeModel; | ||||
// SAX | // SAX | ||||
import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
// Avalon | |||||
import org.apache.avalon.framework.logger.Logger; | |||||
/** | /** | ||||
* Class storing information for the FOP Document being processed, and managing | * Class storing information for the FOP Document being processed, and managing | ||||
* the processing of it. | * the processing of it. | ||||
return foInputHandler; | return foInputHandler; | ||||
} | } | ||||
/** | |||||
* @return the Logger to be used for processing this Document | |||||
*/ | |||||
public Logger getLogger() { | |||||
return getDriver().getLogger(); | |||||
} | |||||
/** | |||||
* @return the FOUserAgent used for processing this document | |||||
*/ | |||||
public FOUserAgent getUserAgent() { | |||||
return getDriver().getUserAgent(); | |||||
} | |||||
} | } |
userAgent = agent; | userAgent = agent; | ||||
} | } | ||||
private FOUserAgent getUserAgent() { | |||||
protected FOUserAgent getUserAgent() { | |||||
if (userAgent == null) { | if (userAgent == null) { | ||||
userAgent = new FOUserAgent(); | userAgent = new FOUserAgent(); | ||||
userAgent.enableLogging(getLogger()); | userAgent.enableLogging(getLogger()); |
* | * | ||||
*/ | */ | ||||
public abstract class FONode { | public abstract class FONode { | ||||
/** FO User Agent for this node (for logger etc.)*/ | |||||
protected FOUserAgent userAgent; | |||||
/** Parent FO node */ | /** Parent FO node */ | ||||
protected FONode parent; | protected FONode parent; | ||||
/** Name of the node */ | /** Name of the node */ | ||||
* @return the logger | * @return the logger | ||||
*/ | */ | ||||
public Logger getLogger() { | public Logger getLogger() { | ||||
return userAgent.getLogger(); | |||||
} | |||||
/** | |||||
* Sets the user agent for the node. | |||||
* @param ua the user agent | |||||
*/ | |||||
public void setUserAgent(FOUserAgent ua) { | |||||
userAgent = ua; | |||||
return getFOTreeControl().getLogger(); | |||||
} | } | ||||
/** | /** | ||||
* @return FOUserAgent | * @return FOUserAgent | ||||
*/ | */ | ||||
public FOUserAgent getUserAgent() { | public FOUserAgent getUserAgent() { | ||||
return userAgent; | |||||
return getFOTreeControl().getUserAgent(); | |||||
} | } | ||||
/** | /** |
try { | try { | ||||
fobj = fobjMaker.make(currentFObj); | fobj = fobjMaker.make(currentFObj); | ||||
fobj.setName(localName); | fobj.setName(localName); | ||||
// set the user agent for resolving user agent values | |||||
fobj.setUserAgent(userAgent); | |||||
// set the structure handler so that appropriate | |||||
// elements can signal structure events | |||||
fobj.handleAttrs(attlist); | fobj.handleAttrs(attlist); | ||||
} catch (FOPException e) { | } catch (FOPException e) { | ||||
throw new SAXException(e); | throw new SAXException(e); |
import java.util.Set; | import java.util.Set; | ||||
// FOP | // FOP | ||||
import org.apache.fop.apps.FOUserAgent; | |||||
import org.apache.fop.fo.extensions.Bookmarks; | import org.apache.fop.fo.extensions.Bookmarks; | ||||
import org.apache.fop.fonts.FontMetrics; | import org.apache.fop.fonts.FontMetrics; | ||||
// Avalon | |||||
import org.apache.avalon.framework.logger.Logger; | |||||
/** | /** | ||||
* An interface for classes that are conceptually the parent class of the | * An interface for classes that are conceptually the parent class of the | ||||
* fo.pagination.Root object. The purpose of the interface is to maintain | * fo.pagination.Root object. The purpose of the interface is to maintain | ||||
* @return the FOInputHandler for parsing this FO Tree | * @return the FOInputHandler for parsing this FO Tree | ||||
*/ | */ | ||||
FOInputHandler getFOInputHandler(); | FOInputHandler getFOInputHandler(); | ||||
/** | |||||
* @return the Logger being used with this FO Tree | |||||
*/ | |||||
Logger getLogger(); | |||||
/** | |||||
* @return the FOUserAgent used for processing this FO Tree | |||||
*/ | |||||
FOUserAgent getUserAgent(); | |||||
} | } |
} | } | ||||
FOText ft = new FOText(data, start, length, textInfo, this); | FOText ft = new FOText(data, start, length, textInfo, this); | ||||
ft.setUserAgent(userAgent); | |||||
getFOTreeControl().getFOInputHandler().characters(ft.ca, ft.start, ft.length); | getFOTreeControl().getFOInputHandler().characters(ft.ca, ft.start, ft.length); | ||||
addChild(ft); | addChild(ft); | ||||
} | } |
/* if width and height are zero, get the bounds of the content. */ | /* if width and height are zero, get the bounds of the content. */ | ||||
try { | try { | ||||
String baseDir = userAgent.getBaseURL(); | |||||
String baseDir = getUserAgent().getBaseURL(); | |||||
if (baseDir != null) { | if (baseDir != null) { | ||||
((SVGOMDocument)doc).setURLObject(new URL(baseDir)); | ((SVGOMDocument)doc).setURLObject(new URL(baseDir)); | ||||
} | } | ||||
} | } | ||||
Element e = ((SVGDocument)doc).getRootElement(); | Element e = ((SVGDocument)doc).getRootElement(); | ||||
final float ptmm = userAgent.getPixelUnitToMillimeter(); | |||||
final float ptmm = getUserAgent().getPixelUnitToMillimeter(); | |||||
// temporary svg context | // temporary svg context | ||||
SVGContext dc = new SVGContext() { | SVGContext dc = new SVGContext() { | ||||
public float getPixelToMM() { | public float getPixelToMM() { | ||||
SVGDOMImplementation.SVG_NAMESPACE_URI); | SVGDOMImplementation.SVG_NAMESPACE_URI); | ||||
//} | //} | ||||
int fontSize = 12; | int fontSize = 12; | ||||
Point2D p2d = getSize(fontSize, svgRoot, userAgent.getPixelUnitToMillimeter()); | |||||
Point2D p2d = getSize(fontSize, svgRoot, getUserAgent().getPixelUnitToMillimeter()); | |||||
((SVGOMElement)e).setSVGContext(null); | ((SVGOMElement)e).setSVGContext(null); | ||||
return p2d; | return p2d; |
int scaling = properties.get("scaling").getEnum(); | int scaling = properties.get("scaling").getEnum(); | ||||
if ((scaling == Scaling.UNIFORM) || (cwidth == -1) || cheight == -1) { | if ((scaling == Scaling.UNIFORM) || (cwidth == -1) || cheight == -1) { | ||||
ImageFactory fact = ImageFactory.getInstance(); | ImageFactory fact = ImageFactory.getInstance(); | ||||
fopimage = fact.getImage(url, userAgent); | |||||
fopimage = fact.getImage(url, getUserAgent()); | |||||
if (fopimage == null) { | if (fopimage == null) { | ||||
// error | // error | ||||
url = null; | url = null; | ||||
return; | return; | ||||
} | } | ||||
// load dimensions | // load dimensions | ||||
if (!fopimage.load(FopImage.DIMENSIONS, userAgent)) { | |||||
if (!fopimage.load(FopImage.DIMENSIONS, getUserAgent())) { | |||||
// error | // error | ||||
url = null; | url = null; | ||||
return; | return; |
if (node.getChildren() != null) { | if (node.getChildren() != null) { | ||||
InlineStackingLayoutManager lm; | InlineStackingLayoutManager lm; | ||||
lm = new InlineStackingLayoutManager(); | lm = new InlineStackingLayoutManager(); | ||||
Document doc = (Document)node.getFOTreeControl(); | |||||
lm.setUserAgent(node.getUserAgent()); | lm.setUserAgent(node.getUserAgent()); | ||||
lm.setFObj(node); | lm.setFObj(node); | ||||
lm.setLMiter(new LMiter(node.getChildren())); | lm.setLMiter(new LMiter(node.getChildren())); |