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 2003/12/26 23:11:17 UTC
cvs commit: xml-fop/src/java/org/apache/fop/fo/extensions Label.java
gmazza 2003/12/26 14:11:17
Modified: src/java/org/apache/fop/fo FONode.java FOTreeBuilder.java
FObj.java FObjMixed.java UnknownXMLObj.java
XMLObj.java
src/java/org/apache/fop/fo/extensions Label.java
Log:
----------------------------------------------------------------------
Bug #25646 (Patch by Finn Bock): setting SAX Locator (line and column
index of input fo stream) for debugging and better error feedback.
Revision Changes Path
1.14 +12 -1 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FONode.java 16 Sep 2003 05:21:04 -0000 1.13
+++ FONode.java 26 Dec 2003 22:11:17 -0000 1.14
@@ -55,6 +55,7 @@
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
// Avalon
import org.apache.avalon.framework.logger.Logger;
@@ -91,6 +92,14 @@
}
/**
+ * Sets the name of the node.
+ * @param str the name
+ */
+ public void setLocation(Locator locator) {
+ // do nothing by default
+ }
+
+ /**
* Returns the logger for the node.
* @return the logger
*/
@@ -127,8 +136,10 @@
* @param data text
* @param start start position
* @param length length of the text
+ * @param locator location in fo source file.
*/
- protected void addCharacters(char data[], int start, int length) {
+ protected void addCharacters(char data[], int start, int length,
+ Locator locator) {
// ignore
}
1.20 +14 -1 xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java
Index: FOTreeBuilder.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOTreeBuilder.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- FOTreeBuilder.java 19 Sep 2003 14:33:15 -0000 1.19
+++ FOTreeBuilder.java 26 Dec 2003 22:11:17 -0000 1.20
@@ -67,6 +67,7 @@
import org.apache.fop.fo.ElementMapping.Maker;
import org.apache.fop.fo.pagination.Root;
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -110,6 +111,9 @@
/** The FOTreeControl object managing the FO Tree that is being built */
public FOTreeControl foTreeControl;
+ /** The SAX locator object maneging the line and column counters */
+ private Locator locator;
+
/**
* Default constructor
*/
@@ -205,12 +209,20 @@
}
/**
+ * SAX Handler for locator
+ * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
+ */
+ public void setDocumentLocator(Locator locator) {
+ this.locator = locator;
+ }
+
+ /**
* SAX Handler for characters
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
*/
public void characters(char data[], int start, int length) {
if (currentFObj != null) {
- currentFObj.addCharacters(data, start, start + length);
+ currentFObj.addCharacters(data, start, start + length, locator);
}
}
@@ -264,6 +276,7 @@
try {
fobj = fobjMaker.make(currentFObj);
fobj.setName(localName);
+ fobj.setLocation(locator);
fobj.handleAttrs(attlist);
} catch (FOPException e) {
throw new SAXException(e);
1.28 +15 -0 xml-fop/src/java/org/apache/fop/fo/FObj.java
Index: FObj.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObj.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- FObj.java 24 Dec 2003 00:06:13 -0000 1.27
+++ FObj.java 26 Dec 2003 22:11:17 -0000 1.28
@@ -61,6 +61,7 @@
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.properties.FOPropertyMapping;
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
/**
* Base class for representation of formatting objects and their processing.
@@ -130,6 +131,12 @@
name = "fo:" + str;
}
+ public void setLocation(Locator locator) {
+ line = locator.getLineNumber();
+ column = locator.getColumnNumber();
+ systemId = locator.getSystemId();
+ }
+
/**
* Handle the attributes for this element.
* The attributes must be used immediately as the sax attributes
@@ -420,5 +427,13 @@
public void acceptVisitor(FOTreeVisitor fotv) {
fotv.serveFObj(this);
}
+
+ /**
+ * Return a string representation of the fo element.
+ */
+ public String toString() {
+ return getName() + " at line " + line + ":" + column;
+ }
+
}
1.18 +7 -1 xml-fop/src/java/org/apache/fop/fo/FObjMixed.java
Index: FObjMixed.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FObjMixed.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- FObjMixed.java 20 Dec 2003 06:53:22 -0000 1.17
+++ FObjMixed.java 26 Dec 2003 22:11:17 -0000 1.18
@@ -50,6 +50,8 @@
*/
package org.apache.fop.fo;
+import org.xml.sax.Locator;
+
/**
* Base class for representation of mixed content formatting objects
* and their processing
@@ -69,8 +71,10 @@
* @param data array of characters containing text to be added
* @param start starting array element to add
* @param length number of characters to add
+ * @param locator location in fo source file.
*/
- protected void addCharacters(char data[], int start, int length) {
+ protected void addCharacters(char data[], int start, int length,
+ Locator locator) {
if (textInfo == null) {
// Really only need one of these, but need to get fontInfo
// stored in propMgr for later use.
@@ -79,6 +83,8 @@
}
FOText ft = new FOText(data, start, length, textInfo, this);
+ ft.setLocation(locator);
+ ft.setName("text");
/* characters() processing empty for FOTreeHandler, not empty for RTF & MIFHandlers */
getFOTreeControl().getFOInputHandler().characters(ft.ca, ft.start, ft.length);
1.6 +5 -2 xml-fop/src/java/org/apache/fop/fo/UnknownXMLObj.java
Index: UnknownXMLObj.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/UnknownXMLObj.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- UnknownXMLObj.java 16 Sep 2003 05:21:04 -0000 1.5
+++ UnknownXMLObj.java 26 Dec 2003 22:11:17 -0000 1.6
@@ -50,6 +50,8 @@
*/
package org.apache.fop.fo;
+import org.xml.sax.Locator;
+
/**
* Class for handling generic XML from a namespace not recognized by FOP
*/
@@ -111,11 +113,12 @@
/**
* @see XMLObj#addCharacters
*/
- protected void addCharacters(char data[], int start, int length) {
+ protected void addCharacters(char data[], int start, int length,
+ Locator locator) {
if (doc == null) {
createBasicDocument();
}
- super.addCharacters(data, start, length);
+ super.addCharacters(data, start, length, locator);
}
/**
1.7 +4 -1 xml-fop/src/java/org/apache/fop/fo/XMLObj.java
Index: XMLObj.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/XMLObj.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XMLObj.java 16 Sep 2003 05:21:04 -0000 1.6
+++ XMLObj.java 26 Dec 2003 22:11:17 -0000 1.7
@@ -57,6 +57,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
import javax.xml.parsers.DocumentBuilderFactory;
// FOP
@@ -224,8 +225,10 @@
* @param data array of characters contaning the text to add
* @param start starting array element to add
* @param length number of characters from the array to add
+ * @param locator location in fo source file.
*/
- protected void addCharacters(char data[], int start, int length) {
+ protected void addCharacters(char data[], int start, int length,
+ Locator locator) {
String str = new String(data, start, length - start);
org.w3c.dom.Text text = doc.createTextNode(str);
element.appendChild(text);
1.3 +6 -2 xml-fop/src/java/org/apache/fop/fo/extensions/Label.java
Index: Label.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/extensions/Label.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Label.java 16 Sep 2003 05:21:05 -0000 1.2
+++ Label.java 26 Dec 2003 22:11:17 -0000 1.3
@@ -50,6 +50,8 @@
*/
package org.apache.fop.fo.extensions;
+import org.xml.sax.Locator;
+
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOTreeVisitor;
@@ -77,8 +79,10 @@
* @param data the character data
* @param start the start position in the data array
* @param end the end position in the character array
+ * @param locator location in fo source file.
*/
- protected void addCharacters(char data[], int start, int end) {
+ protected void addCharacters(char data[], int start, int end,
+ Locator locator) {
label += new String(data, start, end - start);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org