Procházet zdrojové kódy

changes for the text elements, character data, tspan etc.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193684 13f79535-47bb-0310-9956-ffa450edef68
tags/pre-columns
Keiron Liddle před 24 roky
rodič
revize
53ff53db6b

+ 114
- 0
src/org/apache/fop/dom/CharacterDataImpl.java Zobrazit soubor

/*-- $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;
}
}

src/org/apache/fop/dom/svg/ElementImpl.java → src/org/apache/fop/dom/ElementImpl.java Zobrazit soubor

Software Foundation, please see <http://www.apache.org/>. Software Foundation, please see <http://www.apache.org/>.


*/ */
package org.apache.fop.dom.svg;
package org.apache.fop.dom;


import org.apache.fop.datatypes.*; import org.apache.fop.datatypes.*;


* *
* *
*/ */
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) public Node replaceChild(Node n, Node no)
{ {
return null; return null;
} }


public String getNodeName()
/* public String getNodeName()
{ {
return null; return null;
} }


public Document getOwnerDocument() 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, public Node insertBefore(Node newChild,
Node refChild) Node refChild)
throws DOMException throws DOMException
{ {
childs.addElement(newChild); childs.addElement(newChild);
if(newChild instanceof ElementImpl) { if(newChild instanceof ElementImpl) {
((ElementImpl)newChild).parent = this;
ElementImpl ele = (ElementImpl)newChild;
ele.parent = this;
ele.setOwnerDocument(ownerDoc);
} }
return newChild; return newChild;
} }
{ {
return null; return null;
} }
*/
public String getAttribute(String name) public String getAttribute(String name)
{ {
return null; return null;
return false; return false;
} }
} }
/*
class NodeListImpl implements NodeList class NodeListImpl implements NodeList
{ {
Vector vect = null; Vector vect = null;
{ {
return (Node)vect.elementAt(i); return (Node)vect.elementAt(i);
} }
}
}*/

+ 325
- 0
src/org/apache/fop/dom/NodeImpl.java Zobrazit soubor

/*-- $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();
}
}

+ 79
- 0
src/org/apache/fop/dom/svg/SVGAnimatedLengthListImpl.java Zobrazit soubor

/*-- $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;
}
}

+ 29
- 0
src/org/apache/fop/dom/svg/SVGDocumentImpl.java Zobrazit soubor



import java.util.*; import java.util.*;


import org.apache.fop.dom.ElementImpl;

import org.w3c.dom.svg.*; import org.w3c.dom.svg.*;
import org.w3c.dom.*; import org.w3c.dom.*;
import org.w3c.dom.events.*; import org.w3c.dom.events.*;


public SVGDocumentImpl() public SVGDocumentImpl()
{ {
ownerDoc = this;
} }


public String getTitle() public String getTitle()
this.title = title; this.title = title;
} }


public String getNamespaceURI()
{
return namespaceURI;
}

public String getReferrer() public String getReferrer()
{ {
return null; return null;


public Element getElementById(String elementId) 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; return null;
} }



+ 9
- 0
src/org/apache/fop/dom/svg/SVGElementImpl.java Zobrazit soubor

package org.apache.fop.dom.svg; package org.apache.fop.dom.svg;


import org.apache.fop.datatypes.*; import org.apache.fop.datatypes.*;
import org.apache.fop.dom.ElementImpl;


import org.w3c.dom.css.CSSStyleDeclaration; import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSValue; import org.w3c.dom.css.CSSValue;
return idString; return idString;
} }


public String getNamespaceURI()
{
return SVGDocumentImpl.namespaceURI;
}

public void setId(String id) public void setId(String id)
{ {
idString = id; idString = id;
{ {
CSSStyleDeclaration style; CSSStyleDeclaration style;
style = getStyle(); style = getStyle();
if(style == null) {
return null;
}
CSSValue val; CSSValue val;
val = style.getPropertyCSSValue(name); val = style.getPropertyCSSValue(name);
if(val == null) { if(val == null) {

+ 3
- 18
src/org/apache/fop/dom/svg/SVGLengthListImpl.java Zobrazit soubor

* a length quantity in XSL * a length quantity in XSL
*/ */
public class SVGLengthListImpl extends SVGListImpl implements SVGLengthList { public class SVGLengthListImpl extends SVGListImpl implements SVGLengthList {

protected float millipoints = 0;
protected Vector valueList = new Vector();

protected float fontsize = 12; protected float fontsize = 12;


public void setValueAsString( String valueAsString ) public void setValueAsString( String valueAsString )
int l = len.length(); int l = len.length();


if (l == 0) { if (l == 0) {
MessageHandler.errorln("WARNING: empty length");
this.millipoints = 0;
// MessageHandler.errorln("WARNING: empty length");
} else { } else {
// could be an array of points, as in for svg:text // could be an array of points, as in for svg:text
int pos; int pos;
pos = len.trim().indexOf(" "); pos = len.trim().indexOf(" ");
if(pos != -1) { if(pos != -1) {
this.millipoints = 0;
StringTokenizer st = new StringTokenizer(len.trim()); StringTokenizer st = new StringTokenizer(len.trim());
while(st.hasMoreTokens()) { while(st.hasMoreTokens()) {
String val = st.nextToken(); String val = st.nextToken();
float dvalue = getFloatValue(val, val.length()); float dvalue = getFloatValue(val, val.length());
float intValue = dvalue; float intValue = dvalue;
this.valueList.addElement(new Float(intValue));
appendItem(new Float(intValue));
} }
} else { } else {
float dvalue = getFloatValue(len, l); float dvalue = getFloatValue(len, l);
this.millipoints = dvalue;
this.valueList.addElement(new Float(millipoints));
appendItem(new Float(dvalue));
} }
} }
} }
} }
return dvalue; return dvalue;
} }

/**
* return the length in 1/1000ths of a point
*/
public Vector valueList()
{
return this.valueList;
}
} }

+ 8
- 10
src/org/apache/fop/dom/svg/SVGTSpanElementImpl.java Zobrazit soubor

public String str; public String str;
public int dx = 0; public int dx = 0;
public int dy = 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;


/** /**
* *


public SVGAnimatedLengthList getX( ) public SVGAnimatedLengthList getX( )
{ {
return null;
return xlist;
} }


public SVGAnimatedLengthList getY( ) public SVGAnimatedLengthList getY( )
{ {
return null;
return ylist;
} }


public SVGAnimatedLengthList getDx( ) public SVGAnimatedLengthList getDx( )
{ {
return null;
return dxlist;
} }


public SVGAnimatedLengthList getDy( ) public SVGAnimatedLengthList getDy( )
{ {
return null;
return dylist;
} }


public SVGAnimatedTextRotate getRotate( ) public SVGAnimatedTextRotate getRotate( )

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