Procházet zdrojové kódy

1.) Check for fo:color-profile made to ensure no child elements during processing.

2.) Error messages for bad fo: files now give locator (line/col. #) information.
3.) Parent of the fo:root (FO Tree) "lowered" from apps.Document to fo.FOInputHandler;
IDReferences moved from former to latter.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197717 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Glen Mazza před 20 roky
rodič
revize
ff3ccfb841
30 změnil soubory, kde provedl 124 přidání a 110 odebrání
  1. 0
    22
      src/java/org/apache/fop/apps/Document.java
  2. 18
    0
      src/java/org/apache/fop/fo/FOInputHandler.java
  3. 23
    15
      src/java/org/apache/fop/fo/FONode.java
  4. 2
    2
      src/java/org/apache/fop/fo/FOTreeBuilder.java
  5. 1
    1
      src/java/org/apache/fop/fo/FObj.java
  6. 3
    3
      src/java/org/apache/fop/fo/FObjMixed.java
  7. 2
    3
      src/java/org/apache/fop/fo/flow/BasicLink.java
  8. 2
    2
      src/java/org/apache/fop/fo/flow/Block.java
  9. 1
    1
      src/java/org/apache/fop/fo/flow/ExternalGraphic.java
  10. 2
    2
      src/java/org/apache/fop/fo/flow/Footnote.java
  11. 2
    3
      src/java/org/apache/fop/fo/flow/FootnoteBody.java
  12. 2
    2
      src/java/org/apache/fop/fo/flow/Inline.java
  13. 1
    1
      src/java/org/apache/fop/fo/flow/Leader.java
  14. 2
    3
      src/java/org/apache/fop/fo/flow/ListBlock.java
  15. 2
    2
      src/java/org/apache/fop/fo/flow/ListItem.java
  16. 2
    3
      src/java/org/apache/fop/fo/flow/ListItemLabel.java
  17. 3
    3
      src/java/org/apache/fop/fo/flow/PageNumber.java
  18. 1
    1
      src/java/org/apache/fop/fo/flow/PageNumberCitation.java
  19. 2
    2
      src/java/org/apache/fop/fo/flow/Table.java
  20. 2
    2
      src/java/org/apache/fop/fo/flow/TableBody.java
  21. 2
    2
      src/java/org/apache/fop/fo/flow/TableCell.java
  22. 2
    2
      src/java/org/apache/fop/fo/flow/TableColumn.java
  23. 2
    2
      src/java/org/apache/fop/fo/flow/TableRow.java
  24. 9
    0
      src/java/org/apache/fop/fo/pagination/ColorProfile.java
  25. 4
    3
      src/java/org/apache/fop/fo/pagination/Declarations.java
  26. 2
    2
      src/java/org/apache/fop/fo/pagination/Flow.java
  27. 2
    2
      src/java/org/apache/fop/fo/pagination/PageSequence.java
  28. 26
    22
      src/java/org/apache/fop/fo/pagination/Root.java
  29. 1
    1
      src/java/org/apache/fop/fo/pagination/Title.java
  30. 1
    1
      src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java

+ 0
- 22
src/java/org/apache/fop/apps/Document.java Zobrazit soubor

@@ -18,20 +18,12 @@

package org.apache.fop.apps;

// Java
import java.util.Map;
import java.util.Set;
import java.util.HashSet;

// FOP
import org.apache.fop.area.AreaTree;
import org.apache.fop.area.AreaTreeModel;

import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.fonts.FontInfo;

import org.apache.commons.logging.Log;

// SAX
import org.xml.sax.SAXException;

