diff options
Diffstat (limited to 'src/org/apache/fop/fo')
22 files changed, 221 insertions, 243 deletions
diff --git a/src/org/apache/fop/fo/ColorProfile.java b/src/org/apache/fop/fo/ColorProfile.java index 012361d07..1f6010c9b 100644 --- a/src/org/apache/fop/fo/ColorProfile.java +++ b/src/org/apache/fop/fo/ColorProfile.java @@ -65,9 +65,9 @@ public class ColorProfile extends FObj { ICC_Profile iccProfile = ICC_Profile.getInstance(is); colorSpace = new ICC_ColorSpace(iccProfile); } catch(IOException ioe) { - log.error("Could not read Color Profile src", ioe); + getLogger().error("Could not read Color Profile src", ioe); } catch(IllegalArgumentException iae) { - log.error("Color Profile src not an ICC Profile", iae); + getLogger().error("Color Profile src not an ICC Profile", iae); } } } diff --git a/src/org/apache/fop/fo/Declarations.java b/src/org/apache/fop/fo/Declarations.java index ec52363a2..6e2304423 100644 --- a/src/org/apache/fop/fo/Declarations.java +++ b/src/org/apache/fop/fo/Declarations.java @@ -45,11 +45,11 @@ public class Declarations extends FObj { } if(colorProfiles.get(cp.getProfileName()) != null) { // duplicate names - log.warn("Duplicate fo:color-profile profile name : " + cp.getProfileName()); + getLogger().warn("Duplicate fo:color-profile profile name : " + cp.getProfileName()); } colorProfiles.put(cp.getProfileName(), cp); } else { - log.warn("color-profile-name required for color profile"); + getLogger().warn("color-profile-name required for color profile"); } } else if(node instanceof XMLObj) { if(external == null) { @@ -57,7 +57,7 @@ public class Declarations extends FObj { } external.add(node); } else { - log.warn("invalid element " + node.getName() + "inside declarations"); + getLogger().warn("invalid element " + node.getName() + "inside declarations"); } } children = null; diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index aa4b601fa..4b0a532d9 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -29,8 +29,6 @@ abstract public class FONode { protected FONode parent; protected String name; - protected Logger log; - protected FONode(FONode parent) { this.parent = parent; } @@ -39,8 +37,8 @@ abstract public class FONode { name = str; } - public void setLogger(Logger logger) { - log = logger; + public Logger getLogger() { + return userAgent.getLogger(); } public void setUserAgent(FOUserAgent ua) { @@ -97,7 +95,7 @@ abstract public class FONode { * @return A ListIterator. */ public ListIterator getChildren() { - return null; + return null; } /** @@ -108,11 +106,11 @@ abstract public class FONode { * this FObj. */ public ListIterator getChildren(FONode childNode) { - return null; + return null; } public CharIterator charIterator() { - return new OneCharIterator(CharUtilities.CODE_EOT); + return new OneCharIterator(CharUtilities.CODE_EOT); } } diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java index cb8e3ecca..7a7c259fe 100644 --- a/src/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/org/apache/fop/fo/FOTreeBuilder.java @@ -30,7 +30,7 @@ import java.io.IOException; /** * SAX Handler that builds the formatting object tree. - * + * * Modified by Mark Lillywhite mark-fop@inomial.com. Now uses * StreamRenderer to automagically render the document as * soon as it receives a page-sequence end-tag. Also, @@ -70,13 +70,12 @@ public class FOTreeBuilder extends DefaultHandler { * (mark-fop@inomial.com) */ private StructureHandler structHandler; - private Logger log; private FOUserAgent userAgent; public FOTreeBuilder() {} - public void setLogger(Logger logger) { - log = logger; + public Logger getLogger() { + return userAgent.getLogger(); } public void setUserAgent(FOUserAgent ua) { @@ -129,13 +128,13 @@ public class FOTreeBuilder extends DefaultHandler { public void startDocument() throws SAXException { rootFObj = null; // allows FOTreeBuilder to be reused - log.info("building formatting object tree"); + getLogger().info("building formatting object tree"); structHandler.startDocument(); } public void endDocument() throws SAXException { - log.info("Parsing of document complete, stopping renderer"); + getLogger().info("Parsing of document complete, stopping renderer"); structHandler.endDocument(); } @@ -164,7 +163,7 @@ public class FOTreeBuilder extends DefaultHandler { String fullName = uri + "^" + localName; if (!this.unknownFOs.containsKey(fullName)) { this.unknownFOs.put(fullName, ""); - log.warn("Unknown formatting object " + getLogger().warn("Unknown formatting object " + fullName); } if(namespaces.contains(uri.intern())) { @@ -179,7 +178,6 @@ public class FOTreeBuilder extends DefaultHandler { try { fobj = fobjMaker.make(currentFObj); fobj.setName(localName); - fobj.setLogger(log); // set the user agent for resolving user agent values fobj.setUserAgent(userAgent); // set the stream renderer so that appropriate diff --git a/src/org/apache/fop/fo/FOUserAgent.java b/src/org/apache/fop/fo/FOUserAgent.java index f81753d83..e5823180f 100644 --- a/src/org/apache/fop/fo/FOUserAgent.java +++ b/src/org/apache/fop/fo/FOUserAgent.java @@ -10,6 +10,7 @@ package org.apache.fop.fo; import org.apache.fop.render.XMLHandler; import org.apache.fop.render.RendererContext; +import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.w3c.dom.*; @@ -31,13 +32,13 @@ import java.util.HashMap; * These areas may contain resolveable areas that will be processed * with other resolveable areas */ -public class FOUserAgent { +public class FOUserAgent implements LogEnabled { HashMap defaults = new HashMap(); HashMap handlers = new HashMap(); Logger log; String base; - public void setLogger(Logger logger) { + public void enableLogging(Logger logger) { log = logger; } @@ -83,7 +84,7 @@ public class FOUserAgent { mh.put(ns, handler); } - /** + /** * Render the xml document with the given xml namespace. * The Render Context is by the handle to render into the current * rendering target. @@ -104,11 +105,11 @@ public class FOUserAgent { handler.handleXML(ctx, doc, namespace); } catch (Throwable t) { // could not handle document - log.error("Could not render XML", t); + getLogger().error("Could not render XML", t); } } else { // no handler found for document - log.debug("No handler defined for XML: " + namespace); + getLogger().debug("No handler defined for XML: " + namespace); } } } diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index 223db278e..fc29ef8a2 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -153,7 +153,7 @@ public class FObj extends FONode { id = str; idrefs.add(id); } else { - log.warn("duplicate id:" + str + " ignored"); + getLogger().warn("duplicate id:" + str + " ignored"); } } } @@ -348,7 +348,7 @@ public class FObj extends FONode { if (!markers.containsKey(mcname) && children.isEmpty()) { markers.put(mcname, marker); } else { - log.error("fo:marker must be an initial child," + "and 'marker-class-name' must be unique for same parent"); + getLogger().error("fo:marker must be an initial child," + "and 'marker-class-name' must be unique for same parent"); throw new FOPException( "fo:marker must be an initial child," + "and 'marker-class-name' must be unique for same parent"); } diff --git a/src/org/apache/fop/fo/FObjMixed.java b/src/org/apache/fop/fo/FObjMixed.java index 79fc437ef..94d572fab 100644 --- a/src/org/apache/fop/fo/FObjMixed.java +++ b/src/org/apache/fop/fo/FObjMixed.java @@ -36,7 +36,7 @@ public class FObjMixed extends FObj { public void addLayoutManager(List lms) { lms.add(new InlineStackingBPLayoutManager(this, - new LMiter(children.listIterator()))); + new LMiter(children.listIterator()))); // set start and end properties for this element, id, etc. // int numChildren = this.children.size(); // for (int i = 0; i < numChildren; i++) { @@ -50,14 +50,14 @@ public class FObjMixed extends FObj { protected void addCharacters(char data[], int start, int length) { if(textInfo == null) { - // Really only need one of these, but need to get fontInfo - // stored in propMgr for later use. - propMgr.setFontInfo(fontInfo); - textInfo = propMgr.getTextLayoutProps(fontInfo); + // Really only need one of these, but need to get fontInfo + // stored in propMgr for later use. + propMgr.setFontInfo(fontInfo); + textInfo = propMgr.getTextLayoutProps(fontInfo); } FOText ft = new FOText(data, start, length, textInfo); - ft.setLogger(log); + ft.setUserAgent(userAgent); ft.setStructHandler(structHandler); addChild(ft); } diff --git a/src/org/apache/fop/fo/Property.java b/src/org/apache/fop/fo/Property.java index 116c1daeb..3f038de80 100644 --- a/src/org/apache/fop/fo/Property.java +++ b/src/org/apache/fop/fo/Property.java @@ -15,8 +15,6 @@ import org.apache.fop.fo.expr.PropertyException; import org.apache.fop.apps.FOPException; import java.util.Vector; -import org.apache.avalon.framework.logger.Logger; - public class Property { public static class Maker { @@ -132,7 +130,7 @@ public class Property { return setSubprop(baseProp, partName, p); } } else { - //log.error("compound property component " + //getLogger().error("compound property component " // + partName + " unknown."); } return baseProp; @@ -223,10 +221,10 @@ public class Property { } } catch (FOPException e) { - //log.error("convertShorthandProperty caught FOPException " + //getLogger().error("convertShorthandProperty caught FOPException " // + e); } catch (org.apache.fop.fo.expr.PropertyException propEx) { - //log.error("convertShorthandProperty caught PropertyException " + //getLogger().error("convertShorthandProperty caught PropertyException " // + propEx); } if (pret != null) { @@ -332,7 +330,7 @@ public class Property { return make(propertyList, specVal, propertyList.getParentFObj()); } catch (FOPException e) { - //log.error("Error computing property value for " + //getLogger()error("Error computing property value for " // + propName + " from " // + specVal); return null; @@ -359,12 +357,6 @@ public class Property { */ private String specVal; - protected Logger log; - - public void setLogger(Logger logger) { - log = logger; - } - /** * Set the original value specified for the property attribute. * @param specVal The specified value. diff --git a/src/org/apache/fop/fo/ToBeImplementedElement.java b/src/org/apache/fop/fo/ToBeImplementedElement.java index 12d83a969..049e8c1ca 100644 --- a/src/org/apache/fop/fo/ToBeImplementedElement.java +++ b/src/org/apache/fop/fo/ToBeImplementedElement.java @@ -22,7 +22,7 @@ public class ToBeImplementedElement extends FObj { } public void setup() { - log.debug("This element \"" + this.name + getLogger().debug("This element \"" + this.name + "\" is not yet implemented."); } diff --git a/src/org/apache/fop/fo/Unknown.java b/src/org/apache/fop/fo/Unknown.java index edaf630a5..b7dd97ecd 100644 --- a/src/org/apache/fop/fo/Unknown.java +++ b/src/org/apache/fop/fo/Unknown.java @@ -33,6 +33,6 @@ public class Unknown extends FONode { } public void setup() { - log.debug("Layout Unknown element"); + getLogger().debug("Layout Unknown element"); } } diff --git a/src/org/apache/fop/fo/XMLObj.java b/src/org/apache/fop/fo/XMLObj.java index f0ac6fcb3..e536b68ac 100644 --- a/src/org/apache/fop/fo/XMLObj.java +++ b/src/org/apache/fop/fo/XMLObj.java @@ -138,7 +138,7 @@ public abstract class XMLObj extends FONode { // in theory someone might want to embed some defined // xml (eg. fo) inside the foreign xml // they could use a different namespace - log.debug("Invalid element: " + child.getName() + " inside foreign xml markup"); + getLogger().debug("Invalid element: " + child.getName() + " inside foreign xml markup"); } } diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index 208b0f6d8..3a2908de7 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -221,7 +221,7 @@ public class Block extends FObjMixed { } private void handleWhiteSpace() { - log.debug("fo:block: handleWhiteSpace"); + getLogger().debug("fo:block: handleWhiteSpace"); if (firstInlineChild != null) { boolean bInWS = false; boolean bPrevWasLF = false; diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java index 614c6953d..561f95ac9 100644 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/org/apache/fop/fo/flow/ExternalGraphic.java @@ -143,7 +143,7 @@ public class ExternalGraphic extends FObj { cheight = (int)(fopimage.getHeight() * 1000); } if(scaling == Scaling.UNIFORM) { - // adjust the larger + // adjust the larger double rat1 = cwidth / (fopimage.getWidth() * 1000f); double rat2 = cheight / (fopimage.getHeight() * 1000f); if(rat1 < rat2) { @@ -167,7 +167,7 @@ public class ExternalGraphic extends FObj { if(overflow == Overflow.HIDDEN) { clip = true; } else if(overflow == Overflow.ERROR_IF_OVERFLOW) { - log.error("Image: " + url + " overflows the viewport"); + getLogger().error("Image: " + url + " overflows the viewport"); clip = true; } } @@ -208,7 +208,7 @@ public class ExternalGraphic extends FObj { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - // Common Aural Properties + // Common Aural Properties AuralProps mAurProps = propMgr.getAuralProps(); // Common Border, Padding, and Background Properties diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java index 6657524ec..398293f43 100644 --- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -157,7 +157,7 @@ public class InstreamForeignObject extends FObj { } } else {*/ cheight = len.mvalue(); - } + } Point2D csize = new Point2D.Float(cwidth == -1 ? -1 : cwidth / 1000f, cheight == -1 ? -1 : cheight / 1000f); Point2D size = child.getDimension(csize); @@ -197,7 +197,7 @@ public class InstreamForeignObject extends FObj { if(overflow == Overflow.HIDDEN) { clip = true; } else if(overflow == Overflow.ERROR_IF_OVERFLOW) { - log.error("Instream foreign object overflows the viewport"); + getLogger().error("Instream foreign object overflows the viewport"); clip = true; } } @@ -262,7 +262,7 @@ public class InstreamForeignObject extends FObj { // Common Accessibility Properties AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - + // Common Aural Properties AuralProps mAurProps = propMgr.getAuralProps(); @@ -285,7 +285,7 @@ public class InstreamForeignObject extends FObj { // this.properties.get("content-width"); // this.properties.get("display-align"); // this.properties.get("dominant-baseline"); - // this.properties.get("height"); + // this.properties.get("height"); setupID(); // this.properties.get("inline-progression-dimension"); // this.properties.get("keep-with-next"); diff --git a/src/org/apache/fop/fo/flow/Marker.java b/src/org/apache/fop/fo/flow/Marker.java index 5119d4c9a..a9ef5aebc 100644 --- a/src/org/apache/fop/fo/flow/Marker.java +++ b/src/org/apache/fop/fo/flow/Marker.java @@ -36,7 +36,7 @@ public class Marker extends FObjMixed { try { ((FObj)parent).addMarker(this); } catch (FOPException fopex) { - log.error("marker cannot be added to '" + parent + getLogger().error("marker cannot be added to '" + parent + "'"); } } diff --git a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java index e09f0e310..dcaf01180 100644 --- a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java @@ -75,7 +75,7 @@ public class ConditionalPageMasterReference extends FObj { break; case PagePosition.LAST: // how the hell do you know at this point? - log.debug("LAST PagePosition NYI"); + getLogger().warn("LAST PagePosition NYI"); okOnPagePosition = true; break; case PagePosition.REST: @@ -147,7 +147,7 @@ public class ConditionalPageMasterReference extends FObj { (RepeatablePageMasterAlternatives)parent; if (getMasterName() == null) { - log.warn("single-page-master-reference" + getLogger().warn("single-page-master-reference" + "does not have a master-name and so is being ignored"); } else { this.repeatablePageMasterAlternatives.addConditionalPageMasterReference(this); diff --git a/src/org/apache/fop/fo/pagination/PageMasterReference.java b/src/org/apache/fop/fo/pagination/PageMasterReference.java index 5f9674a49..e13e517ff 100644 --- a/src/org/apache/fop/fo/pagination/PageMasterReference.java +++ b/src/org/apache/fop/fo/pagination/PageMasterReference.java @@ -68,7 +68,7 @@ public abstract class PageMasterReference extends FObj _pageSequenceMaster = (PageSequenceMaster)parent; if (getMasterName() == null) { - log.warn("" + getName() + getLogger().warn("" + getName() + " does not have a master-reference and so is being ignored"); } else { _pageSequenceMaster.addSubsequenceSpecifier(this); diff --git a/src/org/apache/fop/fo/pagination/PageNumberGenerator.java b/src/org/apache/fop/fo/pagination/PageNumberGenerator.java index facb47f48..e025b4597 100644 --- a/src/org/apache/fop/fo/pagination/PageNumberGenerator.java +++ b/src/org/apache/fop/fo/pagination/PageNumberGenerator.java @@ -11,7 +11,7 @@ package org.apache.fop.fo.pagination; import org.apache.fop.fo.properties.*; // Avalon -import org.apache.avalon.framework.logger.Logger; +import org.apache.avalon.framework.logger.AbstractLogEnabled; // Java import java.util.*; @@ -21,7 +21,7 @@ import java.util.*; * and 'letterValue' properties on fo:page-sequence to return a String * corresponding to the supplied integer page number. */ -public class PageNumberGenerator { +public class PageNumberGenerator extends AbstractLogEnabled { private String format; private char groupingSeparator; @@ -44,8 +44,6 @@ public class PageNumberGenerator { "", "0", "00", "000", "0000", "00000" }; - private Logger log; - public PageNumberGenerator(String format, char groupingSeparator, int groupingSize, int letterValue) { this.format = format; @@ -70,7 +68,7 @@ public class PageNumberGenerator { formatType = UPPERROMAN; } else { // token not handled - //log.debug("'format' token not recognized; using '1'"); + //getLogger().debug("'format' token not recognized; using '1'"); formatType = DECIMAL; minPadding = 0; } @@ -80,7 +78,7 @@ public class PageNumberGenerator { // loop for (int i = 0; i < fmtLen - 1; i++) { if (format.charAt(i) != '0') { - //log.debug("'format' token not recognized; using '1'"); + //getLogger().debug("'format' token not recognized; using '1'"); formatType = DECIMAL; minPadding = 0; } else { @@ -90,10 +88,6 @@ public class PageNumberGenerator { } } - public void setLogger(Logger logger) { - log = logger; - } - public String makeFormattedPageNumber(int number) { String pn = null; if (formatType == DECIMAL) { diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index e9c36a1f4..af0d043f1 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -180,9 +180,9 @@ public class PageSequence extends FObj { masterName = this.properties.get("master-reference").getString(); - // TODO: Add code here to set a reference to the PageSequenceMaster - // if the masterName names a page-sequence-master, else get a - // reference to the SimplePageMaster. Throw an exception if neither? + // TODO: Add code here to set a reference to the PageSequenceMaster + // if the masterName names a page-sequence-master, else get a + // reference to the SimplePageMaster. Throw an exception if neither? // get the 'format' properties this.pageNumberGenerator = @@ -190,6 +190,7 @@ public class PageSequence extends FObj { this.properties.get("grouping-separator").getCharacter(), this.properties.get("grouping-size").getNumber().intValue(), this.properties.get("letter-value").getEnum()); + this.pageNumberGenerator.enableLogging(getLogger()); this.forcePageCount = this.properties.get("force-page-count").getEnum(); @@ -211,7 +212,7 @@ public class PageSequence extends FObj { throw new FOPException("flow-names must be unique within an fo:page-sequence"); } if (!this.layoutMasterSet.regionNameExists(flow.getFlowName())) { - log.error("region-name '" + getLogger().error("region-name '" + flow.getFlowName() + "' doesn't exist in the layout-master-set."); } @@ -228,64 +229,59 @@ public class PageSequence extends FObj { * @param child The flow object child to be added to the PageSequence. */ public void addChild(FONode child) { - try { - String childName = child.getName(); - if (childName.equals("fo:title")) { - if (this._flowMap.size()>0) { - log.warn("fo:title should be first in page-sequence"); - } else { - this.titleFO = (Title)child; - structHandler.startPageSequence(this, titleFO, layoutMasterSet); - sequenceStarted = true; - } - } - else if (childName.equals("fo:flow")) { - if (this.mainFlow != null) { - throw new FOPException("Only a single fo:flow permitted" - + " per fo:page-sequence"); - } - else { - if(!sequenceStarted) { + try { + String childName = child.getName(); + if (childName.equals("fo:title")) { + if (this._flowMap.size()>0) { + getLogger().warn("fo:title should be first in page-sequence"); + } else { + this.titleFO = (Title)child; + structHandler.startPageSequence(this, titleFO, layoutMasterSet); + sequenceStarted = true; + } + } else if (childName.equals("fo:flow")) { + if (this.mainFlow != null) { + throw new FOPException("Only a single fo:flow permitted" + + " per fo:page-sequence"); + } else { + if(!sequenceStarted) { structHandler.startPageSequence(this, titleFO, layoutMasterSet); sequenceStarted = true; } - this.mainFlow = (Flow)child; - addFlow(mainFlow); - super.addChild(child); // For getChildren - } - } - else if (childName.equals("fo:static-content")) { - if (this.mainFlow != null) { - throw new FOPException(childName + - " must precede fo:flow; ignoring"); - } - else { + this.mainFlow = (Flow)child; + addFlow(mainFlow); + super.addChild(child); // For getChildren + } + } else if (childName.equals("fo:static-content")) { + if (this.mainFlow != null) { + throw new FOPException(childName + + " must precede fo:flow; ignoring"); + } else { if(!sequenceStarted) { structHandler.startPageSequence(this, titleFO, layoutMasterSet); sequenceStarted = true; } - addFlow((Flow)child); - } - } - else { - // Ignore it! - log.warn("FO '" + childName + - "' not a legal page-sequence child."); - return; - } - } catch (FOPException fopex) { - log.error("Error in PageSequence.addChild(): " + - fopex.getMessage()); - } + addFlow((Flow)child); + } + } else { + // Ignore it! + getLogger().warn("FO '" + childName + + "' not a legal page-sequence child."); + return; + } + } catch (FOPException fopex) { + getLogger().error("Error in PageSequence.addChild(): " + + fopex.getMessage(), fopex); + } } public void end() { - try { - this.structHandler.endPageSequence(this); - } catch (FOPException fopex) { - log.error("Error in PageSequence.end(): " + - fopex.getMessage()); - } + try { + this.structHandler.endPageSequence(this); + } catch (FOPException fopex) { + getLogger().error("Error in PageSequence.end(): " + + fopex.getMessage(), fopex); + } } @@ -315,22 +311,22 @@ public class PageSequence extends FObj { * Runs the formatting of this page sequence into the given area tree */ public void format(AreaTree areaTree) throws FOPException { - // Make a new PageLayoutManager and a FlowLayoutManager - // Run the PLM in a thread - // Wait for them to finish. - - // If no main flow, nothing to layout! - if (this.mainFlow == null) return; - - // Initialize if already used? + // Make a new PageLayoutManager and a FlowLayoutManager + // Run the PLM in a thread + // Wait for them to finish. + + // If no main flow, nothing to layout! + if (this.mainFlow == null) return; + + // Initialize if already used? this.layoutMasterSet.resetPageMasters(); int firstAvailPageNumber = 0; - // This will layout pages and add them to the area tree - PageLayoutManager pageLM = new PageLayoutManager(areaTree, this); - // For now, skip the threading and just call run directly. - pageLM.run(); + // This will layout pages and add them to the area tree + PageLayoutManager pageLM = new PageLayoutManager(areaTree, this); + // For now, skip the threading and just call run directly. + pageLM.run(); // Thread layoutThread = new Thread(pageLM); // layoutThread.start(); @@ -343,30 +339,30 @@ public class PageSequence extends FObj { // } catch (InterruptedException ie) { // log.error("PageSequence.format() interrupted waiting on layout"); // } - // Tell the root the last page number we created. - this.root.setRunningPageNumberCounter(this.currentPageNumber); + // Tell the root the last page number we created. + this.root.setRunningPageNumberCounter(this.currentPageNumber); } private void initPageNumber() { - this.currentPageNumber = this.root.getRunningPageNumberCounter() + 1; - - if (this.pageNumberType == AUTO_ODD) { - // Next page but force odd. May force empty page creation! - // Whose master is used for this??? Assume no. - // Use force-page-count=auto - // on preceding page-sequence to make sure that there is no gap! - if (currentPageNumber % 2 == 0) { - this.currentPageNumber++; - } - } else if (pageNumberType == AUTO_EVEN) { - if (currentPageNumber % 2 == 1) { - this.currentPageNumber++; - } - } - else if (pageNumberType == EXPLICIT) { - this.currentPageNumber = this.explicitFirstNumber; - } - this.firstPageNumber = this.currentPageNumber; + this.currentPageNumber = this.root.getRunningPageNumberCounter() + 1; + + if (this.pageNumberType == AUTO_ODD) { + // Next page but force odd. May force empty page creation! + // Whose master is used for this??? Assume no. + // Use force-page-count=auto + // on preceding page-sequence to make sure that there is no gap! + if (currentPageNumber % 2 == 0) { + this.currentPageNumber++; + } + } else if (pageNumberType == AUTO_EVEN) { + if (currentPageNumber % 2 == 1) { + this.currentPageNumber++; + } + } + else if (pageNumberType == EXPLICIT) { + this.currentPageNumber = this.explicitFirstNumber; + } + this.firstPageNumber = this.currentPageNumber; } /** @@ -376,22 +372,22 @@ public class PageSequence extends FObj { * @param bIsBlank If true, use a master for a blank page. * @param bIsLast If true, use the master for the last page in the sequence. */ - public PageViewport createPage(boolean bIsBlank, boolean bIsLast) - throws FOPException + public PageViewport createPage(boolean bIsBlank, boolean bIsLast) + throws FOPException { - // Set even/odd flag and first flag based on current state - // Should do it this way, but fix it later.... - /*boolean bEvenPage = ((this.currentPageNumber %2)==0); - currentPage = makePage(bEvenPage, */ - currentPage = makePage(this.currentPageNumber, - this.currentPageNumber==this.firstPageNumber, - bIsLast, bIsBlank); - return currentPage; - // The page will have a viewport/reference area pair defined - // for each region in the master. - // Set up the page itself - // currentPage.setNumber(this.currentPageNumber); + // Set even/odd flag and first flag based on current state + // Should do it this way, but fix it later.... + /*boolean bEvenPage = ((this.currentPageNumber %2)==0); + currentPage = makePage(bEvenPage, */ + currentPage = makePage(this.currentPageNumber, + this.currentPageNumber==this.firstPageNumber, + bIsLast, bIsBlank); + return currentPage; + // The page will have a viewport/reference area pair defined + // for each region in the master. + // Set up the page itself + // currentPage.setNumber(this.currentPageNumber); // SKIP ALL THIS FOR NOW!!! // String formattedPageNumber = // pageNumberGenerator.makeFormattedPageNumber(this.currentPageNumber); @@ -412,7 +408,7 @@ public class PageSequence extends FObj { // this.pageCount++; // used for 'force-page-count' calculations // handle the 'force-page-count' - //forcePage(areaTree, firstAvailPageNumber); + //forcePage(areaTree, firstAvailPageNumber); } /** @@ -422,13 +418,13 @@ public class PageSequence extends FObj { * @param isFirstPage true when this is the first page in the sequence * @param isEmptyPage true if this page will be empty * (e.g. forced even or odd break) - * @return a Page layout object based on the page master selected + * @return a Page layout object based on the page master selected * from the params * TODO: modify the other methods to use even/odd flag and bIsLast */ private PageViewport makePage(int firstAvailPageNumber, - boolean isFirstPage, boolean bIsLast, - boolean isEmptyPage) throws FOPException { + boolean isFirstPage, boolean bIsLast, + boolean isEmptyPage) throws FOPException { // layout this page sequence // while there is still stuff in the flow, ask the @@ -441,7 +437,7 @@ public class PageSequence extends FObj { // a legal alternative is to use the last sub-sequence // specification which should be handled in getNextSubsequence. - // That's not done here. + // That's not done here. if (pageMaster == null) { throw new FOPException("page masters exhausted. Cannot recover."); } @@ -587,7 +583,7 @@ public class PageSequence extends FObj { SubSequenceSpecifier nextSubsequence = getNextSubsequence(sequenceMaster); if (nextSubsequence == null) { - log.error("Page subsequences exhausted. Using previous subsequence."); + getLogger().error("Page subsequences exhausted. Using previous subsequence."); thisIsFirstPage = true; // this becomes the first page in the new (old really) page master currentSubsequence.reset(); @@ -679,7 +675,7 @@ public class PageSequence extends FObj { // } else { -// System.out.println("flow is null. regionClass = '" + regionClass +// getLogger().error("flow is null. regionClass = '" + regionClass // + "' currentSPM = " // + getCurrentSimplePageMaster()); diff --git a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java index 0054cb226..e32819ba7 100644 --- a/src/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -47,7 +47,7 @@ public class PageSequenceMaster extends FObj { this.layoutMasterSet = (LayoutMasterSet)parent; String pm = this.properties.get("master-name").getString(); if (pm == null) { - log.warn("page-sequence-master does not have " + getLogger().warn("page-sequence-master does not have " + "a master-name and so is being ignored"); } else { this.layoutMasterSet.addPageSequenceMaster(pm, this); diff --git a/src/org/apache/fop/fo/pagination/RegionBody.java b/src/org/apache/fop/fo/pagination/RegionBody.java index b2132c330..f8dadc4f4 100644 --- a/src/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/org/apache/fop/fo/pagination/RegionBody.java @@ -34,20 +34,20 @@ public class RegionBody extends Region { protected Rectangle getViewportRectangle (FODimension reldims) { - /* - * Use space-before and space-after which will use corresponding - * absolute margin properties if specified. For indents: - * try to get corresponding absolute margin property using the - * writing-mode on the page (not on the region-body!). If that's not - * set but indent is explicitly set, it will return that. - */ + /* + * Use space-before and space-after which will use corresponding + * absolute margin properties if specified. For indents: + * try to get corresponding absolute margin property using the + * writing-mode on the page (not on the region-body!). If that's not + * set but indent is explicitly set, it will return that. + */ MarginProps mProps = propMgr.getMarginProps(); - int start = getRelMargin(PropertyList.START, "start-indent"); - return new Rectangle( start, mProps.spaceBefore, - reldims.ipd - start - - getRelMargin(PropertyList.END, "end-indent"), - reldims.bpd - mProps.spaceBefore - - mProps.spaceAfter); + int start = getRelMargin(PropertyList.START, "start-indent"); + return new Rectangle( start, mProps.spaceBefore, + reldims.ipd - start - + getRelMargin(PropertyList.END, "end-indent"), + reldims.bpd - mProps.spaceBefore - + mProps.spaceAfter); } /** @@ -55,18 +55,18 @@ public class RegionBody extends Region { * writing mode. */ private int getRelMargin(int reldir, String sRelPropName) { - FObj parent = (FObj) getParent(); - String sPropName = "margin-" + - parent.properties.wmRelToAbs(reldir); - Property prop = properties.getExplicitBaseProp(sPropName); - if (prop == null) { - prop = properties.getExplicitBaseProp(sRelPropName); - } - return ((prop != null)? prop.getLength().mvalue() : 0); + FObj parent = (FObj) getParent(); + String sPropName = "margin-" + + parent.properties.wmRelToAbs(reldir); + Property prop = properties.getExplicitBaseProp(sPropName); + if (prop == null) { + prop = properties.getExplicitBaseProp(sRelPropName); + } + return ((prop != null)? prop.getLength().mvalue() : 0); } protected void setRegionTraits(RegionReference r, Rectangle2D absRegVPRect) { - super.setRegionTraits(r, absRegVPRect); + super.setRegionTraits(r, absRegVPRect); // r.setBackgroundColor(backgroundColor); } @@ -88,24 +88,24 @@ public class RegionBody extends Region { * Override the inherited method. */ public RegionReference makeRegionReferenceArea(Rectangle2D absRegVPRect) { - // Should set some column stuff here I think, or put it elsewhere - BodyRegion body = new BodyRegion(); - setRegionTraits(body, absRegVPRect); + // Should set some column stuff here I think, or put it elsewhere + BodyRegion body = new BodyRegion(); + setRegionTraits(body, absRegVPRect); int columnCount= this.properties.get("column-count").getNumber().intValue(); if ((columnCount > 1) && (overflow == Overflow.SCROLL)) { // recover by setting 'column-count' to 1. This is allowed but // not required by the spec. - log.error("Setting 'column-count' to 1 because " + getLogger().error("Setting 'column-count' to 1 because " + "'overflow' is set to 'scroll'"); columnCount = 1; } - body.setColumnCount(columnCount); + body.setColumnCount(columnCount); int columnGap = this.properties.get("column-gap").getLength().mvalue(); - body.setColumnGap(columnGap); - return body; + body.setColumnGap(columnGap); + return body; } } diff --git a/src/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/org/apache/fop/fo/pagination/SimplePageMaster.java index 73be3f0e2..e08c34de1 100644 --- a/src/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -51,7 +51,7 @@ public class SimplePageMaster extends FObj { LayoutMasterSet layoutMasterSet = (LayoutMasterSet)parent; masterName = this.properties.get("master-name").getString(); if (masterName == null) { - log.warn("simple-page-master does not have " + getLogger().warn("simple-page-master does not have " + "a master-name and so is being ignored"); } else { layoutMasterSet.addSimplePageMaster(this); @@ -79,48 +79,48 @@ public class SimplePageMaster extends FObj { // Get absolute margin properties (top, left, bottom, right) MarginProps mProps = propMgr.getMarginProps(); - /* Create the page reference area rectangle in first quadrant coordinates - * (ie, 0,0 is at bottom,left of the "page media" and y increases - * when moving towards the top of the page. - * The media rectangle itself is (0,0,pageWidth,pageHeight). - */ - Rectangle pageRefRect = - new Rectangle(mProps.marginLeft, mProps.marginTop, - pageWidth - mProps.marginLeft - mProps.marginRight, - pageHeight - mProps.marginTop - mProps.marginBottom); + /* Create the page reference area rectangle in first quadrant coordinates + * (ie, 0,0 is at bottom,left of the "page media" and y increases + * when moving towards the top of the page. + * The media rectangle itself is (0,0,pageWidth,pageHeight). + */ + Rectangle pageRefRect = + new Rectangle(mProps.marginLeft, mProps.marginTop, + pageWidth - mProps.marginLeft - mProps.marginRight, + pageHeight - mProps.marginTop - mProps.marginBottom); - // ??? KL shouldn't this take the viewport too??? - Page page = new Page(); // page reference area + // ??? KL shouldn't this take the viewport too??? + Page page = new Page(); // page reference area // Set up the CTM on the page reference area based on writing-mode // and reference-orientation - FODimension reldims=new FODimension(0,0); - CTM pageCTM = propMgr.getCTMandRelDims(pageRefRect, reldims); + FODimension reldims=new FODimension(0,0); + CTM pageCTM = propMgr.getCTMandRelDims(pageRefRect, reldims); - // Create a RegionViewport/ reference area pair for each page region + // Create a RegionViewport/ reference area pair for each page region - boolean bHasBody=false; + boolean bHasBody=false; for (Iterator regenum = _regions.values().iterator(); regenum.hasNext(); ) { Region r = (Region)regenum.next(); - RegionViewport rvp = r.makeRegionViewport(reldims, pageCTM); - rvp.setRegion(r.makeRegionReferenceArea(rvp.getViewArea())); - page.setRegion(r.getRegionAreaClass(), rvp); - if (r.getRegionAreaClass() == RegionReference.BODY) { - bHasBody = true; - } + RegionViewport rvp = r.makeRegionViewport(reldims, pageCTM); + rvp.setRegion(r.makeRegionReferenceArea(rvp.getViewArea())); + page.setRegion(r.getRegionAreaClass(), rvp); + if (r.getRegionAreaClass() == RegionReference.BODY) { + bHasBody = true; + } } - if (!bHasBody) { - log.error("simple-page-master has no region-body"); + if (!bHasBody) { + getLogger().error("simple-page-master has no region-body"); } - this.pageMaster = new PageMaster(new PageViewport(page, - new Rectangle(0,0, - pageWidth,pageHeight))); + this.pageMaster = new PageMaster(new PageViewport(page, + new Rectangle(0,0, + pageWidth,pageHeight))); - // _regions = null; // PageSequence access SimplePageMaster.... + // _regions = null; // PageSequence access SimplePageMaster.... children = null; properties = null; } @@ -142,19 +142,18 @@ public class SimplePageMaster extends FObj { } protected void addChild(FONode child) { - if (child instanceof Region) { - addRegion((Region)child); - } - else { - log.error("SimplePageMaster cannot have child of type " + - child.getName()); - } + if (child instanceof Region) { + addRegion((Region)child); + } else { + getLogger().error("SimplePageMaster cannot have child of type " + + child.getName()); + } } protected void addRegion(Region region) { - String key = region.getRegionClass(); + String key = region.getRegionClass(); if (_regions.containsKey(key)) { - log.error("Only one region of class " + getLogger().error("Only one region of class " + key + " allowed within a simple-page-master."); // throw new FOPException("Only one region of class " |