deweese 2002/08/28 13:14:51
Modified: sources/org/apache/batik/swing/svg JSVGComponent.java
sources/org/apache/batik/util
ParsedURLDefaultProtocolHandler.java
Log:
Fixed a bug in linking with 'a' element and relative URLs.
Revision Changes Path
1.58 +19 -13 xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java
Index: JSVGComponent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- JSVGComponent.java 2 Aug 2002 00:18:35 -0000 1.57
+++ JSVGComponent.java 28 Aug 2002 20:14:51 -0000 1.58
@@ -2446,29 +2446,35 @@
return;
}
+ // Always use anchor element's document for base URI,
+ // for when it comes from an external resource.
+ ParsedURL newURI = new ParsedURL
+ (((SVGDocument)elt.getOwnerDocument()).getURL(), href);
+
+ // replace href with a fully resolved URI.
+ href = newURI.toString();
+
// Avoid reloading if possible.
if (svgDocument != null) {
- // if the anchor element is in an external resource
- if (elt.getOwnerDocument() != svgDocument) {
- SVGDocument doc = (SVGDocument)elt.getOwnerDocument();
- href = new ParsedURL(doc.getURL(), href).toString();
- }
ParsedURL oldURI = new ParsedURL(svgDocument.getURL());
- ParsedURL newURI = new ParsedURL(oldURI, href);
-
- String s = newURI.getRef();
+ // Check if they reference the same file.
if (newURI.sameFile(oldURI)) {
- if ((fragmentIdentifier == null && s != null) ||
- (s == null && fragmentIdentifier != null) ||
- (s != null && !s.equals(fragmentIdentifier))) {
+ // They do, see if it's a new Fragment Ident.
+ String s = newURI.getRef();
+ if ((fragmentIdentifier != s) &&
+ ((s == null) || (!s.equals(fragmentIdentifier)))) {
+ // It is, so update rendering transform.
fragmentIdentifier = s;
computeRenderingTransform();
}
- fireLinkActivatedEvent(elt, newURI.toString());
+ // Let every one know the link fired (but don't
+ // load doc, it's already loaded.).
+ fireLinkActivatedEvent(elt, href);
return;
}
}
+
fireLinkActivatedEvent(elt, href);
if (svgUserAgent != null) {
svgUserAgent.openLink(href, false);
1.10 +6 -6
xml-batik/sources/org/apache/batik/util/ParsedURLDefaultProtocolHandler.java
Index: ParsedURLDefaultProtocolHandler.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURLDefaultProtocolHandler.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ParsedURLDefaultProtocolHandler.java 1 Aug 2002 20:24:32 -0000 1.9
+++ ParsedURLDefaultProtocolHandler.java 28 Aug 2002 20:14:51 -0000 1.10
@@ -68,14 +68,14 @@
public ParsedURLData parseURL(String urlStr) {
try {
URL url = new URL(urlStr);
- // System.out.println("System Parse: " + urlStr);
+ // System.err.println("System Parse: " + urlStr);
return constructParsedURLData(url);
} catch (MalformedURLException mue) {
// Built in URL wouldn't take it...
}
// new Exception("Custom Parse: " + urlStr).printStackTrace();
- // System.out.println("Custom Parse: " + urlStr);
+ // System.err.println("Custom Parse: " + urlStr);
ParsedURLData ret = constructParsedURLData();
@@ -222,7 +222,7 @@
if (urlStr.length() == 0)
return baseURL.data;
- // System.out.println("Base: " + baseURL + "\n" +
+ // System.err.println("Base: " + baseURL + "\n" +
// "Sub: " + urlStr);
int idx;
@@ -291,8 +291,8 @@
else
path = path.substring(0,idx+1);
- // System.out.println("Base Path: " + path);
- // System.out.println("Base PortStr: " + baseURL.getPortStr());
+ // System.err.println("Base Path: " + path);
+ // System.err.println("Base PortStr: " + baseURL.getPortStr());
return parseURL(baseURL.getPortStr() + path + urlStr);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]