poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From virtu...@apache.org
Subject svn commit: r1709354 [3/3] - in /poi/trunk/src: ooxml/java/org/apache/poi/xdgf/ ooxml/java/org/apache/poi/xdgf/exceptions/ ooxml/java/org/apache/poi/xdgf/geom/ ooxml/java/org/apache/poi/xdgf/usermodel/ ooxml/java/org/apache/poi/xdgf/usermodel/section/ ...
Date Mon, 19 Oct 2015 05:52:37 GMT
Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/LineTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/LineTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/LineTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/LineTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,88 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+public class LineTo implements GeometryRow {
+
+	LineTo _master = null;
+	
+	Double x = null;
+	Double y = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public LineTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in LineTo row");
+			}
+		}
+	}
+	
+	@Override
+	public String toString() {
+		return "LineTo: x=" + getX() + "; y=" + getY();
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (LineTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		if (getDel()) return;
+		path.lineTo(getX(), getY());
+	}	
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/MoveTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/MoveTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/MoveTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/MoveTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,93 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+/**
+ * Contains the x- and y-coordinates of the first vertex of a shape or the x-
+ * and y-coordinates of the first vertex after a break in a path, relative to
+ * the height and width of the shape.
+ */
+public class MoveTo implements GeometryRow {
+	
+	MoveTo _master = null;
+	
+	Double x = null;
+	Double y = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public MoveTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in MoveTo row");
+			}
+		}
+	}
+	
+	@Override
+	public String toString() {
+		return "MoveTo: x=" + getX() + "; y=" + getY();
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (MoveTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		if (getDel()) return;
+		path.moveTo(getX(), getY());
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,205 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import java.awt.geom.Point2D;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.geom.SplineRenderer;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.graphbuilder.curve.ControlPath;
+import com.graphbuilder.curve.ShapeMultiPath;
+import com.graphbuilder.curve.ValueVector;
+import com.graphbuilder.geom.PointFactory;
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+public class NURBSTo implements GeometryRow {
+	
+	NURBSTo _master = null;
+	
+	// The x-coordinate of the last control point of a NURBS.
+	Double x = null;
+	
+	// The y-coordinate of the last control point of a NURBS.
+	Double y = null;
+	
+	// The second to the last knot of the NURBS.
+	Double a = null;
+	
+	// The last weight of the NURBS.
+	Double b = null;
+	
+	// The first knot of the NURBS.
+	Double c = null;
+	
+	// The first weight of the NURBS.
+	Double d = null;
+	
+	// A NURBS formula.
+	String e = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public NURBSTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("A")) {
+				a = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("B")) {
+				b = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("C")) {
+				c = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("D")) {
+				d = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("E")) {
+				e = cell.getV();
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in NURBS row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	public Double getA() {
+		return a == null ? _master.a : a;
+	}
+	
+	public Double getB() {
+		return b == null ? _master.b : b;
+	}
+	
+	public Double getC() {
+		return c == null ? _master.c : c;
+	}
+	
+	public Double getD() {
+		return d == null ? _master.d : d;
+	}
+	
+	public String getE() {
+		return e == null ? _master.e : e;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (NURBSTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		if (getDel()) return;
+		
+		Point2D last = path.getCurrentPoint();
+		
+		// A NURBS formula: knotLast, degree, xType, yType, x1, y1, knot1, weight1, ..
+		String formula = getE().trim();
+		if (!formula.startsWith("NURBS(") || !formula.endsWith(")"))
+			throw new POIXMLException("Invalid NURBS formula: " + formula);
+		
+		String [] components = formula.substring(6, formula.length()-1).split(",");
+		
+		if (components.length < 8)
+			throw new POIXMLException("Invalid NURBS formula (not enough arguments)");
+		
+		if ((components.length - 4) % 4 != 0)
+			throw new POIXMLException("Invalid NURBS formula -- need 4 + n*4 arguments, got " + components.length);
+		
+		double lastControlX = getX();
+		double lastControlY = getY();
+		double secondToLastKnot = getA();
+		double lastWeight = getB();
+		double firstKnot = getC();
+		double firstWeight = getD();
+		
+		double lastKnot = Double.parseDouble(components[0].trim());
+		int degree = Integer.parseInt(components[1].trim());
+		int xType = Integer.parseInt(components[2].trim());
+		int yType = Integer.parseInt(components[3].trim());
+		
+		double xScale = 1;
+		double yScale = 1;
+		
+		if (xType == 0)
+			xScale = parent.getWidth();
+		if (yType == 0)
+			yScale = parent.getHeight();
+		
+		// setup first knots/weights/control point
+		ControlPath controlPath = new ControlPath();
+		ValueVector knots = new ValueVector();
+		ValueVector weights = new ValueVector();
+		
+		knots.add(firstKnot);
+		weights.add(firstWeight);
+		controlPath.addPoint(PointFactory.create(last.getX(), last.getY()));
+		
+		// iterate get knots/weights
+		int sets = (components.length - 4) / 4;
+		for (int i = 0; i < sets; i++) {
+			double x1 = Double.parseDouble(components[4 + i*4 + 0].trim());
+			double y1 = Double.parseDouble(components[4 + i*4 + 1].trim());
+			double k = Double.parseDouble(components[4 + i*4 + 2].trim());
+			double w = Double.parseDouble(components[4 + i*4 + 3].trim());
+			
+			controlPath.addPoint(PointFactory.create(x1*xScale, y1*yScale));
+			knots.add(k);
+			weights.add(w);
+		}
+		
+		// last knots/weights/control point
+		knots.add(secondToLastKnot);
+		knots.add(lastKnot);
+		
+		weights.add(lastWeight);
+		
+		controlPath.addPoint(PointFactory.create(lastControlX, lastControlY));
+		
+		ShapeMultiPath shape = SplineRenderer.createNurbsSpline(controlPath, knots, weights, degree);
+		path.append(shape, true);
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,95 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+public class PolyLineTo implements GeometryRow {
+	
+	PolyLineTo _master = null;
+	
+	// The x-coordinate of the ending vertex of a polyline.
+	Double x = null;
+	
+	// The y-coordinate of the ending vertex of a polyline.
+	Double y = null;
+	
+	// The polyline formula
+	String a = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public PolyLineTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("A")) {
+				a = cell.getV();
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in ArcTo row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	public String getA() {
+		return a == null ? _master.a : a;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (PolyLineTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		if (getDel()) return;
+		throw new POIXMLException("Polyline support not implemented");
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,127 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+public class RelCubBezTo implements GeometryRow {
+	
+	RelCubBezTo _master = null;
+	
+	// The x-coordinate of the ending vertex of a cubic Bézier curve relative to the width of the shape.
+	Double x = null;
+	
+	// The y-coordinate of the ending vertex of a cubic Bézier curve relative to the height of the shape.
+	Double y = null;
+	
+	// The x-coordinate of the curve’s beginning control point relative to the shape’s width; a point on the arc. The control point is best located between the beginning and ending vertices of the arc.
+	Double a = null;
+	
+	// The y-coordinate of a curve’s beginning control point relative to the shape’s height.
+	Double b = null;
+	
+	// The x-coordinate of the curve’s ending control point relative to the shape’s width; a point on the arc. The control point is best located between the beginning control point and ending vertices of the arc.
+	Double c = null;
+	
+	// The y-coordinate of a curve's ending control point relative to the shape’s height.
+	Double d = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public RelCubBezTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("A")) {
+				a = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("B")) {
+				b = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("C")) {
+				c = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("D")) {
+				d = XDGFCell.parseDoubleValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in RelCubBezTo row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	public Double getA() {
+		return a == null ? _master.a : a;
+	}
+	
+	public Double getB() {
+		return b == null ? _master.b : b;
+	}
+	
+	public Double getC() {
+		return c == null ? _master.c : c;
+	}
+	
+	public Double getD() {
+		return d == null ? _master.d : d;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (RelCubBezTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		
+		if (getDel()) return;
+		
+		double w = parent.getWidth();
+		double h = parent.getHeight();
+		
+		path.curveTo(getA()*w, getB()*h, getC()*w, getD()*h, getX()*w, getY()*h);
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,141 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+public class RelEllipticalArcTo implements GeometryRow {
+	
+	RelEllipticalArcTo _master = null;
+	
+	// The x-coordinate of the ending vertex on an arc relative to the width of
+	// the shape.
+	Double x = null;
+
+	// The y-coordinate of the ending vertex on an arc relative to the height of
+	// the shape.
+	Double y = null;
+
+	// The x-coordinate of the arc's control point relative to the shape’s
+	// width; a point on the arc.
+	Double a = null;
+
+	// The y-coordinate of an arc's control point relative to the shape’s width.
+	Double b = null;
+
+	// The angle of an arc's major axis relative to the x-axis of its parent.
+	Double c = null;
+
+	// The ratio of an arc's major axis to its minor axis. Despite the usual
+	// meaning of these words, the "major" axis does not have to be greater than
+	// the "minor" axis, so this ratio does not have to be greater than 1.
+	Double d = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public RelEllipticalArcTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("A")) {
+				a = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("B")) {
+				b = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("C")) {
+				c = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("D")) {
+				d = XDGFCell.parseDoubleValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in RelEllipticalArcTo row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	public Double getA() {
+		return a == null ? _master.a : a;
+	}
+	
+	public Double getB() {
+		return b == null ? _master.b : b;
+	}
+	
+	public Double getC() {
+		return c == null ? _master.c : c;
+	}
+	
+	public Double getD() {
+		return d == null ? _master.d : d;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (RelEllipticalArcTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		
+		if (getDel()) return;
+		
+		double w = parent.getWidth();
+		double h = parent.getHeight();
+		
+		// intentionally shadowing variables here
+		double x = getX()*w;
+		double y = getY()*h;
+		double a = getA()*w;
+		double b = getB()*h;
+		double c = getC();
+		double d = getD();
+		
+		EllipticalArcTo.createEllipticalArc(x, y, a, b, c, d, path);
+		
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelLineTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelLineTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelLineTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelLineTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,90 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+/**
+ * Contains x-and y-coordinates of the ending vertex of a straight line segment
+ * relative to a shape’s width and height.
+ */
+public class RelLineTo implements GeometryRow {
+	
+	RelLineTo _master = null;
+	
+	Double x = null;
+	Double y = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public RelLineTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in RelLineTo row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (RelLineTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		
+		if (getDel()) return;
+		
+		path.lineTo(getX()*parent.getWidth(),
+				    getY()*parent.getHeight());
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelMoveTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelMoveTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelMoveTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelMoveTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,86 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+public class RelMoveTo implements GeometryRow {
+	
+	RelMoveTo _master = null;
+	
+	Double x = null;
+	Double y = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public RelMoveTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in RelMoveTo row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (RelMoveTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		
+		if (getDel()) return;
+		
+		path.moveTo(getX()*parent.getWidth(),
+				    getY()*parent.getHeight());
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelQuadBezTo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelQuadBezTo.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelQuadBezTo.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/RelQuadBezTo.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,114 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+/**
+ * Contains the x- and y-coordinates of the endpoint of a quadratic Bézier curve
+ * relative to the shape’s width and height and the x- and y-coordinates of the
+ * control point of the curve relative shape’s width and height.
+ */
+public class RelQuadBezTo implements GeometryRow {
+	
+	RelQuadBezTo _master = null;
+	
+	// The x-coordinate of the ending vertex of a quadratic Bézier curve relative to the width of the shape.
+	Double x = null;
+	
+	// The y-coordinate of the ending vertex of a quadratic Bézier curve relative to the height of the shape.
+	Double y = null;
+	
+	// The x-coordinate of the curve’s control point relative to the shape’s width; a point on the arc. The control point is best located about halfway between the beginning and ending vertices of the arc.
+	Double a = null;
+	
+	// The y-coordinate of a curve’s control point relative to the shape’s height.
+	Double b = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public RelQuadBezTo(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("A")) {
+				a = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("B")) {
+				b = XDGFCell.parseDoubleValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in RelQuadBezTo row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	public Double getA() {
+		return a == null ? _master.a : a;
+	}
+	
+	public Double getB() {
+		return b == null ? _master.b : b;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (RelQuadBezTo) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		
+		if (getDel()) return;
+		
+		double w = parent.getWidth();
+		double h = parent.getHeight();
+		
+		path.quadTo(getA()*w, getB()*h, getX()*w, getY()*h);
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineKnot.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineKnot.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineKnot.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineKnot.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,102 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+/**
+ * Contains x- and y-coordinates for a spline's control point and a spline's knot.
+ */
+public class SplineKnot implements GeometryRow {
+	
+	SplineKnot _master = null;
+	
+	// The x-coordinate of a control point.
+	Double x = null;
+	
+	// The y-coordinate of a control point.
+	Double y = null;
+	
+	// One of the spline's knots (other than the last one or the first two).
+	Double a = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public SplineKnot(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("A")) {
+				a = XDGFCell.parseDoubleValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in SplineKnot row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	public Double getA() {
+		return a == null ? _master.a : a;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (SplineKnot) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		throw new POIXMLException("Error: Use SplineRenderer!");
+	}
+	
+	@Override
+	public String toString() {
+		return "{SplineKnot x=" + getX() + " y=" + getY() + " a=" + getA() + "}";
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineStart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineStart.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineStart.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineStart.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,132 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.xdgf.usermodel.section.geometry;
+
+import org.apache.poi.POIXMLException;
+import org.apache.poi.xdgf.usermodel.XDGFCell;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+import com.microsoft.schemas.office.visio.x2012.main.CellType;
+import com.microsoft.schemas.office.visio.x2012.main.RowType;
+
+/**
+ * Contains x- and y-coordinates for a spline's second control point, its second
+ * knot, its first knot, the last knot, and the degree of the spline.
+ */
+public class SplineStart implements GeometryRow {
+	
+	SplineStart _master = null;
+	
+	// The x-coordinate of a spline's second control point.
+	Double x = null;
+	
+	// The y-coordinate of a spline's second control point.
+	Double y = null;
+	
+	// The second knot of the spline.
+	Double a = null;
+	
+	// The first knot of a spline.
+	Double b = null;
+	
+	// The last knot of a spline.
+	Double c = null;
+	
+	// The degree of a spline (an integer from 1 to 25).
+	Integer d = null;
+	
+	Boolean deleted = null;
+	
+	// TODO: support formulas
+	
+	public SplineStart(RowType row) {
+
+		if (row.isSetDel()) deleted = row.getDel();
+		
+		for (CellType cell: row.getCellArray()) {
+			String cellName = cell.getN();
+			
+			if (cellName.equals("X")) {
+				x = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("Y")) {
+				y = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("A")) {
+				a = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("B")) {
+				b = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("C")) {
+				c = XDGFCell.parseDoubleValue(cell);
+			} else if (cellName.equals("D")) {
+				d = XDGFCell.parseIntegerValue(cell);
+			} else {
+				throw new POIXMLException("Invalid cell '" + cellName + "' in SplineStart row");
+			}
+		}
+	}
+	
+	public boolean getDel() {
+		if (deleted != null)
+			return deleted;
+		
+		if (_master != null)
+			return _master.getDel();
+			
+		return false;
+	}
+	
+	public Double getX() {
+		return x == null ? _master.x : x;
+	}
+	
+	public Double getY() {
+		return y == null ? _master.y : y;
+	}
+	
+	public Double getA() {
+		return a == null ? _master.a : a;
+	}
+	
+	public Double getB() {
+		return b == null ? _master.b : b;
+	}
+	
+	public Double getC() {
+		return c == null ? _master.c : c;
+	}
+	
+	public Integer getD() {
+		return d == null ? _master.d : d;
+	}
+	
+	@Override
+	public void setupMaster(GeometryRow row) {
+		_master = (SplineStart) row;
+	}
+
+	@Override
+	public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
+		throw new POIXMLException("Error: Use SplineRenderer!");
+	}
+	
+	@Override
+	public String toString() {
+		return "{SplineStart x=" + getX() + " y=" + getY() +
+				" a=" + getA() + " b=" + getB() +
+				" c=" + getC() + " d=" + getD() +
+				"}";
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeDataAcceptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeDataAcceptor.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeDataAcceptor.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeDataAcceptor.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,69 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.shape;
+
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+/**
+ * This acceptor only allows traversal to shapes that have useful data
+ * associated with them, and tries to elide details that aren't useful
+ * when analyzing the content of a document.
+ * 
+ * Useful is subjective of course, and is defined as any of:
+ * 
+ * - Has non-empty text
+ * - Is a 1d shape, such as a line
+ * - User specified shapes
+ * - The outline of stencil objects
+ * - TODO
+ */
+public class ShapeDataAcceptor implements ShapeVisitorAcceptor {
+
+	@Override
+	public boolean accept(XDGFShape shape) {
+		
+		if (shape.isDeleted())
+			return false;
+		
+		// text is interesting
+		if (shape.hasText() && shape.getTextAsString().length() != 0)
+			return true;
+		
+		// 1d shapes are interesting, they create connections
+		if (shape.isShape1D())
+			return true;
+		
+		// User specified shapes are interesting
+		if (!shape.hasMaster() && !shape.hasMasterShape())
+			return true;
+		
+		if (shape.hasMaster() && !shape.hasMasterShape())
+			return true;
+		
+		// include stencil content, but try to elide stencil interiors
+		//if (shape.getXmlObject().isSetMaster())
+		//	return true;
+		
+		if (shape.hasMasterShape() && shape.getMasterShape().isTopmost())
+			return true;
+		
+		return false;
+	}
+	
+	
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeDebuggerRenderer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeDebuggerRenderer.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeDebuggerRenderer.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeDebuggerRenderer.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,70 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.shape;
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.geom.Path2D;
+
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+public class ShapeDebuggerRenderer extends ShapeRenderer {
+
+	ShapeVisitorAcceptor _debugAcceptor = null;
+	
+	public ShapeDebuggerRenderer() {
+		super();
+	}
+	
+	public ShapeDebuggerRenderer(Graphics2D g) {
+		super(g);
+	}
+	
+	public void setDebugAcceptor(ShapeVisitorAcceptor acceptor) {
+		_debugAcceptor = acceptor;
+	}
+	
+	@Override
+	protected Path2D drawPath(XDGFShape shape){
+		
+		Path2D path = super.drawPath(shape);
+		if (_debugAcceptor == null || _debugAcceptor.accept(shape)) {
+		
+			// show numbers to associate shapes with ids.. doesn't always work
+			Font f = _graphics.getFont();
+			_graphics.scale(1, -1);
+			_graphics.setFont(f.deriveFont(0.05F));
+			
+			String shapeId = "" +  shape.getID();
+			float shapeOffset = -0.1F;
+			
+			if (shape.hasMasterShape()) {
+				shapeId += " MS:" + shape.getMasterShape().getID();
+				shapeOffset -= 0.15F;
+			}
+			
+			
+			_graphics.drawString(shapeId, shapeOffset, 0);
+			_graphics.setFont(f);
+			_graphics.scale(1, -1);
+		}
+		
+		return path;
+	}
+
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeRenderer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeRenderer.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeRenderer.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeRenderer.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,93 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.shape;
+
+import java.awt.BasicStroke;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Path2D;
+
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+import org.apache.poi.xdgf.usermodel.XDGFText;
+
+/**
+ * To use this to render only particular shapes, override it and provide an
+ * appropriate implementation of getAcceptor() or accept()
+ */
+public class ShapeRenderer extends ShapeVisitor {
+
+	protected Graphics2D _graphics;
+	
+	public ShapeRenderer() {
+		_graphics = null;
+	}
+	
+	public ShapeRenderer(Graphics2D g) {
+		_graphics = g;
+	}
+	
+	public void setGraphics(Graphics2D g) {
+		_graphics = g;
+	}
+	
+	@Override
+	public void visit(XDGFShape shape, AffineTransform globalTransform, int level) {
+		
+		AffineTransform savedTr = _graphics.getTransform();
+		_graphics.transform(globalTransform);
+		
+		drawPath(shape);
+		drawText(shape);
+		
+		// we're done, undo the transforms
+		_graphics.setTransform(savedTr);
+	}
+	
+	protected Path2D drawPath(XDGFShape shape) {
+		Path2D.Double path = shape.getPath();
+		if (path != null) {
+			
+			// setup the stroke for this line
+			
+			_graphics.setColor(shape.getLineColor());
+			_graphics.setStroke(shape.getStroke());
+			_graphics.draw(path);
+		}
+		
+		return path;
+	}
+	
+	protected void drawText(XDGFShape shape) {
+		XDGFText text = shape.getText();
+		if (text != null) {
+			
+			if (text.getTextContent().equals("Header"))
+				text.getTextBounds();
+			
+			Font oldFont = _graphics.getFont();
+			
+			_graphics.setFont(oldFont.deriveFont(shape.getFontSize().floatValue()));
+			_graphics.setColor(shape.getFontColor());
+			
+			text.draw(_graphics);
+			_graphics.setFont(oldFont);
+		}
+	}
+
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeVisitor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeVisitor.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeVisitor.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeVisitor.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,68 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.shape;
+
+import java.awt.geom.AffineTransform;
+
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+/**
+ * Used to iterate through shapes
+ * 
+ * To change the behavior of a particular visitor, you can override either
+ * accept() or getAcceptor() [preferred]
+ * 
+ * If accept() or visit() throw StopVisitingThisBranch, the iteration will
+ * not visit subshapes of the shape.
+ */
+public abstract class ShapeVisitor{
+
+	ShapeVisitorAcceptor _acceptor;
+	
+	public ShapeVisitor() {
+		_acceptor = getAcceptor();
+	}
+	
+	// is only called on construction of the visitor, allows
+	// mixing visitors and acceptors
+	public ShapeVisitorAcceptor getAcceptor() {
+		return new ShapeVisitorAcceptor() {
+			@Override
+			public boolean accept(XDGFShape shape) {
+				return !shape.isDeleted();
+			}
+		};
+	}
+	
+	public void setAcceptor(ShapeVisitorAcceptor acceptor) {
+		_acceptor = acceptor;
+	}
+	
+	
+	public boolean accept(XDGFShape shape) {
+		return _acceptor.accept(shape);
+	}
+	
+	/**
+	 * @param shape				Current shape
+	 * @param globalTransform   A transform that can convert the shapes points to global coordinates
+	 * @param level             Level in the tree (0 is topmost, 1 is next level...
+	 */
+	public abstract void visit(XDGFShape shape, AffineTransform globalTransform, int level);
+	
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeVisitorAcceptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeVisitorAcceptor.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeVisitorAcceptor.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/ShapeVisitorAcceptor.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,26 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.shape;
+
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+
+public interface ShapeVisitorAcceptor {
+
+	public boolean accept(XDGFShape shape);
+	
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/exceptions/StopVisiting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/exceptions/StopVisiting.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/exceptions/StopVisiting.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/exceptions/StopVisiting.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,24 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.shape.exceptions;
+
+public class StopVisiting extends RuntimeException {
+
+	private static final long serialVersionUID = -4651207777092840750L;
+
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/exceptions/StopVisitingThisBranch.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/exceptions/StopVisitingThisBranch.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/exceptions/StopVisitingThisBranch.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/usermodel/shape/exceptions/StopVisitingThisBranch.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,24 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.shape.exceptions;
+
+public class StopVisitingThisBranch extends RuntimeException {
+
+	private static final long serialVersionUID = 5262319077534717862L;
+
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/HierarchyPrinter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/HierarchyPrinter.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/HierarchyPrinter.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/HierarchyPrinter.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,84 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.util;
+
+import java.awt.geom.AffineTransform;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import org.apache.poi.xdgf.usermodel.XDGFPage;
+import org.apache.poi.xdgf.usermodel.XDGFShape;
+import org.apache.poi.xdgf.usermodel.XmlVisioDocument;
+import org.apache.poi.xdgf.usermodel.shape.ShapeVisitor;
+
+public class HierarchyPrinter {
+
+	public static void printHierarchy(XDGFPage page, File outDir) throws FileNotFoundException {
+		
+		File pageFile = new File(outDir, "page" + page.getPageNumber() + "-" + Util.sanitizeFilename(page.getName()) + ".txt");
+		
+		OutputStream os = new FileOutputStream(pageFile);
+		PrintStream pos = new PrintStream(os);
+		
+		printHierarchy(page, pos);
+		
+		pos.close();
+	}
+	
+	public static void printHierarchy(XDGFPage page, final PrintStream os) {
+
+		page.getContent().visitShapes(new ShapeVisitor() {
+			
+			@Override
+			public void visit(XDGFShape shape, AffineTransform globalTransform, int level) {
+				for (int i = 0; i < level; i++) {
+					os.append("  ");
+				}
+				// TODO: write text?
+				os.println(shape.toString() + " [" + shape.getShapeType() + ", " + shape.getSymbolName() + "] " + shape.getMasterShape() + " " + shape.getTextAsString().trim());
+			}
+		});	
+	}
+	
+	public static void printHierarchy(XmlVisioDocument document, String outDirname) throws FileNotFoundException {
+		
+		File outDir = new File(outDirname);
+		
+		for (XDGFPage page: document.getPages()) {
+			printHierarchy(page, outDir);
+		}
+	}
+	
+	
+	public static void main(String [] args) throws Exception {
+		if (args.length != 2) {
+			System.err.println("Usage: in.vsdx outdir");
+			System.exit(1);
+		}
+		
+		String inFilename = args[0];
+		String outDir = args[1];
+		
+		XmlVisioDocument doc = new XmlVisioDocument(new FileInputStream(inFilename));
+		printHierarchy(doc, outDir);
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/ObjectFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/ObjectFactory.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/ObjectFactory.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/ObjectFactory.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,57 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.poi.POIXMLException;
+import org.apache.xmlbeans.XmlObject;
+
+
+public class ObjectFactory<T, X extends XmlObject> {
+	
+	Map<String, Constructor<? extends T>> _types = new HashMap<>();
+	
+	public void put(String typeName, Class<? extends T> cls, Class<?>... varargs) throws NoSuchMethodException, SecurityException {		
+		_types.put(typeName, cls.getDeclaredConstructor(varargs));
+	}
+	
+	public T load(String name, Object... varargs) {
+		Constructor<? extends T> constructor = _types.get(name);
+		if (constructor == null) {
+			
+			@SuppressWarnings("unchecked")
+			X xmlObject = (X) varargs[0];
+			
+			String typeName = xmlObject.schemaType().getName().getLocalPart();
+			throw new POIXMLException("Invalid '" + typeName + "' name '" + name + "'");
+		}
+		
+		try {
+			return constructor.newInstance(varargs);
+		} catch (InvocationTargetException e) {
+			throw new POIXMLException(e.getCause());
+		} catch (Exception e) {
+			throw new POIXMLException(e);
+		}
+	}
+	
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/Util.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/Util.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/Util.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/Util.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,37 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.util;
+
+public class Util {
+	
+	public static int countLines(String str) {
+	    int lines = 1;
+	    int pos = 0;
+	    while ((pos = str.indexOf("\n", pos) + 1) != 0) {
+	        lines++;
+	    }
+	    return lines;
+	}
+	
+	// this probably isn't 100% correct, so don't use it in security-sensitive
+	// applications!
+	// from: http://www.rgagnon.com/javadetails/java-0662.html
+	public static String sanitizeFilename(String name) {
+		return name.replaceAll("[:\\\\/*\"?|<>]", "_");
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/VsdxToPng.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/VsdxToPng.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/VsdxToPng.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/util/VsdxToPng.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,118 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.util;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import org.apache.poi.xdgf.geom.Dimension2dDouble;
+import org.apache.poi.xdgf.usermodel.XDGFPage;
+import org.apache.poi.xdgf.usermodel.XmlVisioDocument;
+import org.apache.poi.xdgf.usermodel.shape.ShapeDebuggerRenderer;
+import org.apache.poi.xdgf.usermodel.shape.ShapeRenderer;
+
+public class VsdxToPng {
+
+	
+	public static void renderToPng(XDGFPage page, String outFilename, double scale, ShapeRenderer renderer) throws IOException {
+		renderToPng(page, new File(outFilename), scale, renderer);
+	}
+	
+	public static void renderToPngDir(XDGFPage page, File outDir, double scale, ShapeRenderer renderer) throws IOException {
+		
+		File pageFile = new File(outDir, "page" + page.getPageNumber() + "-" + Util.sanitizeFilename(page.getName()) + ".png");
+		System.out.println("** Writing image to " + pageFile);
+		
+		renderToPng(page, pageFile, scale, renderer);
+		
+	}
+	
+	public static void renderToPng(XDGFPage page, File outFile, double scale, ShapeRenderer renderer) throws IOException {
+		
+		Dimension2dDouble sz = page.getPageSize();
+		
+		int width = (int)(scale * sz.getWidth());
+		int height = (int)(scale * sz.getHeight());
+		
+		BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        final Graphics2D graphics = img.createGraphics();
+
+        // default rendering options
+        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+        graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+        graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+
+        graphics.setColor(Color.black);
+        graphics.setBackground(Color.white);
+        graphics.clearRect(0, 0, width, height);
+        
+        // Visio's coordinate system is flipped, so flip the image vertically
+        graphics.translate(0,  img.getHeight());
+        graphics.scale(scale, -scale);
+        
+        // toplevel shapes only
+        renderer.setGraphics(graphics);
+        page.getContent().visitShapes(renderer);
+        
+        graphics.dispose();
+        
+        FileOutputStream out = new FileOutputStream(outFile);
+        ImageIO.write(img, "png", out);
+        out.close();
+	}
+	
+	public static void renderToPng(XmlVisioDocument document, String outDirname, double scale, ShapeRenderer renderer) throws IOException {
+		
+		File outDir = new File(outDirname);
+		
+		for (XDGFPage page: document.getPages()) {
+			renderToPngDir(page, outDir, scale, renderer);
+		}
+	}
+	
+	public static void main(String [] args) throws Exception {
+		if (args.length > 2) {
+			System.err.println("Usage: [--debug] in.vsdx outdir");
+			System.exit(1);
+		}
+		
+		ShapeRenderer renderer = new ShapeRenderer();
+		
+		String inFilename = args[0];
+		String pngDir = args[1];
+		
+		if (args[0].equals("--debug")) {
+			inFilename = args[1];
+			pngDir = args[2];
+			renderer = new ShapeDebuggerRenderer();
+		}
+		
+		XmlVisioDocument doc = new XmlVisioDocument(new FileInputStream(inFilename));
+		renderToPng(doc, pngDir, 2000/11.0, renderer);
+	}
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xdgf/xml/XDGFXMLDocumentPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xdgf/xml/XDGFXMLDocumentPart.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xdgf/xml/XDGFXMLDocumentPart.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xdgf/xml/XDGFXMLDocumentPart.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,33 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.xdgf.xml;
+
+import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.xdgf.usermodel.XDGFDocument;
+
+public class XDGFXMLDocumentPart extends POIXMLDocumentPart {
+
+	protected XDGFDocument _document;
+	
+	public XDGFXMLDocumentPart(PackagePart part, PackageRelationship rel, XDGFDocument document) {
+		super(part, rel);
+		_document = document;
+	}
+	
+}

Added: poi/trunk/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java (added)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java Mon Oct 19 05:52:35 2015
@@ -0,0 +1,159 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xdgf.usermodel.section;
+
+import java.util.Iterator;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CombinedIteratorTest {
+
+	void testIteration(CombinedIterable<String> iterable, String... expected) {
+		
+		Iterator<String> iter = iterable.iterator();
+		
+		for (int i = 0; i < expected.length; i++) {
+			Assert.assertEquals(true, iter.hasNext());
+			Assert.assertEquals(expected[i], iter.next());
+		}
+		
+		Assert.assertEquals(false, iter.hasNext());
+	}
+	
+	@Test
+	public void testNullMaster() {
+		
+		SortedMap<Long, String> base = new TreeMap<>();
+		base.put(1L, "B1");
+		base.put(2L, "B2");
+		base.put(3L, "B3");
+		
+		testIteration(new CombinedIterable<>(base, null),
+					  "B1", "B2", "B3");
+	}
+	
+	@Test
+	public void testNoMatchesBaseFirst() {
+		
+		SortedMap<Long, String> base = new TreeMap<>();
+		base.put(1L, "B1");
+		base.put(2L, "B2");
+		base.put(3L, "B3");
+		
+		SortedMap<Long, String> master = new TreeMap<>();
+		master.put(4L, "M4");
+		master.put(5L, "M5");
+		master.put(6L, "M6");
+		
+		testIteration(new CombinedIterable<>(base, master),
+				  "B1", "B2", "B3", "M4", "M5", "M6");	
+	}
+	
+	@Test
+	public void testNoMatchesMasterFirst() {
+		
+		SortedMap<Long, String> base = new TreeMap<>();
+		base.put(4L, "B4");
+		base.put(5L, "B5");
+		base.put(6L, "B6");
+		
+		SortedMap<Long, String> master = new TreeMap<>();
+		master.put(1L, "M1");
+		master.put(2L, "M2");
+		master.put(3L, "M3");
+		
+		testIteration(new CombinedIterable<>(base, master),
+				  "M1", "M2", "M3", "B4", "B5", "B6");	
+	}
+	
+	@Test
+	public void testInterleaved1() {
+		
+		SortedMap<Long, String> base = new TreeMap<>();
+		base.put(1L, "B1");
+		base.put(3L, "B3");
+		base.put(5L, "B5");
+		
+		SortedMap<Long, String> master = new TreeMap<>();
+		master.put(2L, "M2");
+		master.put(4L, "M4");
+		master.put(6L, "M6");
+		
+		testIteration(new CombinedIterable<>(base, master),
+				  "B1", "M2", "B3", "M4", "B5", "M6");	
+	}
+	
+	@Test
+	public void testInterleaved2() {
+		
+		SortedMap<Long, String> base = new TreeMap<>();
+		base.put(1L, "B1");
+		base.put(2L, "B2");
+		base.put(5L, "B5");
+		base.put(6L, "B6");
+		
+		SortedMap<Long, String> master = new TreeMap<>();
+		master.put(3L, "M3");
+		master.put(4L, "M4");
+		master.put(7L, "M7");
+		master.put(8L, "M8");
+		
+		testIteration(new CombinedIterable<>(base, master),
+				  "B1", "B2", "M3", "M4", "B5", "B6", "M7", "M8");	
+	}
+	
+	@Test
+	public void testAllMatching() {
+		
+		SortedMap<Long, String> base = new TreeMap<>();
+		base.put(1L, "B1");
+		base.put(2L, "B2");
+		base.put(3L, "B3");
+		
+		SortedMap<Long, String> master = new TreeMap<>();
+		master.put(1L, "M1");
+		master.put(2L, "M2");
+		master.put(3L, "M3");
+		
+		testIteration(new CombinedIterable<>(base, master),
+				  "B1", "B2", "B3");	
+	}
+	
+	@Test
+	public void testAllMatching2() {
+		
+		SortedMap<Long, String> base = new TreeMap<>();
+		base.put(1L, "B1");
+		base.put(2L, "B2");
+		base.put(3L, "B3");
+		
+		SortedMap<Long, String> master = new TreeMap<>();
+		master.put(1L, "M1");
+		master.put(2L, "M2");
+		master.put(3L, "M3");
+		master.put(4L, "M4");
+		
+		testIteration(new CombinedIterable<>(base, master),
+				  "B1", "B2", "B3", "M4");	
+	}
+	
+	
+}

Added: poi/trunk/src/resources/devtools/unpack_ooxml.sh
URL: http://svn.apache.org/viewvc/poi/trunk/src/resources/devtools/unpack_ooxml.sh?rev=1709354&view=auto
==============================================================================
--- poi/trunk/src/resources/devtools/unpack_ooxml.sh (added)
+++ poi/trunk/src/resources/devtools/unpack_ooxml.sh Mon Oct 19 05:52:35 2015
@@ -0,0 +1,45 @@
+#!/bin/bash -e
+#
+#   Licensed to the Apache Software Foundation (ASF) under one or more
+#   contributor license agreements.  See the NOTICE file distributed with
+#   this work for additional information regarding copyright ownership.
+#   The ASF licenses this file to You under the Apache License, Version 2.0
+#   (the "License"); you may not use this file except in compliance with
+#   the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+# basename it
+
+FILENAME="$1"
+BASENAME="${FILENAME##*/}"
+OUTDIR="${BASENAME%.*}"
+
+if [ ! -f "$FILENAME" ]; then
+    echo "File $FILENAME does not exist"
+    exit 1
+fi
+
+# if dir exists, fail
+if [ -d "$OUTDIR" ]; then
+    echo "Directory '$OUTDIR' already exists!"
+    exit 1
+fi
+
+mkdir "$OUTDIR"
+unzip -d "$OUTDIR" "$FILENAME"
+
+pushd "$OUTDIR"
+
+find . -type f \( -iname "*.xml" -or -iname "*.rels" \) -exec python -c "import os, sys, xml.dom.minidom
+with open('{}', 'r') as fp:
+    s = fp.read()
+with open('{}.bak', 'w') as fp:
+    fp.write(xml.dom.minidom.parseString(s).toprettyxml().encode('utf-8'))
+os.rename('{}.bak', '{}')" \;

Propchange: poi/trunk/src/resources/devtools/unpack_ooxml.sh
------------------------------------------------------------------------------
    svn:executable = *



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message