浏览代码

6.0.2.4 release

David Benson 8 年之前
父节点
当前提交
6b771d04cb

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+14-DEC-2016: 6.0.2.4
+
+- Adds text field support for .vsdx import
+
 13-DEC-2016: 6.0.2.3
 
 - Improves .vsdx import text handling

+ 1 - 1
VERSION

@@ -1 +1 @@
-6.0.2.3
+6.0.2.4

+ 17 - 7
src/com/mxgraph/io/vsdx/Paragraph.java

@@ -14,23 +14,28 @@ public class Paragraph
 {
 	protected ArrayList<String> values;
 	
-	protected ArrayList<String> charIndex;
+	protected ArrayList<String> charIndices;
+	
+	protected ArrayList<String> fields;
 	
 	protected String paraIndex;
 	
-	public Paragraph(String val, String ch, String pg)
+	public Paragraph(String val, String ch, String pg, String field)
 	{
 		this.values = new ArrayList<String>();
 		this.values.add(val);
-		this.charIndex = new ArrayList<String>();
-		this.charIndex.add(ch);
+		this.charIndices = new ArrayList<String>();
+		this.charIndices.add(ch);
+		this.fields = new ArrayList<String>();
+		this.fields.add(field);
 		this.paraIndex = pg;
 	}
 	
-	public void addValue(String val, String ch)
+	public void addText(String val, String ch, String field)
 	{
 		this.values.add(val);
-		this.charIndex.add(ch);
+		this.charIndices.add(ch);
+		this.fields.add(field);
 	}
 	
 	public String getParagraphIndex()
@@ -45,6 +50,11 @@ public class Paragraph
 	
 	public String getChar(int index)
 	{
-		return charIndex.get(index);
+		return charIndices.get(index);
+	}
+	
+	public String getField(int index)
+	{
+		return fields.get(index);
 	}
 }

+ 35 - 0
src/com/mxgraph/io/vsdx/Shape.java

@@ -26,6 +26,11 @@ public class Shape extends Style
 	 */
 	protected Element text;
 	
+	/**
+	 * The text fields of the shape, if any
+	 */
+	protected LinkedHashMap<String, String> fields;
+	
 	/**
 	 * List of paragraphs in this shape
 	 */
@@ -201,6 +206,36 @@ public class Shape extends Style
 
 			this.geom.add(elem);
 		}
