removing svg from save operation

This commit is contained in:
Pablo Luna
2011-03-31 15:16:45 +01:00
parent 6cc4d2eaff
commit c4021bf3c4
13 changed files with 32 additions and 63 deletions

View File

@@ -64,8 +64,7 @@ public class EmbeddedViewController extends BaseMultiActionController {
} else {
view = new ModelAndView("embeddedViewImg");
view.addObject("mindmap", mindmap);
view = new ModelAndView("embeddedViewNotSupported");
}
view.addObject("fullView", fullView);

View File

@@ -20,7 +20,6 @@ package com.wisemapping.controller;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.MindMapNative;
import com.wisemapping.model.User;
import com.wisemapping.security.Utils;
import com.wisemapping.service.MindmapService;
@@ -55,8 +54,6 @@ public class NewMindmapController
final String defaultNativeMap = getDefaultMindmapXml(title);
mindmap.setNativeXml(defaultNativeMap);
final MindMapNative nativeBrowser = new MindMapNative();
mindmap.setNativeBrowser(nativeBrowser);
final User dbUSer = getUserService().getUserBy(user.getId());
service.addMindmap(mindmap, dbUSer);

View File

@@ -32,7 +32,6 @@ import java.util.Calendar;
import java.util.Date;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.MindMapNative;
import com.wisemapping.model.User;
import com.wisemapping.service.MindmapService;
import com.wisemapping.exceptions.WiseMappingException;
@@ -50,22 +49,12 @@ public class MapEditorService
}
public ResponseMessage saveMap(final int mapId, final String nativeXml,
String chartXml, final String editorProperties,boolean saveHistory)
final String editorProperties,boolean saveHistory)
throws IOException, WiseMappingException {
final MindmapService serservice = getMindmapService();
final MindMap mindMap = serservice.getMindmapById(mapId);
final User user = this.getUser();
MindMapNative nativeBrowser = mindMap.getNativeBrowser();
if (nativeBrowser == null) {
nativeBrowser = new MindMapNative();
}
nativeBrowser.setSvgXml(chartXml);
nativeBrowser.setVmlXml((byte[]) null);
mindMap.setNativeBrowser(nativeBrowser);
mindMap.setProperties(editorProperties);
final Calendar now = Calendar.getInstance();

View File

@@ -23,7 +23,6 @@ import com.wisemapping.importer.Importer;
import com.wisemapping.importer.ImporterException;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.ShapeStyle;
import com.wisemapping.model.MindMapNative;
import com.wisemapping.util.JAXBUtils;
import com.wisemapping.xml.freemind.*;
import com.wisemapping.xml.freemind.Map;
@@ -93,7 +92,6 @@ public class FreemindImporter
map.setNativeXml(new String(out.toByteArray(), Charset.forName("UTF-8")));
map.setTitle(mapName);
map.setDescription(description);
map.setNativeBrowser(new MindMapNative());
} catch (JAXBException e) {
throw new ImporterException(e);

View File

@@ -64,7 +64,7 @@ public class MindMap {
private String lastModifierUser;
private Set<MindmapUser> mindmapUsers = new HashSet<MindmapUser>();
private MindMapNative nativeBrowser;
private MindMapNative nativeBrowser = new MindMapNative();
private User owner;
private String properties;
private String tags;
@@ -218,38 +218,15 @@ public class MindMap {
public char[] generateSvgXml(String mapSvg)
throws IOException, JAXBException {
String svgText = mapSvg;
final MindMapNative mindmapNativeBrowser = this.getNativeBrowser();
if(svgText==null){
svgText = mindmapNativeBrowser.getUnzippedSvgXml();
}
if (svgText == null || svgText.length() == 0) {
// The map must be saved using IE. Convert VML to SVG.
// Add namespace to the converter ...
String vmlXml = mindmapNativeBrowser.getUnzippedVmlXml();
vmlXml = vmlXml.replaceFirst("<v:group ", "<v:group xmlns:v=\"http://wisemapping.com/xml/vmlmap\" ");
String result = "<?xml version='1.0' encoding='UTF-8'?>\n" + svgText;
char[] bytes = vmlXml.toCharArray();
final CharArrayReader is = new CharArrayReader(bytes);
// Convert Map ...
final VmlToSvgConverter converter = new VmlToSvgConverter();
converter.convert(is);
final CharArrayWriter os = new CharArrayWriter();
converter.toXml(os);
return os.toCharArray();
} else {
String result = "<?xml version='1.0' encoding='UTF-8'?>\n" + svgText;
// Add namespace...
result = result.replaceFirst("<svg ", "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
// Add namespace...
result = result.replaceFirst("<svg ", "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
// result = result.replaceAll("<image([^>]+)>", "<image$1/>");
return result.toCharArray();
}
return result.toCharArray();
}
public String getDescription() {

View File

@@ -229,12 +229,6 @@ public class MindmapServiceImpl
welcomeMap.setDescription(savedWelcome.getDescription());
welcomeMap.setXml(savedWelcome.getXml());
final MindMapNative mindmapNative = new MindMapNative();
mindmapNative.setSvgXml(savedWelcome.getNativeBrowser().getSvgXml());
mindmapNative.setVmlXml(savedWelcome.getNativeBrowser().getVmlXml());
welcomeMap.setNativeBrowser(mindmapNative);
addMindmap(welcomeMap, user);
}
}