git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193684 13f79535-47bb-0310-9956-ffa450edef68tags/pre-columns
@@ -0,0 +1,114 @@ | |||
/*-- $Id$ -- | |||
============================================================================ | |||
The Apache Software License, Version 1.1 | |||
============================================================================ | |||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||
Redistribution and use in source and binary forms, with or without modifica- | |||
tion, are permitted provided that the following conditions are met: | |||
1. Redistributions of source code must retain the above copyright notice, | |||
this list of conditions and the following disclaimer. | |||
2. Redistributions in binary form must reproduce the above copyright notice, | |||
this list of conditions and the following disclaimer in the documentation | |||
and/or other materials provided with the distribution. | |||
3. The end-user documentation included with the redistribution, if any, must | |||
include the following acknowledgment: "This product includes software | |||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||
Alternately, this acknowledgment may appear in the software itself, if | |||
and wherever such third-party acknowledgments normally appear. | |||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||
endorse or promote products derived from this software without prior | |||
written permission. For written permission, please contact | |||
apache@apache.org. | |||
5. Products derived from this software may not be called "Apache", nor may | |||
"Apache" appear in their name, without prior written permission of the | |||
Apache Software Foundation. | |||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
This software consists of voluntary contributions made by many individuals | |||
on behalf of the Apache Software Foundation and was originally created by | |||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||
Software Foundation, please see <http://www.apache.org/>. | |||
*/ | |||
package org.apache.fop.dom; | |||
import org.apache.fop.datatypes.*; | |||
import org.apache.fop.messaging.*; | |||
import org.apache.fop.dom.svg.*; | |||
import org.w3c.dom.*; | |||
import java.util.*; | |||
/** | |||
* | |||
* | |||
*/ | |||
public class CharacterDataImpl extends NodeImpl implements CharacterData { | |||
String str; | |||
public CharacterDataImpl() | |||
{ | |||
} | |||
public String getData() | |||
{ | |||
return str; | |||
} | |||
public void setData(String s) | |||
{ | |||
str = s; | |||
} | |||
public void insertData(int i, String s) | |||
{ | |||
} | |||
public void deleteData(int i, int j) | |||
{ | |||
} | |||
public int getLength() | |||
{ | |||
return str.length(); | |||
} | |||
public void appendData(String s) | |||
{ | |||
str = str + s; | |||
} | |||
public void replaceData(int i, int j, String s) | |||
{ | |||
} | |||
public String substringData(int i, int j) | |||
{ | |||
return str.substring(i, j); | |||
} | |||
public String toString() | |||
{ | |||
return "Character Data: " + str; | |||
} | |||
} |
@@ -48,7 +48,7 @@ | |||
Software Foundation, please see <http://www.apache.org/>. | |||
*/ | |||
package org.apache.fop.dom.svg; | |||
package org.apache.fop.dom; | |||
import org.apache.fop.datatypes.*; | |||
@@ -60,16 +60,17 @@ import java.util.*; | |||
* | |||
* | |||
*/ | |||
public class ElementImpl implements Element { | |||
Vector childs = new Vector(); | |||
Node parent = null; | |||
public class ElementImpl extends NodeImpl implements Element { | |||
// Vector childs = new Vector(); | |||
// Node parent = null; | |||
// Document ownerDoc; | |||
public Node replaceChild(Node n, Node no) | |||
{ | |||
return null; | |||
} | |||
public String getNodeName() | |||
/* public String getNodeName() | |||
{ | |||
return null; | |||
} | |||
@@ -116,9 +117,21 @@ public class ElementImpl implements Element { | |||
public Document getOwnerDocument() | |||
{ | |||
return null; | |||
return ownerDoc; | |||
} | |||
void setOwnerDocument(Document doc) | |||
{ | |||
ownerDoc = doc; | |||
NodeList nl = getChildNodes(); | |||
for(int count = 0; count < nl.getLength(); count++) { | |||
Node n = nl.item(count); | |||
if(n instanceof ElementImpl) { | |||
((ElementImpl)n).setOwnerDocument(ownerDoc); | |||
} | |||
} | |||
} | |||
public Node insertBefore(Node newChild, | |||
Node refChild) | |||
throws DOMException | |||
@@ -137,7 +150,9 @@ public class ElementImpl implements Element { | |||
{ | |||
childs.addElement(newChild); | |||
if(newChild instanceof ElementImpl) { | |||
((ElementImpl)newChild).parent = this; | |||
ElementImpl ele = (ElementImpl)newChild; | |||
ele.parent = this; | |||
ele.setOwnerDocument(ownerDoc); | |||
} | |||
return newChild; | |||
} | |||
@@ -194,7 +209,7 @@ public class ElementImpl implements Element { | |||
{ | |||
return null; | |||
} | |||
*/ | |||
public String getAttribute(String name) | |||
{ | |||
return null; | |||
@@ -283,7 +298,7 @@ public class ElementImpl implements Element { | |||
return false; | |||
} | |||
} | |||
/* | |||
class NodeListImpl implements NodeList | |||
{ | |||
Vector vect = null; | |||
@@ -302,4 +317,4 @@ class NodeListImpl implements NodeList | |||
{ | |||
return (Node)vect.elementAt(i); | |||
} | |||
} | |||
}*/ |
@@ -0,0 +1,325 @@ | |||
/*-- $Id$ -- | |||
============================================================================ | |||
The Apache Software License, Version 1.1 | |||
============================================================================ | |||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||
Redistribution and use in source and binary forms, with or without modifica- | |||
tion, are permitted provided that the following conditions are met: | |||
1. Redistributions of source code must retain the above copyright notice, | |||
this list of conditions and the following disclaimer. | |||
2. Redistributions in binary form must reproduce the above copyright notice, | |||
this list of conditions and the following disclaimer in the documentation | |||
and/or other materials provided with the distribution. | |||
3. The end-user documentation included with the redistribution, if any, must | |||
include the following acknowledgment: "This product includes software | |||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||
Alternately, this acknowledgment may appear in the software itself, if | |||
and wherever such third-party acknowledgments normally appear. | |||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||
endorse or promote products derived from this software without prior | |||
written permission. For written permission, please contact | |||
apache@apache.org. | |||
5. Products derived from this software may not be called "Apache", nor may | |||
"Apache" appear in their name, without prior written permission of the | |||
Apache Software Foundation. | |||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
This software consists of voluntary contributions made by many individuals | |||
on behalf of the Apache Software Foundation and was originally created by | |||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||
Software Foundation, please see <http://www.apache.org/>. | |||
*/ | |||
package org.apache.fop.dom; | |||
import org.apache.fop.datatypes.*; | |||
import org.w3c.dom.*; | |||
import java.util.*; | |||
/** | |||
* | |||
* | |||
*/ | |||
public class NodeImpl implements Node { | |||
protected Vector childs = new Vector(); | |||
Node parent = null; | |||
protected Document ownerDoc; | |||
public Node replaceChild(Node n, Node no) | |||
{ | |||
return null; | |||
} | |||
public String getNodeName() | |||
{ | |||
return null; | |||
} | |||
public short getNodeType() | |||
{ | |||
return 0; | |||
} | |||
public Node getParentNode() | |||
{ | |||
return parent; | |||
} | |||
public NodeList getChildNodes() | |||
{ | |||
return new NodeListImpl(childs); | |||
} | |||
public Node getFirstChild() | |||
{ | |||
return null; | |||
} | |||
public Node getLastChild() | |||
{ | |||
return null; | |||
} | |||
public Node getPreviousSibling() | |||
{ | |||
return null; | |||
} | |||
public Node getNextSibling() | |||
{ | |||
return null; | |||
} | |||
public NamedNodeMap getAttributes() | |||
{ | |||
return null; | |||
} | |||
public Document getOwnerDocument() | |||
{ | |||
return ownerDoc; | |||
} | |||
void setOwnerDocument(Document doc) | |||
{ | |||
ownerDoc = doc; | |||
NodeList nl = getChildNodes(); | |||
for(int count = 0; count < nl.getLength(); count++) { | |||
Node n = nl.item(count); | |||
if(n instanceof ElementImpl) { | |||
((ElementImpl)n).setOwnerDocument(ownerDoc); | |||
} | |||
} | |||
} | |||
public Node insertBefore(Node newChild, | |||
Node refChild) | |||
throws DOMException | |||
{ | |||
return null; | |||
} | |||
public Node removeChild(Node oldChild) | |||
throws DOMException | |||
{ | |||
return null; | |||
} | |||
public Node appendChild(Node newChild) | |||
throws DOMException | |||
{ | |||
childs.addElement(newChild); | |||
if(newChild instanceof ElementImpl) { | |||
ElementImpl ele = (ElementImpl)newChild; | |||
ele.parent = this; | |||
ele.setOwnerDocument(ownerDoc); | |||
} | |||
return newChild; | |||
} | |||
public boolean hasChildNodes() | |||
{ | |||
return childs.size() > 0; | |||
} | |||
public Node cloneNode(boolean deep) | |||
{ | |||
return null; | |||
} | |||
public void normalize() | |||
{ | |||
} | |||
public boolean supports(String feature, | |||
String version) | |||
{ | |||
return false; | |||
} | |||
public String getNamespaceURI() | |||
{ | |||
return ""; | |||
} | |||
public String getPrefix() | |||
{ | |||
return "svg"; | |||
} | |||
public void setPrefix(String prefix) throws DOMException | |||
{ | |||
} | |||
public String getLocalName() | |||
{ | |||
return null; | |||
} | |||
public String getNodeValue() throws DOMException | |||
{ | |||
return null; | |||
} | |||
public void setNodeValue(String nodeValue) throws DOMException | |||
{ | |||
} | |||
public String getTagName() | |||
{ | |||
return null; | |||
} | |||
/* public String getAttribute(String name) | |||
{ | |||
return null; | |||
} | |||
public void setAttribute(String name, String value) throws DOMException | |||
{ | |||
} | |||
public void removeAttribute(String name) throws DOMException | |||
{ | |||
} | |||
public Attr getAttributeNode(String name) | |||
{ | |||
return null; | |||
} | |||
public Attr setAttributeNode(Attr newAttr) | |||
throws DOMException | |||
{ | |||
return null; | |||
} | |||
public Attr removeAttributeNode(Attr oldAttr) | |||
throws DOMException | |||
{ | |||
return null; | |||
} | |||
public NodeList getElementsByTagName(String name) | |||
{ | |||
return null; | |||
} | |||
public String getAttributeNS(String namespaceURI, | |||
String localName) | |||
{ | |||
return null; | |||
} | |||
public void setAttributeNS(String namespaceURI, | |||
String qualifiedName, | |||
String value) | |||
throws DOMException | |||
{ | |||
} | |||
public void removeAttributeNS(String namespaceURI, | |||
String localName) | |||
throws DOMException | |||
{ | |||
} | |||
public Attr getAttributeNodeNS(String namespaceURI, | |||
String localName) | |||
{ | |||
return null; | |||
} | |||
public Attr setAttributeNodeNS(Attr newAttr) | |||
throws DOMException | |||
{ | |||
return null; | |||
} | |||
public NodeList getElementsByTagNameNS(String namespaceURI, | |||
String localName) | |||
{ | |||
return null; | |||
} | |||
public boolean hasAttributeNS (String namespaceURI, | |||
String localName) | |||
{ | |||
return false; | |||
} | |||
public boolean hasAttribute (String name) | |||
{ | |||
return false; | |||
} | |||
*/ | |||
public boolean hasAttributes() | |||
{ | |||
return false; | |||
} | |||
} | |||
class NodeListImpl implements NodeList | |||
{ | |||
Vector vect = null; | |||
NodeListImpl(Vector v) | |||
{ | |||
vect = v; | |||
} | |||
public int getLength() | |||
{ | |||
return vect.size(); | |||
} | |||
public Node item(int i) | |||
{ | |||
return (Node)vect.elementAt(i); | |||
} | |||
public String toString() | |||
{ | |||
return vect.toString(); | |||
} | |||
} |
@@ -0,0 +1,79 @@ | |||
/*-- $Id$ -- | |||
============================================================================ | |||
The Apache Software License, Version 1.1 | |||
============================================================================ | |||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||
Redistribution and use in source and binary forms, with or without modifica- | |||
tion, are permitted provided that the following conditions are met: | |||
1. Redistributions of source code must retain the above copyright notice, | |||
this list of conditions and the following disclaimer. | |||
2. Redistributions in binary form must reproduce the above copyright notice, | |||
this list of conditions and the following disclaimer in the documentation | |||
and/or other materials provided with the distribution. | |||
3. The end-user documentation included with the redistribution, if any, must | |||
include the following acknowledgment: "This product includes software | |||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||
Alternately, this acknowledgment may appear in the software itself, if | |||
and wherever such third-party acknowledgments normally appear. | |||
4. The names "Fop" and "Apache Software Foundation" must not be used to | |||
endorse or promote products derived from this software without prior | |||
written permission. For written permission, please contact | |||
apache@apache.org. | |||
5. Products derived from this software may not be called "Apache", nor may | |||
"Apache" appear in their name, without prior written permission of the | |||
Apache Software Foundation. | |||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
This software consists of voluntary contributions made by many individuals | |||
on behalf of the Apache Software Foundation and was originally created by | |||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||
Software Foundation, please see <http://www.apache.org/>. | |||
*/ | |||
package org.apache.fop.dom.svg; | |||
import org.w3c.dom.svg.*; | |||
/** | |||
* a length quantity in XSL | |||
*/ | |||
public class SVGAnimatedLengthListImpl extends SVGListImpl implements SVGAnimatedLengthList { | |||
SVGLengthList baseVal; | |||
public SVGAnimatedLengthListImpl() | |||
{ | |||
} | |||
public SVGLengthList getBaseVal( ) | |||
{ | |||
return baseVal; | |||
} | |||
public void setBaseVal(SVGLengthList baseVal) | |||
{ | |||
this.baseVal = baseVal; | |||
} | |||
public SVGLengthList getAnimVal( ) | |||
{ | |||
return baseVal; | |||
} | |||
} |
@@ -52,6 +52,8 @@ package org.apache.fop.dom.svg; | |||
import java.util.*; | |||
import org.apache.fop.dom.ElementImpl; | |||
import org.w3c.dom.svg.*; | |||
import org.w3c.dom.*; | |||
import org.w3c.dom.events.*; | |||
@@ -65,6 +67,7 @@ public class SVGDocumentImpl extends ElementImpl implements SVGDocument { | |||
public SVGDocumentImpl() | |||
{ | |||
ownerDoc = this; | |||
} | |||
public String getTitle() | |||
@@ -77,6 +80,11 @@ public class SVGDocumentImpl extends ElementImpl implements SVGDocument { | |||
this.title = title; | |||
} | |||
public String getNamespaceURI() | |||
{ | |||
return namespaceURI; | |||
} | |||
public String getReferrer() | |||
{ | |||
return null; | |||
@@ -99,6 +107,27 @@ public class SVGDocumentImpl extends ElementImpl implements SVGDocument { | |||
public Element getElementById(String elementId) | |||
{ | |||
SVGSVGElement svg = getRootElement(); | |||
return findChild(svg, elementId); | |||
} | |||
protected Element findChild(Node ele, String id) | |||
{ | |||
NodeList nl = ele.getChildNodes(); | |||
for(int count = 0; count < nl.getLength(); count++) { | |||
Node n = nl.item(count); | |||
if(n instanceof SVGElement) { | |||
if(id.equals(((SVGElement)n).getId())) { | |||
return (Element)n; | |||
} | |||
} | |||
if(n != null) { | |||
Element el = findChild(n, id); | |||
if(el != null) { | |||
return el; | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
@@ -51,6 +51,7 @@ | |||
package org.apache.fop.dom.svg; | |||
import org.apache.fop.datatypes.*; | |||
import org.apache.fop.dom.ElementImpl; | |||
import org.w3c.dom.css.CSSStyleDeclaration; | |||
import org.w3c.dom.css.CSSValue; | |||
@@ -68,6 +69,11 @@ public abstract class SVGElementImpl extends ElementImpl implements SVGElement { | |||
return idString; | |||
} | |||
public String getNamespaceURI() | |||
{ | |||
return SVGDocumentImpl.namespaceURI; | |||
} | |||
public void setId(String id) | |||
{ | |||
idString = id; | |||
@@ -96,6 +102,9 @@ public abstract class SVGElementImpl extends ElementImpl implements SVGElement { | |||
{ | |||
CSSStyleDeclaration style; | |||
style = getStyle(); | |||
if(style == null) { | |||
return null; | |||
} | |||
CSSValue val; | |||
val = style.getPropertyCSSValue(name); | |||
if(val == null) { |
@@ -61,10 +61,6 @@ import org.w3c.dom.svg.*; | |||
* a length quantity in XSL | |||
*/ | |||
public class SVGLengthListImpl extends SVGListImpl implements SVGLengthList { | |||
protected float millipoints = 0; | |||
protected Vector valueList = new Vector(); | |||
protected float fontsize = 12; | |||
public void setValueAsString( String valueAsString ) | |||
@@ -97,25 +93,22 @@ public class SVGLengthListImpl extends SVGListImpl implements SVGLengthList { | |||
int l = len.length(); | |||
if (l == 0) { | |||
MessageHandler.errorln("WARNING: empty length"); | |||
this.millipoints = 0; | |||
// MessageHandler.errorln("WARNING: empty length"); | |||
} else { | |||
// could be an array of points, as in for svg:text | |||
int pos; | |||
pos = len.trim().indexOf(" "); | |||
if(pos != -1) { | |||
this.millipoints = 0; | |||
StringTokenizer st = new StringTokenizer(len.trim()); | |||
while(st.hasMoreTokens()) { | |||
String val = st.nextToken(); | |||
float dvalue = getFloatValue(val, val.length()); | |||
float intValue = dvalue; | |||
this.valueList.addElement(new Float(intValue)); | |||
appendItem(new Float(intValue)); | |||
} | |||
} else { | |||
float dvalue = getFloatValue(len, l); | |||
this.millipoints = dvalue; | |||
this.valueList.addElement(new Float(millipoints)); | |||
appendItem(new Float(dvalue)); | |||
} | |||
} | |||
} | |||
@@ -158,12 +151,4 @@ public class SVGLengthListImpl extends SVGListImpl implements SVGLengthList { | |||
} | |||
return dvalue; | |||
} | |||
/** | |||
* return the length in 1/1000ths of a point | |||
*/ | |||
public Vector valueList() | |||
{ | |||
return this.valueList; | |||
} | |||
} |
@@ -62,12 +62,10 @@ public class SVGTSpanElementImpl extends SVGTextContentElementImpl implements SV | |||
public String str; | |||
public int dx = 0; | |||
public int dy = 0; | |||
// public int x = 0; | |||
// public int y = 0; | |||
public Vector xlist = null; | |||
public Vector ylist = null; | |||
public Vector dxlist = null; | |||
public Vector dylist = null; | |||
public SVGAnimatedLengthList xlist = null; | |||
public SVGAnimatedLengthList ylist = null; | |||
public SVGAnimatedLengthList dxlist = null; | |||
public SVGAnimatedLengthList dylist = null; | |||
/** | |||
* | |||
@@ -78,22 +76,22 @@ public class SVGTSpanElementImpl extends SVGTextContentElementImpl implements SV | |||
public SVGAnimatedLengthList getX( ) | |||
{ | |||
return null; | |||
return xlist; | |||
} | |||
public SVGAnimatedLengthList getY( ) | |||
{ | |||
return null; | |||
return ylist; | |||
} | |||
public SVGAnimatedLengthList getDx( ) | |||
{ | |||
return null; | |||
return dxlist; | |||
} | |||
public SVGAnimatedLengthList getDy( ) | |||
{ | |||
return null; | |||
return dylist; | |||
} | |||
public SVGAnimatedTextRotate getRotate( ) |