mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-22 19:33:48 +01:00
Quich fix for export error
This commit is contained in:
parent
bd7c83f17d
commit
92d39f0a08
@ -38,6 +38,7 @@ import java.io.IOException;
|
||||
public class ExportController extends BaseMultiActionController {
|
||||
private static final String IMG_EXPORT_FORMAT = "IMG_EXPORT_FORMAT";
|
||||
private static final String MAP_ID_PARAMETER = "mapId";
|
||||
private static final String MAP_SVG_PARAMETER = "mapSvg";
|
||||
private static final String EXPORT_FORMAT_PARAMETER = "exportFormat";
|
||||
private static final String IMG_SIZE_PARAMETER = "imgSize";
|
||||
|
||||
@ -57,6 +58,8 @@ public class ExportController extends BaseMultiActionController {
|
||||
|
||||
int mindmapId = Integer.parseInt(mapIdStr);
|
||||
|
||||
final String mapSvg = request.getParameter(MAP_SVG_PARAMETER);
|
||||
|
||||
String formatStr = request.getParameter(EXPORT_FORMAT_PARAMETER);
|
||||
if (IMG_EXPORT_FORMAT.endsWith(formatStr)) {
|
||||
formatStr = request.getParameter("imgFormat");
|
||||
@ -92,7 +95,7 @@ public class ExportController extends BaseMultiActionController {
|
||||
|
||||
// Write content ...
|
||||
final ServletOutputStream outputStream = response.getOutputStream();
|
||||
mindMap.export(properties, outputStream);
|
||||
mindMap.export(properties, outputStream, mapSvg);
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
@ -135,6 +138,8 @@ public class ExportController extends BaseMultiActionController {
|
||||
logger.info("Export Controller: generating image WiseMap action");
|
||||
|
||||
final String mapIdStr = request.getParameter(MAP_ID_PARAMETER);
|
||||
final String mapSvg = request.getParameter(MAP_SVG_PARAMETER);
|
||||
|
||||
int mindmapId = Integer.parseInt(mapIdStr);
|
||||
final MindmapService service = getMindmapService();
|
||||
final MindMap mindMap = service.getMindmapById(mindmapId);
|
||||
@ -154,7 +159,7 @@ public class ExportController extends BaseMultiActionController {
|
||||
|
||||
// Write content ...
|
||||
final ServletOutputStream outputStream = response.getOutputStream();
|
||||
mindMap.export(imageProperties, outputStream);
|
||||
mindMap.export(imageProperties, outputStream, mapSvg);
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
|
@ -52,7 +52,7 @@ public class SvgExporter {
|
||||
private SvgExporter() {
|
||||
}
|
||||
|
||||
public static void export(ExportProperties properties, MindMap map, OutputStream output) throws TranscoderException, IOException, ParserConfigurationException, SAXException, XMLStreamException, TransformerException, JAXBException, ExportException {
|
||||
public static void export(ExportProperties properties, MindMap map, OutputStream output, String mapSvg) throws TranscoderException, IOException, ParserConfigurationException, SAXException, XMLStreamException, TransformerException, JAXBException, ExportException {
|
||||
final ExportFormat format = properties.getFormat();
|
||||
|
||||
final String imgPath = properties.getBaseImgPath();
|
||||
@ -66,7 +66,7 @@ public class SvgExporter {
|
||||
transcoder.addTranscodingHint(ImageTranscoder.KEY_WIDTH, size.getWidth());
|
||||
|
||||
// Create the transcoder input.
|
||||
char[] xml = map.generateSvgXml();
|
||||
char[] xml = map.generateSvgXml(mapSvg);
|
||||
xml = normalizeSvg(xml, imgPath);
|
||||
final CharArrayReader is = new CharArrayReader(xml);
|
||||
TranscoderInput input = new TranscoderInput(is);
|
||||
@ -87,7 +87,7 @@ public class SvgExporter {
|
||||
transcoder.addTranscodingHint(ImageTranscoder.KEY_WIDTH, size.getWidth());
|
||||
|
||||
// Create the transcoder input.
|
||||
final char[] xml = map.generateSvgXml();
|
||||
final char[] xml = map.generateSvgXml(mapSvg);
|
||||
char[] svgXml = normalizeSvg(xml, imgPath);
|
||||
final CharArrayReader is = new CharArrayReader(svgXml);
|
||||
TranscoderInput input = new TranscoderInput(is);
|
||||
@ -102,7 +102,7 @@ public class SvgExporter {
|
||||
final Transcoder transcoder = new PDFTranscoder();
|
||||
|
||||
// Create the transcoder input.
|
||||
final char[] xml = map.generateSvgXml();
|
||||
final char[] xml = map.generateSvgXml(mapSvg);
|
||||
char[] svgXml = normalizeSvg(xml, imgPath);
|
||||
final CharArrayReader is = new CharArrayReader(svgXml);
|
||||
TranscoderInput input = new TranscoderInput(is);
|
||||
@ -113,7 +113,7 @@ public class SvgExporter {
|
||||
break;
|
||||
}
|
||||
case SVG: {
|
||||
final char[] xml = map.generateSvgXml();
|
||||
final char[] xml = map.generateSvgXml(mapSvg);
|
||||
char[] svgXml = normalizeSvg(xml, imgPath);
|
||||
output.write(new String(svgXml).getBytes("UTF-8"));
|
||||
break;
|
||||
|
@ -215,10 +215,13 @@ public class MindMap {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public char[] generateSvgXml()
|
||||
public char[] generateSvgXml(String mapSvg)
|
||||
throws IOException, JAXBException {
|
||||
String svgText = mapSvg;
|
||||
final MindMapNative mindmapNativeBrowser = this.getNativeBrowser();
|
||||
String svgText = mindmapNativeBrowser.getUnzippedSvgXml();
|
||||
if(svgText==null){
|
||||
svgText = mindmapNativeBrowser.getUnzippedSvgXml();
|
||||
}
|
||||
|
||||
if (svgText == null || svgText.length() == 0) {
|
||||
// The map must be saved using IE. Convert VML to SVG.
|
||||
@ -265,8 +268,8 @@ public class MindMap {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
public void export(final ExportProperties properties, OutputStream output) throws JAXBException, TranscoderException, TransformerException, IOException, ParserConfigurationException, ExportException, SAXException, XMLStreamException {
|
||||
SvgExporter.export(properties, this, output);
|
||||
public void export(final ExportProperties properties, OutputStream output, String mapSvg) throws JAXBException, TranscoderException, TransformerException, IOException, ParserConfigurationException, ExportException, SAXException, XMLStreamException {
|
||||
SvgExporter.export(properties, this, output, mapSvg);
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
|
@ -38,6 +38,7 @@
|
||||
<form method="post" id="printForm" name="printForm" action='<c:url value="export.htm"/>' style="height:100%;" target="${mindmap.title}">
|
||||
<input type="hidden" name="action" value="print" >
|
||||
<input type="hidden" name="mapId" value="${mindmap.id}" >
|
||||
<input type="hidden" name="mapSvg" value="">
|
||||
</form>
|
||||
|
||||
<div id="waitDialog" style="display:none">
|
||||
@ -76,6 +77,7 @@
|
||||
var isTryMode = ${editorTryMode};
|
||||
|
||||
function printMap() {
|
||||
document.printForm.mapSvg.value = $("workspaceContainer").innerHTML;
|
||||
document.printForm.submit();
|
||||
}
|
||||
</script>
|
||||
|
@ -7,6 +7,7 @@
|
||||
<form method="post" id="exportForm" name="exportForm" action="<c:url value="export.htm"/>" style="height:100%;">
|
||||
<input type="hidden" name="action" value="export"/>
|
||||
<input type="hidden" name="mapId" value="${mindmap.id}"/>
|
||||
<input type="hidden" name="mapSvg" value=""/>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -88,4 +89,6 @@
|
||||
|
||||
});
|
||||
|
||||
document.exportForm.mapSvg.value = $("workspaceContainer").innerHTML;
|
||||
|
||||
</script>
|
@ -227,10 +227,10 @@
|
||||
<spring:message code="PUBLISH"/>
|
||||
</a>
|
||||
</c:if>
|
||||
<a href="export.htm?mapId=${mindmap.id}"
|
||||
<%--<a href="export.htm?mapId=${mindmap.id}"
|
||||
rel="moodalbox 600px 400px" title="<spring:message code="EXPORT_DETAILS"/>">
|
||||
<spring:message code="EXPORT"/>
|
||||
</a>
|
||||
</a>--%>
|
||||
<a href="javascript:printMap(${mindmap.id});">
|
||||
<spring:message code="PRINT"/>
|
||||
</a>
|
||||
|
@ -3,11 +3,7 @@ package com.wisemapping.test.export;
|
||||
import com.wisemapping.exporter.ExportException;
|
||||
import com.wisemapping.exporter.ExportFormat;
|
||||
import com.wisemapping.exporter.ExportProperties;
|
||||
import com.wisemapping.exporter.freemind.FreemindExporter;
|
||||
import com.wisemapping.importer.ImportFormat;
|
||||
import com.wisemapping.importer.Importer;
|
||||
import com.wisemapping.importer.ImporterException;
|
||||
import com.wisemapping.importer.ImporterFactory;
|
||||
|
||||
import com.wisemapping.model.MindMap;
|
||||
import com.wisemapping.model.MindMapNative;
|
||||
@ -23,8 +19,6 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
@Test
|
||||
public class ExportTest {
|
||||
@ -60,7 +54,7 @@ public class ExportTest {
|
||||
if(pngFile.exists()){
|
||||
// Export mile content ...
|
||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
mindMap.export(properties, bos);
|
||||
mindMap.export(properties, bos, svgXml);
|
||||
|
||||
// Load rec file co
|
||||
final FileInputStream fis = new FileInputStream(pngFile);
|
||||
@ -92,7 +86,7 @@ public class ExportTest {
|
||||
}
|
||||
else{
|
||||
OutputStream outputStream = new FileOutputStream(pngFile, false);
|
||||
mindMap.export(properties, outputStream);
|
||||
mindMap.export(properties, outputStream, svgXml);
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user