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