Fix parser error on export.

This commit is contained in:
Paulo Gustavo Veiga 2012-11-01 00:14:21 -03:00
parent dafe8eeb03
commit e5e2e86fce
4 changed files with 11 additions and 3 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ wisemapping.log*
*/.DS_Store */.DS_Store
.DS_Store .DS_Store
target target
.idea

View File

@ -207,7 +207,8 @@ public class FreemindExporter
htmlContent.append("</body></html>"); htmlContent.append("</body></html>");
DocumentBuilder db = getInstanceBuilder(); DocumentBuilder db = getInstanceBuilder();
Document document = db.parse(new ByteArrayInputStream(htmlContent.toString().getBytes())); byte[] bytes = htmlContent.toString().getBytes("UTF-8");
Document document = db.parse(new ByteArrayInputStream(bytes), "UTF-8");
richcontent.setHtml(document.getDocumentElement()); richcontent.setHtml(document.getDocumentElement());
return richcontent; return richcontent;
} }

View File

@ -119,6 +119,12 @@ public class FreemindImporter
final String version = freemindMap.getVersion(); final String version = freemindMap.getVersion();
if (version != null) { if (version != null) {
// Is freemind mindmap ?
if (version.charAt(0) != '0') {
throw new ImporterException("Mindmap is not a FreeMind document. Document type info " + version);
}
final VersionNumber mapVersion = new VersionNumber(version); final VersionNumber mapVersion = new VersionNumber(version);
if (SUPPORTED_FREEMIND_VERSION.isGreaterThan(mapVersion)) { if (SUPPORTED_FREEMIND_VERSION.isGreaterThan(mapVersion)) {
throw new ImporterException("FreeMind version " + mapVersion.getVersion() + " is not supported."); throw new ImporterException("FreeMind version " + mapVersion.getVersion() + " is not supported.");
@ -408,7 +414,7 @@ public class FreemindImporter
if (depth == 1) { if (depth == 1) {
final String side = freeChild.getPOSITION(); final String side = freeChild.getPOSITION();
x = x * (side!=null && POSITION_LEFT.equals(side) ? -1 : 1); x = x * (side != null && POSITION_LEFT.equals(side) ? -1 : 1);
} else { } else {
final Coord coord = Coord.parse(wiseParent.getPosition()); final Coord coord = Coord.parse(wiseParent.getPosition());
x = x * (coord.isOnLeftSide() ? -1 : 1); x = x * (coord.isOnLeftSide() ? -1 : 1);

View File

@ -1,4 +1,4 @@
<map version="1.9.0"> <map version="0.9.0">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net --> <!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1301246214383" ID="ID_886000454" MODIFIED="1301246809450" TEXT="Fonts"> <node CREATED="1301246214383" ID="ID_886000454" MODIFIED="1301246809450" TEXT="Fonts">
<node CREATED="1301246745581" ID="ID_1660145973" MODIFIED="1301246791264" POSITION="right" TEXT="Styles"> <node CREATED="1301246745581" ID="ID_1660145973" MODIFIED="1301246791264" POSITION="right" TEXT="Styles">