mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Fix SVG export tests...
This commit is contained in:
parent
202c3f28a3
commit
b6ee7e61b8
4
pom.xml
4
pom.xml
@ -105,8 +105,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -140,9 +140,7 @@ public class ExporterFactory {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
final DocumentBuilder documentBuilder = factory.newDocumentBuilder();
|
||||
|
||||
if (!svgXml.trim().startsWith("<svg xmlns=\"http://www.w3.org/2000/svg\"")) {
|
||||
svgXml = svgXml.replaceFirst("<svg ", "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
|
||||
} else {
|
||||
if (!svgXml.contains("xmlns:xlink=\"http://www.w3.org/1999/xlink\"")) {
|
||||
svgXml = svgXml.replaceFirst("<svg ", "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
|
||||
}
|
||||
|
||||
@ -222,30 +220,32 @@ public class ExporterFactory {
|
||||
|
||||
Element elem = (Element) node;
|
||||
|
||||
// Cook image href ...
|
||||
// If the image is a external URL, embeed it...
|
||||
String imgUrl = elem.getAttribute("href");
|
||||
elem.removeAttribute("href");
|
||||
if (!imgUrl.startsWith("image/png;base64") ||!imgUrl.startsWith("data:image/png;base64") ) {
|
||||
elem.removeAttribute("href");
|
||||
|
||||
if (imgUrl == null || imgUrl.isEmpty()) {
|
||||
imgUrl = elem.getAttribute("xlink:href"); // Do not support namespaces ...
|
||||
elem.removeAttribute("xlink:href");
|
||||
}
|
||||
FileInputStream fis = null;
|
||||
if (imgUrl == null || imgUrl.isEmpty()) {
|
||||
imgUrl = elem.getAttribute("xlink:href"); // Do not support namespaces ...
|
||||
elem.removeAttribute("xlink:href");
|
||||
}
|
||||
FileInputStream fis = null;
|
||||
|
||||
// Obtains file name ...
|
||||
try {
|
||||
final File iconFile = iconFile(imgUrl);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
fis = new FileInputStream(iconFile);
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
encoder.encode(fis, bos);
|
||||
// Obtains file name ...
|
||||
try {
|
||||
final File iconFile = iconFile(imgUrl);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
fis = new FileInputStream(iconFile);
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
encoder.encode(fis, bos);
|
||||
|
||||
elem.setAttribute("xlink:href", "data:image/png;base64," + bos.toString("8859_1"));
|
||||
elem.appendChild(document.createTextNode(" "));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(fis);
|
||||
elem.setAttribute("xlink:href", "data:image/png;base64," + bos.toString("8859_1"));
|
||||
elem.appendChild(document.createTextNode(" "));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(fis);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user