You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by gm...@apache.org on 2004/06/13 21:58:58 UTC
cvs commit: xml-fop/src/java/org/apache/fop/fo/pagination Declarations.java Root.java
gmazza 2004/06/13 12:58:58
Modified: src/java/org/apache/fop/apps Document.java
src/java/org/apache/fop/area AreaTree.java
src/java/org/apache/fop/fo FONode.java FOTreeHandler.java
src/java/org/apache/fop/fo/pagination Declarations.java
Root.java
Removed: src/java/org/apache/fop/area AreaTreeControl.java
Log:
1.) App now returns an error if no page-sequence declared within fo:root.
2.) Standardized node names via a new static FONode.getNodeName() method
3.) Declarations object now tied to Root object, will no longer return NPE
if empty (bug fixed).
4.) AreaTreeControl removed in favor of direct connection between Document
and the Area Tree.
Revision Changes Path
1.18 +2 -3 xml-fop/src/java/org/apache/fop/apps/Document.java
Index: Document.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/apps/Document.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Document.java 13 Jun 2004 01:11:49 -0000 1.17
+++ Document.java 13 Jun 2004 19:58:58 -0000 1.18
@@ -25,7 +25,6 @@
// FOP
import org.apache.fop.area.AreaTree;
-import org.apache.fop.area.AreaTreeControl;
import org.apache.fop.area.AreaTreeModel;
import org.apache.fop.fo.FOInputHandler;
@@ -42,7 +41,7 @@
* Class storing information for the FOP Document being processed, and managing
* the processing of it.
*/
-public class Document implements FOTreeControl, AreaTreeControl {
+public class Document implements FOTreeControl {
/** The parent Driver object */
private Driver driver;
1.10 +11 -10 xml-fop/src/java/org/apache/fop/area/AreaTree.java
Index: AreaTree.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/AreaTree.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AreaTree.java 22 Apr 2004 21:38:39 -0000 1.9
+++ AreaTree.java 13 Jun 2004 19:58:58 -0000 1.10
@@ -18,6 +18,7 @@
package org.apache.fop.area;
+import org.apache.fop.apps.Document;
import org.apache.fop.area.extensions.BookmarkData;
import org.apache.fop.fo.extensions.Outline;
@@ -50,7 +51,7 @@
// allows for different models to deal with adding/rendering
// in different situations
private AreaTreeModel model;
- private AreaTreeControl atControl;
+ private Document document;
// hashmap of arraylists containing pages with id area
private Map idLocations = new HashMap();
@@ -60,10 +61,10 @@
/**
* Constructor.
- * @param atControl the AreaTreeControl object controlling this AreaTree
+ * @param document the apps.Document object controlling this AreaTree
*/
- public AreaTree (AreaTreeControl atControl) {
- this.atControl = atControl;
+ public AreaTree (Document document) {
+ this.document = document;
}
@@ -219,13 +220,13 @@
* Create the bookmark data in the area tree.
*/
public void addBookmarksToAreaTree() {
- if (atControl.getBookmarks() == null) {
+ if (document.getBookmarks() == null) {
return;
}
- atControl.getDriver().getLogger().debug("adding bookmarks to area tree");
+ document.getDriver().getLogger().debug("adding bookmarks to area tree");
BookmarkData data = new BookmarkData();
- for (int count = 0; count < atControl.getBookmarks().getOutlines().size(); count++) {
- Outline out = (Outline)(atControl.getBookmarks().getOutlines()).get(count);
+ for (int count = 0; count < document.getBookmarks().getOutlines().size(); count++) {
+ Outline out = (Outline)(document.getBookmarks().getOutlines()).get(count);
data.addSubData(createBookmarkData(out));
}
addTreeExtension(data);
@@ -251,8 +252,8 @@
return data;
}
- public AreaTreeControl getAreaTreeControl() {
- return atControl;
+ public Document getDocument() {
+ return document;
}
}
1.20 +11 -0 xml-fop/src/java/org/apache/fop/fo/FONode.java
Index: FONode.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- FONode.java 12 Jun 2004 23:18:52 -0000 1.19
+++ FONode.java 13 Jun 2004 19:58:58 -0000 1.20
@@ -195,5 +195,16 @@
fotv.serveFONode(this);
}
+ /**
+ * Helper function to standardize the names of all namespace URI - local
+ * name pairs in text messages.
+ * @param namespaceURI URI of node found
+ * (e.g., "http://www.w3.org/1999/XSL/Format")
+ * @param localName local name of node, (e.g., "root" for "fo:root")
+ * @return a string combining the two values
+ */
+ public static String getNodeString(String namespaceURI, String localName) {
+ return "(Namespace URI: \"" + namespaceURI + "\", Local Name: \"" + localName + "\")";
+ }
}
1.18 +8 -2 xml-fop/src/java/org/apache/fop/fo/FOTreeHandler.java
Index: FOTreeHandler.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeHandler.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- FOTreeHandler.java 13 Jun 2004 01:11:49 -0000 1.17
+++ FOTreeHandler.java 13 Jun 2004 19:58:58 -0000 1.18
@@ -69,7 +69,8 @@
// TODO: Collecting of statistics should be configurable
private final boolean collectStatistics = true;
private static final boolean MEM_PROFILE_WITH_GC = false;
-
+ private boolean pageSequenceFound = false;
+
/**
* Somewhere to get our stats from.
*/
@@ -135,6 +136,10 @@
*/
public void endDocument() throws SAXException {
try {
+ if (pageSequenceFound == false) {
+ throw new SAXException("Error: No fo:page-sequence child " +
+ "found within fo:root element.");
+ }
getAreaTree().endDocument();
getDriver().getRenderer().stopRenderer();
} catch (IOException ex) {
@@ -174,6 +179,7 @@
* @param pageSeq the page sequence starting
*/
public void startPageSequence(PageSequence pageSeq) {
+ pageSequenceFound = true;
}
/**
1.7 +25 -22 xml-fop/src/java/org/apache/fop/fo/pagination/Declarations.java
Index: Declarations.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Declarations.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Declarations.java 12 Jun 2004 23:18:52 -0000 1.6
+++ Declarations.java 13 Jun 2004 19:58:58 -0000 1.7
@@ -47,37 +47,40 @@
*/
public Declarations(FONode parent) {
super(parent);
+ ((Root) parent).setDeclarations(this);
}
/**
- * At then end of this element sort out the child into
+ * At the end of this element sort out the child into
* a hashmap of color profiles and a list of external xml.
*/
public void end() {
- for (Iterator iter = children.iterator(); iter.hasNext();) {
- FONode node = (FONode)iter.next();
- if (node.getName().equals("fo:color-profile")) {
- ColorProfile cp = (ColorProfile)node;
- if (!"".equals(cp.getProfileName())) {
- if (colorProfiles == null) {
- colorProfiles = new java.util.HashMap();
+ if (children != null) {
+ for (Iterator iter = children.iterator(); iter.hasNext();) {
+ FONode node = (FONode)iter.next();
+ if (node.getName().equals("fo:color-profile")) {
+ ColorProfile cp = (ColorProfile)node;
+ if (!"".equals(cp.getProfileName())) {
+ if (colorProfiles == null) {
+ colorProfiles = new java.util.HashMap();
+ }
+ if (colorProfiles.get(cp.getProfileName()) != null) {
+ // duplicate names
+ getLogger().warn("Duplicate fo:color-profile profile name : "
+ + cp.getProfileName());
+ }
+ colorProfiles.put(cp.getProfileName(), cp);
+ } else {
+ getLogger().warn("color-profile-name required for color profile");
}
- if (colorProfiles.get(cp.getProfileName()) != null) {
- // duplicate names
- getLogger().warn("Duplicate fo:color-profile profile name : "
- + cp.getProfileName());
+ } else if (node instanceof XMLObj) {
+ if (external == null) {
+ external = new java.util.ArrayList();
}
- colorProfiles.put(cp.getProfileName(), cp);
+ external.add(node);
} else {
- getLogger().warn("color-profile-name required for color profile");
+ getLogger().warn("invalid element " + node.getName() + "inside declarations");
}
- } else if (node instanceof XMLObj) {
- if (external == null) {
- external = new java.util.ArrayList();
- }
- external.add(node);
- } else {
- getLogger().warn("invalid element " + node.getName() + "inside declarations");
}
}
children = null;
1.13 +23 -3 xml-fop/src/java/org/apache/fop/fo/pagination/Root.java
Index: Root.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/pagination/Root.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Root.java 12 Jun 2004 23:18:52 -0000 1.12
+++ Root.java 13 Jun 2004 19:58:58 -0000 1.13
@@ -34,6 +34,8 @@
private LayoutMasterSet layoutMasterSet;
private Declarations declarations;
private List pageSequences;
+ // temporary until above list populated
+ private boolean pageSequenceFound = false;
/**
* Keeps count of page number from over PageSequence instances
@@ -72,7 +74,7 @@
} else if (declarations != null) { // only one fo:declarations
throw new IllegalArgumentException("Error: Only one" +
" fo:declarations may be defined per fo:root");
- } else if (!pageSequences.isEmpty()) { // no page-seqs yet
+ } else if (pageSequenceFound) { // no page-seqs yet
throw new IllegalArgumentException("Error: fo:declarations" +
" must be defined before fo:page-sequence declarations");
}
@@ -80,13 +82,15 @@
if (layoutMasterSet == null) { // must already have a l-m-s
throw new IllegalArgumentException("Error:" +
" fo:layout-master-set must be first child of fo:root");
+ } else {
+ pageSequenceFound = true;
}
} else
throw new IllegalArgumentException("Error: Invalid child" +
" node \"fo:" + localName + "\" of fo:root");
} else {
- throw new IllegalArgumentException("Error: Invalid child node ("
- + namespaceURI + ") \"" + localName + "\" of fo:root");
+ throw new IllegalArgumentException("Error: Invalid child node " +
+ FONode.getNodeString(namespaceURI, localName) + " of fo:root");
}
}
@@ -146,6 +150,22 @@
*/
public void setLayoutMasterSet(LayoutMasterSet layoutMasterSet) {
this.layoutMasterSet = layoutMasterSet;
+ }
+
+ /**
+ * Returns the associated Declarations.
+ * @return the Declarations instance
+ */
+ public Declarations getDeclarations() {
+ return this.declarations;
+ }
+
+ /**
+ * Sets the associated Declarations.
+ * @param Declarations the Declarations to use
+ */
+ public void setDeclarations(Declarations declarations) {
+ this.declarations = declarations;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org
Re: cvs commit: xml-fop/src/...
Posted by Glen Mazza <gr...@yahoo.com>.
Not necessary. There is already a getFObj() method
within PropertyList, from which getName() can be
called. propertyList.getElement() was only used once
in the app, for which I quickly replaced it with the
method above.
Glen
--- Simon Pepping <sp...@leverkruid.nl> wrote:
> Glen,
>
> On Wed, Jun 16, 2004 at 04:51:01PM -0700, Glen Mazza
> wrote:
> > Done, thanks.
>
> Thanks. I want to reinstate
> PropertyList.getElement() so that
> PropertyMaker can report which FO element it is
> working on via
> PropertyList; PropertyList.fobj is private. I want
> to rename it to
> FOname().
>
> Simon
>
> --
> Simon Pepping
> home page: http://www.leverkruid.nl
>
>
Re: cvs commit: xml-fop/src/...
Posted by Simon Pepping <sp...@leverkruid.nl>.
Glen,
On Wed, Jun 16, 2004 at 04:51:01PM -0700, Glen Mazza wrote:
> Done, thanks.
Thanks. I want to reinstate PropertyList.getElement() so that
PropertyMaker can report which FO element it is working on via
PropertyList; PropertyList.fobj is private. I want to rename it to
FOname().
Simon
--
Simon Pepping
home page: http://www.leverkruid.nl
Re: cvs commit: xml-fop/src/...
Posted by Glen Mazza <gr...@yahoo.com>.
Done, thanks.
Glen
--- Simon Pepping <sp...@leverkruid.nl> wrote:
>
> If I see correctly, FONode.name and
> PropertyList.elementName are now
> always null, and PropertyList.getElement() now
> always returns
> null. Can you fix that?
>
> Simon
>
Re: cvs commit: xml-fop/src/java/org/apache/fop/fo/pagination Declarations.java Root.java
Posted by Simon Pepping <sp...@leverkruid.nl>.
On Sun, Jun 13, 2004 at 07:58:58PM -0000, gmazza@apache.org wrote:
> gmazza 2004/06/13 12:58:58
>
> Modified: src/java/org/apache/fop/apps Document.java
> src/java/org/apache/fop/area AreaTree.java
> src/java/org/apache/fop/fo FONode.java FOTreeHandler.java
> src/java/org/apache/fop/fo/pagination Declarations.java
> Root.java
> Removed: src/java/org/apache/fop/area AreaTreeControl.java
> Log:
> 2.) Standardized node names via a new static FONode.getNodeName() method
If I see correctly, FONode.name and PropertyList.elementName are now
always null, and PropertyList.getElement() now always returns
null. Can you fix that?
Simon
--
Simon Pepping
home page: http://www.leverkruid.nl