@@ -53,12 +45,6 @@ public class Document {
/** The AreaTreeModel for the PageSequence being rendered. */
public AreaTreeModel atModel;

/**
* The current set of id's in the FO tree.
* This is used so we know if the FO tree contains duplicates.
*/
private Set idReferences = new HashSet();

/**
* Structure handler used to notify structure
* events such as start end element.
@@ -99,14 +85,6 @@ public class Document {
return areaTree;
}

/**
* Retuns the set of ID references.
* @return the ID references
*/
public Set getIDReferences() {
return idReferences;
}

/**
* @return the FOInputHandler for parsing this FO Tree
*/

+ 18
- 0
src/java/org/apache/fop/fo/FOInputHandler.java Zobrazit soubor

@@ -18,6 +18,10 @@

package org.apache.fop.fo;

// Java
import java.util.HashSet;
import java.util.Set;

// FOP
import org.apache.fop.apps.Document;
import org.apache.fop.apps.Driver;
@@ -68,6 +72,12 @@ public abstract class FOInputHandler {
*/
protected Log logger = null;

/**
* The current set of id's in the FO tree.
* This is used so we know if the FO tree contains duplicates.
*/
private Set idReferences = new HashSet();

/**
* Main constructor
* @param document the apps.Document implementation that is controlling
@@ -77,6 +87,14 @@ public abstract class FOInputHandler {
doc = document;
}

/**
* Retuns the set of ID references.
* @return the ID references
*/
public Set getIDReferences() {
return idReferences;
}

/**
* Sets the Commons-Logging instance for this class
* @param logger The Commons-Logging instance

+ 23
- 15
src/java/org/apache/fop/fo/FONode.java Zobrazit soubor

@@ -28,7 +28,6 @@ import org.xml.sax.Locator;
import org.apache.commons.logging.Log;

// FOP
import org.apache.fop.apps.Document;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.util.CharUtilities;
@@ -60,7 +59,7 @@ public abstract class FONode {
* @return FOUserAgent
*/
public FOUserAgent getUserAgent() {
return getDocument().getDriver().getUserAgent();
return getFOInputHandler().getDriver().getUserAgent();
}

/**
@@ -68,7 +67,7 @@ public abstract class FONode {
* @return the logger
*/
public Log getLogger() {
return getDocument().getDriver().getLogger();
return getFOInputHandler().getDriver().getLogger();
}

/**
@@ -101,7 +100,7 @@ public abstract class FONode {
* @param localName (e.g. "table" for "fo:table")
* @throws IllegalArgumentException if incoming node not valid for parent
*/
protected void validateChildNode(String namespaceURI, String localName) {}
protected void validateChildNode(Locator loc, String namespaceURI, String localName) {}

/**
* Adds characters (does nothing here)
@@ -180,12 +179,12 @@ public abstract class FONode {
}

/**
* Recursively goes up the FOTree hierarchy until the FONode is found,
* which returns the parent Document.
* @return the Document object that is the parent of this node.
* Recursively goes up the FOTree hierarchy until the fo:root is found,
* which returns the parent FOInputHandler.
* @return the FOInputHandler object that is the parent of the FO Tree
*/
public Document getDocument() {
return parent.getDocument();
public FOInputHandler getFOInputHandler() {
return parent.getFOInputHandler();
}

/**
@@ -226,9 +225,9 @@ public abstract class FONode {
* (e.g., two fo:declarations within fo:root)
* @param offendingNode incoming node that would cause a duplication.
*/
protected void tooManyNodesError(String offendingNode) {
protected void tooManyNodesError(Locator loc, String offendingNode) {
throw new IllegalArgumentException(
"Error: for " + getName() + ", only one "
errorText(loc) + getName() + ", only one "
+ offendingNode + " may be declared.");
}

@@ -238,9 +237,10 @@ public abstract class FONode {
* @param tooLateNode string name of node that should be earlier in document
* @param tooEarlyNode string name of node that should be later in document
*/
protected void nodesOutOfOrderError(String tooLateNode, String tooEarlyNode) {
protected void nodesOutOfOrderError(Locator loc, String tooLateNode,
String tooEarlyNode) {
throw new IllegalArgumentException(
"Error: for " + getName() + ", " + tooLateNode
errorText(loc) + getName() + ", " + tooLateNode
+ " must be declared before " + tooEarlyNode + ".");
}
@@ -250,11 +250,19 @@ public abstract class FONode {
* @param nsURI namespace URI of incoming invalid node
* @param lName local name (i.e., no prefix) of incoming node
*/
protected void invalidChildError(String nsURI, String lName) {
protected void invalidChildError(Locator loc, String nsURI, String lName) {
throw new IllegalArgumentException(
"Error: " + getNodeString(nsURI, lName) +
errorText(loc) + getNodeString(nsURI, lName) +
" is not valid child element of " + getName() + ".");
}
/**
* Helper function to return "Error (line#/column#)" string for
* above exception messages
* @param loc org.xml.sax.Locator object
*/
protected static String errorText(Locator loc) {
return "Error(" + loc.getLineNumber() + "/" + loc.getColumnNumber() + "): ";
}
}


+ 2
- 2
src/java/org/apache/fop/fo/FOTreeBuilder.java Zobrazit soubor

@@ -234,7 +234,7 @@ public class FOTreeBuilder extends DefaultHandler {
}
} else { // check that incoming node is valid for currentFObj
try {
currentFObj.validateChildNode(namespaceURI, localName);
currentFObj.validateChildNode(locator, namespaceURI, localName);
} catch (IllegalArgumentException e) {
throw new SAXException(e);
}
@@ -254,7 +254,7 @@ public class FOTreeBuilder extends DefaultHandler {

if (rootFObj == null) {
rootFObj = (Root) foNode;
rootFObj.setDocument(document);
rootFObj.setFOInputHandler(document.getFOInputHandler());
} else {
currentFObj.addChild(foNode);
}

+ 1
- 1
src/java/org/apache/fop/fo/FObj.java Zobrazit soubor

@@ -298,7 +298,7 @@ public class FObj extends FONode implements Constants {
if (prop != null) {
String str = prop.getString();
if (str != null && !str.equals("")) {
Set idrefs = getDocument().getIDReferences();
Set idrefs = getFOInputHandler().getIDReferences();
if (!idrefs.contains(str)) {
id = str;
idrefs.add(id);

+ 3
- 3
src/java/org/apache/fop/fo/FObjMixed.java Zobrazit soubor

@@ -46,8 +46,8 @@ public class FObjMixed extends FObj {
if (textInfo == null) {
// Really only need one of these, but need to get fontInfo
// stored in propMgr for later use.
propMgr.setFontInfo(getDocument());
textInfo = propMgr.getTextLayoutProps(getDocument());
propMgr.setFontInfo(getFOInputHandler().getDocument());
textInfo = propMgr.getTextLayoutProps(getFOInputHandler().getDocument());
}

FOText ft = new FOText(data, start, length, textInfo, this);
@@ -55,7 +55,7 @@ public class FObjMixed extends FObj {
ft.setName("text");
/* characters() processing empty for FOTreeHandler, not empty for RTF & MIFHandlers */
getDocument().getFOInputHandler().characters(ft.ca, ft.startIndex, ft.endIndex);
getFOInputHandler().characters(ft.ca, ft.startIndex, ft.endIndex);

addChild(ft);
}

+ 2
- 3
src/java/org/apache/fop/fo/flow/BasicLink.java Zobrazit soubor

@@ -54,7 +54,7 @@ public class BasicLink extends Inline {
*/
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
getDocument().getFOInputHandler().startLink(this);
getFOInputHandler().startLink(this);
}

public void setup() {
@@ -142,8 +142,7 @@ public class BasicLink extends Inline {
*/
public void end() {
super.end();
getDocument().getFOInputHandler().endLink();
getFOInputHandler().endLink();
}
public String getName() {

+ 2
- 2
src/java/org/apache/fop/fo/flow/Block.java Zobrazit soubor

@@ -111,7 +111,7 @@ public class Block extends FObjMixed {

setupID();

getDocument().getFOInputHandler().startBlock(this);
getFOInputHandler().startBlock(this);
}

private void setup() {
@@ -238,7 +238,7 @@ public class Block extends FObjMixed {
*/
public void end() {
handleWhiteSpace();
getDocument().getFOInputHandler().endBlock(this);
getFOInputHandler().endBlock(this);
}

private void handleWhiteSpace() {

+ 1
- 1
src/java/org/apache/fop/fo/flow/ExternalGraphic.java Zobrazit soubor

@@ -63,7 +63,7 @@ public class ExternalGraphic extends FObj {
*/
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
getDocument().getFOInputHandler().image(this);
getFOInputHandler().image(this);
}

/**

+ 2
- 2
src/java/org/apache/fop/fo/flow/Footnote.java Zobrazit soubor

@@ -48,7 +48,7 @@ public class Footnote extends FObj {
*/
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
getDocument().getFOInputHandler().startFootnote(this);
getFOInputHandler().startFootnote(this);
}

/**
@@ -79,7 +79,7 @@ public class Footnote extends FObj {
protected void end() {
super.end();
getDocument().getFOInputHandler().endFootnote(this);
getFOInputHandler().endFootnote(this);
}
public String getName() {

+ 2
- 3
src/java/org/apache/fop/fo/flow/FootnoteBody.java Zobrazit soubor

@@ -52,7 +52,7 @@ public class FootnoteBody extends FObj {
*/
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
getDocument().getFOInputHandler().startFootnoteBody(this);
getFOInputHandler().startFootnoteBody(this);
}

public void acceptVisitor(FOTreeVisitor fotv) {
@@ -61,8 +61,7 @@ public class FootnoteBody extends FObj {

protected void end() {
super.end();
getDocument().getFOInputHandler().endFootnoteBody(this);
getFOInputHandler().endFootnoteBody(this);
}
public String getName() {

+ 2
- 2
src/java/org/apache/fop/fo/flow/Inline.java Zobrazit soubor

@@ -114,7 +114,7 @@ public class Inline extends FObjMixed {
this.lineThrough = true;
}
getDocument().getFOInputHandler().startInline(this);
getFOInputHandler().startInline(this);
}

/**
@@ -139,7 +139,7 @@ public class Inline extends FObjMixed {
* @see org.apache.fop.fo.FONode#end
*/
public void end() {
getDocument().getFOInputHandler().endInline(this);
getFOInputHandler().endInline(this);
}

public String getName() {

+ 1
- 1
src/java/org/apache/fop/fo/flow/Leader.java Zobrazit soubor

@@ -66,7 +66,7 @@ public class Leader extends FObjMixed {
CommonBackground bProps = propMgr.getBackgroundProps();

// Common Font Properties
this.fontState = propMgr.getFontState(getDocument());
this.fontState = propMgr.getFontState(getFOInputHandler().getDocument());

// Common Margin Properties-Inline
CommonMarginInline mProps = propMgr.getMarginInlineProps();

+ 2
- 3
src/java/org/apache/fop/fo/flow/ListBlock.java Zobrazit soubor

@@ -64,7 +64,7 @@ public class ListBlock extends FObj {
*/
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
getDocument().getFOInputHandler().startList(this);
getFOInputHandler().startList(this);
}

private void setup() throws FOPException {
@@ -138,8 +138,7 @@ public class ListBlock extends FObj {

protected void end() {
super.end();
getDocument().getFOInputHandler().endList(this);
getFOInputHandler().endList(this);
}
public String getName() {

+ 2
- 2
src/java/org/apache/fop/fo/flow/ListItem.java Zobrazit soubor

@@ -64,7 +64,7 @@ public class ListItem extends FObj {
*/
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
getDocument().getFOInputHandler().startListItem(this);
getFOInputHandler().startListItem(this);
}

private void setup() {
@@ -148,7 +148,7 @@ public class ListItem extends FObj {

protected void end() {
super.end();
getDocument().getFOInputHandler().endListItem(this);
getFOInputHandler().endListItem(this);
}

public String getName() {

+ 2
- 3
src/java/org/apache/fop/fo/flow/ListItemLabel.java Zobrazit soubor

@@ -46,7 +46,7 @@ public class ListItemLabel extends FObj {
*/
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
getDocument().getFOInputHandler().startListLabel();
getFOInputHandler().startListLabel();
}

private void setup() {
@@ -85,8 +85,7 @@ public class ListItemLabel extends FObj {

protected void end() {
super.end();
getDocument().getFOInputHandler().endListLabel();
getFOInputHandler().endListLabel();
}
public String getName() {

+ 3
- 3
src/java/org/apache/fop/fo/flow/PageNumber.java Zobrazit soubor

@@ -61,7 +61,7 @@ public class PageNumber extends FObj {
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
setup();
getDocument().getFOInputHandler().startPageNumber(this);
getFOInputHandler().startPageNumber(this);
}

public void setup() {
@@ -77,7 +77,7 @@ public class PageNumber extends FObj {
CommonBackground bProps = propMgr.getBackgroundProps();

// Common Font Properties
this.fontState = propMgr.getFontState(getDocument());
this.fontState = propMgr.getFontState(getFOInputHandler().getDocument());

// Common Margin Properties-Inline
CommonMarginInline mProps = propMgr.getMarginInlineProps();
@@ -129,7 +129,7 @@ public class PageNumber extends FObj {
}

protected void end() {
getDocument().getFOInputHandler().endPageNumber(this);
getFOInputHandler().endPageNumber(this);
}
public String getName() {

+ 1
- 1
src/java/org/apache/fop/fo/flow/PageNumberCitation.java Zobrazit soubor

@@ -82,7 +82,7 @@ public class PageNumberCitation extends FObj {
CommonBackground bProps = propMgr.getBackgroundProps();

// Common Font Properties
this.fontState = propMgr.getFontState(getDocument());
this.fontState = propMgr.getFontState(getFOInputHandler().getDocument());

// Common Margin Properties-Inline
CommonMarginInline mProps = propMgr.getMarginInlineProps();

+ 2
- 2
src/java/org/apache/fop/fo/flow/Table.java Zobrazit soubor

@@ -81,7 +81,7 @@ public class Table extends FObj {
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
setupID();
getDocument().getFOInputHandler().startTable(this);
getFOInputHandler().startTable(this);
}

/**
@@ -203,7 +203,7 @@ public class Table extends FObj {
}

protected void end() {
getDocument().getFOInputHandler().endTable(this);
getFOInputHandler().endTable(this);
}

public String getName() {

+ 2
- 2
src/java/org/apache/fop/fo/flow/TableBody.java Zobrazit soubor

@@ -57,7 +57,7 @@ public class TableBody extends FObj {
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
setupID();
getDocument().getFOInputHandler().startBody(this);
getFOInputHandler().startBody(this);
}

private void setup() throws FOPException {
@@ -104,7 +104,7 @@ public class TableBody extends FObj {
}

protected void end() {
getDocument().getFOInputHandler().endBody(this);
getFOInputHandler().endBody(this);
}

public String getName() {

+ 2
- 2
src/java/org/apache/fop/fo/flow/TableCell.java Zobrazit soubor

@@ -123,7 +123,7 @@ public class TableCell extends FObj {
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
doSetup(); // init some basic property values
getDocument().getFOInputHandler().startCell(this);
getFOInputHandler().startCell(this);
}

/**
@@ -348,7 +348,7 @@ public class TableCell extends FObj {
}

protected void end() {
getDocument().getFOInputHandler().endCell(this);
getFOInputHandler().endCell(this);
}
public String getName() {

+ 2
- 2
src/java/org/apache/fop/fo/flow/TableColumn.java Zobrazit soubor

@@ -60,7 +60,7 @@ public class TableColumn extends FObj {
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
initialize(); // init some basic property values
getDocument().getFOInputHandler().startColumn(this);
getFOInputHandler().startColumn(this);
}

/**
@@ -124,7 +124,7 @@ public class TableColumn extends FObj {
}

protected void end() {
getDocument().getFOInputHandler().endColumn(this);
getFOInputHandler().endColumn(this);
}
public String getName() {

+ 2
- 2
src/java/org/apache/fop/fo/flow/TableRow.java Zobrazit soubor

@@ -68,7 +68,7 @@ public class TableRow extends FObj {
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
setupID();
getDocument().getFOInputHandler().startRow(this);
getFOInputHandler().startRow(this);
}

/**
@@ -145,7 +145,7 @@ public class TableRow extends FObj {
}

protected void end() {
getDocument().getFOInputHandler().endRow(this);
getFOInputHandler().endRow(this);
}
public String getName() {

+ 9
- 0
src/java/org/apache/fop/fo/pagination/ColorProfile.java Zobrazit soubor

@@ -24,6 +24,7 @@ import java.awt.color.ICC_ColorSpace;
import java.net.URL;
import java.io.IOException;
import java.io.InputStream;
import org.xml.sax.Locator;

// FOP
import org.apache.fop.datatypes.ColorType;
@@ -48,6 +49,14 @@ public class ColorProfile extends FObj {
super(parent);
}

/**
* @see org.apache.fop.fo.FONode#validateChildNode(String, String)
XSL 1.0/FOP: EMPTY (no child nodes permitted)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName) {
invalidChildError(loc, nsURI, localName);
}

/**
* Special processing for the end of parsing an ColorProfile object.
* Extract instance variables from the collection of properties for this

+ 4
- 3
src/java/org/apache/fop/fo/pagination/Declarations.java Zobrazit soubor

@@ -29,6 +29,7 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.fo.XMLObj;
import org.xml.sax.Locator;


/**
@@ -54,12 +55,12 @@ public class Declarations extends FObj {
/**
* @see org.apache.fop.fo.FONode#validateChildNode(String, String)
XSL 1.0: (color-profile)+ (and non-XSL NS nodes)
FOP (currently): (color-profile)* (and non-XSL NS nodes)
FOP/XSL 1.1: (color-profile)* (and non-XSL NS nodes)
*/
protected void validateChildNode(String nsURI, String localName) {
protected void validateChildNode(Locator loc, String nsURI, String localName) {
if (nsURI == FOElementMapping.URI) {
if (!localName.equals("color-profile")) {
invalidChildError(nsURI, localName);
invalidChildError(loc, nsURI, localName);
}
} // anything outside of XSL namespace is OK.
}

+ 2
- 2
src/java/org/apache/fop/fo/pagination/Flow.java Zobrazit soubor

@@ -92,14 +92,14 @@ public class Flow extends FObj {
// Now done in addChild of page-sequence
//pageSequence.addFlow(this);

getDocument().getFOInputHandler().startFlow(this);
getFOInputHandler().startFlow(this);
}

/**
* Tell the StructureRenderer that we are at the end of the flow.
*/
public void end() {
getDocument().getFOInputHandler().endFlow(this);
getFOInputHandler().endFlow(this);
}

/**

+ 2
- 2
src/java/org/apache/fop/fo/pagination/PageSequence.java Zobrazit soubor

@@ -291,7 +291,7 @@ public class PageSequence extends FObj {
*/
private void startStructuredPageSequence() {
if (!sequenceStarted) {
getDocument().getFOInputHandler().startPageSequence(this);
getFOInputHandler().startPageSequence(this);
sequenceStarted = true;
}
}
@@ -303,7 +303,7 @@ public class PageSequence extends FObj {
*/
public void end() {
try {
this.getDocument().getFOInputHandler().endPageSequence(this);
getFOInputHandler().endPageSequence(this);
} catch (FOPException fopex) {
getLogger().error("Error in PageSequence.end(): "
+ fopex.getMessage(), fopex);

+ 26
- 22
src/java/org/apache/fop/fo/pagination/Root.java Zobrazit soubor

@@ -22,13 +22,14 @@ package org.apache.fop.fo.pagination;
import java.util.List;

// FOP
import org.apache.fop.apps.Document;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fo.extensions.Bookmarks;
import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.fo.FOTreeVisitor;
import org.xml.sax.Locator;

/**
* The fo:root formatting object. Contains page masters, page-sequences.
@@ -47,7 +48,10 @@ public class Root extends FObj {
*/
private int runningPageNumberCounter = 0;

private Document document = null;
/**
* Controlling FOTreeHandler object for this FO Tree
*/
private FOInputHandler foInputHandler = null;

/**
* @see org.apache.fop.fo.FONode#FONode(FONode)
@@ -66,43 +70,43 @@ public class Root extends FObj {
XSL 1.0 Spec: (layout-master-set,declarations?,page-sequence+)
FOP: (layout-master-set, declarations?, fox:bookmarks?, page-sequence+)
*/
protected void validateChildNode(String nsURI, String localName) {
protected void validateChildNode(Locator loc, String nsURI, String localName) {
if (nsURI == FOElementMapping.URI) {
if (localName.equals("layout-master-set")) {
if (layoutMasterSet != null) {
tooManyNodesError("fo:layout-master-set");
tooManyNodesError(loc, "fo:layout-master-set");
}
} else if (localName.equals("declarations")) {
if (layoutMasterSet == null) {
nodesOutOfOrderError("fo:layout-master-set", "fo:declarations");
nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:declarations");
} else if (declarations != null) {
tooManyNodesError("fo:declarations");
tooManyNodesError(loc, "fo:declarations");
} else if (bookmarks != null) {
nodesOutOfOrderError("fo:declarations", "fox:bookmarks");
nodesOutOfOrderError(loc, "fo:declarations", "fox:bookmarks");
} else if (pageSequenceFound) {
nodesOutOfOrderError("fo:declarations", "fo:page-sequence");
nodesOutOfOrderError(loc, "fo:declarations", "fo:page-sequence");
}
} else if (localName.equals("page-sequence")) {
if (layoutMasterSet == null) {
nodesOutOfOrderError("fo:layout-master-set", "fo:page-sequence");
nodesOutOfOrderError(loc, "fo:layout-master-set", "fo:page-sequence");
} else {
pageSequenceFound = true;
}
} else {
invalidChildError(nsURI, localName);
invalidChildError(loc, nsURI, localName);
}
} else if (nsURI.equals(ExtensionElementMapping.URI)) {
if (!localName.equals("bookmarks")) {
invalidChildError(nsURI, localName);
invalidChildError(loc, nsURI, localName);
} else if (layoutMasterSet == null) {
nodesOutOfOrderError("fo:layout-master-set", "fox:bookmarks");
nodesOutOfOrderError(loc, "fo:layout-master-set", "fox:bookmarks");
} else if (bookmarks != null) {
tooManyNodesError("fox:bookmarks");
tooManyNodesError(loc, "fox:bookmarks");
} else if (pageSequenceFound) {
nodesOutOfOrderError("fox:bookmarks", "fo:page-sequence");
nodesOutOfOrderError(loc, "fox:bookmarks", "fo:page-sequence");
}
} else {
invalidChildError(nsURI, localName);
invalidChildError(loc, nsURI, localName);
}
}

@@ -201,19 +205,19 @@ public class Root extends FObj {
* @param document the apps.Document implementation to which this Root
* is attached
*/
public void setDocument(Document document) {
this.document = document;
public void setFOInputHandler(FOInputHandler foInputHandler) {
this.foInputHandler = foInputHandler;
}

/**
* This method overrides the FONode version. The FONode version calls the
* method by the same name for the parent object. Since Root is at the top
* of the tree, it returns the actual apps.Document object. Thus, any FONode
* can use this chain to find which apps.Document it is being built for.
* @return the Document implementation that this Root is attached to
* of the tree, it returns the actual FOInputHandler object. Thus, any FONode
* can use this chain to find which FOInputHandler it is being built for.
* @return the FOInputHandler implementation that this Root is attached to
*/
public Document getDocument() {
return document;
public FOInputHandler getFOInputHandler() {
return foInputHandler;
}

/**

+ 1
- 1
src/java/org/apache/fop/fo/pagination/Title.java Zobrazit soubor

@@ -59,7 +59,7 @@ public class Title extends FObjMixed {
CommonBackground bProps = propMgr.getBackgroundProps();

// Common Font Properties
Font fontState = propMgr.getFontState(getDocument());
Font fontState = propMgr.getFontState(getFOInputHandler().getDocument());

// Common Margin Properties-Inline
CommonMarginInline mProps = propMgr.getMarginInlineProps();

+ 1
- 1
src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Zobrazit soubor

@@ -74,7 +74,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
childLMiter = new BlockLMiter(this, childLMiter);
userAgent = inBlock.getUserAgent();
setBlockTextInfo(inBlock.getPropertyManager().getTextLayoutProps(
inBlock.getDocument()));
inBlock.getFOInputHandler().getDocument()));
}

private void setBlockTextInfo(TextInfo ti) {

Načítá se…
Zrušit
Uložit