+		if (n.equals("Field"))
+		{
+			ArrayList<Element> rows = mxVsdxUtils.getDirectChildNamedElements(elem, "Row");
+			
+			for (Element row : rows)
+			{
+				String ix = row.getAttribute("IX");
+				ArrayList<Element> cells = mxVsdxUtils.getDirectChildNamedElements(row, "Cell");
+				
+				for (Element cell : cells)
+				{
+					n = cell.getAttribute("N");
+					
+					if (n.equals("Value"))
+					{
+						String v = cell.getAttribute("V");
+						
+						if (!ix.isEmpty() && !v.isEmpty())
+						{
+							if (this.fields == null)
+							{
+								fields = new LinkedHashMap<String, String>();
+							}
+
+							this.fields.put(ix, v);
+						}
+					}
+				}
+			}
+		}
 		else
 		{
 			super.parseSection(elem);

+ 123 - 74
src/com/mxgraph/io/vsdx/VsdxShape.java

@@ -239,13 +239,12 @@ public class VsdxShape extends Shape
 	 */
 	public String getTextLabel()
 	{
-		String masterId = this.getMasterId();
 		Shape masterShape = null;
 		NodeList txtChildren = getTextChildren();
 
 		if ((txtChildren == null || txtChildren.getLength() == 0) && master != null)
 		{
-			if (masterId != null)
+			if (this.getMasterId() != null)
 			{
 				masterShape = master.getMasterShape();
 			}
@@ -308,58 +307,62 @@ public class VsdxShape extends Shape
 		paragraphs = new LinkedHashMap<String,Paragraph>();
 		String ch = null;
 		String pg = null;
+		String fld = null;
 
 		for (int index = 0; index < children.getLength(); index++)
 		{
 			String value = null;
 			Node node = children.item(index);
+			String nodeName = node.getNodeName();
 			
-			if (node.getNodeName().equals("cp"))
-			{
-				Element elem = (Element)node;
-				ch = elem.getAttribute("IX");
-			}
-			else if (node.getNodeName().equals("tp"))
-			{
-				// TODO
-				Element elem = (Element)node;
-				elem.getAttribute("IX");
-			}
-			else if (node.getNodeName().equals("pp"))
-			{
-				Element elem = (Element)node;
-				pg = elem.getAttribute("IX");
-
-			}
-			else if (node.getNodeName().equals("fld"))
+			switch (nodeName)
 			{
-				// TODO
-				Element elem = (Element)node;
-				elem.getAttribute("IX");
-			}
-			else if (node.getNodeName().equals("#text"))
-			{
-				value = StringUtils.chomp(node.getTextContent());
-			}
-		
-			if (value != null && value.length() > 0)
-			{
-				// Assumes text is always last
-				// null key is allowed
-				Paragraph para = paragraphs.get(pg);
-				
-				if (para == null)
+				case "cp":
 				{
-					para = new Paragraph(value, ch, pg);
-					paragraphs.put(pg, para);
+					Element elem = (Element)node;
+					ch = elem.getAttribute("IX");
 				}
-				else
+					break;
+				case "tp":
 				{
-					para.addValue(value, ch);
+					// TODO
+					Element elem = (Element)node;
+					elem.getAttribute("IX");
+				}
+					break;
+				case "pp":
+				{
+					Element elem = (Element)node;
+					pg = elem.getAttribute("IX");
+				}
+					break;
+				case "fld":
+				{
+					Element elem = (Element)node;
+					fld = elem.getAttribute("IX");
+					break;
+				}
+				case "#text":
+				{
+					value = StringUtils.chomp(node.getTextContent());
+					
+					// Assumes text is always last
+					// null key is allowed
+					Paragraph para = paragraphs.get(pg);
+					
+					if (para == null)
+					{
+						para = new Paragraph(value, ch, pg, fld);
+						paragraphs.put(pg, para);
+					}
+					else
+					{
+						para.addText(value, ch, fld);
+					}
+					
+					ch = null;
+					pg = null;
 				}
-				
-				ch = null;
-				pg = null;
 			}
 		}
 	}
@@ -385,7 +388,38 @@ public class VsdxShape extends Shape
 		fontStyle |= isUnderline(index) ? mxConstants.FONT_UNDERLINE : 0;
 		this.styleMap.put("fontStyle", String.valueOf(fontStyle));
 
-		return para.getValue(0);
+		String value = para.getValue(0);
+		
+		if (value.isEmpty() && this.fields != null)
+		{
+			String fieldIx = para.getField(0);
+			
+			if (fieldIx != null)
+			{
+				value = this.fields.get(fieldIx);
+				
+				if (value == null)
+				{
+					Shape masterShape = null;
+
+					if (this.getMasterId() != null)
+					{
+						masterShape = master.getMasterShape();
+					}
+					else 
+					{
+						masterShape = master.getSubShape(this.getShapeMasterId());
+					}
+					
+					if (masterShape != null && masterShape.fields != null)
+					{
+						value = masterShape.fields.get(fieldIx);
+					}
+				}
+			}
+		}
+		
+		return value == null ? "" : value;
 	}
 	
 	/**
@@ -1616,6 +1650,8 @@ public class VsdxShape extends Shape
 		int currentPointCount = 0;
 		double lastX = startPoint.getX();
 		double lastY = startPoint.getY();
+		double offsetX = 0;
+		double offsetY = 0;
 		
 		for (int i = 0; i < 2; i++)
 		{
@@ -1644,45 +1680,58 @@ public class VsdxShape extends Shape
 						{
 							switch (childName)
 							{
-								case "LineTo":
-									if (i == 0)
-									{
-										controlPointCount++;
-									}
-									else if (currentPointCount < controlPointCount - 1)
+								case "MoveTo":
 									{
+										// Initial moveto behaves as a offset to the whole connector
 										Map <String, String> children = getChildValues(childElem, null);
 										String xValue = children.get("X");
 										String yValue = children.get("Y");
-										double x = 0, y = 0;
-											
-										if (xValue != null)
-										{
-											x = Double.parseDouble(xValue) * mxVsdxUtils.conversionFactor;
-											lastX = x;
-											x += startPoint.getX();
-										}
-										else
-										{
-											x = lastX;
-										}
 										
-										if (yValue != null)
+										offsetX = xValue != null ? Double.parseDouble(xValue) : 0;
+										offsetY = yValue != null ? Double.parseDouble(yValue) : 0;
+									}
+									break;
+								case "LineTo":
+									{
+										if (i == 0)
 										{
-											y = (Double.parseDouble(yValue) * mxVsdxUtils.conversionFactor) * -1;
-											lastY = y;
-											y += startPoint.getY();
+											controlPointCount++;
 										}
-										else
+										else if (currentPointCount < controlPointCount - 1)
 										{
-											y = lastY;
+											Map <String, String> children = getChildValues(childElem, null);
+											String xValue = children.get("X");
+											String yValue = children.get("Y");
+											double x = 0, y = 0;
+												
+											if (xValue != null)
+											{
+												x = (Double.parseDouble(xValue) - offsetX) * mxVsdxUtils.conversionFactor;
+												lastX = x;
+												x += startPoint.getX();
+											}
+											else
+											{
+												x = lastX;
+											}
+											
+											if (yValue != null)
+											{
+												y = ((Double.parseDouble(yValue) - offsetY) * mxVsdxUtils.conversionFactor) * -1;
+												lastY = y;
+												y += startPoint.getY();
+											}
+											else
+											{
+												y = lastY;
+											}
+											
+											x = Math.round(x * 100.0) / 100.0;
+											y = Math.round(y * 100.0) / 100.0;
+				
+											points.add(new mxPoint(x, y));
+											currentPointCount++;
 										}
-										
-										x = Math.round(x * 100.0) / 100.0;
-										y = Math.round(y * 100.0) / 100.0;
-			
-										points.add(new mxPoint(x, y));
-										currentPointCount++;
 									}
 									break;
 								default:

+ 1 - 1
src/com/mxgraph/io/vsdx/mxPropertiesManager.java

@@ -50,7 +50,7 @@ public class mxPropertiesManager
 	{
 		defaultColors.put("0", "#000000");
 		defaultColors.put("1", "#FFFFFF");
-		defaultColors.put("2", "#FF0000");
+		defaultColors.put("2", "#FFFFFF"); // Multiple label background test cases suggest white, flow3.vsdx for example
 		defaultColors.put("3", "#00FF00");
 		defaultColors.put("4", "#0000FF");
 		defaultColors.put("5", "#FFFF00");

+ 1 - 1
war/WEB-INF/appengine-web.xml

@@ -2,7 +2,7 @@
 <appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
 	<application>drawdotio</application>
 	<!-- IMPORTANT! DO NOT CHANGE THIS VALUE IN SOURCE CONTROL! -->
-	<version>6-0-2-3</version>
+	<version>6-0-2-4</version>
 	
 	<!-- Configure java.util.logging -->
 	<system-properties>

+ 1 - 1
war/cache.manifest

@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
 # THIS FILE WAS GENERATED. DO NOT MODIFY!
-# 12/13/2016 04:10 PM
+# 12/14/2016 02:50 PM
 
 /app.html
 /index.html?offline=1

文件差异内容过多而无法显示
+ 1 - 1
war/js/app.min.js


文件差异内容过多而无法显示
+ 1 - 1
war/js/atlas.min.js


文件差异内容过多而无法显示
+ 1 - 1
war/js/embed-static.min.js


文件差异内容过多而无法显示
+ 1 - 1
war/js/reader.min.js